~pmikkelsen/euler-apl

4aa2f577f6419b79d046357813be08cdd9b55b6a — Peter Mikkelsen 6 months ago 4e33aab
Solve euler 34,35,36,37,38
5 files changed, 17 insertions(+), 0 deletions(-)

A Euler34.aplf
A Euler35.aplf
A Euler36.aplf
A Euler37.aplf
A Euler38.aplf
A Euler34.aplf => Euler34.aplf +2 -0
@@ 0,0 1,2 @@
r←Euler34
r←+⌿1 2~⍨⍸{⍵=+⌿!10⊥⍣¯1⊢⍵}¨⍳100000

A Euler35.aplf => Euler35.aplf +2 -0
@@ 0,0 1,2 @@
 r←Euler35
r←+⌿{∧⌿IsPrime⍤⍎⍤⌽∘x¨⍳≢x←⍕⍵}¨PrimesBelow 1e6

A Euler36.aplf => Euler36.aplf +2 -0
@@ 0,0 1,2 @@
 r←Euler36
 r←+⌿⍸{∧⌿2 10{(⊢≡⌽)⍺⊥⍣¯1⊢⍵}¨⍵}¨⍳1000000

A Euler37.aplf => Euler37.aplf +2 -0
@@ 0,0 1,2 @@
 r←Euler37
 r←+⌿ps⌷⍨⊂4↓⍸{x←10⊥⍣¯1⊢⍵ ⋄ ∧⌿IsPrime¨10⊥¨↓∘x¨(≢x)-⍨⍳¯1+2×≢x}¨ps←PrimesBelow 1000000

A Euler38.aplf => Euler38.aplf +9 -0
@@ 0,0 1,9 @@
 r←Euler38
 heh←{
     prods←10⊥⍣¯1¨⍵×⍳9
     ~9∊+⍀≢¨prods:0
     digits←9↑∊prods
     prod←10⊥digits
     prod×(⍳9)≡{⍵[⍋⍵]}digits
 }
 r←⌈⌿0~⍨heh¨⍳1e4