In events entirely unrelated to what will hopefully happen to me in the next couple of days, I task you to write code that does the following:

  1. Print

    Legen... wait for it...

    immediately, with a trailing newline.

  2. Wait until the next full hour (when the cron job for awarding the badge runs).

  3. Print


    with an optional trailing newline.

Additional rules

  • You may write a program or a function, but the output has to be printed to STDOUT (or its closest alternative of your language).

  • You have to wait until the next full hour, not just for 60 minutes. If the code is run at 6:58, it should print the second line at 7:00.

  • The last line must be printed no later than one second after the next full hour.

  • In the event that the program is started in the first second of a full hour, it should it wait for the next full hour.

  • You may query local or UTC time.

  • Standard rules apply.

  • 2
    \$\begingroup\$ I don't understand how the third additional rule differs from the basic "wait until the next full hour" \$\endgroup\$
    – Fatalize
    Nov 26, 2015 at 15:59
  • 4
    \$\begingroup\$ @Fatalize That's just a clarification that you have to wait until the hour changes, not until the minutes and seconds are both at 00. \$\endgroup\$
    – Dennis
    Nov 26, 2015 at 16:45
  • 27
    \$\begingroup\$ Happy Legendary Badge, @Dennis! \$\endgroup\$
    – user41805
    Nov 26, 2015 at 19:49
  • 42
    \$\begingroup\$ @ΚριτικσιΛίθος Thanks! (Thank god for tab-completion.) \$\endgroup\$
    – Dennis
    Nov 26, 2015 at 19:50
  • 4
    \$\begingroup\$ "On the hour" would be a more standard (and I believe much more clear) way of describing what you call "the next full hour" (at least in American English). \$\endgroup\$
    – jpmc26
    Nov 28, 2015 at 1:05

43 Answers 43


QBIC, 58 bytes

?@Legen... wait for it...|#Dary!|{~mid$$|(_d,4,2)=@00||_XB


?@Legen... wait for it...|     Define string literal "Leg[..]it..." and print it
#Dary!|                        Define string B as "Dary!", but don't use it yet
{                              Opens an indefinite DO loop
~mid$$|(...)=@00|              Translates to IF MID$(...) = C$, where C$ is "00"
    The MID$ takes two characters, starting from pos 4, from the system's time (_d)
    So, if the string "11:00" has "00" starting at pos 4,
_XB                            Terminate the program and print string B
(The DO loop and the IF are closed implicitly)

C#, 119 Bytes


var d=DateTime.Now;Console.Write("Legen... wait for it...");while(DateTime.Now.Hour!=d.Hour+1){}Console.Write("dary!");

Only needs using System; to run - I will add this into the byte count if it's required.


"Legen... wait for it..."

(Still waiting for the "dary!" to appear...)

  • 2
    \$\begingroup\$ Did the "dary!" finally appear? Because I'm worried... \$\endgroup\$ Nov 20, 2016 at 20:12
  • 1
    \$\begingroup\$ @Erik the Golfer It did you know! And I can tell you, it was worth the...wait! :) \$\endgroup\$
    – Pete Arden
    Nov 20, 2016 at 20:43

Pascal (FPC), 125 bytes

Uses sysutils;var t:real;begin t:=Now;writeln('Legen... wait for it...');while trunc(t*24)=trunc(Now*24)do;write('dary!')end.

Try it online! (Wait for the next minute version)

After digging through FPC's source code, I learned that return type of Now() (and Time() and Date()) is TDateTime which is the same as Double and Real and that the whole part is used for the date and the fractional part is used for the time. Multiplying Now() by 24 gives the number of hours in the whole part. The program saves the current time in t at the start and waits until the mutiplied whole part changes (by comparing truncated values).


Ruby, 66 bytes

Very straight forward, i guess

puts"Legen... wait for it...";sleep 60.*60-Time.now.min;puts:dary!


C (Windows API), 119 bytes

#include <Windows.h>
WORD s[8];main(){puts("Legen... wait for it...");do{GetLocalTime(s);}while(s[6]!=0);puts("dary!");}

Bean, 58 bytes


00000000: a653 d080 a038 2080 4023 8100 35cc d420  ¦SÐ. 8 .@#..5ÌÔ 
00000010: 218f 2581 0126 2381 02cc e5e7 e5ee aeae  !.%..&#..Ìåçåî®®
00000020: aea0 f7e1 e9f4 a0e6 eff2 a0e9 f4ae ae2e  ® ÷áéô æïò éô®®.
00000030: b3ae b6e5 36e4 e1f2 f921                 ³®¶å6äáòù!

