aboutsummaryrefslogtreecommitdiff
path: root/aoc2021/day-19/day-19.rkt
diff options
context:
space:
mode:
authorH.J <thechairman@thechairman.info>2024-10-09 11:36:55 -0400
committerH.J <thechairman@thechairman.info>2024-10-09 11:36:55 -0400
commit8777ff071f7bb37631baa7b6717ad29961e50911 (patch)
tree6d59c4ed58e454b960339c3d1151f0a879e8d7cb /aoc2021/day-19/day-19.rkt
parent6156a9ef7be4012063a042aafb4e9b0d7eadde8e (diff)
downloadgleam_aoc-8777ff071f7bb37631baa7b6717ad29961e50911.tar.gz
gleam_aoc-8777ff071f7bb37631baa7b6717ad29961e50911.zip
sorting by language
Diffstat (limited to 'aoc2021/day-19/day-19.rkt')
-rw-r--r--aoc2021/day-19/day-19.rkt48
1 files changed, 0 insertions, 48 deletions
diff --git a/aoc2021/day-19/day-19.rkt b/aoc2021/day-19/day-19.rkt
deleted file mode 100644
index 4c6334d..0000000
--- a/aoc2021/day-19/day-19.rkt
+++ /dev/null
@@ -1,48 +0,0 @@
-#lang racket
-(require "../../jj-aoc.rkt"
- threading
- racket/struct)
-
-(struct coord (x y z) #:transparent)
-
-(define (coord-broadcast f c1 c2)
- (match-define (coord x1 y1 z1) c1)
- (match-define (coord x2 y2 z2) c2)
- (coord (f x1 x2) (f y1 y2) (f z1 z2)))
-
-(define (coord-reduce f c1 c2)
- (foldl (λ (i1 i2 acc) (+ acc (f i1 i2))) 0 (struct->list c1) (struct->list c2)))
-
-(define coord-delta (curry coord-broadcast -))
-(define coord-sum (curry coord-broadcast +))
-(define coord-manhattan (curry coord-reduce (coord 0 0 0)))
-
-(define (create-scan-data d)
- (for/list ([l (in-list d)])
- (for/list ([pt (in-list (~> (string-split l "\n") rest))])
- (~>> pt
- (regexp-match #px"(-?\\d+),(-?\\d+),(-?\\d+)")
- rest
- (map string->number)
- (apply coord)))))
-
-(define scanner-data (create-scan-data (~>> (open-day 19 2021) port->string (string-split _ "\n\n"))))
-
-(define (generate-rotations scanner)
- (apply
- map
- list
- (for*/list ([pt (in-list scanner)])
- (match-define (coord x y z) pt)
- (define orientations (list (list x y z) (list x z (- y)) (list x (- y) (- z)) (list x (- z) y)))
- (append* (for/list ([o (in-list orientations)])
- (match-define (list x* y* z*) o)
- (list (list x y z)
- (list (- x) z y)
- (list z (- y) x)
- (list y x (- z))
- (list (- y) (- z) x)))))))
-
-(define (find-overlaps scan1 scan2)
- (for/list ([rotation (in-permutations scan2)])
- (map coord-sum scan1 rotation)))