Skip to content

Instantly share code, notes, and snippets.

@MaroShim
Created November 1, 2016 08:05
Show Gist options
  • Save MaroShim/6b81b452f55902f34500230a25313905 to your computer and use it in GitHub Desktop.
Save MaroShim/6b81b452f55902f34500230a25313905 to your computer and use it in GitHub Desktop.
# 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