Last active
December 13, 2022 18:57
-
-
Save LdBeth/30636cc7757c4b9d0d51c60163bb3c72 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
∇out←dir lines;l;path;size;ls | |
path←⊂'' | |
ls←⍬ | |
size←0 | |
:For l :In lines | |
:If 1=⍴('\$ cd'⎕S'$1')l | |
ls,←⊂(⊃{⍺,'/',⍵}/path)size | |
:If '..'≢5↓l | |
path,←⊂5↓l | |
:Else | |
path←¯1↓path | |
:EndIf | |
size←0 | |
:ElseIf 1≤⍴('^[0-9]'⎕S 0)l | |
size+←⊃(//⎕VFI)l | |
:EndIf | |
:EndFor | |
ls,←⊂(⊃{⍺,'/',⍵}/path)size | |
out←ls | |
∇ | |
isprefix←⊃⍷ | |
vv←dir data | |
indx←(↑vv)[;1] | |
foo←{⊃⊃+/((⍵∘isprefix)¨indx)/(↑vv)[;2]}¨indx | |
z←indx {⊃⍵}⌸ foo | |
⍝ Part I | |
+/(z≤100000)/z | |
⍝ Part II | |
⌊/(z≥30000000-70000000-⊃z)/z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment