or 01-01-01 10:10:10
Interview question: write a program to list them all!
Me: Is it OK if it doesn't print until it's done?
Interviewer: Uh, sure, why not?
Me: while(1){}
Me: Finished. This produces the exact desired output of the program you specified.
Interviewer: GTFO.
Interestingly in Haskell the only pure program of type variable “a” where a means any type at all is the one that never quits:
myProg: a
myProg = myProg
Which amounts to the same thing: it can do anything - produce any type - but it takes literally forever.ruby -e 'require"date";a=DateTime.new(0,1,1,0,0,0);(0..4e9).each{|d|b=(a+Rational(d,86400));c=b.strftime("%y%m%d%H%M%S");puts b.strftime("%y-%m-%d %H:%M:%S")if c==c.reverse}'
About the most inefficient anyone could make it, but I think it works!
Get rid of the variable `a` since it is used in only one place.
`DateTime.new(0,1,1,0,0,0)` -> `DateTime.new(0,1,1)`
also in newer ruby versions you can use numbered parameters to replace d with _1 and remove `|d|`
Pretty sure there might be some more which i do not see immediately :)
151 bytes (including the ruby -e, down from 174.) Thanks!
0..2e9|%{date(date 0).AddSeconds($_)-f 'yy-MM-dd HH:mm:ss'}|?{$_-match'(.)(.)-(.)(.)-(.)(.) \6\5:\4\3:\2\1'}[1] https://www.bipm.org/documents/20126/64811223/Resolutions-20...