I just finished problem 4:
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91*99.
Find the largest palindrome made from the product of two 3-digit numbers.
And this is the solution:
(
Read more... )
Comments 1
This is almost exactly like my solution, but it can be simplified slightly:
isPalindrome xs = xs == reverse xs
main = print $ maximum [a*b | a <- [100..999], b <- [a..999], isPalindrome $ show (a*b)]
Fiddly formatting details: "do" is needed only if you are chaining together more than one IO action. Your final ($) is also unneeded.
99 Prolog Problems are some similar toy problems but with more variety than Project Euler. And the exercises in Real World Haskell are much closer to, you know, real-world programming.
Reply
Leave a comment