1 min read

APL Hacking: Project Euler Daily (#17)

This one I did the old fashioned way at first, with a loop and a lot of cases and branching. Either with branch arrows or with Control Structures, it felt wrong. In the end, I realized that I could condense things down a bit if I removed most of the casing and made the casing implicit in the expressions. That makes for only a single loop and a few lines that are easier to read.

On the other hand, I still think that I am missing something. I feel like the solution is right there in the front, but I just haven't grasped it or spent the time on it.

Problem #17:


W←'' 'one' 'two' 'three' 'four' 'five' 'six' 'seven' 'eight'
W←W,'nine' 'ten' 'eleven' 'twelve' 'thirteen' 'fourteen'
W←W,'fifteen' 'sixteen' 'seventeen' 'eighteen' 'nineteen'

WT←'' 'ten' 'twenty' 'thirty' 'forty' 'fifty' 'sixty'
WT←WT,'seventy' 'eighty' 'ninety'

I←1 ⋄ R←0

→(I=1000)/0 ⋄ I←I+1 ⋄ →NEXT