Skip to content

Instantly share code, notes, and snippets.

@rak1507
Last active December 7, 2022 18:23
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 rak1507/072748ba9bb5056c103d4a1c6eb396ce to your computer and use it in GitHub Desktop.
Save rak1507/072748ba9bb5056c103d4a1c6eb396ce to your computer and use it in GitHub Desktop.
⍝ approach 1
M←⎕json⍠'M'⎕json r⊣{⍺≡'$ cd ..':⍵.##⋄'$'≡⊃⍺:⍵⍎5↓⍺,'←⎕ns⍬'⋄'d'≢⊃⍺:⍵⊣⍵⍎1↓∊'←',¨0(7162⌶)¨@0⌽' '(≠⊆⊢)⍺⋄⍵}/(r←⎕ns⍬),⍨⌽1↓'$ ls'~⍨⍥⊆⊃⎕NGET'7.txt'1
sizes←(∊↑M[;2])+.×⍨{⍵∧∧\1,2≤/⍵}≠\(1=⊢/M)⌿(∘.≤⍨⍳≢M)×∘.≥⍨⊣/M
({+/⍵/⍨⍵≤1e5}, {⌊/⍵/⍨⍵≥4e7-⍨⊃⍵}) sizes
⍝ approach 2
depth type size←{(+\type) (type←(('$ cd'≡4↑⊢)ׯ1*'.'∊⊢)¨⍵) ({⊃⊃⊢/⎕vfi ⍵}¨⍵)}⊃⎕nget'7.txt'1
sizes←(1=type)/size+.×⍨{{⍵∧∧\1,2≤/⍵}(∘.≤⍨⍳≢⍵)×∘.≤⍨⍵}depth
({+/⍵/⍨⍵≤1e5}, {⌊/⍵/⍨⍵≥4e7-⍨⊃⍵}) sizes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment