aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-12-12 19:38:53 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-12-12 19:38:53 +0100
commit13440b6d1d67118b56afa6e2036bba45ace43878 (patch)
tree598771dadc5136c2964a81e24bf87b0d509de4ad
parent9e156294949420b56788bc03fdbe72d67cc8ec94 (diff)
Fix formatting
-rw-r--r--2024/10/puzzles.lisp12
-rw-r--r--2024/12/puzzles.lisp7
2 files changed, 8 insertions, 11 deletions
diff --git a/2024/10/puzzles.lisp b/2024/10/puzzles.lisp
index d67b075..fcea592 100644
--- a/2024/10/puzzles.lisp
+++ b/2024/10/puzzles.lisp
@@ -4,9 +4,9 @@
(loop with lines = (read-file-to-lines filename)
with dimensions = (array-dimensions lines)
for i from 0 below (first dimensions)
- summing (loop for j from 0 below (second dimensions)
- when (char= #\0 (aref lines i j))
- summing (score-for-trail-head lines i j))))
+ sum (loop for j from 0 below (second dimensions)
+ when (char= #\0 (aref lines i j))
+ sum (score-for-trail-head lines i j))))
(defun read-file-to-lines (filename)
(with-open-file (stream filename)
@@ -33,9 +33,9 @@
with dimensions = (array-dimensions lines)
for (i . j) in (list (cons (1- i) j) (cons i (1- j))
(cons (1+ i) j) (cons i (1+ j)))
- when (and (< -1 i (first dimensions))
- (< -1 j (second dimensions))
- (char= (aref lines i j) needs))
+ if (and (< -1 i (first dimensions))
+ (< -1 j (second dimensions))
+ (char= (aref lines i j) needs))
append (positions-of-nines lines i j)))))
(format t "~d~%" (main "input")) \ No newline at end of file
diff --git a/2024/12/puzzles.lisp b/2024/12/puzzles.lisp
index 3a02033..a07575e 100644
--- a/2024/12/puzzles.lisp
+++ b/2024/12/puzzles.lisp
@@ -3,8 +3,8 @@
(defparameter *seen*
(make-hash-table :test #'equal))
-(defun read-grid (filename)
- (with-open-file (stream filename)
+(defconstant +farm+
+ (with-open-file (stream "input")
(let ((lines (loop for line = (read-line stream nil)
while line
collect (coerce line 'array))))
@@ -12,9 +12,6 @@
(length (first lines)))
:initial-contents lines))))
-(defconstant +farm+
- (read-grid "input"))
-
(defun main ()
(loop with dimensions = (array-dimensions +farm+)
for i from 0 below (first dimensions)