Created
October 7, 2016 09:04
-
-
Save track8/0e8c5c4d05185ad3e2eea403451c9e95 to your computer and use it in GitHub Desktop.
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
def euler_62 | |
n = 1 | |
hash = Hash.new {|h, k| h[k] = []} | |
current_length = 1 | |
while true | |
cubic = n**3 | |
key = cubic.to_s.split('').sort.join | |
hash[key] << cubic | |
if key.length > current_length | |
current_length = key.length | |
r = hash.values.find_all {|v| v.length == 5}.flatten.min | |
break r if r | |
end | |
n += 1 | |
end | |
end | |
p euler_62 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment