commit ab2cca9082ec882b367db2a76376feee65e21bee parent f88c724af9327931f158d8b1c34dd62ead150c32 Author: mpizzzle <m@michaelpercival.xyz> Date: Wed, 8 Dec 2021 20:29:17 +0000 puzzle 2 part 2 complete Diffstat:
| M | 2021/puzzle_2.apl | | | 8 | ++++++-- |
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/2021/puzzle_2.apl b/2021/puzzle_2.apl @@ -2,7 +2,11 @@ input← ⎕FIO[49] 'files/2.txt' -x← { +/⍵ { ↑ (⍺ = ⍵) × ⍎⍵[⍴ ⍵] } ¨ input } ¨ 'fdu' -x[1] × x[2] - x[3] ⍝ part 1 +x← { ⍵ { 1 ⍴ (⍺ = ⍵) × ⍎⍵[≢ ⍵] } ¨ input } ¨ 'fdu' + +y[1] × y[2] - (y← +/¨ x)[3] ⍝ part 1 + +f← { 0 0 ⍺ ↓⍤3⍵ } ++/z × +/(+⊢/1 f -1 f y) × z← ⊢/2 f⌽ y← ⊃ (⊂ ⍤1)⍉ ⊃ ⊃ x ⍝ part 2 )OFF