diff options
author | H.J <thechairman@thechairman.info> | 2024-10-09 11:36:55 -0400 |
---|---|---|
committer | H.J <thechairman@thechairman.info> | 2024-10-09 11:36:55 -0400 |
commit | 8777ff071f7bb37631baa7b6717ad29961e50911 (patch) | |
tree | 6d59c4ed58e454b960339c3d1151f0a879e8d7cb /aoc2021/day-19 | |
parent | 6156a9ef7be4012063a042aafb4e9b0d7eadde8e (diff) | |
download | gleam_aoc-8777ff071f7bb37631baa7b6717ad29961e50911.tar.gz gleam_aoc-8777ff071f7bb37631baa7b6717ad29961e50911.zip |
sorting by language
Diffstat (limited to 'aoc2021/day-19')
-rw-r--r-- | aoc2021/day-19/day-19.rkt | 48 | ||||
-rw-r--r-- | aoc2021/day-19/test-scanners | 136 |
2 files changed, 0 insertions, 184 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))) diff --git a/aoc2021/day-19/test-scanners b/aoc2021/day-19/test-scanners deleted file mode 100644 index b596cc4..0000000 --- a/aoc2021/day-19/test-scanners +++ /dev/null @@ -1,136 +0,0 @@ ---- scanner 0 --- -404,-588,-901 -528,-643,409 --838,591,734 -390,-675,-793 --537,-823,-458 --485,-357,347 --345,-311,381 --661,-816,-575 --876,649,763 --618,-824,-621 -553,345,-567 -474,580,667 --447,-329,318 --584,868,-557 -544,-627,-890 -564,392,-477 -455,729,728 --892,524,684 --689,845,-530 -423,-701,434 -7,-33,-71 -630,319,-379 -443,580,662 --789,900,-551 -459,-707,401 - ---- scanner 1 --- -686,422,578 -605,423,415 -515,917,-361 --336,658,858 -95,138,22 --476,619,847 --340,-569,-846 -567,-361,727 --460,603,-452 -669,-402,600 -729,430,532 --500,-761,534 --322,571,750 --466,-666,-811 --429,-592,574 --355,545,-477 -703,-491,-529 --328,-685,520 -413,935,-424 --391,539,-444 -586,-435,557 --364,-763,-893 -807,-499,-711 -755,-354,-619 -553,889,-390 - ---- scanner 2 --- -649,640,665 -682,-795,504 --784,533,-524 --644,584,-595 --588,-843,648 --30,6,44 --674,560,763 -500,723,-460 -609,671,-379 --555,-800,653 --675,-892,-343 -697,-426,-610 -578,704,681 -493,664,-388 --671,-858,530 --667,343,800 -571,-461,-707 --138,-166,112 --889,563,-600 -646,-828,498 -640,759,510 --630,509,768 --681,-892,-333 -673,-379,-804 --742,-814,-386 -577,-820,562 - ---- scanner 3 --- --589,542,597 -605,-692,669 --500,565,-823 --660,373,557 --458,-679,-417 --488,449,543 --626,468,-788 -338,-750,-386 -528,-832,-391 -562,-778,733 --938,-730,414 -543,643,-506 --524,371,-870 -407,773,750 --104,29,83 -378,-903,-323 --778,-728,485 -426,699,580 --438,-605,-362 --469,-447,-387 -509,732,623 -647,635,-688 --868,-804,481 -614,-800,639 -595,780,-596 - ---- scanner 4 --- -727,592,562 --293,-554,779 -441,611,-461 --714,465,-776 --743,427,-804 --660,-479,-426 -832,-632,460 -927,-485,-438 -408,393,-506 -466,436,-512 -110,16,151 --258,-428,682 --393,719,612 --211,-452,876 -808,-476,-593 --575,615,604 --485,667,467 --680,325,-822 --627,-443,-432 -872,-547,-609 -833,512,582 -807,604,487 -839,-516,451 -891,-625,532 --652,-548,-490 -30,-46,-14
\ No newline at end of file |