Skip to content

Instantly share code, notes, and snippets.

@inage
Created December 7, 2013 14:49
Show Gist options
  • Select an option

  • Save inage/7843386 to your computer and use it in GitHub Desktop.

Select an option

Save inage/7843386 to your computer and use it in GitHub Desktop.
2進数変換と比較(効率の悪い解き方)
## 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