Problem 4
I could see that the problem 4 of the Euler project could be solve with a brute force function. Since one needed to calculate the product of two 3-digit numbers, I created two lists of all possible 3-digit numbers, and tried all combinations. Here is my implementation:
import List
palindrome = [ n*m | n <- [100..999],
m <- [100..999],
show (n*m) ==
reverse (show (n*m)) ]
lpal = (last . sort)
palindrome GHCi took about 2 seconds (and a lot of bytes!) in my computer to figure out the result.
blog comments powered by Disqus