Added Solution for 2021 day 19
This commit is contained in:
parent
a89f7ded79
commit
90a1203fda
5 changed files with 1676 additions and 0 deletions
8
2021/day19_beacon_scanner/Cargo.toml
Normal file
8
2021/day19_beacon_scanner/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "day19_beacon_scanner"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
412
2021/day19_beacon_scanner/challenge.txt
Normal file
412
2021/day19_beacon_scanner/challenge.txt
Normal file
|
@ -0,0 +1,412 @@
|
|||
As your [probe](17) drifted down through this area, it released an assortment of *beacons* and *scanners* into the water. It's difficult to navigate in the pitch black open waters of the ocean trench, but if you can build a map of the trench using data from the scanners, you should be able to safely reach the bottom.
|
||||
|
||||
The beacons and scanners float motionless in the water; they're designed to maintain the same position for long periods of time. Each scanner is capable of detecting all beacons in a large cube centered on the scanner; beacons that are at most 1000 units away from the scanner in each of the three axes (`x`, `y`, and `z`) have their precise position determined relative to the scanner. However, scanners cannot detect other scanners. The submarine has automatically summarized the relative positions of beacons detected by each scanner (your puzzle input).
|
||||
|
||||
For example, if a scanner is at `x,y,z` coordinates `500,0,-500` and there are beacons at `-500,1000,-1500` and `1501,0,-500`, the scanner could report that the first beacon is at `-1000,1000,-1000` (relative to the scanner) but would not detect the second beacon at all.
|
||||
|
||||
Unfortunately, while each scanner can report the positions of all detected beacons relative to itself, *the scanners do not know their own position*. You'll need to determine the positions of the beacons and scanners yourself.
|
||||
|
||||
The scanners and beacons map a single contiguous 3d region. This region can be reconstructed by finding pairs of scanners that have overlapping detection regions such that there are *at least 12 beacons* that both scanners detect within the overlap. By establishing 12 common beacons, you can precisely determine where the scanners are relative to each other, allowing you to reconstruct the beacon map one scanner at a time.
|
||||
|
||||
For a moment, consider only two dimensions. Suppose you have the following scanner reports:
|
||||
|
||||
```
|
||||
--- scanner 0 ---
|
||||
0,2
|
||||
4,1
|
||||
3,3
|
||||
|
||||
--- scanner 1 ---
|
||||
-1,-1
|
||||
-5,0
|
||||
-2,1
|
||||
|
||||
```
|
||||
|
||||
Drawing `x` increasing rightward, `y` increasing upward, scanners as `S`, and beacons as `B`, scanner `0` detects this:
|
||||
|
||||
```
|
||||
...B.
|
||||
B....
|
||||
....B
|
||||
S....
|
||||
|
||||
```
|
||||
|
||||
Scanner `1` detects this:
|
||||
|
||||
```
|
||||
...B..
|
||||
B....S
|
||||
....B.
|
||||
|
||||
```
|
||||
|
||||
For this example, assume scanners only need 3 overlapping beacons. Then, the beacons visible to both scanners overlap to produce the following complete map:
|
||||
|
||||
```
|
||||
...B..
|
||||
B....S
|
||||
....B.
|
||||
S.....
|
||||
|
||||
```
|
||||
|
||||
Unfortunately, there's a second problem: the scanners also don't know their *rotation or facing direction*. Due to magnetic alignment, each scanner is rotated some integer number of 90-degree turns around all of the `x`, `y`, and `z` axes. That is, one scanner might call a direction positive `x`, while another scanner might call that direction negative `y`. Or, two scanners might agree on which direction is positive `x`, but one scanner might be upside-down from the perspective of the other scanner. In total, each scanner could be in any of 24 different orientations: facing positive or negative `x`, `y`, or `z`, and considering any of four directions "up" from that facing.
|
||||
|
||||
For example, here is an arrangement of beacons as seen from a scanner in the same position but in different orientations:
|
||||
|
||||
```
|
||||
--- scanner 0 ---
|
||||
-1,-1,1
|
||||
-2,-2,2
|
||||
-3,-3,3
|
||||
-2,-3,1
|
||||
5,6,-4
|
||||
8,0,7
|
||||
|
||||
--- scanner 0 ---
|
||||
1,-1,1
|
||||
2,-2,2
|
||||
3,-3,3
|
||||
2,-1,3
|
||||
-5,4,-6
|
||||
-8,-7,0
|
||||
|
||||
--- scanner 0 ---
|
||||
-1,-1,-1
|
||||
-2,-2,-2
|
||||
-3,-3,-3
|
||||
-1,-3,-2
|
||||
4,6,5
|
||||
-7,0,8
|
||||
|
||||
--- scanner 0 ---
|
||||
1,1,-1
|
||||
2,2,-2
|
||||
3,3,-3
|
||||
1,3,-2
|
||||
-4,-6,5
|
||||
7,0,8
|
||||
|
||||
--- scanner 0 ---
|
||||
1,1,1
|
||||
2,2,2
|
||||
3,3,3
|
||||
3,1,2
|
||||
-6,-4,-5
|
||||
0,7,-8
|
||||
|
||||
```
|
||||
|
||||
By finding pairs of scanners that both see at least 12 of the same beacons, you can assemble the entire map. For example, consider the following report:
|
||||
|
||||
```
|
||||
--- 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
|
||||
|
||||
```
|
||||
|
||||
Because all coordinates are relative, in this example, all "absolute" positions will be expressed relative to scanner `0` (using the orientation of scanner `0` and as if scanner `0` is at coordinates `0,0,0`).
|
||||
|
||||
Scanners `0` and `1` have overlapping detection cubes; the 12 beacons they both detect (relative to scanner `0`) are at the following coordinates:
|
||||
|
||||
```
|
||||
-618,-824,-621
|
||||
-537,-823,-458
|
||||
-447,-329,318
|
||||
404,-588,-901
|
||||
544,-627,-890
|
||||
528,-643,409
|
||||
-661,-816,-575
|
||||
390,-675,-793
|
||||
423,-701,434
|
||||
-345,-311,381
|
||||
459,-707,401
|
||||
-485,-357,347
|
||||
|
||||
```
|
||||
|
||||
These same 12 beacons (in the same order) but from the perspective of scanner `1` are:
|
||||
|
||||
```
|
||||
686,422,578
|
||||
605,423,415
|
||||
515,917,-361
|
||||
-336,658,858
|
||||
-476,619,847
|
||||
-460,603,-452
|
||||
729,430,532
|
||||
-322,571,750
|
||||
-355,545,-477
|
||||
413,935,-424
|
||||
-391,539,-444
|
||||
553,889,-390
|
||||
|
||||
```
|
||||
|
||||
Because of this, scanner `1` must be at `68,-1246,-43` (relative to scanner `0`).
|
||||
|
||||
Scanner `4` overlaps with scanner `1`; the 12 beacons they both detect (relative to scanner `0`) are:
|
||||
|
||||
```
|
||||
459,-707,401
|
||||
-739,-1745,668
|
||||
-485,-357,347
|
||||
432,-2009,850
|
||||
528,-643,409
|
||||
423,-701,434
|
||||
-345,-311,381
|
||||
408,-1815,803
|
||||
534,-1912,768
|
||||
-687,-1600,576
|
||||
-447,-329,318
|
||||
-635,-1737,486
|
||||
|
||||
```
|
||||
|
||||
So, scanner `4` is at `-20,-1133,1061` (relative to scanner `0`).
|
||||
|
||||
Following this process, scanner `2` must be at `1105,-1205,1229` (relative to scanner `0`) and scanner `3` must be at `-92,-2380,-20` (relative to scanner `0`).
|
||||
|
||||
The full list of beacons (relative to scanner `0`) is:
|
||||
|
||||
```
|
||||
-892,524,684
|
||||
-876,649,763
|
||||
-838,591,734
|
||||
-789,900,-551
|
||||
-739,-1745,668
|
||||
-706,-3180,-659
|
||||
-697,-3072,-689
|
||||
-689,845,-530
|
||||
-687,-1600,576
|
||||
-661,-816,-575
|
||||
-654,-3158,-753
|
||||
-635,-1737,486
|
||||
-631,-672,1502
|
||||
-624,-1620,1868
|
||||
-620,-3212,371
|
||||
-618,-824,-621
|
||||
-612,-1695,1788
|
||||
-601,-1648,-643
|
||||
-584,868,-557
|
||||
-537,-823,-458
|
||||
-532,-1715,1894
|
||||
-518,-1681,-600
|
||||
-499,-1607,-770
|
||||
-485,-357,347
|
||||
-470,-3283,303
|
||||
-456,-621,1527
|
||||
-447,-329,318
|
||||
-430,-3130,366
|
||||
-413,-627,1469
|
||||
-345,-311,381
|
||||
-36,-1284,1171
|
||||
-27,-1108,-65
|
||||
7,-33,-71
|
||||
12,-2351,-103
|
||||
26,-1119,1091
|
||||
346,-2985,342
|
||||
366,-3059,397
|
||||
377,-2827,367
|
||||
390,-675,-793
|
||||
396,-1931,-563
|
||||
404,-588,-901
|
||||
408,-1815,803
|
||||
423,-701,434
|
||||
432,-2009,850
|
||||
443,580,662
|
||||
455,729,728
|
||||
456,-540,1869
|
||||
459,-707,401
|
||||
465,-695,1988
|
||||
474,580,667
|
||||
496,-1584,1900
|
||||
497,-1838,-617
|
||||
527,-524,1933
|
||||
528,-643,409
|
||||
534,-1912,768
|
||||
544,-627,-890
|
||||
553,345,-567
|
||||
564,392,-477
|
||||
568,-2007,-577
|
||||
605,-1665,1952
|
||||
612,-1593,1893
|
||||
630,319,-379
|
||||
686,-3108,-505
|
||||
776,-3184,-501
|
||||
846,-3110,-434
|
||||
1135,-1161,1235
|
||||
1243,-1093,1063
|
||||
1660,-552,429
|
||||
1693,-557,386
|
||||
1735,-437,1738
|
||||
1749,-1800,1813
|
||||
1772,-405,1572
|
||||
1776,-675,371
|
||||
1779,-442,1789
|
||||
1780,-1548,337
|
||||
1786,-1538,337
|
||||
1847,-1591,415
|
||||
1889,-1729,1762
|
||||
1994,-1805,1792
|
||||
|
||||
```
|
||||
|
||||
In total, there are `*79*` beacons.
|
||||
|
||||
Assemble the full map of beacons. *How many beacons are there?*
|
||||
|
||||
Your puzzle answer was `430`.
|
||||
|
||||
\--- Part Two ---
|
||||
----------
|
||||
|
||||
Sometimes, it's a good idea to appreciate just how big the ocean is. Using the [Manhattan distance](https://en.wikipedia.org/wiki/Taxicab_geometry), how far apart do the scanners get?
|
||||
|
||||
In the above example, scanners `2` (`1105,-1205,1229`) and `3` (`-92,-2380,-20`) are the largest Manhattan distance apart. In total, they are `1197 + 1175 + 1249 = *3621*` units apart.
|
||||
|
||||
*What is the largest Manhattan distance between any two scanners?*
|
||||
|
||||
Your puzzle answer was `11860`.
|
||||
|
||||
Both parts of this puzzle are complete! They provide two gold stars: \*\*
|
||||
|
||||
At this point, you should [return to your Advent calendar](/2021) and try another puzzle.
|
||||
|
||||
If you still want to see it, you can [get your puzzle input](19/input).
|
199
2021/day19_beacon_scanner/src/lib.rs
Normal file
199
2021/day19_beacon_scanner/src/lib.rs
Normal file
|
@ -0,0 +1,199 @@
|
|||
use core::fmt::Display;
|
||||
use std::{num::ParseIntError, collections::{HashSet, HashMap}};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum ParseError {
|
||||
ParseIntError(std::num::ParseIntError),
|
||||
LineMalformed(String),
|
||||
}
|
||||
|
||||
impl From<ParseIntError> for ParseError {
|
||||
fn from(value: ParseIntError) -> Self {
|
||||
Self::ParseIntError(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for ParseError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::ParseIntError(e) => write!(f, "Unable to parse into integer: {e}"),
|
||||
Self::LineMalformed(v) => write!(f, "Line is malformed: {v}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const ROTATIONS_MATRICES: [[isize; 9]; 24] = [
|
||||
[1, 0, 0, 0, 1, 0, 0, 0, 1],
|
||||
[1, 0, 0, 0, 0, 1, 0, -1, 0],
|
||||
[1, 0, 0, 0, -1, 0, 0, 0, -1],
|
||||
[1, 0, 0, 0, 0, -1, 0, 1, 0],
|
||||
[0, 1, 0, 0, 0, 1, 1, 0, 0],
|
||||
[0, 1, 0, 1, 0, 0, 0, 0, -1],
|
||||
[0, 1, 0, 0, 0, -1, -1, 0, 0],
|
||||
[0, 1, 0, -1, 0, 0, 0, 0, 1],
|
||||
[0, 0, 1, 1, 0, 0, 0, 1, 0],
|
||||
[0, 0, 1, 0, 1, 0, -1, 0, 0],
|
||||
[0, 0, 1, -1, 0, 0, 0, -1, 0],
|
||||
[0, 0, 1, 0, -1, 0, 1, 0, 0],
|
||||
[-1, 0, 0, 0, -1, 0, 0, 0, 1],
|
||||
[-1, 0, 0, 0, 0, 1, 0, 1, 0],
|
||||
[-1, 0, 0, 0, 1, 0, 0, 0, -1],
|
||||
[-1, 0, 0, 0, 0, -1, 0, -1, 0],
|
||||
[0, -1, 0, 0, 0, -1, 1, 0, 0],
|
||||
[0, -1, 0, 1, 0, 0, 0, 0, 1],
|
||||
[0, -1, 0, 0, 0, 1, -1, 0, 0],
|
||||
[0, -1, 0, -1, 0, 0, 0, 0, -1],
|
||||
[0, 0, -1, -1, 0, 0, 0, 1, 0],
|
||||
[0, 0, -1, 0, 1, 0, 1, 0, 0],
|
||||
[0, 0, -1, 1, 0, 0, 0, -1, 0],
|
||||
[0, 0, -1, 0, -1, 0, -1, 0, 0],
|
||||
];
|
||||
|
||||
type Coordinates = (isize, isize, isize);
|
||||
|
||||
struct Scan {
|
||||
probes: Vec<Coordinates>,
|
||||
distances: Vec<Vec<(usize, usize, usize)>>,
|
||||
}
|
||||
|
||||
impl TryFrom<&str> for Scan {
|
||||
type Error = ParseError;
|
||||
|
||||
fn try_from(value: &str) -> Result<Self, Self::Error> {
|
||||
let mut probes = Vec::new();
|
||||
let mut distances: Vec<Vec<(usize, usize, usize)>> = Vec::new();
|
||||
|
||||
for line in value.lines().skip(1) {
|
||||
let coords: Vec<_> = line.split(',').map(|i| i.parse()).collect::<Result<Vec<_>, _>>()?;
|
||||
if coords.len() != 3 {
|
||||
return Err(Self::Error::LineMalformed(line.to_string()));
|
||||
}
|
||||
let this = (coords[0], coords[1], coords[2]);
|
||||
probes.push(this);
|
||||
let mut this_distances = Vec::new();
|
||||
for other in &probes {
|
||||
this_distances.push((manhattan_distance(this, *other), min_distance(this, *other), max_distance(this, *other)));
|
||||
}
|
||||
for (idx, other_distances) in distances.iter_mut().enumerate() {
|
||||
other_distances.push(this_distances[idx]);
|
||||
}
|
||||
distances.push(this_distances);
|
||||
}
|
||||
|
||||
Ok(Self { probes, distances, })
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run(input: &str) -> Result<(usize, usize), ParseError> {
|
||||
let mut scans: Vec<_> = input.split("\n\n").map(Scan::try_from).collect::<Result<Vec<_>, _>>()?;
|
||||
let mut known_beacons: HashSet<_> = scans[0].probes.iter().cloned().collect();
|
||||
let mut known_distances = HashMap::new();
|
||||
extend_distances(&mut known_distances, &scans[0].probes.to_vec());
|
||||
let mut scanners = vec![(0, 0, 0)];
|
||||
scans.swap_remove(0);
|
||||
|
||||
while !scans.is_empty() {
|
||||
for (idx, scan) in scans.iter().enumerate() {
|
||||
if let Some((scanner, report)) = find_match(&known_beacons, &known_distances, scan) {
|
||||
extend_distances(&mut known_distances, &report);
|
||||
scanners.push(scanner);
|
||||
known_beacons.extend(report.iter());
|
||||
scans.swap_remove(idx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let first = known_beacons.len();
|
||||
let second = scanners.iter().map(|lhs| scanners.iter().map(|rhs| manhattan_distance(*lhs, *rhs)).max().unwrap()).max().unwrap();
|
||||
Ok((first, second))
|
||||
}
|
||||
|
||||
fn find_match(known_beacons: &HashSet<Coordinates>, known_distances: &HashMap<(usize, usize, usize), Vec<[Coordinates; 2]>>, scan: &Scan) -> Option<(Coordinates, Vec<Coordinates>)> {
|
||||
let matches = scan.distances.iter().enumerate().flat_map(|(y, row)| row.iter().enumerate().skip(y+1).filter(|(_x, dist)| known_distances.contains_key(dist)).map(|(x, _dist)| (y, x)).collect::<Vec<_>>()).collect::<Vec<_>>();
|
||||
|
||||
// Ignore if we have matches for less than 12 probes (2 choose 12 = 66 matches in total)
|
||||
if matches.len() < 66 {
|
||||
return None;
|
||||
}
|
||||
|
||||
for (y, x) in matches {
|
||||
for known_pair in known_distances.get(&scan.distances[y][x]).unwrap() {
|
||||
let [kp1, kp2] = known_pair;
|
||||
let [rp1, rp2] = [scan.probes[y], scan.probes[x]];
|
||||
|
||||
if let Some(rotation) = ROTATIONS_MATRICES.iter()
|
||||
.find(|&r| vec_sub(*kp1, matrix_mul(r, rp1)) == vec_sub(*kp2, matrix_mul(r, rp2))) {
|
||||
let translation = vec_sub(*kp1, matrix_mul(rotation, rp1));
|
||||
|
||||
let transformed = scan.probes.iter()
|
||||
.map(|p| vec_add(matrix_mul(rotation, *p), translation))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if transformed.iter().filter(|p| known_beacons.contains(p)).count() >= 3 {
|
||||
return Some((translation, transformed));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn extend_distances(known_distances: &mut HashMap<(usize, usize, usize), Vec<[Coordinates; 2]>>, report: &Vec<Coordinates>) {
|
||||
for lhs in report {
|
||||
for rhs in report {
|
||||
let distances = (manhattan_distance(*lhs, *rhs), min_distance(*lhs, *rhs), max_distance(*lhs, *rhs));
|
||||
known_distances.entry(distances).or_insert(Vec::from([[*lhs, *rhs]]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn matrix_mul(matrix: &[isize; 9], vec: Coordinates) -> Coordinates {
|
||||
(
|
||||
vec.0 * matrix[0] + vec.1 * matrix[3] + vec.2 * matrix[6],
|
||||
vec.0 * matrix[1] + vec.1 * matrix[4] + vec.2 * matrix[7],
|
||||
vec.0 * matrix[2] + vec.1 * matrix[5] + vec.2 * matrix[8]
|
||||
)
|
||||
}
|
||||
|
||||
fn vec_sub(lhs: Coordinates, rhs: Coordinates) -> Coordinates {
|
||||
(lhs.0-rhs.0, lhs.1-rhs.1, lhs.2-rhs.2)
|
||||
}
|
||||
|
||||
fn vec_add(lhs: Coordinates, rhs: Coordinates) -> Coordinates {
|
||||
(lhs.0+rhs.0, lhs.1+rhs.1, lhs.2+rhs.2)
|
||||
}
|
||||
|
||||
fn manhattan_distance(lhs: Coordinates, rhs: Coordinates) -> usize {
|
||||
lhs.0.abs_diff(rhs.0) + lhs.1.abs_diff(rhs.1) + lhs.2.abs_diff(rhs.2)
|
||||
}
|
||||
|
||||
fn min_distance(lhs: Coordinates, rhs: Coordinates) -> usize {
|
||||
lhs.0.abs_diff(rhs.0).min(lhs.1.abs_diff(rhs.1)).min(lhs.2.abs_diff(rhs.2))
|
||||
}
|
||||
|
||||
fn max_distance(lhs: Coordinates, rhs: Coordinates) -> usize {
|
||||
lhs.0.abs_diff(rhs.0).max(lhs.1.abs_diff(rhs.1)).max(lhs.2.abs_diff(rhs.2))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::fs::read_to_string;
|
||||
|
||||
fn read_file(name: &str) -> String {
|
||||
read_to_string(name).expect(&format!("Unable to read file: {name}")[..]).trim().to_string()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sample() {
|
||||
let sample_input = read_file("tests/sample_input");
|
||||
assert_eq!(run(&sample_input), Ok((79, 3621)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_challenge() {
|
||||
let challenge_input = read_file("tests/challenge_input");
|
||||
assert_eq!(run(&challenge_input), Ok((430, 11860)));
|
||||
}
|
||||
}
|
921
2021/day19_beacon_scanner/tests/challenge_input
Normal file
921
2021/day19_beacon_scanner/tests/challenge_input
Normal file
|
@ -0,0 +1,921 @@
|
|||
--- scanner 0 ---
|
||||
-377,550,716
|
||||
405,-463,594
|
||||
-612,-603,479
|
||||
-673,637,-463
|
||||
536,-465,715
|
||||
821,322,-697
|
||||
-676,-693,500
|
||||
643,432,654
|
||||
366,-500,-472
|
||||
708,409,-755
|
||||
469,-498,555
|
||||
738,371,759
|
||||
600,282,729
|
||||
362,-630,-324
|
||||
-446,-778,-395
|
||||
-679,-672,612
|
||||
-450,654,697
|
||||
353,-429,-389
|
||||
-661,719,-393
|
||||
118,-178,-1
|
||||
702,313,-718
|
||||
-540,-676,-341
|
||||
-716,754,-469
|
||||
-313,635,722
|
||||
-546,-749,-540
|
||||
-46,-64,45
|
||||
|
||||
--- scanner 1 ---
|
||||
-393,569,-783
|
||||
823,673,744
|
||||
492,605,-667
|
||||
568,-702,420
|
||||
498,-690,338
|
||||
-442,536,-928
|
||||
-458,-493,-747
|
||||
-617,-342,422
|
||||
-654,709,686
|
||||
539,-496,-476
|
||||
540,570,-668
|
||||
-416,521,-829
|
||||
756,-480,-461
|
||||
-387,-515,-848
|
||||
-549,614,625
|
||||
-611,-406,507
|
||||
666,628,-671
|
||||
-592,-479,403
|
||||
632,-478,-385
|
||||
802,792,735
|
||||
860,679,648
|
||||
27,17,-91
|
||||
-624,571,775
|
||||
-535,-422,-848
|
||||
574,-745,303
|
||||
|
||||
--- scanner 2 ---
|
||||
558,-741,-564
|
||||
646,-807,485
|
||||
464,437,812
|
||||
-898,-528,468
|
||||
616,-770,-508
|
||||
-127,-22,17
|
||||
351,393,-850
|
||||
532,-629,-522
|
||||
-680,-690,-789
|
||||
600,353,768
|
||||
-655,-827,-770
|
||||
593,-678,448
|
||||
675,-648,590
|
||||
-808,525,-539
|
||||
-765,-461,537
|
||||
335,474,-887
|
||||
-777,396,-580
|
||||
241,407,-941
|
||||
-787,793,667
|
||||
-973,848,720
|
||||
-661,-763,-685
|
||||
-789,519,-676
|
||||
449,424,815
|
||||
-815,754,730
|
||||
-42,81,-107
|
||||
-877,-464,558
|
||||
|
||||
--- scanner 3 ---
|
||||
-436,572,-578
|
||||
746,-456,727
|
||||
-475,513,-649
|
||||
-451,-549,481
|
||||
-562,-572,-515
|
||||
774,-516,696
|
||||
-704,791,507
|
||||
768,-722,-551
|
||||
812,-661,-568
|
||||
-613,684,551
|
||||
700,767,716
|
||||
-303,592,-650
|
||||
116,21,-89
|
||||
-408,-507,547
|
||||
753,-717,750
|
||||
609,753,-601
|
||||
-62,-9,37
|
||||
553,672,-596
|
||||
836,-673,-599
|
||||
-467,-404,-483
|
||||
-660,817,634
|
||||
-609,-356,-546
|
||||
602,796,-590
|
||||
692,646,766
|
||||
-565,-477,532
|
||||
702,620,743
|
||||
|
||||
--- scanner 4 ---
|
||||
538,-453,-833
|
||||
-126,24,29
|
||||
-352,-473,-587
|
||||
-444,-449,-740
|
||||
691,-464,520
|
||||
626,828,344
|
||||
-565,-317,406
|
||||
775,942,-788
|
||||
-369,-409,417
|
||||
-708,823,-645
|
||||
727,935,-697
|
||||
-746,539,507
|
||||
-806,434,481
|
||||
-789,742,-763
|
||||
-556,-362,404
|
||||
-690,470,523
|
||||
593,877,489
|
||||
405,-436,-796
|
||||
317,-447,-785
|
||||
-404,-427,-788
|
||||
-13,189,-5
|
||||
-698,727,-823
|
||||
600,898,-737
|
||||
561,-551,518
|
||||
641,854,443
|
||||
733,-626,469
|
||||
|
||||
--- scanner 5 ---
|
||||
46,10,147
|
||||
758,-651,532
|
||||
-527,-618,452
|
||||
-823,464,-569
|
||||
690,764,759
|
||||
-564,-447,-551
|
||||
764,-302,-267
|
||||
684,881,802
|
||||
456,449,-735
|
||||
435,440,-616
|
||||
107,94,-30
|
||||
760,846,747
|
||||
-677,-709,468
|
||||
-647,455,-499
|
||||
-408,-549,-539
|
||||
398,536,-622
|
||||
-293,614,774
|
||||
829,-503,-276
|
||||
-385,-416,-489
|
||||
-272,801,808
|
||||
-563,-622,372
|
||||
-612,469,-575
|
||||
613,-622,632
|
||||
-278,753,780
|
||||
681,-373,-280
|
||||
812,-549,626
|
||||
|
||||
--- scanner 6 ---
|
||||
579,574,-541
|
||||
-505,493,-632
|
||||
618,658,359
|
||||
-341,743,774
|
||||
-322,-636,574
|
||||
716,580,-522
|
||||
366,-369,516
|
||||
-654,544,-722
|
||||
401,-424,440
|
||||
-413,-618,481
|
||||
-785,-692,-593
|
||||
-785,-599,-445
|
||||
466,-635,-650
|
||||
675,451,-553
|
||||
89,132,-70
|
||||
-427,825,855
|
||||
-398,-634,698
|
||||
570,-708,-669
|
||||
-60,27,13
|
||||
522,657,457
|
||||
-376,606,841
|
||||
-684,-621,-516
|
||||
485,-772,-675
|
||||
475,716,376
|
||||
-647,496,-573
|
||||
483,-412,510
|
||||
|
||||
--- scanner 7 ---
|
||||
512,585,-747
|
||||
807,772,880
|
||||
733,795,840
|
||||
-767,-876,-603
|
||||
-719,662,750
|
||||
-612,458,-552
|
||||
570,-882,858
|
||||
-589,-932,-661
|
||||
623,-601,-378
|
||||
-343,-464,739
|
||||
-589,632,-556
|
||||
746,-608,-532
|
||||
494,492,-838
|
||||
-652,610,660
|
||||
-554,584,-555
|
||||
111,-115,-49
|
||||
589,-757,885
|
||||
-618,631,899
|
||||
496,368,-762
|
||||
618,-644,-539
|
||||
696,-814,921
|
||||
-640,-913,-544
|
||||
737,746,813
|
||||
-310,-533,587
|
||||
-23,-193,76
|
||||
-85,0,-51
|
||||
-447,-527,622
|
||||
|
||||
--- scanner 8 ---
|
||||
-419,640,-664
|
||||
-722,-533,531
|
||||
705,861,595
|
||||
577,-689,716
|
||||
-842,-385,512
|
||||
632,-792,-344
|
||||
815,768,660
|
||||
490,-691,586
|
||||
-502,623,-798
|
||||
-554,-811,-585
|
||||
676,809,607
|
||||
560,496,-785
|
||||
-943,400,567
|
||||
415,-740,758
|
||||
679,-805,-531
|
||||
732,438,-813
|
||||
-792,347,621
|
||||
724,-803,-540
|
||||
-489,-738,-726
|
||||
-746,-370,499
|
||||
-2,59,-33
|
||||
558,494,-753
|
||||
-515,574,-768
|
||||
-486,-634,-564
|
||||
-122,-93,-71
|
||||
-872,325,554
|
||||
|
||||
--- scanner 9 ---
|
||||
506,-688,-561
|
||||
571,721,622
|
||||
503,-562,-503
|
||||
-709,-714,-463
|
||||
-835,437,457
|
||||
-948,-735,-497
|
||||
314,-589,962
|
||||
495,809,-475
|
||||
-788,360,-772
|
||||
-612,-499,488
|
||||
291,-602,907
|
||||
-580,-584,424
|
||||
-119,8,40
|
||||
-636,429,-805
|
||||
408,627,663
|
||||
555,634,776
|
||||
301,-483,836
|
||||
-799,-766,-396
|
||||
-671,423,-668
|
||||
-725,535,411
|
||||
10,-85,163
|
||||
554,772,-348
|
||||
-726,558,457
|
||||
507,-736,-526
|
||||
612,828,-526
|
||||
-444,-607,500
|
||||
|
||||
--- scanner 10 ---
|
||||
-643,-839,-726
|
||||
-663,-800,-791
|
||||
-17,49,1
|
||||
-428,-762,319
|
||||
-452,-869,434
|
||||
806,-584,-592
|
||||
-468,406,-817
|
||||
118,-97,56
|
||||
530,403,850
|
||||
-433,399,-634
|
||||
521,-484,654
|
||||
881,-476,-533
|
||||
954,-520,-545
|
||||
781,439,-557
|
||||
609,-463,682
|
||||
-327,671,688
|
||||
-542,-771,-726
|
||||
-328,557,674
|
||||
661,-458,693
|
||||
510,298,863
|
||||
-240,536,611
|
||||
785,322,-393
|
||||
-432,416,-779
|
||||
-475,-744,471
|
||||
518,305,832
|
||||
823,411,-365
|
||||
|
||||
--- scanner 11 ---
|
||||
-559,-302,-674
|
||||
-766,553,760
|
||||
-687,-322,850
|
||||
-800,-238,758
|
||||
370,-773,-566
|
||||
-851,883,-504
|
||||
-804,954,-655
|
||||
-716,-388,-711
|
||||
17,134,92
|
||||
884,-743,798
|
||||
905,900,-296
|
||||
-681,-359,-759
|
||||
-84,7,-30
|
||||
851,833,-390
|
||||
-756,459,918
|
||||
479,-816,-448
|
||||
-848,870,-519
|
||||
707,-731,809
|
||||
814,914,-406
|
||||
503,782,753
|
||||
544,911,722
|
||||
767,-719,748
|
||||
640,788,734
|
||||
572,-776,-603
|
||||
-781,-228,812
|
||||
-703,514,732
|
||||
|
||||
--- scanner 12 ---
|
||||
-593,845,571
|
||||
-95,162,7
|
||||
-509,-378,-516
|
||||
504,-445,343
|
||||
-400,708,-674
|
||||
-554,-465,-583
|
||||
431,-519,471
|
||||
-473,-359,-516
|
||||
-592,828,716
|
||||
-931,-358,491
|
||||
-906,-487,413
|
||||
-628,838,754
|
||||
-487,573,-751
|
||||
370,841,-913
|
||||
625,922,330
|
||||
663,833,302
|
||||
429,-748,-651
|
||||
358,939,-895
|
||||
244,-687,-680
|
||||
-794,-417,415
|
||||
621,805,494
|
||||
350,946,-926
|
||||
351,-656,-694
|
||||
-488,687,-737
|
||||
575,-504,385
|
||||
|
||||
--- scanner 13 ---
|
||||
-540,634,673
|
||||
764,-806,-384
|
||||
489,306,-588
|
||||
141,-5,-53
|
||||
577,221,-522
|
||||
-383,-685,663
|
||||
-575,616,539
|
||||
-558,-546,-541
|
||||
-444,-533,-673
|
||||
-356,-714,588
|
||||
-603,633,440
|
||||
791,-862,408
|
||||
763,728,555
|
||||
610,-722,-434
|
||||
758,-918,432
|
||||
693,-743,468
|
||||
-611,661,-390
|
||||
607,-706,-368
|
||||
-1,-144,-29
|
||||
-280,-701,796
|
||||
-706,583,-501
|
||||
-709,727,-493
|
||||
764,719,476
|
||||
763,692,397
|
||||
643,299,-606
|
||||
-566,-523,-601
|
||||
|
||||
--- scanner 14 ---
|
||||
-636,680,-483
|
||||
718,525,642
|
||||
822,571,-429
|
||||
534,-636,-655
|
||||
-464,-684,-415
|
||||
34,31,141
|
||||
-600,748,862
|
||||
-629,673,889
|
||||
719,758,705
|
||||
-438,-516,679
|
||||
-448,-588,801
|
||||
780,425,-363
|
||||
-616,881,965
|
||||
467,-723,-700
|
||||
-462,-614,-303
|
||||
806,549,-467
|
||||
668,-416,539
|
||||
746,-305,634
|
||||
-461,-456,687
|
||||
701,624,670
|
||||
-795,747,-546
|
||||
-726,811,-463
|
||||
-540,-743,-278
|
||||
-82,-24,3
|
||||
812,-408,536
|
||||
467,-742,-736
|
||||
|
||||
--- scanner 15 ---
|
||||
570,716,-401
|
||||
813,-522,-700
|
||||
-565,-663,616
|
||||
577,-384,448
|
||||
71,-43,-130
|
||||
-641,-610,619
|
||||
-731,-539,-421
|
||||
-448,392,521
|
||||
563,363,512
|
||||
-486,-548,601
|
||||
792,-612,-764
|
||||
638,513,555
|
||||
-760,-644,-580
|
||||
680,-591,-767
|
||||
533,452,650
|
||||
-701,454,-458
|
||||
698,-382,317
|
||||
-309,433,468
|
||||
576,631,-465
|
||||
-18,83,4
|
||||
-617,468,-599
|
||||
737,-417,381
|
||||
-678,-502,-550
|
||||
-643,510,-487
|
||||
595,735,-538
|
||||
-419,340,533
|
||||
|
||||
--- scanner 16 ---
|
||||
-99,-26,105
|
||||
-171,-173,17
|
||||
-808,-569,-752
|
||||
-430,-810,823
|
||||
276,298,847
|
||||
-545,545,909
|
||||
406,-582,-466
|
||||
797,-624,681
|
||||
-592,481,-545
|
||||
-566,579,670
|
||||
483,-511,-365
|
||||
283,346,756
|
||||
390,447,-285
|
||||
766,-707,633
|
||||
341,480,-430
|
||||
-591,-585,-737
|
||||
814,-646,819
|
||||
-404,-880,890
|
||||
-381,-806,850
|
||||
-544,516,-546
|
||||
-514,646,760
|
||||
320,473,796
|
||||
-718,539,-542
|
||||
364,432,-384
|
||||
-684,-567,-828
|
||||
335,-604,-365
|
||||
|
||||
--- scanner 17 ---
|
||||
-814,515,-501
|
||||
351,736,-672
|
||||
-840,-376,629
|
||||
-809,-483,615
|
||||
420,355,558
|
||||
452,-906,-323
|
||||
-512,341,793
|
||||
461,-873,-478
|
||||
534,356,572
|
||||
-618,422,726
|
||||
-901,-561,658
|
||||
-866,536,-417
|
||||
346,616,-702
|
||||
-798,-485,-246
|
||||
-31,-18,-10
|
||||
-785,-377,-340
|
||||
786,-490,414
|
||||
-885,-489,-394
|
||||
278,697,-583
|
||||
-163,40,154
|
||||
-828,605,-546
|
||||
-531,377,793
|
||||
555,268,635
|
||||
793,-482,383
|
||||
688,-502,396
|
||||
346,-856,-366
|
||||
|
||||
--- scanner 18 ---
|
||||
-599,-418,-687
|
||||
485,631,359
|
||||
-642,-843,277
|
||||
894,-574,-927
|
||||
137,-133,-101
|
||||
-513,528,790
|
||||
-703,425,-406
|
||||
623,-464,487
|
||||
843,-793,-941
|
||||
616,-512,636
|
||||
-661,-584,-635
|
||||
857,650,-567
|
||||
765,-461,546
|
||||
-612,-497,-702
|
||||
-561,611,821
|
||||
-770,355,-380
|
||||
485,724,507
|
||||
929,-711,-860
|
||||
-699,589,838
|
||||
948,668,-660
|
||||
-730,429,-357
|
||||
-605,-829,293
|
||||
-24,-73,10
|
||||
586,653,430
|
||||
-757,-881,273
|
||||
872,666,-784
|
||||
|
||||
--- scanner 19 ---
|
||||
805,-688,638
|
||||
106,-100,35
|
||||
673,664,467
|
||||
-736,-787,-834
|
||||
-702,-600,-813
|
||||
641,-450,-283
|
||||
561,430,-721
|
||||
-708,-739,-828
|
||||
571,-441,-459
|
||||
-562,-605,531
|
||||
-610,479,771
|
||||
590,617,600
|
||||
-611,307,692
|
||||
623,461,-542
|
||||
-300,636,-543
|
||||
755,-696,517
|
||||
-551,-598,488
|
||||
-557,-549,612
|
||||
-380,632,-579
|
||||
-77,14,78
|
||||
611,563,-698
|
||||
782,-698,664
|
||||
-396,723,-429
|
||||
546,708,493
|
||||
-539,440,712
|
||||
647,-455,-494
|
||||
|
||||
--- scanner 20 ---
|
||||
-73,-55,-94
|
||||
679,574,-740
|
||||
412,-822,-515
|
||||
-380,370,-593
|
||||
587,593,879
|
||||
-693,453,644
|
||||
-818,416,667
|
||||
722,670,792
|
||||
450,-652,686
|
||||
608,656,791
|
||||
-288,297,-533
|
||||
457,-835,651
|
||||
-749,-809,456
|
||||
691,374,-778
|
||||
-793,-809,-818
|
||||
421,-914,-678
|
||||
113,-67,36
|
||||
-695,-740,-793
|
||||
467,-797,687
|
||||
-788,-744,476
|
||||
538,-900,-564
|
||||
-579,-816,-811
|
||||
662,430,-653
|
||||
-720,-744,577
|
||||
-333,306,-554
|
||||
-711,301,691
|
||||
|
||||
--- scanner 21 ---
|
||||
-720,-494,-326
|
||||
-779,-506,-326
|
||||
725,743,-671
|
||||
643,-838,-672
|
||||
735,624,-742
|
||||
780,-444,760
|
||||
635,-395,727
|
||||
-773,-551,682
|
||||
523,664,668
|
||||
712,637,-797
|
||||
4,104,146
|
||||
-655,857,-500
|
||||
-883,800,504
|
||||
-152,-49,102
|
||||
-923,-626,725
|
||||
681,-418,775
|
||||
-827,-424,-336
|
||||
601,-802,-556
|
||||
520,538,726
|
||||
617,-733,-612
|
||||
-698,874,-492
|
||||
-834,-656,587
|
||||
-892,821,623
|
||||
519,490,691
|
||||
-920,866,-491
|
||||
-796,858,617
|
||||
|
||||
--- scanner 22 ---
|
||||
80,-91,68
|
||||
564,449,615
|
||||
694,505,-425
|
||||
820,-741,761
|
||||
697,526,-537
|
||||
-542,-761,600
|
||||
-615,-889,674
|
||||
630,595,-404
|
||||
558,522,416
|
||||
-23,-171,-90
|
||||
635,-555,-793
|
||||
552,-486,-729
|
||||
-335,769,464
|
||||
464,420,470
|
||||
683,-817,702
|
||||
-344,568,399
|
||||
-75,6,7
|
||||
-833,-862,-867
|
||||
-686,-847,615
|
||||
-836,-696,-870
|
||||
615,-645,-662
|
||||
-348,698,547
|
||||
-518,733,-640
|
||||
795,-819,632
|
||||
-874,-749,-817
|
||||
-387,735,-519
|
||||
-451,700,-480
|
||||
|
||||
--- scanner 23 ---
|
||||
-521,536,-591
|
||||
405,-522,-611
|
||||
598,-743,933
|
||||
739,728,856
|
||||
-767,828,470
|
||||
553,913,-698
|
||||
-311,-634,587
|
||||
808,645,792
|
||||
-303,-497,588
|
||||
-36,32,-25
|
||||
475,888,-569
|
||||
447,-593,-552
|
||||
-793,724,594
|
||||
533,-449,-537
|
||||
-589,-447,-308
|
||||
-454,455,-697
|
||||
649,708,725
|
||||
477,776,-639
|
||||
-632,-369,-400
|
||||
-809,762,616
|
||||
545,-781,880
|
||||
105,114,172
|
||||
-310,-582,457
|
||||
432,-740,930
|
||||
-618,-262,-369
|
||||
-454,491,-678
|
||||
|
||||
--- scanner 24 ---
|
||||
-574,-700,-914
|
||||
645,309,-801
|
||||
511,564,648
|
||||
-735,664,363
|
||||
464,628,796
|
||||
703,-469,305
|
||||
691,-453,440
|
||||
-552,404,-633
|
||||
710,348,-821
|
||||
-763,685,451
|
||||
496,-926,-724
|
||||
702,-429,236
|
||||
-885,-631,405
|
||||
1,-36,-128
|
||||
452,672,723
|
||||
-672,-700,-757
|
||||
-928,-818,431
|
||||
-916,-845,434
|
||||
-515,279,-610
|
||||
515,-953,-752
|
||||
645,377,-700
|
||||
421,-973,-621
|
||||
-625,-803,-884
|
||||
-774,690,503
|
||||
-400,386,-586
|
||||
|
||||
--- scanner 25 ---
|
||||
-660,-612,759
|
||||
44,-15,-25
|
||||
-564,539,589
|
||||
-501,550,610
|
||||
817,513,-563
|
||||
412,-387,533
|
||||
-535,416,-425
|
||||
-819,-717,730
|
||||
743,582,558
|
||||
666,604,559
|
||||
-690,-754,677
|
||||
790,542,-488
|
||||
836,-482,-889
|
||||
781,-535,-703
|
||||
-473,-665,-681
|
||||
-540,-734,-814
|
||||
-665,512,540
|
||||
-618,347,-489
|
||||
742,-472,-731
|
||||
341,-434,684
|
||||
425,-390,548
|
||||
593,616,664
|
||||
-555,506,-556
|
||||
-476,-644,-793
|
||||
893,526,-355
|
||||
|
||||
--- scanner 26 ---
|
||||
283,522,745
|
||||
-873,247,471
|
||||
628,-379,499
|
||||
336,469,783
|
||||
-605,567,-596
|
||||
-904,279,268
|
||||
-675,529,-760
|
||||
-944,-764,-808
|
||||
-898,-880,692
|
||||
286,356,742
|
||||
-18,5,-170
|
||||
-93,-106,-29
|
||||
360,663,-726
|
||||
622,-869,-722
|
||||
-946,250,385
|
||||
759,-386,584
|
||||
-742,-793,-828
|
||||
629,-387,636
|
||||
-776,-774,753
|
||||
-830,-795,-768
|
||||
746,-843,-826
|
||||
600,-885,-760
|
||||
-654,540,-697
|
||||
424,732,-643
|
||||
491,573,-706
|
||||
-885,-685,732
|
||||
|
||||
--- scanner 27 ---
|
||||
706,-520,-692
|
||||
-101,126,35
|
||||
771,564,-698
|
||||
-480,528,-493
|
||||
442,456,859
|
||||
559,502,806
|
||||
752,-472,-669
|
||||
514,541,941
|
||||
-584,455,-474
|
||||
-875,-543,521
|
||||
-499,391,-468
|
||||
-747,589,719
|
||||
771,471,-550
|
||||
-763,-660,-431
|
||||
726,-380,811
|
||||
-823,-531,550
|
||||
670,542,-627
|
||||
-782,-478,411
|
||||
677,-552,736
|
||||
675,-422,649
|
||||
851,-487,-643
|
||||
-702,-565,-536
|
||||
-852,-522,-461
|
||||
-43,-34,179
|
||||
-761,448,803
|
||||
-705,477,745
|
||||
|
||||
--- scanner 28 ---
|
||||
573,505,-684
|
||||
8,-24,126
|
||||
428,-551,785
|
||||
857,610,665
|
||||
-56,144,29
|
||||
-507,671,603
|
||||
-723,-628,-438
|
||||
-717,-596,681
|
||||
850,592,511
|
||||
495,394,-589
|
||||
464,-393,785
|
||||
-586,488,-809
|
||||
-697,-643,701
|
||||
-698,573,-725
|
||||
429,497,-687
|
||||
523,-436,-581
|
||||
-702,-787,657
|
||||
-789,-593,-508
|
||||
-533,539,692
|
||||
935,526,599
|
||||
540,-535,-553
|
||||
-778,-650,-426
|
||||
-354,610,678
|
||||
116,29,-19
|
||||
522,-669,-518
|
||||
-553,559,-659
|
||||
437,-472,786
|
||||
|
||||
--- scanner 29 ---
|
||||
683,-540,-630
|
||||
402,-538,-643
|
||||
-329,-493,653
|
||||
840,566,429
|
||||
722,647,510
|
||||
664,-649,866
|
||||
28,-140,-104
|
||||
878,620,-837
|
||||
-765,-884,-623
|
||||
732,696,-778
|
||||
-28,13,9
|
||||
-454,309,-532
|
||||
-327,-538,662
|
||||
948,661,-747
|
||||
-340,-585,849
|
||||
817,-625,774
|
||||
434,-525,-638
|
||||
865,-603,814
|
||||
-430,363,472
|
||||
900,551,520
|
||||
-446,294,528
|
||||
-808,-917,-481
|
||||
-563,315,-597
|
||||
-510,267,-682
|
||||
-758,-915,-590
|
||||
-404,258,412
|
||||
|
||||
--- scanner 30 ---
|
||||
-299,482,-468
|
||||
753,540,-526
|
||||
737,658,-630
|
||||
835,-810,469
|
||||
-294,373,-321
|
||||
-718,-593,401
|
||||
-757,-504,474
|
||||
-637,-474,469
|
||||
-294,618,-363
|
||||
356,-836,-662
|
||||
-536,-675,-691
|
||||
680,719,-521
|
||||
505,718,872
|
||||
-589,832,666
|
||||
885,-853,575
|
||||
-532,795,629
|
||||
-626,-630,-705
|
||||
-56,-7,92
|
||||
385,591,857
|
||||
-380,769,678
|
||||
468,-782,-762
|
||||
517,481,906
|
||||
464,-930,-675
|
||||
-557,-759,-743
|
||||
852,-698,584
|
||||
|
||||
--- scanner 31 ---
|
||||
-504,-722,764
|
||||
-471,-655,604
|
||||
620,778,-539
|
||||
-579,438,-698
|
||||
-750,-487,-538
|
||||
-649,474,-531
|
||||
-41,117,16
|
||||
305,-582,-421
|
||||
-635,-502,-459
|
||||
-524,762,878
|
||||
-469,-786,725
|
||||
276,-591,590
|
||||
365,-453,560
|
||||
420,460,710
|
||||
-635,417,-543
|
||||
372,470,792
|
||||
-182,-19,99
|
||||
253,-570,-392
|
||||
426,-548,665
|
||||
618,810,-537
|
||||
-697,-484,-614
|
||||
346,-635,-282
|
||||
479,460,722
|
||||
-606,786,771
|
||||
-653,734,906
|
||||
676,838,-365
|
||||
|
||||
--- scanner 32 ---
|
||||
-839,-599,715
|
||||
351,-528,-912
|
||||
377,598,754
|
||||
-751,502,-745
|
||||
498,820,-545
|
||||
-631,-549,-889
|
||||
566,-519,640
|
||||
-706,-506,-739
|
||||
-862,-551,669
|
||||
-524,788,651
|
||||
332,607,752
|
||||
-149,64,-129
|
||||
-455,732,635
|
||||
-833,512,-793
|
||||
496,852,-547
|
||||
324,880,-489
|
||||
-419,848,677
|
||||
6,95,-6
|
||||
-763,502,-686
|
||||
479,-649,638
|
||||
380,-540,-860
|
||||
641,-691,689
|
||||
424,411,741
|
||||
241,-593,-819
|
||||
-601,-411,-800
|
||||
-813,-584,814
|
136
2021/day19_beacon_scanner/tests/sample_input
Normal file
136
2021/day19_beacon_scanner/tests/sample_input
Normal file
|
@ -0,0 +1,136 @@
|
|||
--- 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
|
Loading…
Add table
Add a link
Reference in a new issue