Advent of Code 2015

Table of Contents

1. Day 2

2. Day 1

(ql:quickload :uiop)

(defun solve-p1 (input-file)
  (apply #'+
         (mapcar #'(lambda (chr) (if (eq chr #\()
                                     1
                                     -1))
                 (coerce (uiop:read-file-line input-file) 'list))))

(defun solve-p2 (input-file)
  (let ((curr 0)
        (input  (mapcar #'(lambda (chr) (if (eq chr #\()
                                                   1
                                                   -1))
                               (coerce (uiop:read-file-line input-file) 'list))))
    (do ((i 0 (+ 1 i))
         (head input (cdr head)))
        ((= curr -1) i)
      (incf curr (car head)))))
Tags::project: