solved day 17 prepped 18
This commit is contained in:
parent
4f8a43d2e2
commit
7eedde498c
4 changed files with 94 additions and 0 deletions
2
aoc.asd
2
aoc.asd
|
@ -46,6 +46,7 @@
|
||||||
(:file "2024/day15")
|
(:file "2024/day15")
|
||||||
(:file "2024/day16")
|
(:file "2024/day16")
|
||||||
(:file "2024/day17")
|
(:file "2024/day17")
|
||||||
|
(:file "2024/day18")
|
||||||
)))
|
)))
|
||||||
:description "Advent of Code challenges and solutions."
|
:description "Advent of Code challenges and solutions."
|
||||||
:long-description "Solutions for the AOC challenges."
|
:long-description "Solutions for the AOC challenges."
|
||||||
|
@ -79,6 +80,7 @@
|
||||||
(:file "2024/day15-test")
|
(:file "2024/day15-test")
|
||||||
(:file "2024/day16-test")
|
(:file "2024/day16-test")
|
||||||
(:file "2024/day17-test")
|
(:file "2024/day17-test")
|
||||||
|
(:file "2024/day18-test")
|
||||||
)))
|
)))
|
||||||
:description "Test system for aoc"
|
:description "Test system for aoc"
|
||||||
:perform (test-op (op c) (symbol-call :parachute :test :aoc/tests)))
|
:perform (test-op (op c) (symbol-call :parachute :test :aoc/tests)))
|
||||||
|
|
42
src/2024/day18.lisp
Normal file
42
src/2024/day18.lisp
Normal file
|
@ -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))))
|
23
tests/2024/day17.org
Normal file
23
tests/2024/day17.org
Normal file
|
@ -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 ->
|
27
tests/2024/day18-test.lisp
Normal file
27
tests/2024/day18-test.lisp
Normal file
|
@ -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)))
|
Loading…
Reference in a new issue