Created
April 24, 2013 16:09
-
-
Save nevill/5453356 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
String::reverse = -> | |
size = @length + 1 | |
result = "" | |
while size -= 1 | |
result += @[size - 1] | |
result | |
String::reversable = -> | |
@reverse() == @toString() | |
numbers = [999..901] | |
resultSet = [] | |
dict = [] | |
for i in numbers | |
continue if i % 10 == 0 | |
for j in numbers | |
continue if j % 10 == 0 | |
num = i * j | |
resultSet.push num if num.toString().reversable() | |
dict[num] = { i: i, j: j } | |
max = Math.max.apply null, resultSet | |
console.log max | |
console.log dict[max] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment