adventofcode2022

My solutions for Advent of Code 2022
Log | Files | Refs

day11.lisp (973B)


      1 (in-package #:adventofcode2022/test)
      2 
      3 (define-constant +testdata-day11+ "Monkey 0:
      4   Starting items: 79, 98
      5   Operation: new = old * 19
      6   Test: divisible by 23
      7     If true: throw to monkey 2
      8     If false: throw to monkey 3
      9 
     10 Monkey 1:
     11   Starting items: 54, 65, 75, 74
     12   Operation: new = old + 6
     13   Test: divisible by 19
     14     If true: throw to monkey 2
     15     If false: throw to monkey 0
     16 
     17 Monkey 2:
     18   Starting items: 79, 60, 97
     19   Operation: new = old * old
     20   Test: divisible by 13
     21     If true: throw to monkey 1
     22     If false: throw to monkey 3
     23 
     24 Monkey 3:
     25   Starting items: 74
     26   Operation: new = old + 3
     27   Test: divisible by 17
     28     If true: throw to monkey 0
     29     If false: throw to monkey 1"
     30   :test 'equal)
     31 
     32 (def-test day11-task1 ()
     33   (is-true
     34    (= 10605
     35       (run-task 11 1
     36                 (make-string-input-stream +testdata-day11+)))))
     37 
     38 (def-test day11-task2 ()
     39   (is-true
     40    (= 2713310158
     41       (run-task 11 2
     42                 (make-string-input-stream +testdata-day11+)))))