From 7eedde498c4c6836dad76c8319517d76d42a9f66 Mon Sep 17 00:00:00 2001 From: Peter Tillemans Date: Tue, 17 Dec 2024 22:23:45 +0100 Subject: [PATCH] solved day 17 prepped 18 --- aoc.asd | 2 ++ src/2024/day18.lisp | 42 ++++++++++++++++++++++++++++++++++++++ tests/2024/day17.org | 23 +++++++++++++++++++++ tests/2024/day18-test.lisp | 27 ++++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 src/2024/day18.lisp create mode 100644 tests/2024/day17.org create mode 100644 tests/2024/day18-test.lisp diff --git a/aoc.asd b/aoc.asd index e0a6b95..3eeeea6 100644 --- a/aoc.asd +++ b/aoc.asd @@ -46,6 +46,7 @@ (:file "2024/day15") (:file "2024/day16") (:file "2024/day17") + (:file "2024/day18") ))) :description "Advent of Code challenges and solutions." :long-description "Solutions for the AOC challenges." @@ -79,6 +80,7 @@ (:file "2024/day15-test") (:file "2024/day16-test") (:file "2024/day17-test") + (:file "2024/day18-test") ))) :description "Test system for aoc" :perform (test-op (op c) (symbol-call :parachute :test :aoc/tests))) diff --git a/src/2024/day18.lisp b/src/2024/day18.lisp new file mode 100644 index 0000000..e60c56d --- /dev/null +++ b/src/2024/day18.lisp @@ -0,0 +1,42 @@ + +(defpackage :aoc/2024/18 + (:use :cl :aoc :alexandria :trivia :lla) + (:export + #:sample-data + #:sample-data2 + #:part1 + #:part2 + )) + +(in-package :aoc/2024/18) + + +(defun parse-line (line) + line) + + +(defun parse-input (lines) + (mapcar #'parse-line lines)) + +(defparameter input-text (test-input 2024 18)) +(defparameter input-data (parse-input input-text)) + +(defparameter sample-text (aoc:split-lines "")) +(defparameter sample-data + (parse-input sample-text)) + +(defun part1 (data) + (length data)) + +(defun part2 (data) + (length data)) + +(defun solve-day () + (format t "part1: ~A~%" (part1 input-data)) + (format t "part2: ~A~%" (part2 input-data))) + +(defun submit () + (let ((p1 (part1 input-data)) + (p2 (part2 input-data))) + (if p1 (submit-part1 2024 18 p1)) + (if p2 (submit-part2 2024 18 p2)))) diff --git a/tests/2024/day17.org b/tests/2024/day17.org new file mode 100644 index 0000000..3d995f6 --- /dev/null +++ b/tests/2024/day17.org @@ -0,0 +1,23 @@ + + + + + BST 4 --> B = A mod 8 + BXL 1 --> B = B xor 1 + CDV 5 --> C = A shr B + BXC 6 --> B = B xor C + BXL 4 --> B = B xor 4 + ADV 3 --> A = A shr 3 + OUT 5 ---> out B + JNZ 0 + + Loop: + + + + + out -> B + a -> shl 3 +b -> b xor 4 +b -> b xor C +C -> diff --git a/tests/2024/day18-test.lisp b/tests/2024/day18-test.lisp new file mode 100644 index 0000000..4730e2a --- /dev/null +++ b/tests/2024/day18-test.lisp @@ -0,0 +1,27 @@ +(defpackage :aoc/2024/18/tests + (:use :cl :aoc :aoc/tests :aoc/2024/tests :parachute :aoc/2024/18)) + +(in-package :aoc/2024/18/tests) + +(define-test suite-2024-18 + ;:parent suite-2024 + ) + +(define-test test-foo + :parent suite-2024-18 + ) + + +(define-test test-bar + :parent suite-2024-18 + ) + + + +(define-test+run test-part1 + :parent suite-2024-18 + (is equal nil (part1 sample-data))) + +(define-test+run test-part2 + :parent suite-2024-18 + (is equal nil (part2 sample-data)))