Yesterday I found this interesting code-puzzler on java.dzone.com:
How Many 1's Appear in A Binary Clock Across an Entire Day
Say you have a binary clock, where 09:30:22 would be displayed as
Hour: 00001001
Minute: 00011110
Second: 00010110
Calculate the number of 1's that would appear over the course of an entire day of military time starting from 00:00:00 all the way up to 23:59:59
My last entry was:
while(1){$_+=(unpack"%32B*",pack"i3",gmtime++$i)||last}print
I'm sure it's possible to shorten that.
Why not give it a try!
s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: binary clock from java.dzone.com
by choroba (Cardinal) on Apr 04, 2013 at 07:43 UTC | |
Re: binary clock from java.dzone.com
by hdb (Monsignor) on Apr 04, 2013 at 09:44 UTC | |
by grizzley (Chaplain) on Apr 05, 2013 at 11:11 UTC | |
by wrog (Friar) on May 06, 2013 at 11:44 UTC | |
Re: binary clock from java.dzone.com
by Loops (Curate) on Apr 04, 2013 at 08:56 UTC | |
by choroba (Cardinal) on Apr 04, 2013 at 09:19 UTC | |
by Loops (Curate) on Apr 04, 2013 at 09:46 UTC | |
Re: binary clock from java.dzone.com
by Anonymous Monk on Apr 04, 2013 at 11:21 UTC |
Back to
Meditations