2024-06-02 19:00:21 +02:00
|
|
|
;; Day 1: Not Quite Lisp
|
|
|
|
|
2024-06-02 19:33:40 +02:00
|
|
|
(defparameter balance 0)
|
|
|
|
|
|
|
|
(defun direction (char) (cond
|
|
|
|
((char= char #\()
|
|
|
|
+1)
|
|
|
|
((char= char #\))
|
|
|
|
-1)
|
|
|
|
))
|
|
|
|
|
2024-06-02 19:00:21 +02:00
|
|
|
(with-open-file (in "./data/input")
|
2024-06-02 19:33:40 +02:00
|
|
|
|
2024-06-02 19:00:21 +02:00
|
|
|
(do ((char (read-char in nil)
|
|
|
|
(read-char in nil)))
|
|
|
|
((null char))
|
2024-06-02 19:33:40 +02:00
|
|
|
(setf balance (+ balance (direction char)))))
|
|
|
|
|
|
|
|
(print balance)
|