adventofcode2022

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

commit 878e6fe4752560168df28d7ec49fd08fa481c55b
parent 93b38604c87e4ecd583d53887f3e73dee5e86c57
Author: Lukas Henkel <lh@entf.net>
Date:   Thu, 15 Dec 2022 20:22:32 +0100

Use alexandrias define-constant to define test data

Diffstat:
Mt/day01.lisp | 5+++--
Mt/day02.lisp | 5+++--
Mt/day03.lisp | 5+++--
Mt/day04.lisp | 5+++--
Mt/day05.lisp | 5+++--
Mt/day06.lisp | 17+++++++++--------
Mt/day07.lisp | 5+++--
Mt/day08.lisp | 5+++--
Mt/day09.lisp | 10++++++----
Mt/day10.lisp | 4++--
Mt/day11.lisp | 5+++--
Mt/day12.lisp | 5+++--
Mt/day13.lisp | 5+++--
Mt/day14.lisp | 5+++--
Mt/day15.lisp | 5+++--
Mt/package.lisp | 4+++-
16 files changed, 56 insertions(+), 39 deletions(-)

diff --git a/t/day01.lisp b/t/day01.lisp @@ -1,6 +1,6 @@ (in-package #:adventofcode2022/test) -(defconstant +testdata-day01+ "1000 +(define-constant +testdata-day01+ "1000 2000 3000 @@ -13,7 +13,8 @@ 8000 9000 -10000") +10000" + :test 'equal) (def-test day01-task1 () (is-true diff --git a/t/day02.lisp b/t/day02.lisp @@ -1,9 +1,10 @@ (in-package #:adventofcode2022/test) -(defconstant +testdata-day02+ "A Y +(define-constant +testdata-day02+ "A Y B X C Z -") +" + :test 'equal) (def-test day02-task1 () (is-true diff --git a/t/day03.lisp b/t/day03.lisp @@ -1,11 +1,12 @@ (in-package #:adventofcode2022/test) -(defconstant +testdata-day03+ "vJrwpWtwJgWrhcsFMMfFFhFp +(define-constant +testdata-day03+ "vJrwpWtwJgWrhcsFMMfFFhFp jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL PmmdzqPrVvPwwTWBwg wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn ttgJtRGJQctTZtZT -CrZsJsPPZsGzwwsLwLmpwMDw") +CrZsJsPPZsGzwwsLwLmpwMDw" + :test 'equal) (def-test day03-task1 () (is-true diff --git a/t/day04.lisp b/t/day04.lisp @@ -1,11 +1,12 @@ (in-package #:adventofcode2022/test) -(defconstant +testdata-day04+ "2-4,6-8 +(define-constant +testdata-day04+ "2-4,6-8 2-3,4-5 5-7,7-9 2-8,3-7 6-6,4-6 -2-6,4-8") +2-6,4-8" + :test 'equal) (def-test day04-task1 () (is-true diff --git a/t/day05.lisp b/t/day05.lisp @@ -1,6 +1,6 @@ (in-package #:adventofcode2022/test) -(defconstant +testdata-day05+ " [D] +(define-constant +testdata-day05+ " [D] [N] [C] [Z] [M] [P] 1 2 3 @@ -8,7 +8,8 @@ move 1 from 2 to 1 move 3 from 1 to 3 move 2 from 2 to 1 -move 1 from 1 to 2") +move 1 from 1 to 2" + :test 'equal) (def-test day05-task1 () (is-true diff --git a/t/day06.lisp b/t/day06.lisp @@ -1,21 +1,22 @@ (in-package #:adventofcode2022/test) -(defparameter *testdata-day06* - (list (list "mjqjpqmgbljsphdztnvjfqwrcgsmlb" 7 19) - (list "bvwbjplbgvbhsrlpgdmjqwftvncz" 5 23) - (list "nppdvjthqldpwncqszvftbrmjlhg" 6 23) - (list "nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg" 10 29) - (list "zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw" 11 26))) +(define-constant +testdata-day06+ + (list (list "mjqjpqmgbljsphdztnvjfqwrcgsmlb" 7 19) + (list "bvwbjplbgvbhsrlpgdmjqwftvncz" 5 23) + (list "nppdvjthqldpwncqszvftbrmjlhg" 6 23) + (list "nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg" 10 29) + (list "zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw" 11 26)) + :test 'equal) (def-test day06-task1 () - (loop for (data m-1 m-2) in *testdata-day06* + (loop for (data m-1 m-2) in +testdata-day06+ do (is-true (= m-1 (run-task 6 1 (make-string-input-stream data)))))) (def-test day06-task2 () - (loop for (data m-1 m-2) in *testdata-day06* + (loop for (data m-1 m-2) in +testdata-day06+ do (is-true (= m-2 (run-task 6 2 diff --git a/t/day07.lisp b/t/day07.lisp @@ -1,6 +1,6 @@ (in-package #:adventofcode2022/test) -(defconstant +testdata-day07+ "$ cd / +(define-constant +testdata-day07+ "$ cd / $ ls dir a 14848514 b.txt @@ -22,7 +22,8 @@ $ ls 4060174 j 8033020 d.log 5626152 d.ext -7214296 k") +7214296 k" + :test 'equal) (def-test day07-task1 () (is-true diff --git a/t/day08.lisp b/t/day08.lisp @@ -1,10 +1,11 @@ (in-package #:adventofcode2022/test) -(defconstant +testdata-day08+ "30373 +(define-constant +testdata-day08+ "30373 25512 65332 33549 -35390") +35390" + :test 'equal) (def-test day08-task1 () (is-true diff --git a/t/day09.lisp b/t/day09.lisp @@ -1,22 +1,24 @@ (in-package #:adventofcode2022/test) -(defconstant +testdata-day09-task1+ "R 4 +(define-constant +testdata-day09-task1+ "R 4 U 4 L 3 D 1 R 4 D 1 L 5 -R 2") +R 2" + :test 'equal) -(defconstant +testdata-day09-task2+ "R 5 +(define-constant +testdata-day09-task2+ "R 5 U 8 L 8 D 3 R 17 D 10 L 25 -U 20") +U 20" + :test 'equal) (def-test day09-task1 () (is-true diff --git a/t/day10.lisp b/t/day10.lisp @@ -1,6 +1,6 @@ (in-package #:adventofcode2022/test) -(defconstant +testdata-day10+ "addx 15 +(define-constant +testdata-day10+ "addx 15 addx -11 addx 6 addx -3 @@ -145,7 +145,7 @@ addx -6 addx -11 noop noop -noop") +noop" :test 'equal) (def-test day10-task1 () (is-true diff --git a/t/day11.lisp b/t/day11.lisp @@ -1,6 +1,6 @@ (in-package #:adventofcode2022/test) -(defconstant +testdata-day11+ "Monkey 0: +(define-constant +testdata-day11+ "Monkey 0: Starting items: 79, 98 Operation: new = old * 19 Test: divisible by 23 @@ -26,7 +26,8 @@ Monkey 3: Operation: new = old + 3 Test: divisible by 17 If true: throw to monkey 0 - If false: throw to monkey 1") + If false: throw to monkey 1" + :test 'equal) (def-test day11-task1 () (is-true diff --git a/t/day12.lisp b/t/day12.lisp @@ -1,10 +1,11 @@ (in-package #:adventofcode2022/test) -(defconstant +testdata-day12+ "Sabqponm +(define-constant +testdata-day12+ "Sabqponm abcryxxl accszExk acctuvwj -abdefghi") +abdefghi" + :test 'equal) (def-test day12-task1 () (is-true diff --git a/t/day13.lisp b/t/day13.lisp @@ -1,6 +1,6 @@ (in-package #:adventofcode2022/test) -(defconstant +testdata-day13+ "[1,1,3,1,1] +(define-constant +testdata-day13+ "[1,1,3,1,1] [1,1,5,1,1] [[1],[2,3,4]] @@ -22,7 +22,8 @@ [[]] [1,[2,[3,[4,[5,6,7]]]],8,9] -[1,[2,[3,[4,[5,6,0]]]],8,9]") +[1,[2,[3,[4,[5,6,0]]]],8,9]" + :test 'equal) (def-test day13-compare-lists () (is-true (adventofcode2022/day13::compare-lists diff --git a/t/day14.lisp b/t/day14.lisp @@ -1,7 +1,8 @@ (in-package #:adventofcode2022/test) -(defconstant +testdata-day14+ "498,4 -> 498,6 -> 496,6 -503,4 -> 502,4 -> 502,9 -> 494,9") +(define-constant +testdata-day14+ "498,4 -> 498,6 -> 496,6 +503,4 -> 502,4 -> 502,9 -> 494,9" + :test 'equal) (def-test day14-task1 () (is-true diff --git a/t/day15.lisp b/t/day15.lisp @@ -1,6 +1,6 @@ (in-package #:adventofcode2022/test) -(defconstant +testdata-day15+ "Sensor at x=2, y=18: closest beacon is at x=-2, y=15 +(define-constant +testdata-day15+ "Sensor at x=2, y=18: closest beacon is at x=-2, y=15 Sensor at x=9, y=16: closest beacon is at x=10, y=16 Sensor at x=13, y=2: closest beacon is at x=15, y=3 Sensor at x=12, y=14: closest beacon is at x=10, y=16 @@ -13,7 +13,8 @@ Sensor at x=20, y=14: closest beacon is at x=25, y=17 Sensor at x=17, y=20: closest beacon is at x=21, y=22 Sensor at x=16, y=7: closest beacon is at x=15, y=3 Sensor at x=14, y=3: closest beacon is at x=15, y=3 -Sensor at x=20, y=1: closest beacon is at x=15, y=3") +Sensor at x=20, y=1: closest beacon is at x=15, y=3" + :test 'equal) (def-test day15-task1 () (is-true diff --git a/t/package.lisp b/t/package.lisp @@ -1,5 +1,7 @@ (defpackage #:adventofcode2022/test - (:use #:cl #:adventofcode2022 #:5am)) + (:use #:cl #:adventofcode2022 #:5am) + (:import-from #:alexandria + #:define-constant)) (in-package #:adventofcode2022/test) (def-suite adventofcode2022)