Last active
December 9, 2022 05:35
-
-
Save LdBeth/b8efabc2e976e524b3519dec08195063 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
⎕VR 'foo' | |
∇ hist←foo ins;head;end;m | |
[1] hist←⊂0 0 | |
[2] head←0 0 | |
[3] end←0 0 | |
[4] :For m :In ins | |
[5] head+←m | |
[6] :If ∨/2≤|head-end | |
[7] end+←×head-end | |
[8] hist,←⊂end | |
[9] :EndIf | |
[10] :EndFor | |
[11] hist←∪hist | |
∇ | |
⎕VR 'foo2' | |
∇ hist←foo2 ins;ends;m;i;d | |
[1] hist←⊂0 0 | |
[2] ends←10/(⊂0 0) | |
[3] :For m :In ins | |
[4] (1⊃ends)+←m | |
[5] :For i :In ⍳9 | |
[6] :If ∨/2≤|d←(i⊃ends)-((1+i)⊃ends) | |
[7] ((1+i)⊃ends)+←×d | |
[8] :EndIf | |
[9] :EndFor | |
[10] hist,←⊂10⊃ends | |
[11] :EndFor | |
[12] hist←∪hist | |
∇ | |
⎕VR 'ins' | |
∇ ins←{ | |
[1] n←⊃(//)⎕VFI ⍵ | |
[2] 'R'=⊃⍵:n/(⊂0 1) | |
[3] 'L'=⊃⍵:n/(⊂0 ¯1) | |
[4] 'U'=⊃⍵:n/(⊂1 0) | |
[5] 'D'=⊃⍵:n/(⊂¯1 0) | |
[6] } | |
∇ | |
data←⊃,/ins¨⊃⎕NGET'input.txt'1 | |
⊢part1←⍴foo data | |
⊢part2←⍴foo2 data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment