Not Quite Lisp... or is it ?
Solving the first question of Advent Of Code 2015 \o/
This commit is contained in:
parent
b2dc08f0f4
commit
28948d6ed4
File diff suppressed because one or more lines are too long
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue