2024/02-1

This commit is contained in:
Tom Willemse 2025-01-11 14:13:49 -08:00
parent 496e18cce2
commit 40e9c964be
2 changed files with 1024 additions and 0 deletions

1000
2024/day-02/input.txt Normal file

File diff suppressed because it is too large Load diff

24
2024/day-02/stage-1.lisp Normal file
View file

@ -0,0 +1,24 @@
(asdf:load-system "cl-strings")
(require :cl-strings)
(defvar *input*
(mapcar (lambda (line)
(mapcar (lambda (column) (parse-integer column))
(cl-strings:split line " ")))
(uiop:with-safe-io-syntax ()
(uiop:read-file-lines "input.txt"))))
(defun gradual-diff-p (record)
(cond
((null (cdr record)) t)
((not (< 0 (abs (- (car record) (cadr record))) 4)) nil)
(t (gradual-diff-p (cdr record)))))
(defun safep (record)
(and (or (apply #'< record)
(apply #'> record))
(gradual-diff-p record)))
(length (delete nil (mapcar #'safep *input*)))