;; Day 3: Perfectly Spherical Houses in a Vacuum
;;
;; Part 1: How many houses recieve at least one present?


(defun move (char)
  (cond
    ((equal char #\>)
     (list 1 0))
    ((equal char #\^)
     (list 0 -1))
    ((equal char #\<)
     (list -1 0))
    ((equal char #\v)
     (list 0 1))
    (t nil)
  ))

(defparameter *houses* (make-hash-table :test 'equal))

(defparameter visited-houses-counter 0)

(defun visit (house)
  (if (gethash house *houses*)
      "key exist"
      (progn
        (setf visited-houses-counter (+ visited-houses-counter 1))
        (setf (gethash house *houses*) 1))))


(defparameter x 0)
(defparameter y 0)

(visit (list x y))

(defvar walk)

(defun make-move (char)
  (progn
  (setq walk (move char))
  (setf x (+ x (nth 0 walk)))
  (setf y (+ y (nth 1 walk)))
  (visit (list x y))))

(with-open-file (in "./data/input")
  (do ((c (read-char in)
             (read-char in nil 'the-end)))
      ((not (characterp c)))
    (make-move c)))

(print visited-houses-counter)