diff options
author | Hunky Jimpjorps <thechairman@thechairman.info> | 2022-12-12 09:57:35 -0500 |
---|---|---|
committer | Hunky Jimpjorps <thechairman@thechairman.info> | 2022-12-12 09:57:35 -0500 |
commit | 2c50f6aefe5c385672312e8907fc1e6724e215d1 (patch) | |
tree | 704e890034eaddfb5348828d50528a5326c1368c /2022 | |
parent | 0e12a59e64a6f95c2448cc5ddec96984d6111613 (diff) | |
download | gleam_aoc-2c50f6aefe5c385672312e8907fc1e6724e215d1.tar.gz gleam_aoc-2c50f6aefe5c385672312e8907fc1e6724e215d1.zip |
misc changes
Diffstat (limited to '2022')
-rw-r--r-- | 2022/day-07/day-07.rkt | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/2022/day-07/day-07.rkt b/2022/day-07/day-07.rkt index 4ebd3b4..3826cc4 100644 --- a/2022/day-07/day-07.rkt +++ b/2022/day-07/day-07.rkt @@ -15,13 +15,13 @@ (for/fold ([folders (hash)] [current-path '()] [previously-seen? #false] #:result folders) ([cmd (in-list cmds)]) - (match cmd - ["$ ls" (values folders current-path (hash-has-key? folders current-path))] - ["$ cd /" (values folders '("/") #false)] - ["$ cd .." (values folders (rest current-path) #false)] - [(regexp #px"\\$ cd (.+)" (list _ folder)) (values folders (cons folder current-path) #false)] - [(regexp #px"dir (.+)") (values folders current-path previously-seen?)] - [(regexp #px"(.+) (.+)" (list _ (app ->number size) _)) + (match (string-split cmd) + [(list "$" "ls") (values folders current-path (hash-has-key? folders current-path))] + [(list "$" "cd" "/") (values folders '("/") #false)] + [(list "$" "cd" "..") (values folders (rest current-path) #false)] + [(list "$" "cd" folder) (values folders (cons folder current-path) #false)] + [(list "dir" _) (values folders current-path previously-seen?)] + [(list (app ->number size) _) (cond [previously-seen? (values folders current-path previously-seen?)] [else (values (update-sizes folders current-path size) current-path previously-seen?)])]))) |