src/2017/days/day-11.lisp @ cd781337a694
Restructure file layout, add 2017 days 14 & 15
| author | Steve Losh <steve@stevelosh.com> |
|---|---|
| date | Thu, 05 Dec 2019 20:45:46 -0500 |
| parents | src/2017/day-11.lisp@4835e36925af |
| children | 5f6c2d777533 |
(defpackage :advent/2017/11 #.cl-user::*advent-use*) (in-package :advent/2017/11) ;; https://www.redblobgames.com/grids/hexagons/#coordinates (defun coord+ (c1 c2) (map 'vector #'+ c1 c2)) (defun coord- (c1 c2) (map 'vector #'- c1 c2)) (defun distance (c1 &optional (c2 #(0 0 0))) (/ (reduce #'+ (coord- c1 c2) :key #'abs) 2)) (define-problem (2017 11) (data read-comma-separated-values) (773 1560) (iterate (with pos = #(0 0 0)) (for direction :in (mapcar #'ensure-keyword data)) (setf pos (coord+ pos (delta direction))) (maximizing (distance pos) :into furthest) (finally (return (values (distance pos) furthest)))))