From 96b02986a800dc27fbeebbc2e08cfd8650dc00cf Mon Sep 17 00:00:00 2001 From: Blizzard Finnegan Date: Mon, 20 Dec 2021 10:10:08 -0500 Subject: [PATCH] Update days --- day18/data/input.txt | 100 ++++ day18/data/testInput.txt | 10 + day18/part1Instructions.txt | 162 +++++ day19/data/input.txt | 1115 +++++++++++++++++++++++++++++++++++ day19/data/testInput.txt | 136 +++++ day19/part1Instructions.txt | 366 ++++++++++++ day20/data/input.txt | 102 ++++ day20/data/testInput.txt | 7 + day20/part1Instructions.txt | 105 ++++ 9 files changed, 2103 insertions(+) create mode 100644 day18/data/input.txt create mode 100644 day18/data/testInput.txt create mode 100644 day18/part1Instructions.txt create mode 100644 day19/data/input.txt create mode 100644 day19/data/testInput.txt create mode 100644 day19/part1Instructions.txt create mode 100644 day20/data/input.txt create mode 100644 day20/data/testInput.txt create mode 100644 day20/part1Instructions.txt diff --git a/day18/data/input.txt b/day18/data/input.txt new file mode 100644 index 0000000..a9bebd8 --- /dev/null +++ b/day18/data/input.txt @@ -0,0 +1,100 @@ +[6,[[5,[7,7]],[[8,2],2]]] +[[8,[0,0]],[[[1,4],[2,0]],[[2,3],[8,2]]]] +[[[7,[6,1]],[9,[7,9]]],[[6,6],2]] +[[5,[2,0]],[[[9,4],[6,8]],[3,9]]] +[[[3,[0,3]],[5,[9,8]]],[[5,[8,1]],[1,2]]] +[[[5,[8,5]],[[6,3],3]],[[1,[0,9]],[[3,0],[7,3]]]] +[[[[1,2],0],[8,[6,6]]],[6,[7,5]]] +[[[[0,9],[5,3]],[[9,7],8]],[9,[[1,9],1]]] +[[4,[6,[0,8]]],[[2,9],1]] +[[[5,1],[6,[9,5]]],8] +[[[4,[7,0]],1],[3,3]] +[2,[[3,4],6]] +[[[[0,5],[7,1]],[[7,0],[1,7]]],2] +[[3,[7,8]],[[1,0],[[1,7],6]]] +[[[7,[6,3]],1],[4,[1,[6,8]]]] +[[[[5,5],[3,5]],[5,[2,6]]],[3,[1,[3,2]]]] +[[8,2],9] +[[8,[[1,9],2]],[[8,[8,4]],3]] +[[[[8,7],9],5],[[[0,6],5],[6,5]]] +[[2,6],[0,[[9,8],6]]] +[[[[7,9],0],[[1,5],9]],[[[2,2],1],[3,1]]] +[[8,[1,[9,1]]],[0,[0,[2,4]]]] +[[[[0,2],3],[[9,4],9]],[[3,2],[[5,7],[4,8]]]] +[[[[8,0],3],[9,[5,9]]],[4,3]] +[2,[7,[[3,3],[7,9]]]] +[3,[[[6,4],0],5]] +[[1,[[9,9],9]],[[[0,3],[0,6]],0]] +[[7,[[2,3],4]],[6,[9,9]]] +[3,5] +[[[[2,3],2],[1,[9,9]]],[[8,2],[1,[2,0]]]] +[[[[7,2],[3,6]],[[9,7],[8,9]]],[[[5,3],[5,1]],6]] +[8,[[7,0],[[8,2],5]]] +[[[1,[1,0]],[[3,7],[4,5]]],[[[6,5],2],1]] +[8,[[5,0],3]] +[[[4,1],9],[1,5]] +[[9,[5,[3,7]]],[[0,4],4]] +[[[[9,6],4],[8,[7,5]]],[[6,9],5]] +[[[7,[2,5]],0],[8,[0,7]]] +[8,[[4,[1,8]],[[8,9],3]]] +[[[[3,7],[7,3]],[[5,3],1]],[[[6,7],[2,7]],[[2,6],[9,0]]]] +[[[9,[5,4]],[[1,7],2]],[[1,0],[[2,6],0]]] +[[[[3,2],[5,3]],[9,[2,0]]],[[7,6],[[8,2],[0,7]]]] +[[[4,0],0],[9,0]] +[[[[9,4],[0,9]],[2,3]],8] +[[2,[8,[6,7]]],[[[6,1],[5,1]],[3,[1,1]]]] +[[6,[[8,2],7]],5] +[[[[7,3],[9,7]],5],[[[0,9],4],[3,[0,3]]]] +[[2,[6,7]],[[[9,0],[6,7]],4]] +[[[[3,1],5],[7,[5,1]]],[[[8,4],9],[[2,7],[4,6]]]] +[[8,8],[[[1,4],[7,3]],[[9,6],5]]] +[[[[3,0],8],[[5,1],[7,8]]],[[[5,0],[2,2]],[[9,0],[0,7]]]] +[[1,1],7] +[[4,3],[[9,[7,3]],[2,3]]] +[[[5,[3,5]],3],7] +[[[5,[3,2]],1],[[[3,2],8],[8,5]]] +[[7,[6,5]],[[[9,8],7],6]] +[[[7,9],0],[3,4]] +[[[[5,6],[7,4]],[4,[1,7]]],[[[8,2],7],[6,[4,5]]]] +[[[[8,5],1],[[7,0],[9,7]]],[[[5,2],3],2]] +[[[[7,3],9],7],[[[8,1],9],3]] +[[[6,5],[4,[6,1]]],7] +[[[[4,0],1],[4,4]],[[1,7],[3,0]]] +[9,[[2,[9,0]],6]] +[[[[0,0],9],2],[9,3]] +[5,[5,[[6,6],[2,6]]]] +[[[[8,2],[8,9]],[[8,4],[8,0]]],[[[9,5],6],4]] +[[[3,[6,1]],[3,[6,9]]],[3,4]] +[[[7,[6,3]],[[6,7],1]],[[1,1],2]] +[[[[1,2],[7,1]],[[7,7],4]],3] +[[[[7,2],4],[[4,7],[2,4]]],[1,[[6,2],4]]] +[4,[[0,4],5]] +[[[4,6],[0,[8,2]]],[[4,[8,7]],[[7,9],0]]] +[[[9,2],[5,2]],7] +[[9,[2,2]],4] +[[[6,2],[[4,3],[3,9]]],[[4,1],[[9,4],4]]] +[[[7,[4,2]],4],[[8,[9,3]],[[9,0],[5,4]]]] +[[[[4,1],[4,6]],[2,[4,5]]],[[1,[1,5]],9]] +[[[[5,2],8],6],[1,[[8,9],4]]] +[[[6,[4,2]],[6,[5,5]]],[0,3]] +[[7,[5,[7,0]]],[[[7,2],0],[[7,3],8]]] +[[3,[[2,3],[2,8]]],[5,7]] +[[[[8,0],[6,4]],[[3,7],3]],[[[7,3],[9,8]],[[8,0],8]]] +[[2,[5,2]],[[[0,9],[4,1]],[[8,8],4]]] +[[[[4,1],[6,5]],[[2,7],[5,8]]],[[[7,1],[2,3]],2]] +[[3,5],2] +[[9,2],[[6,[1,9]],[9,5]]] +[[4,[3,8]],[[4,[0,3]],[1,1]]] +[[[6,[0,7]],[[0,4],[6,1]]],[[8,5],[[5,2],[7,2]]]] +[[[[8,8],[6,3]],[[0,2],[6,5]]],[[[7,6],[5,4]],[4,[7,1]]]] +[[[[7,6],[5,8]],[6,1]],[0,[[0,8],9]]] +[[[6,[2,2]],[5,2]],6] +[[[7,9],[[1,5],8]],2] +[[[3,3],[5,6]],[[3,[3,6]],[2,[5,9]]]] +[[[[0,8],[0,1]],[[8,6],4]],[[0,[1,3]],4]] +[[6,[4,4]],[4,[0,4]]] +[[[3,4],[4,1]],8] +[[0,[[4,6],[5,1]]],[[0,[4,3]],[6,9]]] +[[[0,7],2],[[4,9],[1,6]]] +[[1,0],[[[4,9],9],[[5,4],9]]] +[8,[[[1,4],[5,5]],[1,[0,9]]]] diff --git a/day18/data/testInput.txt b/day18/data/testInput.txt new file mode 100644 index 0000000..1368dc4 --- /dev/null +++ b/day18/data/testInput.txt @@ -0,0 +1,10 @@ +[[[0,[5,8]],[[1,7],[9,6]]],[[4,[1,2]],[[1,4],2]]] +[[[5,[2,8]],4],[5,[[9,9],0]]] +[6,[[[6,2],[5,6]],[[7,6],[4,7]]]] +[[[6,[0,7]],[0,9]],[4,[9,[9,0]]]] +[[[7,[6,4]],[3,[1,3]]],[[[5,5],1],9]] +[[6,[[7,3],[3,2]]],[[[3,8],[5,7]],4]] +[[[[5,4],[7,7]],8],[[8,3],8]] +[[9,3],[[9,9],[6,[4,9]]]] +[[2,[[7,7],7]],[[5,8],[[9,3],[0,2]]]] +[[[[5,2],5],[8,[3,7]]],[[5,[7,5]],[4,4]]] diff --git a/day18/part1Instructions.txt b/day18/part1Instructions.txt new file mode 100644 index 0000000..a156ed7 --- /dev/null +++ b/day18/part1Instructions.txt @@ -0,0 +1,162 @@ +--- Day 18: Snailfish --- + +You descend into the ocean trench and encounter some snailfish. They say they saw the sleigh keys! They'll even tell you which direction the keys went if you help one of the smaller snailfish with his math homework. + +Snailfish numbers aren't like regular numbers. Instead, every snailfish number is a pair - an ordered list of two elements. Each element of the pair can be either a regular number or another pair. + +Pairs are written as [x,y], where x and y are the elements within the pair. Here are some example snailfish numbers, one snailfish number per line: + +[1,2] +[[1,2],3] +[9,[8,7]] +[[1,9],[8,5]] +[[[[1,2],[3,4]],[[5,6],[7,8]]],9] +[[[9,[3,8]],[[0,9],6]],[[[3,7],[4,9]],3]] +[[[[1,3],[5,3]],[[1,3],[8,7]]],[[[4,9],[6,9]],[[8,2],[7,3]]]] + +This snailfish homework is about addition. To add two snailfish numbers, form a pair from the left and right parameters of the addition operator. For example, [1,2] + [[3,4],5] becomes [[1,2],[[3,4],5]]. + +There's only one problem: snailfish numbers must always be reduced, and the process of adding two snailfish numbers can result in snailfish numbers that need to be reduced. + +To reduce a snailfish number, you must repeatedly do the first action in this list that applies to the snailfish number: + + If any pair is nested inside four pairs, the leftmost such pair explodes. + If any regular number is 10 or greater, the leftmost such regular number splits. + +Once no action in the above list applies, the snailfish number is reduced. + +During reduction, at most one action applies, after which the process returns to the top of the list of actions. For example, if split produces a pair that meets the explode criteria, that pair explodes before other splits occur. + +To explode a pair, the pair's left value is added to the first regular number to the left of the exploding pair (if any), and the pair's right value is added to the first regular number to the right of the exploding pair (if any). Exploding pairs will always consist of two regular numbers. Then, the entire exploding pair is replaced with the regular number 0. + +Here are some examples of a single explode action: + + [[[[[9,8],1],2],3],4] becomes [[[[0,9],2],3],4] (the 9 has no regular number to its left, so it is not added to any regular number). + [7,[6,[5,[4,[3,2]]]]] becomes [7,[6,[5,[7,0]]]] (the 2 has no regular number to its right, and so it is not added to any regular number). + [[6,[5,[4,[3,2]]]],1] becomes [[6,[5,[7,0]]],3]. + [[3,[2,[1,[7,3]]]],[6,[5,[4,[3,2]]]]] becomes [[3,[2,[8,0]]],[9,[5,[4,[3,2]]]]] (the pair [3,2] is unaffected because the pair [7,3] is further to the left; [3,2] would explode on the next action). + [[3,[2,[8,0]]],[9,[5,[4,[3,2]]]]] becomes [[3,[2,[8,0]]],[9,[5,[7,0]]]]. + +To split a regular number, replace it with a pair; the left element of the pair should be the regular number divided by two and rounded down, while the right element of the pair should be the regular number divided by two and rounded up. For example, 10 becomes [5,5], 11 becomes [5,6], 12 becomes [6,6], and so on. + +Here is the process of finding the reduced result of [[[[4,3],4],4],[7,[[8,4],9]]] + [1,1]: + +after addition: [[[[[4,3],4],4],[7,[[8,4],9]]],[1,1]] +after explode: [[[[0,7],4],[7,[[8,4],9]]],[1,1]] +after explode: [[[[0,7],4],[15,[0,13]]],[1,1]] +after split: [[[[0,7],4],[[7,8],[0,13]]],[1,1]] +after split: [[[[0,7],4],[[7,8],[0,[6,7]]]],[1,1]] +after explode: [[[[0,7],4],[[7,8],[6,0]]],[8,1]] + +Once no reduce actions apply, the snailfish number that remains is the actual result of the addition operation: [[[[0,7],4],[[7,8],[6,0]]],[8,1]]. + +The homework assignment involves adding up a list of snailfish numbers (your puzzle input). The snailfish numbers are each listed on a separate line. Add the first snailfish number and the second, then add that result and the third, then add that result and the fourth, and so on until all numbers in the list have been used once. + +For example, the final sum of this list is [[[[1,1],[2,2]],[3,3]],[4,4]]: + +[1,1] +[2,2] +[3,3] +[4,4] + +The final sum of this list is [[[[3,0],[5,3]],[4,4]],[5,5]]: + +[1,1] +[2,2] +[3,3] +[4,4] +[5,5] + +The final sum of this list is [[[[5,0],[7,4]],[5,5]],[6,6]]: + +[1,1] +[2,2] +[3,3] +[4,4] +[5,5] +[6,6] + +Here's a slightly larger example: + +[[[0,[4,5]],[0,0]],[[[4,5],[2,6]],[9,5]]] +[7,[[[3,7],[4,3]],[[6,3],[8,8]]]] +[[2,[[0,8],[3,4]]],[[[6,7],1],[7,[1,6]]]] +[[[[2,4],7],[6,[0,5]]],[[[6,8],[2,8]],[[2,1],[4,5]]]] +[7,[5,[[3,8],[1,4]]]] +[[2,[2,2]],[8,[8,1]]] +[2,9] +[1,[[[9,3],9],[[9,0],[0,7]]]] +[[[5,[7,4]],7],1] +[[[[4,2],2],6],[8,7]] + +The final sum [[[[8,7],[7,7]],[[8,6],[7,7]]],[[[0,7],[6,6]],[8,7]]] is found after adding up the above snailfish numbers: + + [[[0,[4,5]],[0,0]],[[[4,5],[2,6]],[9,5]]] ++ [7,[[[3,7],[4,3]],[[6,3],[8,8]]]] += [[[[4,0],[5,4]],[[7,7],[6,0]]],[[8,[7,7]],[[7,9],[5,0]]]] + + [[[[4,0],[5,4]],[[7,7],[6,0]]],[[8,[7,7]],[[7,9],[5,0]]]] ++ [[2,[[0,8],[3,4]]],[[[6,7],1],[7,[1,6]]]] += [[[[6,7],[6,7]],[[7,7],[0,7]]],[[[8,7],[7,7]],[[8,8],[8,0]]]] + + [[[[6,7],[6,7]],[[7,7],[0,7]]],[[[8,7],[7,7]],[[8,8],[8,0]]]] ++ [[[[2,4],7],[6,[0,5]]],[[[6,8],[2,8]],[[2,1],[4,5]]]] += [[[[7,0],[7,7]],[[7,7],[7,8]]],[[[7,7],[8,8]],[[7,7],[8,7]]]] + + [[[[7,0],[7,7]],[[7,7],[7,8]]],[[[7,7],[8,8]],[[7,7],[8,7]]]] ++ [7,[5,[[3,8],[1,4]]]] += [[[[7,7],[7,8]],[[9,5],[8,7]]],[[[6,8],[0,8]],[[9,9],[9,0]]]] + + [[[[7,7],[7,8]],[[9,5],[8,7]]],[[[6,8],[0,8]],[[9,9],[9,0]]]] ++ [[2,[2,2]],[8,[8,1]]] += [[[[6,6],[6,6]],[[6,0],[6,7]]],[[[7,7],[8,9]],[8,[8,1]]]] + + [[[[6,6],[6,6]],[[6,0],[6,7]]],[[[7,7],[8,9]],[8,[8,1]]]] ++ [2,9] += [[[[6,6],[7,7]],[[0,7],[7,7]]],[[[5,5],[5,6]],9]] + + [[[[6,6],[7,7]],[[0,7],[7,7]]],[[[5,5],[5,6]],9]] ++ [1,[[[9,3],9],[[9,0],[0,7]]]] += [[[[7,8],[6,7]],[[6,8],[0,8]]],[[[7,7],[5,0]],[[5,5],[5,6]]]] + + [[[[7,8],[6,7]],[[6,8],[0,8]]],[[[7,7],[5,0]],[[5,5],[5,6]]]] ++ [[[5,[7,4]],7],1] += [[[[7,7],[7,7]],[[8,7],[8,7]]],[[[7,0],[7,7]],9]] + + [[[[7,7],[7,7]],[[8,7],[8,7]]],[[[7,0],[7,7]],9]] ++ [[[[4,2],2],6],[8,7]] += [[[[8,7],[7,7]],[[8,6],[7,7]]],[[[0,7],[6,6]],[8,7]]] + +To check whether it's the right answer, the snailfish teacher only checks the magnitude of the final sum. The magnitude of a pair is 3 times the magnitude of its left element plus 2 times the magnitude of its right element. The magnitude of a regular number is just that number. + +For example, the magnitude of [9,1] is 3*9 + 2*1 = 29; the magnitude of [1,9] is 3*1 + 2*9 = 21. Magnitude calculations are recursive: the magnitude of [[9,1],[1,9]] is 3*29 + 2*21 = 129. + +Here are a few more magnitude examples: + + [[1,2],[[3,4],5]] becomes 143. + [[[[0,7],4],[[7,8],[6,0]]],[8,1]] becomes 1384. + [[[[1,1],[2,2]],[3,3]],[4,4]] becomes 445. + [[[[3,0],[5,3]],[4,4]],[5,5]] becomes 791. + [[[[5,0],[7,4]],[5,5]],[6,6]] becomes 1137. + [[[[8,7],[7,7]],[[8,6],[7,7]]],[[[0,7],[6,6]],[8,7]]] becomes 3488. + +So, given this example homework assignment: + +[[[0,[5,8]],[[1,7],[9,6]]],[[4,[1,2]],[[1,4],2]]] +[[[5,[2,8]],4],[5,[[9,9],0]]] +[6,[[[6,2],[5,6]],[[7,6],[4,7]]]] +[[[6,[0,7]],[0,9]],[4,[9,[9,0]]]] +[[[7,[6,4]],[3,[1,3]]],[[[5,5],1],9]] +[[6,[[7,3],[3,2]]],[[[3,8],[5,7]],4]] +[[[[5,4],[7,7]],8],[[8,3],8]] +[[9,3],[[9,9],[6,[4,9]]]] +[[2,[[7,7],7]],[[5,8],[[9,3],[0,2]]]] +[[[[5,2],5],[8,[3,7]]],[[5,[7,5]],[4,4]]] + +The final sum is: + +[[[[6,6],[7,6]],[[7,7],[7,0]]],[[[7,7],[7,7]],[[7,8],[9,9]]]] + +The magnitude of this final sum is 4140. + +Add up all of the snailfish numbers from the homework assignment in the order they appear. What is the magnitude of the final sum? diff --git a/day19/data/input.txt b/day19/data/input.txt new file mode 100644 index 0000000..d9a5a5f --- /dev/null +++ b/day19/data/input.txt @@ -0,0 +1,1115 @@ +--- scanner 0 --- +-367,-662,466 +528,-535,-531 +501,-558,-478 +157,-57,-81 +34,54,0 +453,-598,439 +433,-676,317 +-697,-498,-517 +641,352,709 +-415,-496,427 +-464,-504,-539 +865,852,-708 +622,428,706 +-611,761,-486 +-655,703,-675 +-558,-542,-477 +-722,520,551 +623,-555,-407 +590,328,833 +-759,312,567 +795,806,-835 +-777,418,507 +875,775,-910 +-643,650,-530 +431,-641,334 +-394,-546,365 + +--- scanner 1 --- +-514,-699,856 +667,-728,964 +728,-582,-391 +-928,806,581 +445,479,512 +672,-679,-474 +567,598,-396 +-481,821,-611 +729,-588,924 +-548,-810,-249 +-477,-563,939 +-474,-671,-316 +-497,789,-480 +699,-777,899 +-773,749,661 +619,471,583 +45,-81,35 +594,579,-501 +433,531,587 +621,585,-504 +-827,735,459 +-553,693,-551 +690,-613,-390 +-623,-718,-268 +-572,-522,912 +-60,74,89 + +--- scanner 2 --- +448,875,-472 +-767,746,-507 +-428,-372,-558 +438,964,-397 +833,-782,-385 +-844,-814,514 +-450,-408,-612 +516,564,605 +325,-367,518 +-595,718,876 +-560,794,735 +415,-419,510 +-848,771,-401 +420,952,-636 +602,722,658 +-704,792,766 +580,640,472 +353,-246,453 +-814,-692,511 +-451,-267,-677 +680,-784,-474 +-51,121,48 +817,-819,-366 +-857,803,-480 +-746,-727,492 + +--- scanner 3 --- +567,-667,512 +331,-447,-604 +422,497,356 +-630,-529,619 +-617,-543,-729 +-675,-564,-875 +-781,580,-884 +571,450,308 +520,646,-872 +-724,489,514 +-643,-525,555 +356,-429,-680 +-105,-141,-104 +-730,-555,649 +404,-660,386 +-780,586,431 +-742,555,430 +496,358,289 +462,469,-816 +-719,440,-924 +425,605,-899 +394,-406,-486 +-751,391,-859 +530,-643,495 +-32,-6,49 +-668,-504,-808 + +--- scanner 4 --- +258,-463,463 +391,-481,529 +710,-857,-709 +306,380,-639 +-738,698,719 +405,248,721 +-578,-594,582 +-566,-492,431 +414,367,833 +-439,-542,-674 +608,-847,-793 +331,-535,469 +-728,-591,460 +-401,-407,-731 +746,-701,-802 +427,292,-671 +-390,-556,-806 +394,393,598 +-607,632,-651 +354,293,-654 +-139,-21,-5 +-492,620,-532 +-593,699,861 +-565,731,-518 +-803,728,857 + +--- scanner 5 --- +528,460,-401 +-688,-634,-577 +-734,-697,-604 +-622,386,-699 +-466,435,628 +-446,-345,651 +-692,364,-776 +498,444,-360 +440,-740,597 +436,339,-334 +578,-301,-422 +433,-368,-509 +123,33,-88 +524,-592,534 +-502,-536,630 +-53,-30,34 +668,826,560 +437,-705,577 +-515,-495,588 +-409,501,533 +-372,374,499 +-739,332,-649 +448,865,558 +-720,-749,-535 +576,-416,-488 +628,852,621 + +--- scanner 6 --- +136,22,-11 +-662,-494,-732 +-741,-592,-620 +734,427,638 +396,-701,901 +-583,268,700 +829,-403,-443 +520,-844,915 +-499,540,-460 +-411,-885,636 +-693,281,610 +-784,-421,-646 +-531,499,-333 +822,-652,-414 +-13,-81,104 +659,472,615 +-612,259,537 +-523,-820,534 +-343,504,-418 +811,603,-626 +762,553,-536 +747,385,506 +-454,-859,636 +476,-696,948 +802,-470,-462 +814,478,-498 + +--- scanner 7 --- +890,-478,-465 +-569,-530,-481 +-444,-658,-484 +-665,-316,393 +463,707,696 +845,769,-393 +734,-474,-368 +-662,474,-548 +24,85,54 +600,-561,345 +-750,851,398 +-651,713,434 +-604,-455,381 +639,-698,279 +977,703,-355 +177,-18,1 +-657,-407,279 +589,677,705 +689,-636,440 +770,-421,-504 +-575,583,-636 +-494,-568,-533 +734,732,-360 +598,657,797 +-682,792,550 +-620,606,-561 + +--- scanner 8 --- +677,628,-583 +-676,509,-436 +559,728,-523 +-537,800,357 +362,-877,325 +-170,-111,82 +-600,381,-441 +-798,-824,-430 +246,-733,-520 +651,563,-520 +-13,-179,-70 +358,382,720 +18,-1,97 +301,320,893 +-626,647,355 +309,-881,-601 +-764,-483,731 +-829,-484,872 +340,-779,412 +278,-880,-477 +-792,-867,-323 +-710,-461,767 +359,-847,447 +-562,557,-513 +366,292,772 +-518,784,320 +-662,-931,-420 + +--- scanner 9 --- +-777,-499,370 +494,537,-581 +-717,-572,-674 +-510,718,-401 +594,-732,341 +792,-581,-474 +481,516,706 +820,-786,-421 +449,501,-632 +-662,-492,369 +-692,-642,374 +-389,548,585 +501,442,702 +-802,-541,-778 +-395,551,668 +548,508,551 +-54,-3,40 +-697,728,-390 +768,-658,360 +-589,805,-310 +693,-806,343 +880,-694,-538 +403,457,-514 +-336,570,755 +-801,-545,-771 + +--- scanner 10 --- +-649,442,715 +567,-665,-472 +-706,-449,-426 +808,366,691 +685,785,-514 +-402,-528,598 +769,586,689 +-775,799,-498 +770,789,-657 +655,790,-664 +-552,-597,661 +-650,-438,-368 +-623,-524,-288 +562,-719,-546 +795,546,628 +317,-454,750 +-762,355,672 +-601,818,-424 +621,-595,-434 +-593,-584,619 +-700,816,-350 +444,-491,716 +-29,-109,49 +-797,358,652 +378,-548,621 + +--- scanner 11 --- +-317,-591,596 +505,-474,-354 +731,-528,408 +-330,367,-240 +535,548,868 +-663,-618,-575 +533,-679,-407 +-515,-563,-520 +-584,543,519 +861,771,-708 +557,-602,427 +-557,611,586 +60,30,2 +445,-566,-471 +885,750,-731 +-410,336,-315 +632,-454,410 +-615,-515,-532 +-569,715,429 +-340,290,-442 +823,632,-662 +113,-150,156 +-371,-642,767 +683,611,784 +-315,-543,624 +570,568,871 + +--- scanner 12 --- +-553,645,-470 +-615,714,505 +658,-533,446 +-613,-401,-520 +-566,-503,-533 +-54,104,94 +-529,-349,-531 +103,-26,15 +675,674,-540 +-642,811,421 +412,741,805 +475,-668,-670 +453,690,832 +-536,639,-582 +-688,-330,445 +802,642,-581 +-695,-329,560 +-521,559,-412 +519,-744,-557 +-646,818,420 +461,-676,-725 +382,535,803 +717,830,-576 +660,-753,407 +-545,-334,530 +597,-573,420 + +--- scanner 13 --- +-450,748,399 +-816,608,-562 +750,836,-599 +-546,-543,414 +480,-558,712 +-646,-621,338 +424,-740,-376 +462,-694,-515 +-512,-513,327 +476,-492,668 +378,843,507 +715,839,-579 +422,-515,710 +-457,-666,-808 +-855,828,-560 +426,700,486 +602,752,-536 +-430,-615,-767 +-459,-460,-838 +26,45,60 +311,698,420 +400,-763,-397 +-329,840,332 +-842,648,-623 +-434,778,358 + +--- scanner 14 --- +724,502,-441 +-399,864,-710 +-45,59,38 +-678,691,361 +532,-775,410 +122,-54,-71 +-480,886,-783 +-507,-685,-908 +850,475,-382 +-572,666,442 +-599,723,352 +674,-796,495 +675,397,-377 +784,-763,-877 +846,-868,-903 +-537,-651,-821 +-509,877,-620 +754,-747,-836 +-402,-347,758 +-615,-551,-897 +758,552,704 +-467,-488,759 +-521,-452,781 +506,-825,399 +586,548,766 +583,588,704 + +--- scanner 15 --- +-573,-924,-460 +556,772,675 +-5,-136,8 +-682,-424,700 +-723,635,-685 +695,479,-668 +611,-681,-940 +-732,494,279 +-748,-919,-538 +639,-480,588 +582,-518,-949 +-744,-398,805 +762,742,677 +-652,-465,684 +-647,679,-798 +663,352,-709 +-512,496,318 +717,-404,488 +711,701,704 +609,-393,622 +501,-591,-927 +42,28,-83 +-552,557,292 +851,437,-704 +-655,693,-853 +-622,-860,-565 + +--- scanner 16 --- +-468,-389,-584 +349,-444,666 +-694,587,-565 +-679,594,-552 +-885,782,652 +-570,-324,-696 +798,-715,-445 +-570,-350,-653 +483,511,-647 +-778,495,-649 +408,-444,738 +-798,722,585 +13,-46,-19 +399,497,438 +712,-788,-323 +491,363,-506 +438,442,441 +-83,141,-51 +686,-617,-366 +576,472,-491 +-610,-796,542 +-911,717,516 +-557,-651,469 +463,-414,572 +502,425,407 +-580,-554,561 + +--- scanner 17 --- +-682,675,708 +-355,651,-360 +825,-800,-528 +-382,702,-319 +475,799,-730 +-657,-373,638 +728,-342,474 +-384,496,-289 +114,96,174 +-627,-368,788 +855,422,494 +827,475,699 +629,-340,548 +915,539,586 +537,730,-612 +-741,-572,-565 +803,-359,622 +677,-716,-591 +41,25,-5 +-767,-612,-504 +-780,-792,-567 +-766,772,735 +-767,779,739 +499,776,-751 +790,-803,-548 +-742,-369,781 + +--- scanner 18 --- +-537,644,437 +-25,-47,89 +-397,798,-434 +458,685,564 +132,84,123 +-635,-672,-485 +667,731,-678 +752,-806,524 +792,-417,-514 +-452,675,-515 +-498,716,-495 +-734,-732,-372 +-406,-366,637 +-725,-722,-496 +685,-715,604 +634,-760,568 +679,631,-630 +-693,694,395 +845,-389,-719 +-673,584,403 +624,779,-575 +602,617,508 +728,-329,-627 +-316,-379,552 +544,611,484 +-447,-353,498 + +--- scanner 19 --- +389,-865,697 +-671,657,367 +603,682,-635 +-550,847,-357 +-372,-637,-487 +-553,-734,650 +607,753,-476 +523,-668,-341 +432,-758,703 +376,-711,-373 +692,550,548 +60,5,57 +753,682,-496 +-668,779,438 +-628,827,-479 +733,552,545 +-691,752,491 +375,-587,-404 +-430,-708,-565 +-511,-788,627 +721,383,610 +-20,76,-106 +-585,849,-374 +-334,-693,-573 +-509,-730,584 +325,-768,567 +-109,-98,-33 + +--- scanner 20 --- +-738,-816,-771 +478,-830,246 +428,-713,300 +0,-129,-177 +618,342,-454 +-605,517,325 +-948,-461,750 +550,-779,-720 +-660,-838,-641 +-905,-454,558 +726,437,374 +639,485,-502 +767,407,358 +592,-811,-835 +-520,659,346 +351,-783,278 +-409,740,-473 +-936,-522,597 +523,-825,-783 +-816,-755,-690 +705,487,-387 +-118,-14,-102 +-378,709,-600 +793,345,253 +-466,775,-568 +-509,685,296 + +--- scanner 21 --- +418,411,-444 +809,-443,-569 +850,-470,-518 +-608,-331,854 +880,-472,-724 +451,632,587 +569,-574,841 +-668,409,-669 +-670,467,-626 +476,670,459 +516,-538,705 +557,449,-490 +-372,-559,-641 +-749,489,523 +439,387,-421 +-25,26,-6 +-285,-525,-671 +-674,-463,816 +-637,-574,849 +-626,463,-692 +-807,560,445 +632,660,561 +-296,-659,-563 +573,-418,744 +-845,504,531 + +--- scanner 22 --- +916,-479,696 +-392,-582,593 +955,645,-603 +-487,538,438 +-554,404,-545 +-506,565,543 +-279,-957,-539 +12,-82,-130 +-350,-856,-417 +784,659,519 +-336,-802,-619 +-606,416,-470 +823,-491,-466 +858,712,556 +-264,-510,653 +838,694,-525 +148,5,-10 +703,-507,-515 +629,-576,-482 +-500,592,546 +749,675,-617 +918,-468,642 +933,613,440 +-614,590,-541 +-296,-526,522 +769,-562,683 + +--- scanner 23 --- +-382,299,689 +683,510,656 +771,-463,395 +857,-809,-675 +-663,-776,792 +842,-362,517 +-682,-667,-332 +-851,691,-740 +-486,-718,848 +-732,763,-837 +-774,-742,-313 +-690,733,-783 +805,592,-353 +717,600,-312 +701,698,670 +657,636,-291 +825,-793,-544 +-527,-813,875 +729,-737,-615 +-635,-816,-380 +45,16,-28 +785,-517,597 +-537,264,613 +-411,388,569 +686,516,767 + +--- scanner 24 --- +446,765,513 +-915,-737,-690 +-643,827,825 +232,764,500 +7,27,-61 +518,-716,-584 +312,669,520 +410,458,-537 +524,-689,-587 +420,-935,578 +-900,344,-488 +-876,-865,458 +-751,438,-447 +-671,791,840 +-840,-836,-574 +505,-662,-692 +-874,-930,498 +-87,-107,97 +-766,-783,-611 +-835,-944,446 +409,-835,581 +-898,355,-434 +424,-846,426 +282,386,-477 +314,402,-608 +-572,660,774 + +--- scanner 25 --- +-386,-700,-598 +-91,-61,-71 +-629,-712,320 +499,-963,577 +-574,273,-811 +-673,662,426 +531,-941,-466 +-572,313,-804 +606,479,-464 +22,-171,9 +-403,-563,-553 +740,546,519 +-675,659,491 +-493,384,-754 +-406,-467,-573 +554,606,515 +552,492,-572 +579,498,-569 +-713,-709,477 +432,-866,-582 +-634,695,415 +469,-757,591 +728,598,444 +450,-846,499 +-711,-735,322 +485,-792,-545 + +--- scanner 26 --- +-688,-775,784 +-579,645,-611 +547,-496,-497 +-603,-631,-393 +-840,934,465 +-660,-820,802 +-78,61,-70 +-487,742,-634 +34,120,123 +678,415,-621 +631,-404,-413 +-644,-757,703 +731,644,376 +754,569,426 +-560,887,-581 +-778,803,372 +534,-503,-512 +557,-720,683 +671,-757,698 +-813,852,447 +594,-669,754 +566,480,-723 +-670,-691,-306 +635,441,-621 +-534,-626,-280 +745,679,333 + +--- scanner 27 --- +-687,628,604 +358,-792,-853 +882,-517,688 +-505,-854,511 +-528,-881,458 +-824,535,-467 +-643,632,670 +-611,-951,-354 +-8,-94,99 +-568,-929,-459 +382,-741,-729 +615,435,-583 +401,684,422 +-646,-949,-337 +422,708,399 +-862,591,-553 +-525,-759,387 +-65,-180,-82 +459,425,-481 +540,646,468 +836,-587,815 +434,463,-609 +458,-760,-726 +-685,686,647 +-766,606,-545 +805,-507,890 +99,-43,-96 + +--- scanner 28 --- +-470,-562,-553 +778,-836,683 +16,74,77 +279,-677,-286 +-889,642,-545 +673,-814,640 +-536,453,816 +549,550,-543 +-846,715,-624 +-590,-696,745 +-407,-585,-424 +665,650,896 +795,-834,718 +651,540,-387 +-93,-49,-40 +-441,-655,839 +-443,-709,828 +523,578,-362 +-656,502,800 +-602,-617,-458 +403,-626,-310 +579,706,934 +406,-645,-386 +587,721,838 +-954,710,-482 +-730,469,731 + +--- scanner 29 --- +682,-500,-859 +-127,75,-93 +444,875,-856 +-841,515,-464 +669,600,466 +846,-713,279 +-772,560,624 +654,879,-827 +681,449,364 +-566,-834,-539 +640,-633,-760 +-920,568,483 +-501,-808,-675 +-561,-721,-608 +-689,-602,529 +-858,579,-430 +-788,-701,626 +-696,-617,542 +509,737,-826 +519,478,463 +755,-514,-748 +857,-788,428 +-786,476,-461 +808,-656,414 +-811,653,468 +56,121,-20 + +--- scanner 30 --- +-370,651,769 +-283,-615,-605 +780,481,492 +398,451,-581 +577,-457,715 +-763,569,-848 +-17,-49,80 +543,378,-528 +750,575,378 +-538,719,711 +750,647,437 +-685,744,-843 +-274,-586,-442 +-658,618,-784 +640,470,-551 +406,-414,741 +-555,-699,555 +870,-787,-541 +-514,-667,428 +805,-675,-439 +-425,643,755 +479,-536,827 +844,-744,-541 +-296,-505,-515 +-519,-855,513 + +--- scanner 31 --- +-730,-633,447 +646,395,446 +-462,490,469 +-715,-625,351 +825,-841,567 +62,102,-16 +-659,-711,389 +444,380,-635 +-521,475,-716 +805,-719,645 +-478,684,554 +687,544,540 +700,397,457 +560,455,-734 +731,-722,-590 +523,529,-681 +-613,564,-697 +-511,610,485 +827,-824,602 +-690,-857,-506 +-609,-794,-358 +-733,-825,-359 +660,-563,-586 +660,-702,-736 +-93,45,124 +-599,358,-667 + +--- scanner 32 --- +-807,622,604 +465,755,-618 +-775,-454,-597 +506,-759,843 +486,367,835 +292,-700,-883 +-827,-852,479 +466,654,-471 +471,539,745 +-951,643,-590 +498,471,678 +-859,-772,371 +269,-786,816 +-798,-783,307 +-650,-529,-609 +449,780,-458 +-853,593,-508 +-757,607,523 +-688,566,526 +-613,-542,-551 +-147,-1,-54 +-891,625,-488 +395,-701,-825 +29,-135,66 +405,-878,775 +404,-665,-740 + +--- scanner 33 --- +432,936,-473 +-946,-683,-533 +-721,786,746 +495,871,-541 +-747,-274,358 +-984,-597,-477 +377,-423,565 +592,521,646 +-166,77,109 +434,-384,445 +-26,-28,-18 +-781,712,-714 +-776,-279,601 +-701,878,737 +493,-567,-633 +-850,638,-681 +574,828,-468 +-866,518,-730 +-888,-605,-462 +654,360,696 +517,426,735 +-751,777,872 +430,-287,601 +312,-541,-605 +-813,-312,490 +337,-669,-643 + +--- scanner 34 --- +-17,26,119 +-660,410,-488 +769,-474,513 +769,-624,652 +-518,657,789 +-778,-838,-680 +647,453,-501 +-578,757,671 +729,526,-531 +-681,-902,-550 +-624,-851,390 +-500,-852,421 +607,459,-481 +-665,538,-564 +772,462,751 +-588,586,-450 +470,-506,-593 +-581,-704,358 +870,370,792 +792,362,891 +-671,-795,-686 +110,-85,-11 +639,-494,-528 +840,-620,493 +-581,592,763 +637,-535,-531 + +--- scanner 35 --- +-465,821,-713 +408,786,256 +-534,-383,679 +478,913,302 +84,165,-83 +731,653,-652 +-720,-606,-742 +-770,-696,-731 +-780,-705,-855 +-572,-511,704 +-437,874,-508 +651,-628,680 +-817,497,716 +668,-469,-732 +-67,96,4 +-544,-485,523 +-755,566,598 +627,-423,-712 +683,696,-549 +398,988,333 +683,-755,780 +632,-631,756 +-377,757,-600 +583,708,-597 +750,-368,-793 +-793,520,737 + +--- scanner 36 --- +624,-588,-710 +-544,823,-730 +-506,761,-636 +773,390,703 +-557,893,451 +-86,-3,-147 +-78,148,10 +-560,822,329 +665,-591,-779 +804,465,623 +-725,-807,-820 +-714,-743,-881 +759,814,-783 +-500,783,-869 +-701,-271,484 +79,32,-21 +850,592,693 +425,-279,464 +701,625,-827 +-537,769,356 +529,-436,476 +597,-369,449 +-794,-635,-849 +-728,-298,247 +680,-510,-829 +-820,-339,383 +648,770,-815 + +--- scanner 37 --- +800,604,-650 +604,-466,-543 +-297,653,-630 +-492,-582,-424 +-483,-415,-456 +-657,488,837 +772,-419,833 +720,-407,758 +445,954,764 +-583,-678,686 +-672,-697,778 +-537,504,788 +780,-593,762 +-389,633,-639 +150,-38,-15 +-418,-518,-329 +14,99,83 +516,853,886 +769,515,-828 +675,498,-667 +-463,573,821 +-789,-648,700 +706,-642,-564 +502,799,684 +-398,603,-765 +578,-605,-435 + +--- scanner 38 --- +23,-56,75 +-463,657,-620 +-870,-811,665 +-579,-732,-577 +-591,662,-544 +785,775,-428 +-95,-153,-19 +-868,-970,698 +861,723,462 +804,628,427 +-469,410,698 +-861,-895,790 +-639,585,-658 +-464,399,717 +892,596,493 +482,-640,-577 +-512,-610,-627 +685,-652,779 +453,-473,-515 +-506,-650,-607 +742,668,-422 +670,-640,560 +701,-703,723 +849,678,-558 +-354,346,690 +441,-642,-580 + +--- scanner 39 --- +-579,703,483 +454,-640,-289 +485,-556,790 +470,-738,693 +366,-632,-330 +-420,-573,656 +-719,717,-682 +-773,788,467 +314,769,-652 +346,753,-521 +-839,-581,-548 +-868,811,-641 +-355,-510,724 +442,697,-592 +-463,-652,729 +-707,-486,-603 +329,322,540 +11,-48,17 +-121,111,109 +400,423,418 +514,-676,-268 +386,477,620 +-866,800,-695 +488,-550,679 +-653,772,516 +-902,-452,-571 diff --git a/day19/data/testInput.txt b/day19/data/testInput.txt new file mode 100644 index 0000000..4e496e9 --- /dev/null +++ b/day19/data/testInput.txt @@ -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 diff --git a/day19/part1Instructions.txt b/day19/part1Instructions.txt new file mode 100644 index 0000000..c84ae60 --- /dev/null +++ b/day19/part1Instructions.txt @@ -0,0 +1,366 @@ +--- Day 19: Beacon Scanner --- + +As your probe 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? + diff --git a/day20/data/input.txt b/day20/data/input.txt new file mode 100644 index 0000000..758420b --- /dev/null +++ b/day20/data/input.txt @@ -0,0 +1,102 @@ +##.....##.#.#####.#...###...#.##..#....##..#.##.#.#....##.....#.##.##.#.#.#...#.#.#.###.##..#.#.#.#..#.##.#...#..#.#.#..#####.##.#..#..##.#..#.#...#.....#.###..#..#####.##...#..##..##...#.#...##.##..##...##.##.#......#...##.##.#####.#....####....######.#.#.......#.############.###..#..#......####......#..##.####.##....#..#.#.###..#.####.####.#.##.##.##..###.#..#.......#....#..########....##..##.#...#.#.###.###.###..#..#.###..#....#.###..#.##.##..###.#.#####....###.##.###.....#######........#.#.##...##.#.... + +..##.#.#..#..##.###....######.####.....#.#..##..####......####...##...#.##..##.##.#.####.##.#.##.#.# +#.#####.#.#..#.#...##.......#.#...##.#..#.######....#.#####....####...##..##..#.#####..#.##......##. +....#..#...#...######...#.#.##.##.####..####....####.##.......#..##.#.##..#.#..##..#.##...##...#.#.. +.#..#####..#..#..#.#.....#..###.###.##.#..#....#..#...#....#####...###.....#.##.####.#######.##..##. +###.###...###..##.##.######..####.#.###..#....####....#...#.##.#.#....#..#....#.#.#.#.#.......#..### +.#.##.#.#####.....#...##.##..##.##...#####....#.##.###.....##.#..#.######.....###...#.###....#...#.# +##..##.##...#######..#..#.###.##.#.###..##.#.#.#..#..#....##.#..###....#..##.#..#.#....##.##........ +#..#......#.###.#####.##..#....#...#.#.#.#.###.##.##..#.#.##.#...#.##..##....#######.######..##.#.#. +.###.....#....###..#.#...##...#.#.####.##.###.#.##..##..###.#.##.####..##.....##....##.......#.#.### +..#.....#####.#.#..##..##..#.###..#.##.#..#.####....##..####.###....##.##.#.#...#..###.##......##### +#..#..####.#.#...#..#...#######.#......#.#.#..#.##.#......#......#.##.####.######....#####..##...### +.###.#...#..####.##...#.#####.##.#...#.#...#...#.#.##.###..#.##.###..#.##...######.#.#.##..#.##..### +####.#.##....#.#..#########.###.#.###.#..#.####.#..##.##..#.#.#....###...#..#..###..##...#..#.....#. +....#####.#..##.....###..#..#.##...#####..##...#...#.##.###....#..####.##.#####.##.#..##..##.#..#.#. +####...#..#####.#..#######.##.#.####...#####.#.#.##....#.###...#.###.##...#...##.##.##.#.#.....##.## +##..##.##.#.#..##..##.#..#.#..#.##.###.#..#..##.#..##..##.##.#......#.##..##.##.##.....##..#.#...### +#..#.#.#.#####..#.##..##....#.##.#.###.#.#...##.###.#..##.##...##..###.##...##.####...##.#..##..##.. +####....##.#.#........###..#..####.###..#.#.#....#####.#.#...#.##.####.#..#...#..#.#...#.#...#.##.## +#..#..##.##..#....#...#.#.....#...#...##.....####.#.###.#.#.####.#..#.#.#...#.##.###...##.#.##..##.# +##..##..#.###.####.#####.###..#..#.....####.#..#.##.#####.##.#...##...###.######.#.#...#####.#..#... +#...##.#......#####..##..#.....#..###.#.....##.....#####....#.##.###...##.####.#.#...#.##.######.#.. +##.#.###.##.......#.##.####..######...######...####.#..######....##.#.......####...###..##.##...#... +#.....##.#####.####..#.##.#.#.....##.#..#....#.....#.....#.#...#.###.#.....#####.#.###..##..##..###. +#.###..######..#....#...#.#.##..#.....#.###.....#..#.##..#..#.##....#.#..#..#..####.#.##.....#.#.### +#..##..#...##..##........#...#....###.###.#.########.#..#.............#....####..#..##.#.##.#......# +.###..#####........##..##.###.##..#.#.#.####.#..##.##.#...#..####..####..##.##..#.#.#.#......#.##.#. +#.##..##..######....#....##.....#...##..#.#.......#.##.#####.###..##...##.##.#..##.###...##########. +.##.########.##..###....#####.###.###.#.#.##.#.#.#..##.#.#..#.##..#....#.####..###.##..###.....##.#. +..##...#.###.#.#.#...#.##..#.#...#..##..##.##..#.#..##..#.##..##.###.##..##...#.###..##...#..#.#..## +.#.#.####.###.#.##.##.#.###.#.#....##.#........#..##..##..#...##..#.#.###.#.###..#...#.#.##.##..##.# +#.#.####.#.##...###.###.#...#.###.#.#.....#..#.##.#...#.#..#.#.##...###..###.#..#.###.#.####.###.#.. +##..####...#.#.####..#..#...###.##.###.##...##.#.#..##..#.###.#.##.##.#..#.###.#..#######.#....#.#.. +.#.#.######..##.#..###.##.#....##....#.#..###.....#.##...#..#...#.#.#.#.##....##....####....#......# +.#.#.#.##.###...##.#...###.#....#.#.#....##...#.######.#.#.#####..#..######.#.##.#.##.....##.####.## +..######...##..##..#.#.#.##.......##.#.#...#.#####...######..#######...####..##...#.##.##.#..#...#.# +##..#.#.#..##....#.##....#.....#.#####..#.#.#.#.#.#####....#..###..###.###...#...######...##..#.#..# +####.....##...##....##.##.#...#..##.#..###.#....#...###...#..######...####.###..##......##..###.##.. +##.####...#.#.#.#..#..#.#.###..##.#....##.##..#..##........##.##.####.##.#.###.#.#....#####.#.....#. +#...#.....###..#..###..##..#.#..#.###.#..#####.#.###..###..#...##.#..##..#...##...#.#.###.#.#.##.### +##.#...#....##.########..##....##..###.#....###.#.#....#...###.....###.#.##.#..#####......###.#.#.#. +###.###.#...###..#.##....#.#.#.........#.#####.#.#...#######.###.#.#.#..#.#...#..##.#...###.#...##.. +.####.###.#..#.###.#.#.######..#####.#...###..#...###..#.########.#.#.#..####..##.###..#..##..##.... +#..##.#.#...####.#..#..#..###.##...#####..#.###......#..####.####.##..###.....###..#....#.#######... +###..##.#.#.#..##..##...#..#.#......#..####....#.##..#.##.###...####..##..####...#...###...##..#.#.# +##.##..#....###.##......#.#.##.#.###..##...##.##.#....#.#.#.###....##..#....#.########...#.....##.#. +#.#..###.....#######..#.###....####...##......####..#...##....#..####.#....##.#...#....##.###.##.... +#....######..##.##..##.###.....##..#.....#....##...#....###.....##.##...##.#..##.####.#..####.##.#.# +.#.#....#..####..#..#.#...#..#..###..#........###.##...##.##....#.#..#.##..#.##...#####...#..#####.. +.##..####..##...##.###.#..####...#....#..#..##.#...##...#.###.....#.#..######.#.#####..#####..###### +.#...#.#..##.#.##..#.#.#...###..#..#....###.########..######.#.####...##..#..#...##.####...#.####### +.#####.##.#####.#.#.##.#.#....#..###.#..##......#####..#.##.#########...##..###.######.....#.#.####. +##.#.#.#.##..##.##...#.....#########.##.#.......#..#####.#..#.#.#######...#..##.#..###.#####...##.## +##.##...###.###...#..##.#..#.##.##.....##.#.#.###...##.#.##..#.#.#...####..#..###.####..#...##.##.#. +#...#.#.#..#.##..#..####.#..###.#####...#..#.#..#####.#..#.......#..#.....#.#.#.#.#.##.##.###....#.# +....##..#..####.##..#.#...#####...#...###.##.#.#...##.##.##..######......####.##.#..#.##..##...####. +##...###..#.##..##..#.##...#.#.####.####..#.#.###..#.#..##.#...#.#.####..#.#.##.##.#.###.#.###.#.#.. +#.#.#.#..#######.#....#..#.#.####....##...##.###.####.####.#..#..##...##..#..##....#...#..##.####... +.#####.###.##.##..##.##.##.#.##...##..#..##...#.#.##.#...####..#####..#.............###..#..#..#.#.. +.##..##..###.##.##.....#...#....#..#..#.#######....#...#......##.###..#....#.#.####.#....###..##..#. +.##.#.###......#.###..#.#..#.##.###.#.#..#.#.##......##.#..##.###..#.###.##...##.#.........###.#.### +.#.#.###......#..#####.###..#..#.##..........#..##.###.#.##.#..#.##.#.###.#.###..#.#...#.###..###... +.###.####.##.##.###..#.#..###..##..##....###.###..#...###...#.##.#...#.#.##..###.##.##..###.##....## +###.########.#.######..#.##.#.#####.###...###.###.#####.###..#...#.###..#...#..#.###.#......#......# +.##....###...##.####....#....#..##...#....###..#..#..#...#...#..##....#####.#..###...##.####....###. +.....#..##...##....####.#..#.#.##..####.#####..###...###.###..##..#...##.....#.#.##...#.....#.####.. +.#.###.#.#..#.####....#.#.##..#.####..#...#.#.#.#..#..#.####.###....#####.#..##..#.#..##.#.####.#.#. +#.####.#.....###..###.#..#.####.#..#.#.##.##..##..#.#.#..##...#.####..#.###...#....#.#...#.#..##.#.. +.#.####...#.#.#..###.##..#.#...##.##.#.....######...#....#.#.##.....###......##.#...#.###..#....###. +..##.###......#.##...###.#...######..##.#.#.#.#..#####.##...#......#....#.####..#..#..#.#.#.#..#..## +#.##.##.#.##.#.#..#.#.#..###....#####..#.#####.####.##.##.#.##.#..#.#.#.#.###..##.##.#####..##.##### +..#.#..##.#.##.#..###..##.#.#..#.#..#.##....#....##..#.#..#.#.##.##.#.#.#..##..###..##.##.#.###.#### +####.####..#..#.#....##.#...##....#.######...#.##.....#.##..#####.#####..##..#.####.#.##......#.#... +.#####..##...#....#.#..#.#.##.#...#.#..#..###.#..#.#..#..##.#.....#.####.#.#...###..#..##.##......## +###.#.....###...###########.##.##..#....##.#.####.#.#.#.....#...###.#.##..#.#.#...###..........###.# +#.#.##.##..#..#.##.#..##.#.#.####..###.#.#..###.#.#.###..###..#.##...#..#..#.#...#...#..##..#..###.. +..#.#####.###..#.......#..#.####.#.######....#.##.##.#..#..#####..#...#.##.##.##..#...#####.##..#..# +##..##...##...#.####...#.#....##..#.....##.###.####.##..###..#.##..#..##..####....##.#...#.####.#..# +#.#.##...####..#.##....##...#.###..##....##.#.#.....###...####..###.###..#...##.###.#.#.#.#....#.##. +..####.##..##.#.....##...#.#.##.#.....#.#.##..##.##..#.##...##....#.#...###..####.#.#######..##.#.## +#.....##...#...#...#.##.#.####.###..#.#..###.#.#..#######...#.##.###.#.###.#.##.#.##.....#.#...#.##. +#..#####.....#..#..###.#####..##.##....#.###.##.#.#..##...###...#######.##....#...###...#####..##..# +#..############.##.####..#..#..#..#.####........#.###.###..#.######...##..####..###......##.#.#..#.. +##.............###.#.####....##.##....#.#.....#.#.###...##.##.#.#..###.##.##..#.#.#####..#.#.#....## +.####...###.#.###.#..#.#.#.####.#......#..#..#.#...#..#..#....#.##..##.#..##.#..#....#..##.#..##.#.# +###.#..#..###.#...#....###..########....##....#....#.###.#.##...###.#.#.#..##..#.##....#.######.#.#. +#.###....#.##.#.#...#.##.###.##..#..###.##...####..#..#..#.####.#..#..#..#.###....#..#.##...##...### +#..#.##.#.#.#...#.#####.##.#..###.#.#.###........####.#####..#.##..###....#..#.#.#...#.#.#..#.#####. +#..##.##.#####...##...##.##..##.#...#.#..#...#..#..#.....#..####.#...#..#######....########.....#.## +#.....####.#.#.#..#.##..#.#.#####..#.#..######.#.#..#...#..#....#.##.##..##.#.###..#.##...##.#...##. +.###.#..##.##....#.##.#..#.##..####.......##..##.##.#####.###.##.....#.....##.###.#.##.#.#.##..#..## +##....#.#.##.###.#.##.#####.#..#####.#..#####.##.#..#..#..#####.##.###.#..###...#.#...#....######..# +####..#..#..#..######...#####..#..#.#...#.##....###...#...##......#...#####.##.#..#.#.##.#...##.##.# +####...##...#..#..##..#.#....#####...#.#....######.#.#.....#...##..##.##..##...##.###.....##....##.# +.#.####.#..##..####...#.##.##.##..#####..##.#.#..##....#..#.#.####..##.##.#.###.##..####......##.#.. +...#..####...##.##.#..#.#....#######.####.#...###....##.#...####.#.###.####.#.#.##.#.......###.####. +.......#..#..#.#..#..#...#.#####.#.#..####..#..#...##..#.#.####.#...#.#.#.#.#.#...#.#.##.#..#.#.#### +...###.#...#..#.#.#.....##.##.#.#..##.#......#.#######.....#..###.#####.##..###.#..#.#######.#####.# +.####.#..#.#.###...#..#####...#....##..####..#..#######.###.##.##..######.###..##...#####...#.##.#.# +#..##..####.#.#.#..#.####.###...#..###.#.##.##..####..###.####.....#..#.#.####...#.#.#.##.##..#.#.## +..#.###.#...###..#...###.###.####..##..#.#...##.#...#..#....#####.#####..##.####..##.##.##..#...#### diff --git a/day20/data/testInput.txt b/day20/data/testInput.txt new file mode 100644 index 0000000..8fa4bd4 --- /dev/null +++ b/day20/data/testInput.txt @@ -0,0 +1,7 @@ +..#.#..#####.#.#.#.###.##.....###.##.#..###.####..#####..#....#..#..##..###..######.###...####..#..#####..##..#.#####...##.#.#..#.##..#.#......#.###.######.###.####...#.##.##..#..#..#####.....#.#....###..#.##......#.....#..#..#..##..#...##.######.####.####.#.#...#.......#..#.#.#...####.##.#......#..#...##.#.##..#...##.#.##..###.#......#.#.......#.#.#.####.###.##...#.....####.#..#..#.##.#....##..#.####....##...##..#...#......#.#.......#.......##..####..#...#.#.#...##..#.#..###..#####........#..####......#..# + +#..#. +#.... +##..# +..#.. +..### diff --git a/day20/part1Instructions.txt b/day20/part1Instructions.txt new file mode 100644 index 0000000..72d7ad9 --- /dev/null +++ b/day20/part1Instructions.txt @@ -0,0 +1,105 @@ +--- Day 20: Trench Map --- + +With the scanners fully deployed, you turn their attention to mapping the floor of the ocean trench. + +When you get back the image from the scanners, it seems to just be random noise. Perhaps you can combine an image enhancement algorithm and the input image (your puzzle input) to clean it up a little. + +For example: + +..#.#..#####.#.#.#.###.##.....###.##.#..###.####..#####..#....#..#..##..## +#..######.###...####..#..#####..##..#.#####...##.#.#..#.##..#.#......#.### +.######.###.####...#.##.##..#..#..#####.....#.#....###..#.##......#.....#. +.#..#..##..#...##.######.####.####.#.#...#.......#..#.#.#...####.##.#..... +.#..#...##.#.##..#...##.#.##..###.#......#.#.......#.#.#.####.###.##...#.. +...####.#..#..#.##.#....##..#.####....##...##..#...#......#.#.......#..... +..##..####..#...#.#.#...##..#.#..###..#####........#..####......#..# + +#..#. +#.... +##..# +..#.. +..### + +The first section is the image enhancement algorithm. It is normally given on a single line, but it has been wrapped to multiple lines in this example for legibility. The second section is the input image, a two-dimensional grid of light pixels (#) and dark pixels (.). + +The image enhancement algorithm describes how to enhance an image by simultaneously converting all pixels in the input image into an output image. Each pixel of the output image is determined by looking at a 3x3 square of pixels centered on the corresponding input image pixel. So, to determine the value of the pixel at (5,10) in the output image, nine pixels from the input image need to be considered: (4,9), (4,10), (4,11), (5,9), (5,10), (5,11), (6,9), (6,10), and (6,11). These nine input pixels are combined into a single binary number that is used as an index in the image enhancement algorithm string. + +For example, to determine the output pixel that corresponds to the very middle pixel of the input image, the nine pixels marked by [...] would need to be considered: + +# . . # . +#[. . .]. +#[# . .]# +.[. # .]. +. . # # # + +Starting from the top-left and reading across each row, these pixels are ..., then #.., then .#.; combining these forms ...#...#.. By turning dark pixels (.) into 0 and light pixels (#) into 1, the binary number 000100010 can be formed, which is 34 in decimal. + +The image enhancement algorithm string is exactly 512 characters long, enough to match every possible 9-bit binary number. The first few characters of the string (numbered starting from zero) are as follows: + +0 10 20 30 34 40 50 60 70 +| | | | | | | | | +..#.#..#####.#.#.#.###.##.....###.##.#..###.####..#####..#....#..#..##..## + +In the middle of this first group of characters, the character at index 34 can be found: #. So, the output pixel in the center of the output image should be #, a light pixel. + +This process can then be repeated to calculate every pixel of the output image. + +Through advances in imaging technology, the images being operated on here are infinite in size. Every pixel of the infinite output image needs to be calculated exactly based on the relevant pixels of the input image. The small input image you have is only a small region of the actual infinite input image; the rest of the input image consists of dark pixels (.). For the purposes of the example, to save on space, only a portion of the infinite-sized input and output images will be shown. + +The starting input image, therefore, looks something like this, with more dark pixels (.) extending forever in every direction not shown here: + +............... +............... +............... +............... +............... +.....#..#...... +.....#......... +.....##..#..... +.......#....... +.......###..... +............... +............... +............... +............... +............... + +By applying the image enhancement algorithm to every pixel simultaneously, the following output image can be obtained: + +............... +............... +............... +............... +.....##.##..... +....#..#.#..... +....##.#..#.... +....####..#.... +.....#..##..... +......##..#.... +.......#.#..... +............... +............... +............... +............... + +Through further advances in imaging technology, the above output image can also be used as an input image! This allows it to be enhanced a second time: + +............... +............... +............... +..........#.... +....#..#.#..... +...#.#...###... +...#...##.#.... +...#.....#.#... +....#.#####.... +.....#.#####... +......##.##.... +.......###..... +............... +............... +............... + +Truly incredible - now the small details are really starting to come through. After enhancing the original input image twice, 35 pixels are lit. + +Start with the original input image and apply the image enhancement algorithm twice, being careful to account for the infinite size of the images. How many pixels are lit in the resulting image?