65 lines
2.8 KiB
Plaintext
65 lines
2.8 KiB
Plaintext
(load "../UtilMacros.kiss")
|
|
|
|
(defMacro dictInc [theMap key amount]
|
|
`(let [theMap ,theMap key ,key amount ,amount &mut count (dictGet theMap key)]
|
|
(unless count
|
|
(dictSet theMap key (set count (Int64Helper.fromFloat 0))))
|
|
(dictSet theMap key #|count + amount|#)))
|
|
|
|
(function run []
|
|
(day 1
|
|
(load "day1.kiss")
|
|
(assert (= 1475 (countIncreases (Util.readInts "src/year2021/inputs/day1.txt"))))
|
|
(assert (= 1516 (countIncreases (for trio (slicesOf (Util.readInts "src/year2021/inputs/day1.txt") 3) (apply + trio))))))
|
|
(day 2
|
|
(load "day2.kiss")
|
|
(assert (= 2150351 (apply * (simulateSubCommands (readSubCommands "src/year2021/inputs/day2.txt")))))
|
|
(assert (= 1842742223 (apply * (simulateSubCommands (readSubCommands "src/year2021/inputs/day2.txt") true)))))
|
|
(day 3
|
|
(load "day3.kiss")
|
|
(let [inputs (Util.readLines "src/year2021/inputs/day3.txt")]
|
|
(assert (= 845186 (* (rate inputs false) (rate inputs true))))
|
|
(assert (= 4636702 (* (otherRate inputs false) (otherRate inputs true))))))
|
|
(day 4
|
|
(load "day4.kiss")
|
|
(assert (= 4512 (winningScore "src/year2021/inputs/day4-example.txt")))
|
|
(assert (= 46920 (winningScore "src/year2021/inputs/day4.txt")))
|
|
(assert (= 1924 (lastWinningScore "src/year2021/inputs/day4-example.txt")))
|
|
(assert (= 12635 (lastWinningScore "src/year2021/inputs/day4.txt"))))
|
|
(day 5
|
|
(load "day5.kiss")
|
|
(assert (= 5 ~(numHotPositions "src/year2021/inputs/day5-example.txt")))
|
|
(assert (= 7473 (numHotPositions "src/year2021/inputs/day5.txt")))
|
|
(assert (= 12 (numHotPositions "src/year2021/inputs/day5-example.txt" true)))
|
|
(assert (= 24164 (numHotPositions "src/year2021/inputs/day5.txt" true))))
|
|
(day 6
|
|
(load "day6.kiss")
|
|
(assert (= "5934" (countAfter "src/year2021/inputs/day6-example.txt" 80)))
|
|
(assert (= "26984457539" (countAfter "src/year2021/inputs/day6-example.txt" 256)))
|
|
(assert (= "346063" (countAfter "src/year2021/inputs/day6.txt" 80)))
|
|
(assert (= "1572358335990" (countAfter "src/year2021/inputs/day6.txt" 256))))
|
|
(day 7
|
|
(load "day7.kiss")
|
|
(assert (= 2 (bestPosToAlignAt (crabPositions "src/year2021/inputs/day7-example.txt"))))
|
|
(let [positions (crabPositions "src/year2021/inputs/day7.txt")]
|
|
(assert (= 356958 (fuelToAlignAt (bestPosToAlignAt positions) positions)))
|
|
(assert (= 105461913 (fuelToAlignAt (bestPosToAlignAt positions true) positions true)))))
|
|
(dayTodo 8)
|
|
(dayTodo 9)
|
|
(dayTodo 10)
|
|
(dayTodo 11)
|
|
(dayTodo 12)
|
|
(dayTodo 13)
|
|
(dayTodo 14)
|
|
(dayTodo 15)
|
|
(dayTodo 16)
|
|
(dayTodo 17)
|
|
(dayTodo 18)
|
|
(dayTodo 19)
|
|
(dayTodo 20)
|
|
(dayTodo 21)
|
|
(dayTodo 22)
|
|
(dayTodo 23)
|
|
(dayTodo 24)
|
|
(dayTodo 25))
|