33
\$\begingroup\$

Challenge

Given that Christmas is:

  • December
  • Month 12
  • Day 25

Every year, determine today's date, and whether or not today is Christmas. If it is Christmas, you must print "It's Christmas". If it is not Christmas, you must somehow wait until Christmas and then print "It's Christmas".

Example

From this Stack Overflow Question

import time
while time.strftime("%b, %d", time.localtime()) != "Dec, 25":
    time.sleep(60)
print "It's Christmas"

Python in 115 Characters

Rules

Here are the rules:

  • Assume that the computer's clock is always right.
  • Your code must be able to be started at any time.
  • Your code must print "It's Christmas" on Christmas.
  • Looping is certainly not necessary, but once started your code should not stop until it has printed.
  • Shortest code wins.
\$\endgroup\$
  • \$\begingroup\$ I thought the input is in Julian date before I read this post \$\endgroup\$ – Ming-Tang Dec 21 '11 at 9:51

36 Answers 36

0
\$\begingroup\$

PHP - 49 Characters

I got this quite short, so yeah.

<?while(date("dm")!="2512");echo"It's Christmas";

EDIT: Whoops, I printed something else than It's Christmas x3

\$\endgroup\$
0
\$\begingroup\$

Rebol (53 chars)

wait difference 25-Dec-14 now
print "It's Christmas"

Of course the above will only wait till Xmas 2014 :)

Here's a version that will wait for next Xmas day:

next-xmas: does [
    d: now
    make date! reduce [25 12 either all [d/month = 12 d/day > 25][d/year + 1][d/year]]
]

wait difference next-xmas now
print "It's Christmas"
\$\endgroup\$
0
\$\begingroup\$

Befunge-98 (36 chars)

Requires a Unicode-capable interpreter ('𐀀 is used for a literal 65536 and 'ఙ for 3097):

aa+y'𐀀%'ఙ-!#v_
s Christmas"<@,kd"It'

Explanation:

  • Use y with an argument of 20 to get the date field (aa+y)
  • Mask off the month & day portion by reducing mod-65536 ('𐀀%)
  • Subtract 3097 (= month * 256 + day) ('ఙ-)
  • If zero, print the string (abuses edge wrapping)
  • Otherwise repeat
\$\endgroup\$
  • 1
    \$\begingroup\$ Since default code-golf scoring is now in bytes, this should be at least 39 due to the multibyte characters. \$\endgroup\$ – lirtosiast Jun 9 '15 at 1:55
0
\$\begingroup\$

J, 54

'It''s Christmas'[(-^:(3 :'-.12 25-:1 2{6!:0''''')^:_)1
\$\endgroup\$
0
\$\begingroup\$

SmileBASIC, 49 47 bytes

DTREAD OUT,M,D?"It's Christmas"*(M/D==.48)EXEC.

month/day will be 0.48 on December 25th.

\$\endgroup\$
-2
\$\begingroup\$

Groovy - 88

new Timer().schedule({print"It's Christmas"}as TimerTask,Date.parse("yyddMM","112512"))
\$\endgroup\$
  • 1
    \$\begingroup\$ Is all that whitespace necessary? \$\endgroup\$ – Joey Dec 5 '11 at 16:28
  • \$\begingroup\$ @Joey no, it was for the sake of readability. \$\endgroup\$ – mohammad shamsi Dec 5 '11 at 16:32
  • 6
    \$\begingroup\$ Does it work every year? Don't think so. \$\endgroup\$ – user unknown Dec 8 '11 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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