Created
December 7, 2013 14:49
-
-
Save inage/7843386 to your computer and use it in GitHub Desktop.
2進数変換と比較(効率の悪い解き方)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## 2進数変換と比較 | |
| ## http://rubyfiddle.com/riddles/17c56 | |
| day = Time.local(1966,07,13) | |
| ans = [] | |
| def day2bin(date) | |
| return date.strftime("%Y%m%d").to_i.to_s(2) | |
| end | |
| while day != Time.local(2020,07,24) | |
| if day2bin(day) == day2bin(day).reverse | |
| ans.push day.strftime("%Y%m%d") | |
| end | |
| day = day + 24*60*60 | |
| end | |
| print ans.join(",") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment