Skip to content

Instantly share code, notes, and snippets.

@LdBeth
Created December 10, 2022 05:35
Show Gist options
  • Save LdBeth/0afb2b3ac03d47054a0fdefa1fcdc2d7 to your computer and use it in GitHub Desktop.
Save LdBeth/0afb2b3ac03d47054a0fdefa1fcdc2d7 to your computer and use it in GitHub Desktop.
⎕VR 'foo'
∇ res←foo data;fn;d;st;i
[1] fn←{res←⊃(//)⎕VFI('-'⎕R'¯')⍵ ⋄ 0=≢res:1 0 ⋄ 2,⊃res}
[2] d←fn¨data
[3] st←(⊂0 1)
[4] :For i :In d
[5] st,←⊂i+⊃⌽st
[6] :EndFor
[7] res←st
data←⊃⎕NGET'input.txt' 1
tb←↑foo test
fn←{⊃⌽tb[;2]/⍨tb[;1]<⍵}
⍝ Part 1
+/s×fn¨s←20 60 100 140 180 220
⍝ Part 2
' #'[1+1≥|(6 40⍴¯1+⍳40)-(6 40⍴fn¨⍳240)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment