fix assign to final bugs in aoc

This commit is contained in:
2023-04-25 16:39:06 -06:00
parent 7d4fd6a5e5
commit 485ee16ebb
3 changed files with 5 additions and 5 deletions

View File

@@ -1,9 +1,9 @@
(load "../UtilMacros.kiss")
(defMacro dictInc [theMap key amount]
`(let [theMap ,theMap key ,key amount ,amount &mut count (dictGet theMap key)]
`(let [&mut theMap ,theMap key ,key amount ,amount &mut count (dictGet theMap key)]
(unless count
(dictSet theMap key (set count (Int64Helper.fromFloat 0))))
(dictSet theMap key (set count 0i64)))
(dictSet theMap key #{count + amount;}#)))
// Remove and return an arbitrary key-value pair from the given Map

View File

@@ -5,10 +5,10 @@
// special key -1 corresponds to total count
(dictSet theMap -1 (Int64Helper.fromFloat list.length))
(doFor age (range 9)
(dictSet theMap age (Int64Helper.fromFloat 0)))
(dictSet theMap age 0i64))
(doFor age list
(let [count (dictGet theMap age)
one (Int64Helper.fromFloat 1)]
one 1i64]
(dictSet theMap age #{count + one;}#)))
theMap))

View File

@@ -20,7 +20,7 @@
(= 2518
(apply +
(for group (groups (Util.readLines (input 3)) GROUP_SIZE)
(let [freqMap (emptyGroupPossessionMap)
(let [&mut freqMap (emptyGroupPossessionMap)
&mut badge ""]
(doFor [idx :String elf] (enumerate group)
(doFor char (elf.split "")