6
\$\begingroup\$

Task

Constantly having to check on television, or the time on your computer to see if its 2016 is a tedious task. Being programmers, we should be able to automate this task. Write a program that will output 2016 when the system time hits Friday, January 01, 2016 00:00:00. or rather 1451624400000 ms since midnight January 1, 1970.

Input

There will be no input to your program.

Output

Your program will output 2016 to STDOUT or the equivalent when the system time hits 1451624400000. The maximum allowed delay is 1 second or 1000 ms. If your program is started after 1451624400000, it should not output anything (an empty string is fine) and terminate normally.

Rules

  • Your code must be a full program, not just a function.
  • You can assume your program will be started after midnight January 1, 1970.
  • Your program should be able to detect 2016 within a second of it occurring.
  • Your program should terminate after outputting 2016.
  • If your program is started after midnight January 1, 2016, it should not produce any output, or an empty string, and should terminate normally.

Scoring

To keep with the trend of shortcomings in 2015, this is a challenge. The shortest code in bytes wins.

\$\endgroup\$
  • 2
    \$\begingroup\$ Many of Legen… wait for it… and Is it Christmas? solutions seems to be reusable here... \$\endgroup\$ – manatwork Dec 31 '15 at 19:34
  • 2
    \$\begingroup\$ I was actually looking at the Legen… wait for it… challenge. The reason I didn't consider this a duplicate is that this one is easier in that you can hard code the date you're waiting for, so that'll hope allow shortcuts in the code, and also, there isn't a guaranteed output if your code starts after 2016. \$\endgroup\$ – hargasinski Dec 31 '15 at 19:40
  • \$\begingroup\$ So when the program is run prior to 2016-01-01, it should wait until 2016 then print and exit? That is, if this were to hypothetically be run in 1986, it would have to continue to run for 30 years? \$\endgroup\$ – Alex A. Dec 31 '15 at 19:52
  • \$\begingroup\$ Yes, that's right. If it run anytime after Jan 1, 1970 and before Jan 1, 2016, it should run until midnight Jan 1, 2016, print 2016 and then exit \$\endgroup\$ – hargasinski Dec 31 '15 at 20:02
4
\$\begingroup\$

Pyth, 20 17 bytes

WnJ2016.d3=hZ)IZJ

This is rather simple.

  • J2016: assign J = 2016
  • .d3: gets current year
  • WnJ2016.d3: while current year is not 2016
  • =hZ: increment Z, which starts at 0
  • ): end the loop
  • IZJ: print J (2016) if Z is not zero, i.e. the loop was run at least once
\$\endgroup\$
  • 1
    \$\begingroup\$ An alternative to 2016: C\ߠ \$\endgroup\$ – LegionMammal978 Dec 31 '15 at 20:05
  • \$\begingroup\$ @LegionMammal978 One character less, but would take more bytes. Also, Pyth uses ISO-8859-1. \$\endgroup\$ – PurkkaKoodari Dec 31 '15 at 21:21
  • \$\begingroup\$ ߠ uses 2 bytes, so it would cancel out. \$\endgroup\$ – LegionMammal978 Dec 31 '15 at 21:24
  • \$\begingroup\$ @LegionMammal978 Yeah, but then 2016 is still more readable. Also I don't think you can do ߠ in ISO-8859-1 \$\endgroup\$ – PurkkaKoodari Dec 31 '15 at 21:41
  • \$\begingroup\$ It works on the online interpreter for me. \$\endgroup\$ – LegionMammal978 Dec 31 '15 at 21:43
4
\$\begingroup\$

Mathematica, 53 49 bytes

a:=UnixTime[]<1451606400;If[a,While@a;Print@2016]

Not entirely sure if it works. Will have to wait for another 9 hours...

\$\endgroup\$
  • \$\begingroup\$ LOL and what... just imagine... WHAT if it doesn't work?? :O \$\endgroup\$ – nicael Dec 31 '15 at 20:02
  • 2
    \$\begingroup\$ You can change the date on your computer. Also, you can come to Finland where it's only 2 more hours ;-) \$\endgroup\$ – PurkkaKoodari Dec 31 '15 at 20:02

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