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.
Problem #18:
∇R←PEEIGHTEEN M;F;N;BEST;⎕IO ⎕IO←1 ⍝ Find the greatest total through a triangle M N←⊂[2]⊃⎕FI¨(F/(1++\~F))⊂F/M⊣F←⎕R≠M ⊣⎕FX 'R←X BEST Y' 'R←(X+Y)⌈1⌽Y+-1⌽X' R←(⊃BEST/N)[1] ∇

Simon MarsdenSimonMarsden # Thursday, March 24, 2011 10:03:49 AM
I like the approach you used.
I think there's a small error in "R←(X+Y)⌈1⌽Y+-1⌽X", which should probably read "R←(X+Y)⌈X+1⌽Y".
Here's a slightly simpler version using the same algorithm:
Aaron W. Hsuarcfide # Saturday, March 26, 2011 1:21:58 AM