From 56ad813f9f7741da78f9ac02bff0d0f22ff30594 Mon Sep 17 00:00:00 2001 From: cow Date: Tue, 27 Dec 2022 04:16:14 -0500 Subject: [PATCH] day 9 in common lisp --- common-lisp/day-9/example-large.txt | 1 + common-lisp/day-9/example.txt | 1 + common-lisp/day-9/input.txt | 1 + common-lisp/day-9/solution.lisp | 171 +++ input/day-9-example-large.txt | 8 + input/day-9-example.txt | 8 + input/day-9.txt | 2000 +++++++++++++++++++++++++++ 7 files changed, 2190 insertions(+) create mode 120000 common-lisp/day-9/example-large.txt create mode 120000 common-lisp/day-9/example.txt create mode 120000 common-lisp/day-9/input.txt create mode 100755 common-lisp/day-9/solution.lisp create mode 100644 input/day-9-example-large.txt create mode 100644 input/day-9-example.txt create mode 100644 input/day-9.txt diff --git a/common-lisp/day-9/example-large.txt b/common-lisp/day-9/example-large.txt new file mode 120000 index 0000000..9ede1e9 --- /dev/null +++ b/common-lisp/day-9/example-large.txt @@ -0,0 +1 @@ +../../input/day-9-example-large.txt \ No newline at end of file diff --git a/common-lisp/day-9/example.txt b/common-lisp/day-9/example.txt new file mode 120000 index 0000000..cf3a916 --- /dev/null +++ b/common-lisp/day-9/example.txt @@ -0,0 +1 @@ +../../input/day-9-example.txt \ No newline at end of file diff --git a/common-lisp/day-9/input.txt b/common-lisp/day-9/input.txt new file mode 120000 index 0000000..1bd8830 --- /dev/null +++ b/common-lisp/day-9/input.txt @@ -0,0 +1 @@ +../../input/day-9.txt \ No newline at end of file diff --git a/common-lisp/day-9/solution.lisp b/common-lisp/day-9/solution.lisp new file mode 100755 index 0000000..49e194a --- /dev/null +++ b/common-lisp/day-9/solution.lisp @@ -0,0 +1,171 @@ +#!/usr/bin/env -S sbcl --script + +;; Copyright (C) 2022 +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +(require 'asdf) +(require 'uiop) +(require 'iterate) +(require 'str) + +(defpackage advent-of-code-day-9 + (:use :cl :iterate) + (:import-from :uiop :if-let)) + +(in-package :advent-of-code-day-9) + +(defclass point () + ((x + :initarg :x + :reader x) + (y + :initarg :y + :reader y))) + +(defun new-point (x y) + (make-instance 'point :x x :y y)) + +(defmethod print-object ((obj point) stream) + (print-unreadable-object (obj stream :type t) + (format stream "x: ~a, y: ~a" (x obj) (y obj)))) + +(defun point+ (a b) + (new-point + (+ (x a) (x b)) + (+ (y a) (y b)))) + +(defun point- (a b) + (new-point + (- (x a) (x b)) + (- (y a) (y b)))) + +(defun point= (a b) + (and (= (x a) (x b)) + (= (y a) (y b)))) + +(defclass rope () + ((knots + :initarg :knots + :accessor knots))) + +(defun new-rope (len) + (make-instance 'rope :knots (iter (for x from 1 to len) + (collect (new-point 0 0))))) + +(defun touching? (head tail) + (let ((delta (point- head tail))) + (and (<= (abs (x delta)) 1) + (<= (abs (y delta)) 1)))) + +(defun aligned-along-y? (head tail) + (= (x head) (x tail))) + +(defun aligned-along-x? (head tail) + (= (y head) (y tail))) + +(defun aligned? (head tail) + (or (aligned-along-x? head tail) + (aligned-along-y? head tail))) + +;; Not sure what to name this function, but this is used to move the tail +;; towards the head when they are not touching but aligned by row or column, +;; which means we just step once in one direction instead of a diagonal hop. + +(defun catch-up-directional (head tail) + (let ((delta (point- head tail))) + (point+ tail (if (aligned-along-x? head tail) + (if (plusp (x delta)) + (new-point 1 0) + (new-point -1 0)) + (if (plusp (y delta)) + (new-point 0 1) + (new-point 0 -1)))))) + +(defun catch-up-diagonal (head tail) + (let ((delta (point- head tail))) + (point+ tail (cond ((and (plusp (x delta)) (plusp (y delta))) + (new-point 1 1)) + ((and (minusp (x delta)) (plusp (y delta))) + (new-point -1 1)) + ((and (plusp (x delta)) (minusp (y delta))) + (new-point 1 -1)) + ((and (minusp (x delta)) (minusp (y delta))) + (new-point -1 -1)))))) + +(defun catch-up (rope) + (iter (for (head . rest) on (knots rope)) + (while rest) + (for tail = (car rest)) + (unless (touching? head tail) + (setf (car rest) (if (aligned? head tail) + (catch-up-directional head tail) + (catch-up-diagonal head tail)))))) + +(defun move-rope (rope direction) + (with-accessors ((knots knots)) + rope + (setf (car knots) (point+ (car knots) (case direction + (:right (new-point 1 0)) + (:left (new-point -1 0)) + (:up (new-point 0 1)) + (:down (new-point 0 -1)))))) + (catch-up rope)) + +(defun parse-input (input) + (iter (for line in input) + (for parts = (str:split " " line :omit-nulls t)) + (for direction = (car parts)) + (for steps = (parse-integer (cadr parts))) + (collect (cons (cond ((string= direction "R") + :right) + ((string= direction "L") + :left) + ((string= direction "U") + :up) + ((string= direction "D") + :down)) + steps)))) + +(defun solution (input rope-length) + (iter (with rope = (new-rope rope-length)) + (with moves = (parse-input input)) + (with history = nil) + (for (direction . count) in moves) + (iter (repeat count) + (move-rope rope direction) + (for tail = (car (last (knots rope)))) + (unless (find tail history :test 'point=) + (push tail history))) + (finally (return (length history))))) + +(defun debug-print (&key stream width height rope) + (iter (for y from height downto 0) + (iter (for x from 0 to width) + (for current-point = (new-point x y)) + (for position = (position current-point (knots rope) :test 'point=)) + (if position + (format stream "~a " position) + (format stream "* "))) + (format stream "~%") + (finally (format stream "~%")))) + +(assert (= 13 (solution (uiop:read-file-lines "example.txt") 2))) +(assert (= 6044 (solution (uiop:read-file-lines "input.txt") 2))) +(assert (= 1 (solution (uiop:read-file-lines "example.txt") 10))) +(assert (= 36 (solution (uiop:read-file-lines "example-large.txt") 10))) +(assert (= 2384 (solution (uiop:read-file-lines "input.txt") 10))) + +;; Local Variables: +;; mode: lisp +;; End: diff --git a/input/day-9-example-large.txt b/input/day-9-example-large.txt new file mode 100644 index 0000000..60bd43b --- /dev/null +++ b/input/day-9-example-large.txt @@ -0,0 +1,8 @@ +R 5 +U 8 +L 8 +D 3 +R 17 +D 10 +L 25 +U 20 diff --git a/input/day-9-example.txt b/input/day-9-example.txt new file mode 100644 index 0000000..9874df2 --- /dev/null +++ b/input/day-9-example.txt @@ -0,0 +1,8 @@ +R 4 +U 4 +L 3 +D 1 +R 4 +D 1 +L 5 +R 2 diff --git a/input/day-9.txt b/input/day-9.txt new file mode 100644 index 0000000..b3b7f07 --- /dev/null +++ b/input/day-9.txt @@ -0,0 +1,2000 @@ +D 2 +U 1 +D 1 +U 2 +D 2 +U 2 +R 2 +D 1 +L 1 +U 2 +D 1 +R 1 +U 1 +D 1 +U 1 +D 2 +L 1 +D 1 +U 1 +R 1 +D 1 +R 1 +L 2 +D 1 +R 2 +U 2 +L 1 +U 1 +R 1 +D 1 +U 2 +D 1 +U 1 +R 1 +L 1 +U 1 +R 1 +D 2 +U 2 +R 2 +L 1 +R 2 +L 2 +D 1 +L 2 +R 2 +D 2 +R 2 +D 1 +R 2 +D 1 +R 1 +U 2 +L 2 +D 1 +R 2 +U 2 +L 1 +U 1 +R 2 +D 2 +L 1 +U 2 +R 2 +U 1 +R 1 +D 2 +L 1 +R 2 +U 1 +D 2 +U 1 +R 1 +L 2 +D 1 +U 1 +L 1 +R 2 +L 2 +R 1 +D 2 +L 1 +R 2 +L 2 +R 2 +U 2 +L 2 +R 2 +L 2 +R 1 +L 2 +D 1 +L 2 +D 1 +R 2 +D 2 +U 2 +L 2 +R 2 +U 2 +D 1 +R 2 +L 1 +D 2 +U 1 +L 1 +D 2 +L 1 +U 2 +L 2 +U 1 +L 2 +U 2 +D 1 +R 2 +U 3 +R 3 +L 1 +R 2 +D 1 +R 1 +U 2 +L 2 +U 3 +L 1 +U 1 +R 3 +D 1 +U 1 +R 3 +U 2 +L 2 +D 1 +L 2 +D 2 +U 2 +D 2 +L 3 +U 3 +R 3 +D 1 +L 2 +D 3 +R 2 +L 1 +U 3 +D 2 +U 3 +L 1 +R 3 +U 1 +L 2 +R 1 +D 1 +U 2 +D 2 +R 2 +L 1 +U 3 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 14 +R 4 +D 15 +U 2 +L 12 +R 10 +D 15 +L 7 +R 1 +U 17 +R 16 +U 4 +L 12 +D 2 +R 10 +U 17 +D 13 +L 5 +D 16 +R 14 +L 9 +D 3 +U 5 +D 8 +U 17 +L 6 +D 6 +L 4 +D 12 +R 10 +U 10 +D 10 +L 1 +R 7 +U 9 +D 7 +R 14 +L 4 +U 6 +L 17 +U 15 +D 13 +L 17 +R 2 +L 6 +D 10 +U 14 +R 9 +L 11 +U 12 +D 7 +R 15 +D 9 +U 13 +D 13 +U 9 +D 17 +U 8 +D 11 +L 12 +R 17 +U 17 +D 6 +L 17 +D 5 +L 5 +D 11 +R 9 +U 9 +D 15 +L 6 +R 4 +L 6 +U 10 +L 2 +U 15 +L 15 +R 6 +L 15 +U 13 +R 9 +D 12 +R 4 +U 11 +R 3 +L 10 +R 18 +L 5 +R 14 +L 3 +D 1 +U 12 +R 10 +L 16 +R 11 +U 6 +D 7 +U 6 +R 5 +D 19 +L 12 +R 16 +D 4 +L 15 +D 14 +L 17 +U 18 +D 13 +R 3 +D 9 +L 14 +U 16 +L 6 +U 14 +L 10 +D 2 +U 8 +L 1 +U 7 +D 12 +U 16 +L 15 +U 16 +R 15 +D 5 +R 7 +U 5 +R 13 +L 16 +D 7 +L 14 +R 9 +U 10 +L 16 +D 4 +U 17 +L 8 +D 3 +U 9 +D 2 +R 8 +D 3 +L 17 +D 1 +U 19 +R 16 +D 8 +U 18 +D 14 +U 1 +D 4 +U 12 +D 17 +R 19 +U 8 +D 7 +U 19 +R 15 +U 10 +R 6 +D 9 +L 6 +R 13 +D 16 +L 17 +R 18 +U 10 +R 19 +U 12 +D 19 +R 2 +L 8 +D 1 +L 17 +D 11 +R 7 +U 17 +L 4 +R 16 +U 17 +D 5 +L 8 +U 17 +L 16 +U 8 +L 19 +R 15 +U 5 +D 2 +R 18 +L 14 +D 9 +L 1 +D 5 +U 5 +D 8 +U 3 +R 9 +L 5 +R 6 +U 10 +R 3 +L 9