AoC/2015/days/01/lisp.lisp

20 lines
454 B
Common Lisp
Raw Normal View History

2024-06-02 19:00:21 +02:00
;; Day 1: Not Quite Lisp
(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:00:21 +02:00
(do ((char (read-char in nil)
(read-char in nil)))
((null char))
(setf balance (+ balance (direction char)))))
(print balance)