From 6a4e0db6f7676dfb4ac0363ef04f29ea60a3db71 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Tue, 7 May 2024 22:26:37 +0100 Subject: [PATCH] 07: slight cleanups though I'm still not happy --- 07/07a.bqn | 16 ++++++++-------- 07/07b.bqn | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/07/07a.bqn b/07/07a.bqn index f445839..98706c7 100644 --- a/07/07a.bqn +++ b/07/07a.bqn @@ -11,7 +11,7 @@ Prep←{ FS←{𝕤 cwd←⟨⟩ - nothing←⟨0,2⟩⥊⟨⟩ # 0 by 23 array, to return from "cd" + nothing←⟨0,2⟩⥊⟨⟩ # 0 by 2 array, to return from "cd" Exec⇐{ ⟨⟩𝕊⟨"cd", "/"⟩: cwd↩⟨⟩, nothing; ⟨⟩𝕊⟨"cd", ".."⟩: cwd ¯1⊸↓↩, nothing; @@ -23,13 +23,13 @@ FS←{𝕤 Main←{ dev←FS @ - files←∾{(1↓𝕩)dev.Cmd(⊑𝕩)}¨𝕩 - dirs ←⍷({"dir"≡⊑𝕩}˘files)/files - dirs ↩¯1⊏⍉dirs - files↩⍷({"dir"≢⊑𝕩}˘files)/files - [sizes,filepaths]←⍉files - sizes •ParseFloat¨↩ - DirSize←{𝕊dir:+´({∨´dir⊸≡¨↑𝕩}¨filepaths)/sizes} + [sizes,paths]←⍉⍷∾{(1↓𝕩)dev.Cmd(⊑𝕩)}¨𝕩 + isdir←"dir"⊸≡¨sizes + dirs ←isdir/paths + files←(¬isdir)/paths + sizes↩•ParseFloat¨(¬isdir)/sizes + files↩({"dir"≢⊑𝕩}˘files)/files + DirSize←{𝕊dir:+´({∨´dir⊸≡¨↑𝕩}¨files)/sizes} +´ {100000≥𝕩}⊸/ DirSize¨dirs } diff --git a/07/07b.bqn b/07/07b.bqn index 439c968..ec8cd4d 100644 --- a/07/07b.bqn +++ b/07/07b.bqn @@ -11,7 +11,7 @@ Prep←{ FS←{𝕤 cwd←⟨⟩ - nothing←⟨0,2⟩⥊⟨⟩ # 0 by 23 array, to return from "cd" + nothing←⟨0,2⟩⥊⟨⟩ # 0 by 2 array, to return from "cd" Exec⇐{ ⟨⟩𝕊⟨"cd", "/"⟩: cwd↩⟨⟩, nothing; ⟨⟩𝕊⟨"cd", ".."⟩: cwd ¯1⊸↓↩, nothing; @@ -23,13 +23,13 @@ FS←{𝕤 Main←{ dev←FS @ - files←∾{(1↓𝕩)dev.Cmd(⊑𝕩)}¨𝕩 - dirs ←⍷({"dir"≡⊑𝕩}˘files)/files - dirs ↩¯1⊏⍉dirs - files↩⍷({"dir"≢⊑𝕩}˘files)/files - [sizes,filepaths]←⍉files - sizes •ParseFloat¨↩ - DirSize←{𝕊dir:+´({∨´dir⊸≡¨↑𝕩}¨filepaths)/sizes} + [sizes,paths]←⍉⍷∾{(1↓𝕩)dev.Cmd(⊑𝕩)}¨𝕩 + isdir←"dir"⊸≡¨sizes + dirs ←isdir/paths + files←(¬isdir)/paths + sizes↩•ParseFloat¨(¬isdir)/sizes + files↩({"dir"≢⊑𝕩}˘files)/files + DirSize←{𝕊dir:+´({∨´dir⊸≡¨↑𝕩}¨files)/sizes} free←70000000-DirSize⟨⟩ need←30000000-free ⌊´{need≤𝕩}⊸/DirSize¨dirs -- 2.30.2