C#, 174 172 147 bytes
Saved 25 bytes by "borrowing" some ideas from raznagul's C# answer and merging them with the sum of first n numbers trick!
Saved 2 bytes by using the sum of first n numbers trick for a loss of precision of 185 milliseconds.
class P{static void Main(){for(int i=1;;){System.Console.WriteLine(i++<731?"Not ready yet":"Eat your hot dog");System.Threading.Thread.Sleep(i);}}}
Ungolfed program:
class P
{
static void Main()
{
for (int i=1;;)
{
System.Console.WriteLine( i++ < 731 ? "Not ready yet" : "Eat your hot dog");
System.Threading.Thread.Sleep(i);
}
}
}
Explanation:
Since the total time to wait is hardcoded at 267 seconds, one can consider this number as a telescopic sum of the first n natural numbers, n * (n + 1) / 2, which must equal 267000 milliseconds.
This is equivalent to n^2 + n - 534000 = 0.
By solving this second order equation, n1 = 730.2532073142067, n2 = -n1. Of course, only the positive solution is accepted and can be approximated as 730.
The total time can be calculated as 730 * (730 + 1) / 2 = 266815 milliseconds. The imprecision is 185 milliseconds, imperceptible to humans.
The code will now make the main (and only) thread sleeps for 1 millisecond, 2 milliseconds and so on up to 730, so the total sleep period is ~267 seconds.
Update:
La logica del programma può essere ulteriormente semplificata - in pratica deve visualizzare continuamente un messaggio e attendere un tempo specificato fino al passaggio al secondo messaggio.
Il messaggio può essere modificato utilizzando un operatore ternario per verificare il trascorrere del tempo specificato (~ 267 secondi).
L'aspetto del timing viene controllato utilizzando un contatore crescente e mettendo in pausa il thread di esecuzione.
Tuttavia, poiché la variabile contatore continua ad aumentare indefinitamente senza alcuna condizione per verificarne il valore, ci si può aspettare un overflow dei numeri interi in un determinato momento, quando il messaggio torna a Not ready yet.
È possibile aggiungere una condizione per rilevare e mitigare il problema assegnando un valore positivo maggiore di 730 quando si verifica l'overflow, come i=i<1?731:iall'interno del forloop. Purtroppo, ha un costo di 11 byte aggiuntivi:
class P{static void Main(){for(int i=1;;i=i<1?731:i){System.Console.Write(i++<731?"\nNot ready yet":"\nEat your hot dog");System.Threading.Thread.Sleep(i);}}}
La chiave qui sta usando il valore del contatore in millisecondi per ritardare notevolmente il momento dell'overflow.
Il tempo fino all'overflow può essere calcolato in base alla sum(1..n)formula, dove n = il valore intero con segno massimo a 32 bit in C # (e il framework .NET) o 2 ^ 31 - 1 = 2147483647:
2 147 483 647 * 2 147 483 648 / 2 = 2,305843008 x 10^18 milliseconds = 2,305843008 x 10^15 seconds = 26 687 997 779 days = ~73 067 755 years
Dopo 73 milioni di anni , potrebbe non importare se appare un difetto nel sistema: l'hot dog, l'OP affamato e forse la stessa razza umana sono scomparsi da tempo.
Versione precedente (172 byte):
namespace System{class P{static void Main(){for(int i=1;i<731;){Console.Write("\nNot ready yet");Threading.Thread.Sleep(i++);}for(;;)Console.Write("\nEat your hot dog");}}}
Programma non golfato:
namespace System
{
class P
{
static void Main()
{
for (int i = 1; i < 731; )
{
Console.Write("\nNot ready yet");
Threading.Thread.Sleep(i++);
}
for ( ; ; )
Console.Write("\nEat your hot dog");
}
}
}
Versione precedente (174 byte):
namespace System{class P{static void Main(){for(int i=0;i++<267e3;){Console.Write("\nNot ready yet");Threading.Thread.Sleep(1);}for(;;)Console.Write("\nEat your hot dog");}}}
Programma non golfato:
namespace System
{
class P
{
static void Main()
{
for (int i=0; i++ < 267e3; )
{
Console.Write("\nNot ready yet");
Threading.Thread.Sleep(1);
}
for ( ; ; )
Console.Write("\nEat your hot dog");
}
}
}
In alternativa, il programma può essere visualizzato Not ready yetuna sola volta, attendere fino al termine del tempo specificato e quindi essere emesso Eat your hot dogsovrascrivendo il messaggio precedente pur essendo più breve di qualche byte:
C #, 145 byte
namespace System{class P{static void Main(){Console.Write("Not ready yet");Threading.Thread.Sleep(267000);Console.Write("\rEat your hot dog");}}}
Programma non golfato:
namespace System
{
class P
{
static void Main()
{
Console.Write("Not ready yet");
Threading.Thread.Sleep(267000);
Console.Write("\rEat your hot dog");
}
}
}