summaryrefslogtreecommitdiff
path: root/day-03
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-11-30 22:46:45 -0700
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-11-30 22:46:45 -0700
commit3d57434c04a669610d5f15bd2a7713e6928cdef7 (patch)
treea0f1f04a335bbc808369d6492f4fee2ff06a0bdb /day-03
parent59966ade163a39fc03f07a9d905e0bd87a98d60c (diff)
downloadaoc-3d57434c04a669610d5f15bd2a7713e6928cdef7.tar.gz
aoc-3d57434c04a669610d5f15bd2a7713e6928cdef7.zip
add aoc2023
Diffstat (limited to 'day-03')
-rw-r--r--day-03/.gitkeep0
-rw-r--r--day-03/sol.lisp33
2 files changed, 0 insertions, 33 deletions
diff --git a/day-03/.gitkeep b/day-03/.gitkeep
deleted file mode 100644
index e69de29..0000000
--- a/day-03/.gitkeep
+++ /dev/null
diff --git a/day-03/sol.lisp b/day-03/sol.lisp
deleted file mode 100644
index 7f9ba90..0000000
--- a/day-03/sol.lisp
+++ /dev/null
@@ -1,33 +0,0 @@
-(ql:quickload "cl-ppcre")
-
-(defun get-ranges (line)
- (ppcre:register-groups-bind ((#'parse-integer first second third fourth))
- ("(\\d+)-(\\d+),(\\d+)-(\\d+)" line :sharedp t)
- `((,first ,second) (,third ,fourth))))
-
-(defun ranges-may-subset-of-one (a b)
- (member-if
- (lambda (r)
- (and
- (>= (caar r) (caadr r))
- (<= (cadar r) (cadadr r))))
- `((,a ,b) (,b ,a))))
-
-(defun range-is-contained-at-all (a b)
- (and
- (<= (car a) (cadr b))
- (>= (cadr a) (car b))))
-
-(defun main ()
- (let ((lines (uiop:read-file-lines "input")))
- (print
- (mapcar (lambda (f)
- (reduce (lambda (a x)
- (if (apply f (get-ranges x))
- (1+ a)
- a))
- lines
- :initial-value 0))
- '(range-is-contained range-may-be-subset-of-one)))))
-
-(main)