Created
April 25, 2014 23:37
-
-
Save maxluzuriaga/11306913 to your computer and use it in GitHub Desktop.
Fog Creek Puzzle Solution
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
LETTERS = "acdegilmnoprstuw" | |
def reverse(h, str) | |
if (h == 7) | |
return str.reverse | |
elsif (h < 7) | |
return false | |
end | |
if ((h % 1) != 0) | |
return false | |
end | |
0.upto(LETTERS.length - 1) do |i| | |
newh = (h - i) / 37.0 | |
newstr = str + LETTERS[i] | |
result = reverse(newh, newstr) | |
if (result != false) | |
return result | |
end | |
end | |
end | |
puts reverse(910897038977002, "") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment