AOC day 11 debug print
This commit is contained in:
@@ -1,31 +1,38 @@
|
||||
(importAs year2022.inputs.Day11Example MonkeysExample)
|
||||
(importAs year2022.inputs.Day11 Monkeys)
|
||||
|
||||
(function :Float monkeyBusiness [:Array<Monkey> monkeys]
|
||||
(apply * ~(.slice (sort (for monkey monkeys monkey.inspections)) -2)))
|
||||
|
||||
(function printMonkeys [monkeys]
|
||||
(doFor [id monkey] (enumerate monkeys)
|
||||
(print "${id}: $monkey.items (${monkey.inspections} inspections)")))
|
||||
|
||||
// PART 1
|
||||
|
||||
(MonkeysExample.main)
|
||||
(Monkeys.main)
|
||||
(doFor _ (range 20)
|
||||
(MonkeysExample.round true)
|
||||
(Monkeys.round true))
|
||||
|
||||
(doFor [id monkey] (enumerate MonkeysExample.monkeys)
|
||||
(print "${id}: $monkey.items (${monkey.inspections} inspections)"))
|
||||
|
||||
(function :Float monkeyBusiness [:Array<Monkey> monkeys]
|
||||
(apply * ~(.slice (sort (for monkey monkeys monkey.inspections)) -2)))
|
||||
|
||||
(assertEquals 10605 (monkeyBusiness MonkeysExample.monkeys))
|
||||
(assertEquals 118674 (monkeyBusiness Monkeys.monkeys))
|
||||
|
||||
(MonkeysExample.main)
|
||||
(MonkeysExample.round false)
|
||||
|
||||
(doFor [id monkey] (enumerate MonkeysExample.monkeys)
|
||||
(print "${id}: $monkey.items (${monkey.inspections} inspections)"))
|
||||
// PART 2
|
||||
|
||||
(MonkeysExample.main)
|
||||
(Monkeys.main)
|
||||
(doFor _ (range 10000)
|
||||
(MonkeysExample.round false)
|
||||
(Monkeys.round false))
|
||||
|
||||
(assertEquals 2713310158 ~(monkeyBusiness MonkeysExample.monkeys))
|
||||
(doFor num (range 10000)
|
||||
(MonkeysExample.round false)
|
||||
(Monkeys.round false)
|
||||
(let [num (+ 1 num)]
|
||||
(case num
|
||||
((or 1 20 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000)
|
||||
(print "== After round $num ==")
|
||||
(printMonkeys MonkeysExample.monkeys))
|
||||
(otherwise null))))
|
||||
|
||||
|
||||
(assertEquals 2713310158.0 ~(monkeyBusiness MonkeysExample.monkeys))
|
Reference in New Issue
Block a user