diff --git a/data/day_16.txt b/data/day_16.txt new file mode 100644 index 0000000..ddc1596 --- /dev/null +++ b/data/day_16.txt @@ -0,0 +1 @@ +020D78804D397973DB5B934D9280CC9F43080286957D9F60923592619D3230047C0109763976295356007365B37539ADE687F333EA8469200B666F5DC84E80232FC2C91B8490041332EB4006C4759775933530052C0119FAA7CB6ED57B9BBFBDC153004B0024299B490E537AFE3DA069EC507800370980F96F924A4F1E0495F691259198031C95AEF587B85B254F49C27AA2640082490F4B0F9802B2CFDA0094D5FB5D626E32B16D300565398DC6AFF600A080371BA12C1900042A37C398490F67BDDB131802928F5A009080351DA1FC441006A3C46C82020084FC1BE07CEA298029A008CCF08E5ED4689FD73BAA4510C009981C20056E2E4FAACA36000A10600D45A8750CC8010989716A299002171E634439200B47001009C749C7591BD7D0431002A4A73029866200F1277D7D8570043123A976AD72FFBD9CC80501A00AE677F5A43D8DB54D5FDECB7C8DEB0C77F8683005FC0109FCE7C89252E72693370545007A29C5B832E017CFF3E6B262126E7298FA1CC4A072E0054F5FBECC06671FE7D2C802359B56A0040245924585400F40313580B9B10031C00A500354009100300081D50028C00C1002C005BA300204008200FB50033F70028001FE60053A7E93957E1D09940209B7195A56BCC75AE7F18D46E273882402CCD006A600084C1D8ED0E8401D8A90BE12CCF2F4C4ADA602013BC401B8C11360880021B1361E4511007609C7B8CA8002DC32200F3AC01698EE2FF8A2C95B42F2DBAEB48A401BC5802737F8460C537F8460CF3D953100625C5A7D766E9CB7A39D8820082F29A9C9C244D6529C589F8C693EA5CD0218043382126492AD732924022CE006AE200DC248471D00010986D17A3547F200CA340149EDC4F67B71399BAEF2A64024B78028200FC778311CC40188AF0DA194CF743CC014E4D5A5AFBB4A4F30C9AC435004E662BB3EF0 diff --git a/data/day_17.txt b/data/day_17.txt new file mode 100644 index 0000000..51bfbea --- /dev/null +++ b/data/day_17.txt @@ -0,0 +1 @@ +target area: x=156..202, y=-110..-69 diff --git a/data/day_18.txt b/data/day_18.txt new file mode 100644 index 0000000..d287a80 --- /dev/null +++ b/data/day_18.txt @@ -0,0 +1,100 @@ +[[[[4,9],[1,7]],[9,8]],[[7,9],[7,9]]] +[[[1,[1,5]],9],[[[8,0],[8,8]],[[7,2],[4,6]]]] +[[3,7],[[7,[4,6]],[[8,0],[7,8]]]] +[[[[0,1],2],4],[[9,[2,8]],7]] +[[[[9,0],9],7],[[1,0],8]] +[[4,[[1,2],1]],1] +[[[[6,1],[0,2]],[[2,3],4]],[[9,1],8]] +[[[5,9],[1,0]],[[7,0],3]] +[[9,1],[[4,7],[5,[8,6]]]] +[[5,[[3,2],[1,9]]],[[[3,8],9],3]] +[[0,[[5,6],2]],9] +[6,[2,[[4,2],6]]] +[[[[8,2],[9,1]],[9,1]],7] +[9,1] +[[[[9,8],[5,3]],5],[[6,9],[9,[6,8]]]] +[0,[[2,[2,5]],2]] +[[2,6],[[[2,8],1],[[0,2],[0,7]]]] +[[[[7,8],[8,5]],[[3,2],[4,0]]],[2,[[1,0],[2,6]]]] +[[[7,[7,0]],[[1,9],9]],7] +[[[[5,1],[0,9]],4],[[0,[9,7]],[8,[6,8]]]] +[[8,2],[2,[6,0]]] +[[2,6],[[[4,0],6],2]] +[[9,[7,[0,1]]],8] +[[[[3,8],[4,3]],[7,[0,6]]],[[[5,5],[0,4]],[[8,2],0]]] +[[[[9,1],[9,3]],[1,[0,1]]],[[[9,6],8],[9,6]]] +[[[[2,3],[7,1]],[[6,8],6]],[[[6,0],0],0]] +[[7,[[5,0],4]],[[[8,8],[6,2]],[8,2]]] +[[[0,[3,8]],[[0,0],[6,1]]],[[4,5],[[3,9],[5,8]]]] +[4,[[1,[9,6]],[8,2]]] +[[9,[[9,2],3]],[[[5,6],2],[1,[0,9]]]] +[[9,9],[[0,[9,6]],[[8,6],3]]] +[[4,[[8,3],2]],[[[9,9],9],[2,[2,0]]]] +[[[[7,3],[4,2]],7],[4,6]] +[[[2,6],[[4,0],[0,8]]],[[5,0],[3,5]]] +[[[[9,3],[0,3]],[[0,0],[1,1]]],[3,[[8,4],[8,6]]]] +[[[[3,6],8],1],[[4,[4,1]],[[5,1],[3,0]]]] +[[[[8,1],[2,0]],[5,[2,1]]],[[9,[0,0]],[[7,2],[1,0]]]] +[[[6,6],[2,3]],[[7,6],[[9,8],2]]] +[[[0,9],3],[[[9,5],5],[[6,8],[0,4]]]] +[[[0,3],9],[5,[5,[0,5]]]] +[[0,[[9,1],4]],[2,4]] +[[[9,7],[0,[7,8]]],[[[3,3],5],[[0,9],[1,5]]]] +[[0,[[8,0],[5,2]]],[[[1,8],[1,2]],[3,8]]] +[5,[0,[[9,8],9]]] +[[6,[[9,2],[3,5]]],[[[2,3],9],3]] +[1,[1,1]] +[[6,[[0,0],1]],[[7,[4,9]],7]] +[[3,[[3,5],3]],[[[9,9],6],[[5,0],8]]] +[1,5] +[[0,4],[8,7]] +[[7,[[9,2],1]],5] +[[[[6,8],[6,5]],0],4] +[[[4,1],[9,0]],[[[4,3],6],[5,9]]] +[[8,[[1,9],[5,4]]],[[[9,0],4],[5,5]]] +[[0,9],[[[5,5],[7,7]],6]] +[[8,[8,5]],[8,[2,6]]] +[[[[8,4],4],0],[[3,[2,6]],[6,6]]] +[[5,[[5,2],6]],[[[2,3],[5,0]],[[2,9],0]]] +[[[[5,9],6],[[8,9],[5,7]]],[0,[8,[2,5]]]] +[[[[9,0],7],1],2] +[[[9,3],6],[[[6,6],[9,6]],1]] +[[[2,0],[0,[4,6]]],[[[5,7],6],[9,5]]] +[[[3,[4,3]],8],[[[6,3],[0,5]],2]] +[[[[2,8],8],[5,[2,4]]],[[3,7],[2,1]]] +[[1,[[2,7],4]],7] +[[2,[4,[5,9]]],[[[7,0],6],[4,[9,1]]]] +[[[9,[3,5]],[[9,5],[5,2]]],[[2,[4,3]],[[0,5],[1,9]]]] +[[1,[9,0]],[[[0,9],[9,3]],0]] +[[[[7,8],[3,6]],3],[[[2,6],[2,9]],[[1,3],[1,3]]]] +[[[7,[1,4]],[4,7]],[[[0,7],[0,6]],5]] +[[[6,0],[3,[2,3]]],6] +[[0,[3,[1,3]]],[[2,3],9]] +[[[8,6],[0,2]],[[[8,9],[7,0]],9]] +[[[[4,9],6],2],[[[8,9],[1,5]],[9,3]]] +[[[1,5],[6,[2,7]]],[7,[1,7]]] +[5,[3,[9,1]]] +[[[7,5],[1,5]],1] +[2,[[[5,0],[4,0]],[[3,7],5]]] +[[[5,9],1],[[[3,9],4],6]] +[[3,[[5,2],[9,2]]],[4,[[3,6],[8,9]]]] +[[[5,4],[8,8]],1] +[[[[8,9],[5,8]],0],[[9,5],[6,[7,1]]]] +[[[4,[8,8]],[[9,5],4]],3] +[[6,[6,[4,3]]],[[7,[3,9]],[4,8]]] +[[5,[[4,2],[7,3]]],[[[9,0],[0,1]],[[5,8],0]]] +[[[[6,1],6],[9,[0,8]]],[9,9]] +[[4,0],[[[1,4],4],[4,4]]] +[[7,[[0,0],[1,6]]],7] +[[6,3],[5,[[2,7],5]]] +[[1,[7,5]],[0,[4,1]]] +[[[3,7],3],[[3,[0,2]],2]] +[[[0,8],[[7,0],[9,8]]],[[[0,3],4],[[6,0],6]]] +[[[[4,6],[1,7]],[[6,4],[1,5]]],[3,[9,9]]] +[[[2,[1,7]],[9,9]],[[0,[7,8]],[0,[9,6]]]] +[[9,8],[5,[6,[1,8]]]] +[[[7,2],[[0,6],[2,6]]],[[9,[0,4]],[9,[5,8]]]] +[[[8,[6,8]],[[5,5],[9,9]]],[[[2,0],6],[8,1]]] +[[[[0,8],4],[3,4]],[[0,[0,8]],[[7,5],2]]] +[7,[[[3,4],[5,4]],8]] +[[[2,8],[0,2]],6] diff --git a/data/day_19.txt b/data/day_19.txt new file mode 100644 index 0000000..4e496e9 --- /dev/null +++ b/data/day_19.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/data/day_20.txt b/data/day_20.txt new file mode 100644 index 0000000..23921b7 --- /dev/null +++ b/data/day_20.txt @@ -0,0 +1,102 @@ +##..#.#...##.####..#..###.#.#.#.#.####.#.##.....#####.##..#..#.#.##.......##.##.#.#...#....#.####..#.##.##....###..##.#####.##....##.#.#.#.#....####...##.#......#.#..##......##..#..###.#..####.###...##.#.##.#..##.##..#.#.#..###..##.####.#.#.#..#.##...#..##...##.#####..##.##..#...#..###.#.#...#..#..##...#.#..........#...#...#.#.#.#..#.###..##....####..#######.##.#.....#.#.###...##...###...#.##.##.##..#......#.###...#.#.#.#...##.#.#.##.#..###.#...##...##.......####.##..#.#....#.#####..#..#####.#.....#....#.#. + +.##.#...##..##.#..........#####..#.##..######.##..#....#..#####.#.#####.#..#...#..#####..#.......##. +.#.#.#.#####..##.#.###..#.##.##.......#.####.#............#.#....####..#.#####.##.##.#.###..#..##... +.##.#.#...##....#.#..#...........##.#.#..#####...#..##.###..##.###..........#####..##..##.#.####.... +##..####.####.###.......#....#.#####.##...#....###...##...###...#...##..####....####..#####..##..### +...###.##.....#......###.#.###..#..###...#.#..#.#######.##..#..#..#..##.##..#####.#####.###...#.###. +##.###.#....##..####.#..#.###.##.#.##..#...#...###.###.#..#..#.#.###.##.#..###.#.###....###.###..... +#.#.##..#.....#.....##....######...#........#.#.#.#.######..#...##.#.######...#.##########..#.###..# +.##.#...##.#......###..####.##.#...#..##.#.####...##..####..#####..##.###.#.###...#.#.######.#.##### +..#..##..#.#.#...####..###.#..#...#..#.#.#.#.###..####.#...#......#..#..####.#...#.#.#......#...#..# +#...###..#.#.###.#.##.##.#.#.#####....#....#.....#####...#..#..#.#####..##.....#..###.#..###.#..#... +..##.#.#..##.#.#...#...#.#.#..#.#.##....#####....#.##...#..#..#.#....###...##..#.#.##.##.#.......#.# +##.##.#######.###.#..#....#..##..#.###.....#.###..#.#..#....#.#..###.##.#.....#.#.#.##.#...#..##.#.. +.....#.#.#.#.####.#..####.#....##.###.###...########.#.#....#..##.#.#####...##....##....#.......#.#. +##..#...#..#.#.####..#.#..####.#####.#####.###..#.#####.#..#...##.######.###.#..#.##.#.#..#..#.####. +#.##.##.#.####...#.#.#.#..####.#.#...###...#.#....##...####.#..#####.#.####.#..#.....###.#..#...#.#. +.#..#.##...####...##.####...###..####.##........#.#.##..#..#.##...#....##.#.#..#.#.###...##.......#. +..#..#..#.###.##...###....#.#..#..##..#...###.###...#..#.....#..#.####.#.#.#.##..###...#....##.#.### +###.##....##.#.##..####.#.###...###.###.#####..##.###.....#.#####....#.##..##.#####.##..###....#.... +###..#...###..#....#..#.#...#....###.#.####.##..#.#..#.###..#..#.##.#.#.......#...#....#...###..#.## +#...#.#.#...#.####.##.#.#..#...##.....#..##....#..#.##..##.####.#.#.###..##..#.#.#.###.#.#..####..## +.###..###.##..###..#..#.##..#...#.##.#.......####.#..##.#...#.##..#..........##..####..##.###..###.. +###.#.#...###..#...#####.####..#..#######.#.#.###.##.###.#.####.##.#####..###.#####.#...####.##..##. +.##..##..##.#...######.###...#.##.##....##.#...##.#####.#...##..#.#...#.#..#.##.#....##.####.#.##.#. +...####..#...#...####.#.#...#...###..#.##...####.#..######.##.....##..#...#...####.###.#..##.##..#.. +#.#####.##.##..#..##.#.####..##.#.#...#..####.##..###.####.##.##...#.#...#.#.#####.####.#.###..#..#. +..#.....#..##..#...#####..##.###..##.#..##..##..####.#..#.####.###...#####.#.###.....#..#.####.#.##. +#####....###..##.#.######.#.##..##.#.#####.##########.#...##...###....###.#.....#.....###.#.#.#.##.# +##.....#.###.###.#.##.########....##.##.###...#######..##..#.#.#..#.##..####..#.###.#.###.#.#......# +..##..#...#.#.#.#.###.#..#####.#.#..#......####..#.###..###...##...##.##..#..#..#.##.#..###..##.#.#. +.#.#..#..###.##.#.#...#.#...##...#.###..#.#.##.#....#..####..#.#.##.#..#...##.#.....##...####.....#. +##.#..##...#..##.####.##....##..#####.###...#..######..#....#..#######..#..#.####.#...##.##..##..#.. +..##.#.###....#..#.....#..#.#.#.#........#..##.#.#.......####.##...#.#.##.######..##..#....#.#...... +.....#....#.#.##...#..######.###.###.##....##.#.##.###.....#..#.#....#####.#..##.#.....#..#.##....## +##.....#.#...####...##.##.#.##.#.##......#.#########.#.##..##...###.##.#..#....#..##.####..#######.. +##...#.########.###.#....#...#..##.##.###....##...#####..##.####..##..#..#####.#..######.####...#.#. +##.####..##.#####..#..###...##.......#...#.###.#.#..#..#....#.#..##.....#.#....####.###...#.#..##.#. +#.#.#.#.###..#.#####.#...##...#.###.##..#.#####.....#...#.#.#..#...##....#...####.####.##.#.....#### +..###.##.#......#######..#...##..###.##....#....#.#..###...#..###.#.#...#..##...####.###.###..#.#.## +.#..#.#.##..###########.#.#..#.###.######...###.##..#.###..##.#...#.#...###.#.##.##.#..#..#..#.#...# +.#..#.#..##....#....####.#..##....#.###.####..#.##.#.#..###.#.##.#........##.#...###.#.......##.#... +...###.#.#.##.##.##.....#.#.#..#..#.##.#######...##....#.#......##....##.#.####.####.###.#....##..#. +.#.##..#.##.##.####.....##...#..###.###.###..#..##.####..##...#.###.##..##..#####.#..###....###.##.# +#.###...#####.#..#.####...##.#..#...######.....#.#....##.#.#...##....#...........##.##.##.#...###### +##..#..##.....##..#.#..##.##.#..#...####.######.......###..#..##.##..##..##..###..##.##.#.#.....#... +#......###..#####..#######.#.#..#.###..##.#..##.##.##.#..###.###..##.##.....#.#..####.#.##...##..### +.##...#..###..##..#.#####.#####.###...#.........#.##.##.###.#.#.#...###.#..###.##.##.#..#..#...###.# +#.###.###.###.#.###.#.##....##..##.......#....##.###.###.#.###..#..###.#.##.##..#.#...######.####..# +..#####.###.##.#..##.##.#..#.###..#.####....#...##.#.......#.#..##.#.......##.##.#######...######.## +#.##...###..#..##.....#.#.##.#..##...##.#####..#...##...#..#.####.#.##.##.#....##.###.#.##..##..#.#. +..#.###.#.##...#..##.#..####.###..#####.##.####.#.##..####.###..##..#...#.##...#.###....####...####. +.###.....###.#....######.#####..#..#..#.#.#..#..#.###.#........##.###...#...##..#..#...#.....#.###.# +..###.##.#.#####.#..########..##..##.#..###.#.##.#....#.###........#....#...#.#...##.#.##..#..##.##. +###.#.#.#...#..##....#.##....##.#######.#.##.#.##....#....###.#.#.....#.##..###..##..#..##..#.#..##. +.#.##..#.##..##.##.##..#.###.#..##.###.#.###.##......##.#...##.##..##...##.#...##.#..#..#.##..#.##.. +####..####.###..#..#####...###.#....###.#...##........#.#...#..#.#.###..####.#.#.######...#..##.#.#. +#...#..#.##..#.#.#.#.#...##.#.##..#...#.###.###.#....##.#..##.#.###..##....#.###.#.##..#..##....#... +#.###.#.##.###.#..#...####.#....#..#.#####.#...#.###.##.##.###.###..#...#.#.####..###..........##.#. +##.##.#.###.#.##.####...###.#.###..###...####..#####.###...#.##...###.##..#.####.#.##...#....##.#.## +#....#..##.##.##......##...##.##..#####...#.##.###.##...##..##..###..#..#..#...###.##.#..#..#.#...## +###.####.....#.#....####..#.##.........#....##.....#....##.#..##.##..####..###.####.#...##....##.##. +#.......###.#..####.##..#..##...#....###...##.......##.....###.######.#..#..##..#....#.###.#..##.### +#.###.##..##..##.##...#.........####..####..#..##...##.#..#..#######.###...#......#.##.####.#..##... +#.####...##.#...#.#.###...##...#....#.##.##.####.#.#....###....#...#........##.##..#.#.####..#.#.#.. +.#..###.#..#.....##..#..#.###..###.#.##...#.#.....#...#....#.##.#..#.#...#..#.#..###..#.#...###..... +.####....####....#.#.....#..#.#.##........#..#.####.##.##...#.#.####.#..#.##..##..#...#.#.##...#.#.# +#####.#...####.#.####.#...#..#...#.#.##.#..#...##..#.#...##.###.##.#.###.###.#...#..#.###.##.##...#. +#.#....#.###.##..##.##..##.#...#.###....###....###..#.####.###..#.#.##...#..####....#.####...###.#.. +.#...#.###.#.####..#.#####...##...#..##........#....#..#.#.##..##.##.#######.#.#.#.##.#.#.#.##..#... +#....#....#.#.##.##.##..###..###.##..#.##.....###.###......#.#....#..#.##......#.###.#..#.#.#.#..### +#####.#####.##...#.#..#..##.####.#......######..####..##.##.##.#.......#...####..#..###.#..##.#.#.#. +#.##...##..##......###...#.#.##...#.#...#..##.###.#..#.##...#.#.#.##.###.##.#####....#...#.....##..# +..##....##..#..##..##...#..#.##.####.##........###..##.##.#.#.##..#..###...#..#...##.#.##.########.# +#...#.#####.###.#....#....#######.###..#..#.#..##..#.###.#.####.##.#..###..#....###.###....###.#..## +.......###.#.#.#..#.#..###...#.##..#..#...#..#....#..#...#.#####.#...##.#.###.###.#..#.##.#..##..... +....#.##...#.##.#.###..#####..#.######.###...###..##.#.#.##.###.##.####..#..#.....#.......#.######.# +##..####......##...##.#..#..#..#..##.#.#..##..####.#.######.#...##..#..#.##.##..###..#..#.#..#..#... +.##.#..#..##.#.##..#..#.#.#...##.##...##.#.########..##..#...#####.....#.#..###.#.##.##.###..#..#.## +..##...#.#..#.#.##.###..#....#..###...#..##....##.#..######..###.#.#####..#.###.##.###..#####...#### +#.#..###.##.#...#..###..#.##.##...####.####.#.....##....###..#..#...####.####.###...#..#.#.#.#.##..# +###..##...#.#..##..#...##..###.#.....#...##.###.#..###...###.####..###.#..#.#...##.....#............ +.#####..##...##....######...#..###.#.#......#...######.#..#...###.#...#..####.#......##..#..#.#...#. +.#..####.#.#..###..#.#.##.####..#.#....#.####..##...#..#.#.#..###.........##.#.#####...###...#.#..#. +.#.#....#..####..##..#########.#..#.##..###..#..#...###....##.....####...#..#.##....#######.####.##. +##.#.####..#...#..#.##.#..#....##.####..####..###.#.#...#######.#.###..###.###..#.###.##...##.##..#. +.#####.....##.#....##...##...#.#..####.##..#....##.###.#####.##.#.#.#...#...#.#.#.......##..##.##.#. +.##..#.#.###.#.#.#....##.#...#....#...#...#..#######....##.#.#.#####.#.###..#..#...#......#..#.##..# +...##.....#..#.####.###...#####.#.#....##.#.#.#.#...####.####.#..##.#.##.##.###..##...##.....#...### +####.###..###.####..###.##..#.#####.#...##.#..#.#.##.####.#..####..#..##....####.#....#...#.####.#.# +##....##.#.#.##.###..#####.##..##..#..##..##..#.#..###.##.#####...#..#.##.#.####.####..#...##..#..## +#.#..###..##..#..#..####..#..#.#..#.##...###.#.#.#.#...####.#.#...####.##..#.#.#..#.##..##..##.#.... +##.#.####....##..##..####.#######..##....######.##.#....#..#...#.#..#.##.#...#.#.#.#.#..###....#.#.# +.##.###..#.###..##...####.###.#.##.###.#...#..#......######.##.##.##.####.##.##....#.#......####.#.# +#..###.####.#...#.###.###.#..##.###..#.#.#####..#.##.##.#.##.##..###.####...####..#..###...#.##.#### +#...............#.##.###...#..#..#.##.##.#.##.#.#...#.#....#..#.######..#..#..##....#.##..#..#..#.## +###.###...#...#..#....##.......#.#..#...##...#....#..######..#.....##.####..#....#...##...######..## +..##..#..##.#.##..###.#...............####...##..##......#...#.....#..#....#.#...#.....##..#####..## +#.....##.#.##.###......###.#.##..###....###..#...#..###.#..#..##...#..#.##...#.#...#..#.....##...#.# +..##....#..#.#.#.####..#.#.#....#.#.#.#.##.#..#.#..#..#.#.##.####......##..#...##..#.#.##..#.....#.. +.#..##....###.###..##....#####.#....####....#.#.##..#...#.###.##..#.....##........###.###.####..#.#. +.###.##..#..#...#.#.#######.##.#.#.#.#.###.#.#.#.#......#####.###.#.#.#......#.#..#.#.##..#.##.#.#.# diff --git a/src/day_16.jl b/src/day_16.jl new file mode 100644 index 0000000..243e246 --- /dev/null +++ b/src/day_16.jl @@ -0,0 +1,73 @@ +include(joinpath(readchomp(`git rev-parse --show-toplevel`), "aoc.jl")) +import .Aoc: @aoc +using Pipe: @pipe + + +function decode_packet(p, o, version) + version += parse(Int, p[o:o+2], base=2); o+=3 + type = parse(Int, p[o:o+2], base = 2); o+=3 + + if type == 4 + v = "" + while true + tmp = p[o:o+4]; o+=5 + v *= tmp[2:end] + tmp[1] == '0' ? break : continue + end + value = parse(Int, v, base=2) + else + length_type = p[o]; o+=1 + sub_values = [] + if length_type == '0' + length = parse(Int, p[o:o+14], base=2); o+=15 + target = o + length + while o < target + v, o, version = decode_packet(p, o, version) + push!(sub_values, v) + end + else + num = parse(Int, p[o:o+10], base=2); o+=11 + for _ in 1:num + v, o, version = decode_packet(p, o, version) + push!(sub_values, v) + end + end + end + + if type == 0 + value = sum(sub_values) + elseif type == 1 + value = prod(sub_values) + elseif type == 2 + value = minimum(sub_values) + elseif type == 3 + value = maximum(sub_values) + elseif type == 5 + value = sub_values[begin] > sub_values[end] ? 1 : 0 + elseif type == 6 + value = sub_values[begin] < sub_values[end] ? 1 : 0 + elseif type == 7 + value = sub_values[begin] == sub_values[end] ? 1 : 0 + end + return (value, o, version) +end + +function p1(input::Vector{String}) + packet = "" + for c in input[1] + packet *= bitstring(Int8(parse(Int, c, base = 16)))[5:end] + end + v, _, version = decode_packet(packet, 1, 0) + return version +end + +function p2(input::Vector{String}) + packet = "" + for c in input[1] + packet *= bitstring(Int8(parse(Int, c, base = 16)))[5:end] + end + v, _ = decode_packet(packet, 1, 0) + return v +end + +@aoc(2021, 16) diff --git a/src/day_17.jl b/src/day_17.jl new file mode 100644 index 0000000..dcae6d5 --- /dev/null +++ b/src/day_17.jl @@ -0,0 +1,38 @@ +include(joinpath(readchomp(`git rev-parse --show-toplevel`), "aoc.jl")) +import .Aoc: @aoc +using Pipe: @pipe + +function solve(input) + x1, x2, y1, y2 = parse.(Int, match(r"target area: x=(-?\d+)..(-?\d+), y=(-?\d+)..(-?\d+)", input).captures) + total = 0 + best = 0 + for vx in isqrt(2x1)+1:x2, vy in y1:abs(y1) + x,y,maxy = 0,0,0 + Δx, Δy = vx, vy + found = passed = false + while true + inside = false + x += Δx; y += Δy + Δx -= sign(Δx); Δy -= 1 + y > maxy && (maxy = y) + if x in x1:x2 && y in y1:y2 + inside = true + !found && (total += 1); found = true + maxy > best && (best = maxy) + end + (found && !inside) && break + y < y1 && break + end + end + return (best, total) +end + +function p1(input::Vector{String}) + return solve(input[1])[1] +end + +function p2(input::Vector{String}) + return solve(input[1])[2] +end + +@aoc(2021, 17) diff --git a/src/day_18.jl b/src/day_18.jl new file mode 100644 index 0000000..5b11c6d --- /dev/null +++ b/src/day_18.jl @@ -0,0 +1,69 @@ +include(joinpath(readchomp(`git rev-parse --show-toplevel`), "aoc.jl")) +import .Aoc: @aoc +using Pipe: @pipe +using Combinatorics + +function addn(v, n, dir) + n == nothing && (return v) + typeof(v) == Int && (return v+n) + if dir == "left" + return [addn(v[1], n, "left"), v[2]] + else + return [v[1], addn(v[2], n, "right")] + end +end + +function arrexplode(v, n = 4) + typeof(v) == Int && (return (false, nothing, v, nothing)) + n == 0 && (return true, v[1], 0, v[2]) + + l, r = v + exploded, t, l, w = arrexplode(l, n-1) + exploded && (return true, t, [l, addn(r, w, "left")], nothing) + exploded, t, r, w = arrexplode(r, n-1) + exploded && (return true, nothing, [addn(l, t, "right"), r], w) + + false, nothing, v, nothing +end + +function arrsplit(v) + if typeof(v) == Int + v > 9 && (return true, [v ÷ 2, Int(round(v/2, RoundUp))]) + return false, v + end + l, r = v + changed, l = arrsplit(l) + changed && (return true, [l,r]) + changed, r = arrsplit(r) + + changed, [l,r] +end + +function arradd(l, r) + sum = [l,r] + while true + changed, t, sum, w = arrexplode(sum) + changed && continue + changed, sum = arrsplit(sum) + changed && continue + break + end + sum +end + +function magn(v) + typeof(v) == Int && (return v) + 3*magn(v[1]) + 2*magn(v[2]) +end + +function p1(input::Vector{String}) + numbers = [ eval(Meta.parse(x)) for x in input ] + magn(reduce(arradd, numbers)) +end + +function p2(input::Vector{String}) + numbers = [ eval(Meta.parse(x)) for x in input ] + maximum([magn(arradd(l,r)) for (l, r) in Combinatorics.permutations(numbers, 2)]) +end + +@aoc(2021, 18) diff --git a/src/day_19.jl b/src/day_19.jl new file mode 100644 index 0000000..be21d16 --- /dev/null +++ b/src/day_19.jl @@ -0,0 +1,86 @@ +include(joinpath(readchomp(`git rev-parse --show-toplevel`), "aoc.jl")) +import .Aoc: @aoc +using Pipe: @pipe +using Combinatorics + +function prepare_input(input) + dict = [] + tmp = [] + for l in input + l == "" && continue + m = match(r"--- scanner (\d+) ---", l) + if m != nothing + length(tmp) != 0 && push!(dict, tmp) + tmp = [] + continue + end + push!(tmp, parse.(Int, split(l, ","))) + end + dict +end + +function align(a,b, negs, distances) + a2 = Set(a) + for re in 1:6, neg in negs + newb = [ neg .* collect(Combinatorics.permutations(s,3))[re] for s in b ] + for p1 in a2, p2 in newb + count = 0 + remapped = [] + dist = p2 .- p1 + for b2 in newb + to_a = b2 .- dist + to_a in a2 && (count += 1) + push!(remapped, to_a) + end + if count >= 12 + println("match $dist") + push!(distances, dist) + return true, remapped + end + end + end + return false, [] +end + +function p1(input::Vector{String}) + @info "Something is brken. This may take 5 minutes or more to get a slightly wrong result." + negations = [ + [1,1,1], + [-1,1,1], + [1,-1,1], + [1,1,-1], + [-1,-1,1], + [-1,1,-1], + [-1,-1,-1], + [1,-1,-1] + ] + list = prepare_input(input) + aligned_idx = Set(1) + aligned = Dict(1 => list[1]) + beacons = copy(list[1]) + dont_align = Set() + distances = [[0,0,0]] + while length(aligned_idx) < length(list) + for i in 1:length(list) + i in aligned_idx && continue + for j in sort(collect(aligned_idx)) + println("checking $i against $j") + (i,j) in dont_align && continue + found, remapped = align(aligned[j], list[i], negations, distances) + if found + push!(aligned_idx, i) + aligned[i] = remapped + beacons = vcat(beacons, remapped) + break + end + push!(dont_align, (i,j)) + end + end + end + return length(beacons) +end + +function p2(input::Vector{String}) +end + +@aoc(2021, 19) diff --git a/src/day_20.jl b/src/day_20.jl new file mode 100644 index 0000000..fba01bb --- /dev/null +++ b/src/day_20.jl @@ -0,0 +1,60 @@ +include(joinpath(readchomp(`git rev-parse --show-toplevel`), "aoc.jl")) +import .Aoc: @aoc +using Pipe: @pipe + +function prepare_input(input) + code = [ (c == '#') for c in input[1] ] + image = [] + + for l in input[3:end] + push!(image, [ (c == '#') for c in l ]) + end + code, image +end + +function neighbours(i,j) + ( (i+y,j+x) for (y, x) in zip([-1,-1,-1,0,0,0,1,1,1], [-1,0,1,-1,0,1,-1,0,1])) +end + +function get_value(image, y, x, bool) + ( 1 <= y <= length(image) && 1 <= x <= length(image[1])) && return image[y][x] + bool +end + +function apply_alg(image, code, bool) + w = length(image[1]) + h = length(image) + newimage = [] + for y in 0:h+1 + row = [] + for x in 0:w+1 + values = [ get_value(image, y2, x2, bool) for (y2,x2) in neighbours(y, x)] + idx = parse(Int, join(map(b->b ? 1 : 0, values)), base=2) + push!(row, code[idx+1]) + end + push!(newimage, row) + end + newimage +end + +function p1(input::Vector{String}) + code, image = prepare_input(input) + bool = false + for _ in 1:2 + image = apply_alg(image, code, bool) + bool = !bool + end + return sum(vcat(image...)) +end + +function p2(input::Vector{String}) + code, image = prepare_input(input) + bool = false + for _ in 1:50 + image = apply_alg(image, code, bool) + bool = !bool + end + return sum(vcat(image...)) +end + +@aoc(2021, 20)