APL Hacking: Project Euler (#18)
Wednesday, March 23, 2011 2:01:54 PM
For this one, I took advantage of the ability to rotate vectors to get the job done. I am confused about the use of the bracket indexing though, and I do not quite understand why I needed to use ⊃ and ⊂ as much as I did.
∇R←PEEIGHTEEN M;F;N;BEST;⎕IO ⎕IO←1 ⍝ Find the greatest total through a triangle M N←⊂⊃⎕FI¨(F/(1++\~F))⊂F/M⊣F←⎕R≠M ⊣⎕FX 'R←X BEST Y' 'R←(X+Y)⌈1⌽Y+-1⌽X' R←(⊃BEST/N) ∇