1 min read

APL Hacking: Project Euler Daily (#4)

When I first did this problem, I encoded the numbers, did a 1st axis rotate, and then decoded both vectors back into their elements. However, that solution ran in 330ms, whereas this solution runs in 278ms on my machine. In this case, I use a first axis reduction to avoid doing one of the decodings.

Problem #4:


⍝ Find the largest palindrome made from the product of two 3-digit numbers.
X←99↓⍳999 ⋄ X←(6⍴10)⊤∪,X∘.×X ⋄ Y←⊖X