Skip to content

Commit

Permalink
Add 2023/06
Browse files Browse the repository at this point in the history
  • Loading branch information
iamFIREcracker committed Dec 6, 2023
1 parent c2ec0f2 commit ef3b882
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/2023/day06.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
(defpackage :aoc/2023/06 #.cl-user::*aoc-use*)
(in-package :aoc/2023/06)

(defun parse-records (&optional (strings (uiop:read-file-lines #P"src/2023/day06.txt")))
(destructuring-bind (times records) strings
(mapcar #'list
(parse-positive-integers times)
(parse-positive-integers records))))

(defun max-distance (time hold)
(* hold (- time hold)))

(defun count-wins (input)
(destructuring-bind (time record) input
(looping
(dorangei (hold 0 time)
(count! (> (max-distance time hold) record))))))

(defun massage-input (&optional (strings (uiop:read-file-lines #P"src/2023/day06.txt")))
(mapcar [remove-if-not #'digit-char-p _] strings))


(define-solution (2023 06) (strings)
(values (reduce #'* (parse-records strings) :key #'count-wins)
(bnd1 (strings (massage-input strings))
(reduce #'* (parse-records strings) :key #'count-wins))))

(define-test (2023 06) (220320 34454850))

0 comments on commit ef3b882

Please sign in to comment.