1 min read

APL Hacking: Project Euler (#20)

I was avoiding this one for a while simply because I wanted to have a better carry algorithm in mind. On the other hand, it does not seem to matter if I have a bad carry algorithm, because the program runs fairly quickly regardless. I was aiming for a CARRY algorithm that worked using encode and decode instead of relying on scanning and concatenating. Alas, I have not been able to succeed, despite having succeeded at applying such a technique to the act of multiplying, itself.

Problem #20:

⍝ Performs a carry operation.

R←⊃(10 CARRY)/+⌿(¯1+⌽⍳⍴X)⌽((⍴X),-¯1+(⍴Y)+⍴X)↑X∘.×Y

⍝ Compute sum of the decimaal digits of !100