AoC/2015/days/01/lisp.lisp

20 lines
454 B
Common 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")
(do ((char (read-char in nil)
(read-char in nil)))
((null char))
(setf balance (+ balance (direction char)))))
(print balance)