Compare commits

..

No commits in common. "dcc3c287bb8cd463720e4bc401662217a45b6ca1" and "d6ee3239c8cb6e3f845a3f23b736c49882679e14" have entirely different histories.

3 changed files with 0 additions and 50 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,22 +0,0 @@
;; Day 1: Not Quite Lisp
;;
;; Part 1: What is the floor Santa takes ?
(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)

View File

@ -1,27 +0,0 @@
;; Day 1: Not Quite Lisp
;;
;; Part 2: Position of the character with balance -1 (basement)
;;
;; ref.
;; - read: https://lispcookbook.github.io/cl-cookbook/files.html
(defparameter balance 0)
(defparameter position 0)
(defun direction (char) (cond
((char= char #\()
+1)
((char= char #\))
-1)
))
(with-open-file (in "./data/input")
(loop for char = (read-char in nil)
until (= balance -1)
do
(setf balance
(+ balance (direction char)))
(setf position
(+ position 1))))
(print position)