Bean Interpreter

Equivalent JavaScript (66 bytes):

console.log("Legen... wait for it...")
while(new Date%36e5)"dary!"

On the Bean Interpreter, make sure not to run without Multithread enabled or you might crash your browser. If it's enabled you should have nothing to worry about though, as it runs the blocking while loop in a Web Worker.


F#, 117 bytes

let n()=System.DateTime.Now.Hour
let l=
 printfn"Legen... wait for it..."
 let o=n()
 while n()=o do()

The brackets after the n turns it from a value into a function, so it will be re-evaluated every time it's accessed. Other than that, it's a fairly straight-forward while loop.


SmileBASIC, 69 66 62 bytes

?"Legen... wait for it...

05AB1E, 34 37 bytes


+3 bytes because I forgot about rule "In the event that the program is started in the first second of a full hour, it should wait for the next full hour.".

Try it online (with the waiting put under a setting).


”ëÃ!”              # Push Titlecase dictionary word: "Legendary!"
     2ä            # Split it into two equal parts: ["Legen","dary!"]
       ©           # Save this list in the register (without popping)
н                  # Pop and only leave the first value: "Legen"
 …šÏ€‡€•           # Push three space-delimited dictionary words: "wait for it"
        ‚          # Pair them together: ["Legen","wait for it"]
         …...      # Push string "..."
             «     # Append them after each item: ["Legen...","wait for it..."]
              ðý   # Join by spaces: "Legen... wait for it..."
                ,  # Print with a trailing newline
[       }          # Start an infinite loop
 žb                #  Push the current minutes
   žc+             #  Add the current seconds
      _            #  Check if the minutes and seconds combined are exactly 0
       #           #  And if they are 0: stop the infinite loop
®                  # Push the list from the register again
 θ                 # Pop and only leave the last value: "dary!"
  ,                # Print it with trailing newline

See this 05AB1E tip of mine (section How to use the dictionary?) to understand why ”ëÃ!” is "Legendary!" and …šÏ€‡€• is "wait for it".


Japt, 38 bytes

ÈKc ªKb ªOo`ÜÝ`}fOp`Leg... Ø2 fŽ Š...

Try it online!

This program will pause the tab till the hour is reached on Shaggy's intepreter, so it is hosted on tio.

Since Shaggy did most of the work on this one, I'll try to give as best an explanation as possible.

Proof of Concept


ÈKc ªKb ªOo`ÜÝ`}fOp`Leg&#129;.. Ø2 f&#142; &#138;..
È              }                                    create a function with 3 params
                f                                   and call it with the following param till falsy
                 Op`Leg&#129;.. Ø2 f&#142; &#138;.. print first part "Legen..
                                                    (returns undefined)                                                                     
 Kc ªKb ª                                           are current minute and second falsy?
         Oo`ÜÝ`                                     If so, print ..dary!
                                                    (returns undefined, falsy) 
  • 1
    \$\begingroup\$ Looking at the spec, you need 3 dots in both places in the first output and an exclamation mark at the end of the second output. And you should probably mention that Oo returns undefined, which is falsey. \$\endgroup\$
    – Shaggy
    Nov 17, 2020 at 16:13

CJam, 48 bytes

"Legen... wait for it...

Try it online! Or don't. Try this version online instead, because it only waits for the minute to change.


Pascal, 154 B

This full program requires a processor compliant with ISO standard 10206 “Extended Pascal”, in particular the time related features are necessary. The program performs a busy wait until the hour of t differs from the hour of t0 (to save space called s).

program b(output);var t,s:timeStamp;begin
getTimeStamp(s);writeLn('Legen... wait for it...');repeat
getTimeStamp(t)until s.hour<>t.hour;write('dary!')end.


program legendaryPascal(output);
        start, now: timeStamp;
        writeLn(output, 'Legen... wait for it...');
        { NB: The `timeValid` test has been omitted from the golfed version. }
        until false in [start.timeValid, now.timeValid, start.hour = now.hour];
        writeLn(output, 'dary!')

See also the Delphi‑esque FreePascal submission, a non‑standardized yet popular Pascal dialect.


Swift, 119 bytes

import Foundation
puts("Legen... wait for it...")
while Calendar.current.component(.minute,from:.now)>1{}

Fairly self-explanatory. Since we're importing Foundation anyway, we can use the puts function from C instead of Swift's own print function to save 2 bytes.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.