Not Quite Lisp... or is it ?

Solving the first question of Advent Of Code 2015 \o/
This commit is contained in:
Samuel Ortion 2024-06-02 19:33:40 +02:00
parent b2dc08f0f4
commit 28948d6ed4
Signed by: sortion
GPG Key ID: 9B02406F8C4FB765
2 changed files with 14 additions and 1 deletions

1
2015/days/01/data/input Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,19 @@
;; Day 1: Not Quite Lisp ;; Day 1: Not Quite Lisp
(defparameter balance 0)
(defun direction (char) (cond
((char= char #\()
+1)
((char= char #\))
-1)
))
(with-open-file (in "./data/input") (with-open-file (in "./data/input")
(do ((char (read-char in nil) (do ((char (read-char in nil)
(read-char in nil))) (read-char in nil)))
((null char)) ((null char))
(print char))) (setf balance (+ balance (direction char)))))
(print balance)