Last active
July 31, 2018 12:56
-
-
Save expajp/17c4b6327e5176c4562d3f9ca25b5fb1 to your computer and use it in GitHub Desktop.
「Project Eulerから生まれたワンライナーたち」(https://goo.gl/Dd5RPq ) の第2問を``require 'date'``なしで解くワンライナーです
This file contains 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
[*1..1199].map{ |n| | |
( | |
( | |
[ | |
([31]*12).map.with_index{ |n, i| | |
[2, 4, 6, 9, 11].include?(i+1) ? | |
(i+1 == 2 ? 28 : 30) : | |
n | |
} | |
]*100 | |
).map.with_index{ |year, i| | |
(i+1)%4 == 0 ? | |
year.map{ |n| n == 28 ? 29 : n } : | |
year | |
}.flatten | |
)[0..n-1].sum | |
}.map{ |days| days%7 == 5 }.count{ |_| _ } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment