From 6156a9ef7be4012063a042aafb4e9b0d7eadde8e Mon Sep 17 00:00:00 2001 From: "H.J" Date: Wed, 9 Oct 2024 11:35:09 -0400 Subject: cleanup --- aoc2016/day-01/day-01.rkt | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 aoc2016/day-01/day-01.rkt (limited to 'aoc2016/day-01') diff --git a/aoc2016/day-01/day-01.rkt b/aoc2016/day-01/day-01.rkt deleted file mode 100644 index d18c819..0000000 --- a/aoc2016/day-01/day-01.rkt +++ /dev/null @@ -1,38 +0,0 @@ -#lang racket - -(require advent-of-code - threading) - -(struct posn (x y) #:transparent) -(struct dir (x y) #:transparent) - -(define/match (left _d) - [((dir 0 1)) (dir -1 0)] - [((dir -1 0)) (dir 0 -1)] - [((dir 0 -1)) (dir 1 0)] - [((dir 1 0)) (dir 0 1)]) - -(define/match (right _d) - [((dir 0 1)) (dir 1 0)] - [((dir 1 0)) (dir 0 -1)] - [((dir 0 -1)) (dir -1 0)] - [((dir -1 0)) (dir 0 1)]) - -(define/match (go _from _d _dist) - [((posn x y) (dir dx dy) dist) (posn (+ x (* dx dist)) (+ y (* dy dist)))]) - -(define input (~> (fetch-aoc-input (find-session) 2016 1 #:cache #true) string-trim (string-split ", "))) - -;; part 1 -(for/fold ([p (posn 0 0)] - [d (dir 0 1)] - #:result (+ (abs (posn-x p)) (abs (posn-y p)))) - ([instruction (in-list input)]) - (displayln (~a p " " d)) - (match instruction - [(regexp #rx"L(.*)" (list _ n)) (values (go p (left d) (string->number n)) - (left d))] - [(regexp #rx"R(.*)" (list _ n)) (values (go p (right d) (string->number n)) - (right d))])) - -;; part 2 -- cgit v1.2.3