Skip to content

Instantly share code, notes, and snippets.

@LdBeth
Last active December 13, 2022 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LdBeth/30636cc7757c4b9d0d51c60163bb3c72 to your computer and use it in GitHub Desktop.
Save LdBeth/30636cc7757c4b9d0d51c60163bb3c72 to your computer and use it in GitHub Desktop.
∇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