Project Euler (FP) - Problem 4
The Problem
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.
A Solution
It seems the simplest way to find a palindrome is to compare the number against its reverse. I thought about making reverse
accomodate more data types, but decided to wait for that requirement.
reverse
makes finding a palindrome trivial.
Mulling over the rest of the problem on a walk today, I realized I could start from the largest numbers and test the size of the product of the numbers against the size of the largest palindrome so as not to go over the entire collection of possibilities.
Conclusion
Not many aspects of functional programming in this solution. I should probably think of it as a tool in the toolbox rather than a universal panacea.