I solved the Babbage squares problem, but it was very painful and my code is embarrassingly ugly.
My first approach was functional, but it was too slow. I basically created all possible tuples and filtered them with transpose@# == # &. I thought it was elegant, but again, too slow.
transpose@# == # &
It occurred to me that in order to improve performance I had to perform the tests progressively, that is at each Cartesian product, not only at the end. I'm pretty sure I know how I could do it with procedural programming. I would use three (since we know the first word) For loops with conditional Continue instructions in each of them. I am confident that would work, but I really want to learn functional programming and I struggle to find the FP equivalent.
I'm not asking for the solution, but can anyone give me a hint of the correct FP approach for this kind of problem?