AoC/2015/days/01/lisp.lisp

23 lines
501 B
Common Lisp
Raw Permalink Normal View History

2024-06-02 19:00:21 +02:00
;; Day 1: Not Quite Lisp
2024-06-02 20:05:55 +02:00
;;
;; Part 1: What is the floor Santa takes ?
2024-06-02 19:00:21 +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:00:21 +02:00
(do ((char (read-char in nil)
(read-char in nil)))
((null char))
(setf balance (+ balance (direction char)))))
(print balance)