Created
November 1, 2016 08:05
-
-
Save MaroShim/6b81b452f55902f34500230a25313905 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
# 3digit * 3digit, which is palindrome | |
defmodule Problem4 do | |
def palindrome?(n) do | |
s = to_string(n) | |
String.reverse(s) == s | |
end | |
def solve do | |
for i <- (100..999), | |
j <- (100..999), | |
n = i * j, | |
palindrome?(n), | |
do: n | |
end | |
def print do | |
IO.inspect Enum.max(solve()) | |
end | |
end | |
Problem4.print |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment