Compare commits
No commits in common. "c1fbb9fad499bd0d31992fc80f82f16fe90f7d6a" and "739ee1ba536692b0220f7dde968f914f3ad8a2ef" have entirely different histories.
c1fbb9fad4
...
739ee1ba53
4 changed files with 100 additions and 188 deletions
186
aoc.asd
186
aoc.asd
|
@ -1,97 +1,95 @@
|
||||||
(defsystem "aoc"
|
(defsystem "aoc"
|
||||||
:long-name "Advent of Code"
|
:long-name "Advent of Code"
|
||||||
:version "0.1.0"
|
:version "0.1.0"
|
||||||
:author "Peter Tillemans"
|
:author "Peter Tillemans"
|
||||||
:maintainer "Peter Tillemans"
|
:maintainer "Peter Tillemans"
|
||||||
:mailto "pti@snamellit.com"
|
:mailto "pti@snamellit.com"
|
||||||
:license "MIT"
|
:license "MIT"
|
||||||
:homepage "https://forge.snamellit.com/pti/aoc-cl"
|
:homepage "https://forge.snamellit.com/pti/aoc-cl"
|
||||||
:bug-tracker "https://forge.snamellit.com/pti/aoc-cl/issues"
|
:bug-tracker "https://forge.snamellit.com/pti/aoc-cl/issues"
|
||||||
:source-control "https://forge.snamellit.com/pti/aoc-cl"
|
:source-control "https://forge.snamellit.com/pti/aoc-cl"
|
||||||
:depends-on (#:dexador
|
:depends-on (#:dexador
|
||||||
#:cl-cookie
|
#:cl-cookie
|
||||||
#:plump
|
#:plump
|
||||||
#:lquery
|
#:lquery
|
||||||
#:3d-vectors
|
#:3d-vectors
|
||||||
#:array-operations
|
#:array-operations
|
||||||
#:lla
|
#:lla
|
||||||
#:queues.simple-queue
|
#:queues.simple-queue
|
||||||
#:queues.priority-queue
|
#:queues.priority-queue
|
||||||
#:bt-semaphore ; threads higher level lib
|
#:bt-semaphore ; threads higher level lib
|
||||||
#:trivia ; community standard pattern matching
|
#:trivia ; community standard pattern matching
|
||||||
#:transducers
|
#:transducers
|
||||||
#:smug
|
#:smug
|
||||||
#:fset
|
#:fset
|
||||||
#:arrow-macros
|
#:arrow-macros
|
||||||
)
|
)
|
||||||
:components ((:module "src"
|
:components ((:module "src"
|
||||||
:components
|
:components
|
||||||
((:file "main")
|
((:file "main")
|
||||||
(:file "maze")
|
(:file "maze")
|
||||||
(:file "2018/day06")
|
(:file "2018/day06")
|
||||||
(:file "2018/day07")
|
(:file "2018/day07")
|
||||||
(:file "2024/day01")
|
(:file "2024/day01")
|
||||||
(:file "2024/day02")
|
(:file "2024/day02")
|
||||||
(:file "2024/day03")
|
(:file "2024/day03")
|
||||||
(:file "2024/day04")
|
(:file "2024/day04")
|
||||||
(:file "2024/day05")
|
(:file "2024/day05")
|
||||||
(:file "2024/day06")
|
(:file "2024/day06")
|
||||||
(:file "2024/day07")
|
(:file "2024/day07")
|
||||||
(:file "2024/day08")
|
(:file "2024/day08")
|
||||||
(:file "2024/day09")
|
(:file "2024/day09")
|
||||||
(:file "2024/day10")
|
(:file "2024/day10")
|
||||||
(:file "2024/day11")
|
(:file "2024/day11")
|
||||||
(:file "2024/day12")
|
(:file "2024/day12")
|
||||||
(:file "2024/day13")
|
(:file "2024/day13")
|
||||||
(:file "2024/day14")
|
(:file "2024/day14")
|
||||||
(:file "2024/day15")
|
(:file "2024/day15")
|
||||||
(:file "2024/day16")
|
(:file "2024/day16")
|
||||||
(:file "2024/day17")
|
(:file "2024/day17")
|
||||||
(:file "2024/day18")
|
(:file "2024/day18")
|
||||||
(:file "2024/day19")
|
(:file "2024/day19")
|
||||||
(:file "2024/day20")
|
(:file "2024/day20")
|
||||||
(:file "2024/day21")
|
(:file "2024/day21")
|
||||||
(:file "2024/day22")
|
(:file "2024/day22")
|
||||||
(:file "2024/day23")
|
)))
|
||||||
)))
|
: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."
|
:in-order-to ((test-op (test-op "aoc/tests"))))
|
||||||
:in-order-to ((test-op (test-op "aoc/tests"))))
|
|
||||||
|
|
||||||
(defsystem "aoc/tests"
|
(defsystem "aoc/tests"
|
||||||
:author "Peter Tillemans"
|
:author "Peter Tillemans"
|
||||||
:license "GPL"
|
:license "GPL"
|
||||||
:depends-on ("aoc"
|
:depends-on ("aoc"
|
||||||
#:parachute)
|
#:parachute)
|
||||||
:components ((:module "tests"
|
:components ((:module "tests"
|
||||||
:components
|
:components
|
||||||
((:file "main")
|
((:file "main")
|
||||||
(:file "2018/day06-test")
|
(:file "2018/day06-test")
|
||||||
(:file "2018/day07-test")
|
(:file "2018/day07-test")
|
||||||
(:file "2024/main")
|
(:file "2024/main")
|
||||||
(:file "2024/day01-test")
|
(:file "2024/day01-test")
|
||||||
(:file "2024/day02-test")
|
(:file "2024/day02-test")
|
||||||
(:file "2024/day03-test")
|
(:file "2024/day03-test")
|
||||||
(:file "2024/day04-test")
|
(:file "2024/day04-test")
|
||||||
(:file "2024/day05-test")
|
(:file "2024/day05-test")
|
||||||
(:file "2024/day06-test")
|
(:file "2024/day06-test")
|
||||||
(:file "2024/day07-test")
|
(:file "2024/day07-test")
|
||||||
(:file "2024/day08-test")
|
(:file "2024/day08-test")
|
||||||
(:file "2024/day09-test")
|
(:file "2024/day09-test")
|
||||||
(:file "2024/day10-test")
|
(:file "2024/day10-test")
|
||||||
(:file "2024/day11-test")
|
(:file "2024/day11-test")
|
||||||
(:file "2024/day12-test")
|
(:file "2024/day12-test")
|
||||||
(:file "2024/day13-test")
|
(:file "2024/day13-test")
|
||||||
(:file "2024/day14-test")
|
(:file "2024/day14-test")
|
||||||
(: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")
|
(:file "2024/day18-test")
|
||||||
(:file "2024/day19-test")
|
(:file "2024/day19-test")
|
||||||
(:file "2024/day20-test")
|
(:file "2024/day20-test")
|
||||||
(:file "2024/day21-test")
|
(:file "2024/day21-test")
|
||||||
(:file "2024/day22-test")
|
(:file "2024/day22-test")
|
||||||
(:file "2024/day23-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)))
|
|
||||||
|
|
|
@ -262,11 +262,6 @@
|
||||||
sum (let ((ll (gethash (list layer ki kf) leg-lengths)))
|
sum (let ((ll (gethash (list layer ki kf) leg-lengths)))
|
||||||
ll)))
|
ll)))
|
||||||
|
|
||||||
(defun press-move (d pc mc)
|
|
||||||
(loop
|
|
||||||
for i from 1 to (abs d)
|
|
||||||
collect (if (plusp d) pc mc)))
|
|
||||||
|
|
||||||
(defun fill-leg-table (n-robots)
|
(defun fill-leg-table (n-robots)
|
||||||
(setf leg-lengths (make-hash-table :test #'equal))
|
(setf leg-lengths (make-hash-table :test #'equal))
|
||||||
|
|
||||||
|
@ -303,15 +298,19 @@
|
||||||
do (let* (
|
do (let* (
|
||||||
(dx (- xf xi))
|
(dx (- xf xi))
|
||||||
(dy (- yf yi))
|
(dy (- yf yi))
|
||||||
(hp (press-move dx #\> #\<))
|
(hp (loop
|
||||||
(vp (press-move dy #\v #\^))
|
for x from 0 below (abs dx)
|
||||||
|
collect (if (plusp dx) #\> #\<)))
|
||||||
|
(vp (loop
|
||||||
|
for y from 0 below (abs dy)
|
||||||
|
collect (if (minusp dy) #\^ #\v)))
|
||||||
(hf (coerce (append hp vp '(#\A)) 'string))
|
(hf (coerce (append hp vp '(#\A)) 'string))
|
||||||
(h-first (if (equal (cons xf yi) space-pos)
|
(h-first (if (equal (cons xf yi) space-pos)
|
||||||
99999999999
|
999
|
||||||
(fewest-presses (1- layer) hf)))
|
(fewest-presses (1- layer) hf)))
|
||||||
(vf (coerce (append vp hp '(#\A)) 'string))
|
(vf (coerce (append vp hp '(#\A)) 'string))
|
||||||
(v-first (if (equal (cons xi yf) space-pos)
|
(v-first (if (equal (cons xi yf) space-pos)
|
||||||
99999999999
|
999
|
||||||
(fewest-presses (1- layer) vf))))
|
(fewest-presses (1- layer) vf))))
|
||||||
;;(format t "h ~A ~A ~A ~A~%" xi yf hf h-first)
|
;;(format t "h ~A ~A ~A ~A~%" xi yf hf h-first)
|
||||||
;;(format t "v ~A ~A ~A ~A~%" xf yi vf v-first)
|
;;(format t "v ~A ~A ~A ~A~%" xf yi vf v-first)
|
||||||
|
@ -323,13 +322,6 @@
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
(defun print-leg-lengths (stream)
|
|
||||||
(loop
|
|
||||||
for k being the hash-keys in leg-lengths
|
|
||||||
for v being the hash-values in leg-lengths
|
|
||||||
do (format stream "~2,'0D,~A,~A,~A~%" (first k) (second k) (third k) v)))
|
|
||||||
|
|
||||||
(defun complexity (code n)
|
(defun complexity (code n)
|
||||||
(let ((l (fewest-presses n code))
|
(let ((l (fewest-presses n code))
|
||||||
(v (parse-integer (ppcre:scan-to-strings "\\d+" code))))
|
(v (parse-integer (ppcre:scan-to-strings "\\d+" code))))
|
||||||
|
@ -347,15 +339,6 @@
|
||||||
do (format t "~15A~%" (fewest-presses n code))
|
do (format t "~15A~%" (fewest-presses n code))
|
||||||
)))
|
)))
|
||||||
|
|
||||||
(defun write-leg-lengths-to-file (filename)
|
|
||||||
(with-open-file (str filename
|
|
||||||
:direction :output
|
|
||||||
:if-exists :supersede
|
|
||||||
:if-does-not-exist :create)
|
|
||||||
(print-leg-lengths str)))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defun part1 (data)
|
(defun part1 (data)
|
||||||
(fill-leg-table 3)
|
(fill-leg-table 3)
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
|
|
||||||
(defpackage :aoc/2024/24
|
|
||||||
(:use :cl :aoc :alexandria :trivia :lla)
|
|
||||||
(:export
|
|
||||||
#:sample-data
|
|
||||||
#:sample-data2
|
|
||||||
#:part1
|
|
||||||
#:part2
|
|
||||||
))
|
|
||||||
|
|
||||||
(in-package :aoc/2024/24)
|
|
||||||
|
|
||||||
|
|
||||||
(defun parse-line (line)
|
|
||||||
line)
|
|
||||||
|
|
||||||
|
|
||||||
(defun parse-input (lines)
|
|
||||||
(mapcar #'parse-line lines))
|
|
||||||
|
|
||||||
(defparameter input-text (test-input 2024 24))
|
|
||||||
(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 24 p1))
|
|
||||||
(if p2 (submit-part2 2024 24 p2))))
|
|
|
@ -1,27 +0,0 @@
|
||||||
(defpackage :aoc/2024/24/tests
|
|
||||||
(:use :cl :aoc :aoc/tests :aoc/2024/tests :parachute :aoc/2024/24))
|
|
||||||
|
|
||||||
(in-package :aoc/2024/24/tests)
|
|
||||||
|
|
||||||
(define-test suite-2024-24
|
|
||||||
;:parent suite-2024
|
|
||||||
)
|
|
||||||
|
|
||||||
(define-test test-foo
|
|
||||||
:parent suite-2024-24
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
(define-test test-bar
|
|
||||||
:parent suite-2024-24
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(define-test+run test-part1
|
|
||||||
:parent suite-2024-24
|
|
||||||
(is equal nil (part1 sample-data)))
|
|
||||||
|
|
||||||
(define-test+run test-part2
|
|
||||||
:parent suite-2024-24
|
|
||||||
(is equal nil (part2 sample-data)))
|
|
Loading…
Add table
Reference in a new issue