From 4cbdf16fbf2168feb6dc473f003e701623b75584 Mon Sep 17 00:00:00 2001 From: j-james Date: Mon, 13 Dec 2021 01:45:14 -0800 Subject: Day Thirteen --- 2021/13.py | 33 ++ 2021/input/13.txt | 1138 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1171 insertions(+) create mode 100644 2021/13.py create mode 100644 2021/input/13.txt diff --git a/2021/13.py b/2021/13.py new file mode 100644 index 0000000..d5b0765 --- /dev/null +++ b/2021/13.py @@ -0,0 +1,33 @@ +# Day Thirteen: Transparent Origami + +file = open("input/13.txt").readlines() + +def fold(paper: set, axis: str, crease: int) -> set: + result = set() + for dot in paper: + if axis == "x" and dot[0] >= crease: + result.add((crease - (dot[0] - crease), dot[1])) + elif axis == "y" and dot[1] >= crease: + result.add((dot[0], crease - (dot[1] - crease))) + else: + result.add(dot) + return result + +paper = set() +for i, line in enumerate(file): + if i < 1125: # Hardcoded for simplicity + x, y = map(int, line.strip().split(",")) + dot = (x, y) + paper.add(dot) + elif i > 1125: + ins = line.split()[2].split("=") + paper = fold(paper, ins[0], int(ins[1])) + if i == 1126: print(len(paper)) + +for i in range(6): + for j in range(39): + if (j, i) in paper: + print("#", end="") + else: + print(" ", end="") + print() diff --git a/2021/input/13.txt b/2021/input/13.txt new file mode 100644 index 0000000..c7c042e --- /dev/null +++ b/2021/input/13.txt @@ -0,0 +1,1138 @@ +1141,700 +94,21 +1121,880 +1078,686 +1236,824 +1165,413 +1213,435 +803,323 +845,96 +1046,848 +701,348 +98,677 +659,24 +366,592 +426,593 +756,718 +606,829 +850,248 +964,372 +1233,807 +1108,281 +152,858 +165,551 +1173,612 +385,819 +1116,646 +32,134 +1240,582 +224,116 +560,889 +43,525 +905,442 +140,544 +869,560 +633,390 +627,513 +554,176 +865,883 +1004,285 +616,750 +980,553 +455,71 +920,800 +1225,472 +764,807 +1048,665 +823,844 +398,78 +458,312 +405,548 +957,836 +905,715 +1002,792 +546,191 +925,595 +1261,560 +1134,495 +753,780 +602,86 +383,864 +146,525 +236,833 +1193,124 +147,892 +422,460 +1111,883 +194,248 +671,507 +147,225 +308,614 +1178,381 +179,347 +882,73 +1174,434 +139,283 +1096,366 +663,226 +150,812 +957,516 +290,612 +150,63 +746,161 +1173,115 +830,660 +254,841 +962,88 +365,72 +586,87 +472,754 +1160,530 +889,161 +1151,60 +808,281 +858,134 +495,386 +319,516 +856,80 +366,78 +229,435 +498,824 +609,348 +1255,127 +366,582 +1004,624 +318,84 +470,424 +1216,460 +785,585 +500,84 +1198,29 +969,241 +664,474 +152,738 +301,409 +171,864 +1208,329 +1086,564 +1145,551 +207,710 +114,605 +1028,394 +282,394 +426,453 +1151,308 +299,269 +448,57 +224,164 +146,145 +610,836 +1202,535 +1114,737 +636,550 +838,754 +1272,848 +1059,102 +1051,469 +894,261 +1230,862 +627,45 +554,597 +85,44 +560,537 +341,480 +1298,530 +1242,535 +1021,324 +132,572 +271,127 +1155,7 +1121,18 +800,306 +758,338 +1166,60 +125,581 +311,171 +457,607 +1257,782 +277,9 +1285,730 +724,47 +418,509 +1193,572 +733,576 +1297,205 +289,581 +1048,565 +418,725 +147,57 +249,542 +140,798 +199,404 +1109,16 +1292,728 +73,504 +546,87 +565,182 +537,98 +1143,479 +139,72 +912,78 +1285,778 +150,82 +681,575 +1009,92 +1096,701 +1002,74 +862,200 +631,816 +282,210 +289,133 +363,235 +835,387 +1285,147 +1203,577 +1136,858 +1160,812 +1185,784 +1113,305 +1210,561 +1275,263 +194,493 +38,750 +1029,869 +1009,378 +334,185 +425,124 +74,70 +1151,834 +1039,0 +808,410 +676,285 +1163,2 +214,701 +788,676 +1113,753 +15,199 +146,77 +1238,838 +152,156 +1288,880 +589,471 +251,326 +306,382 +372,684 +582,56 +1029,781 +671,619 +291,693 +681,319 +523,334 +55,63 +454,884 +436,703 +633,233 +885,435 +1285,164 +522,124 +341,190 +239,259 +197,305 +196,157 +622,536 +1205,702 +1069,43 +293,361 +276,452 +281,473 +401,838 +683,269 +377,773 +749,742 +252,294 +938,836 +1158,604 +773,98 +1288,513 +1022,592 +120,423 +1223,707 +1166,8 +999,619 +68,271 +522,493 +567,642 +629,575 +458,582 +544,360 +22,14 +360,14 +289,520 +283,705 +1238,61 +557,562 +167,479 +1242,399 +870,147 +669,765 +1128,561 +893,315 +618,178 +922,155 +938,684 +1120,303 +241,403 +1128,614 +401,166 +688,582 +793,115 +647,668 +331,696 +636,614 +445,883 +465,102 +1225,24 +474,189 +446,679 +467,411 +100,718 +731,120 +768,814 +112,29 +1305,82 +502,613 +388,662 +1020,730 +348,470 +390,494 +610,612 +1039,319 +922,232 +251,120 +634,554 +1116,557 +3,498 +944,312 +172,281 +1266,164 +634,312 +852,157 +639,226 +144,820 +294,513 +468,768 +1059,550 +176,495 +117,443 +1084,718 +182,754 +561,733 +497,252 +380,660 +318,768 +586,154 +221,319 +489,343 +1097,101 +1084,878 +36,724 +159,386 +453,878 +811,444 +27,381 +933,325 +1007,691 +962,833 +711,254 +184,609 +373,322 +1197,782 +1022,886 +746,180 +224,730 +1176,183 +1116,136 +1116,269 +69,798 +25,778 +1124,574 +1061,659 +624,478 +1089,640 +1272,144 +1163,669 +1121,96 +189,880 +561,152 +914,180 +43,346 +236,509 +174,281 +754,229 +423,561 +365,772 +350,432 +124,527 +194,625 +1053,518 +540,605 +892,169 +556,229 +1071,259 +49,560 +940,165 +353,409 +214,193 +852,694 +10,324 +3,396 +692,178 +711,624 +636,445 +887,817 +880,340 +618,58 +1164,217 +821,119 +882,128 +415,550 +72,68 +862,57 +934,65 +1019,201 +788,134 +288,886 +353,652 +346,74 +227,707 +350,656 +1208,565 +979,198 +98,217 +544,534 +1272,750 +631,458 +549,799 +1113,589 +1012,729 +651,162 +933,560 +1160,880 +185,334 +281,2 +229,348 +159,834 +659,870 +925,304 +343,322 +361,626 +226,278 +679,458 +331,610 +224,106 +278,829 +1185,38 +274,682 +363,873 +746,266 +289,346 +761,704 +483,752 +694,255 +45,197 +472,568 +517,194 +850,829 +1029,444 +50,142 +85,472 +914,271 +363,659 +366,816 +970,642 +502,738 +1173,880 +282,52 +228,817 +264,94 +1171,463 +992,810 +236,390 +172,532 +927,289 +438,234 +197,309 +485,194 +124,326 +759,280 +1138,810 +918,441 +1166,298 +987,696 +882,869 +1082,817 +330,252 +72,277 +957,409 +117,796 +726,106 +25,164 +293,626 +937,25 +1176,631 +1171,72 +560,460 +463,877 +974,126 +1241,798 +1210,718 +827,752 +497,662 +1193,443 +139,809 +1086,554 +1096,528 +631,78 +182,561 +780,120 +507,387 +577,646 +565,712 +567,792 +418,390 +634,648 +181,481 +565,56 +1163,837 +301,378 +351,339 +609,647 +1170,350 +1086,730 +781,558 +520,711 +445,546 +1223,187 +405,715 +1307,498 +1205,799 +1310,480 +1255,254 +446,742 +616,751 +888,535 +803,837 +1061,211 +454,626 +518,460 +465,880 +1017,626 +1130,257 +679,78 +440,147 +836,301 +90,180 +502,260 +967,423 +1061,442 +1170,798 +10,346 +1178,572 +455,404 +435,656 +351,555 +502,484 +908,485 +1004,176 +617,334 +753,562 +241,491 +1096,162 +313,241 +200,626 +189,96 +857,374 +676,554 +599,158 +179,725 +894,185 +967,883 +1245,326 +636,449 +1302,474 +555,705 +522,760 +15,275 +530,297 +750,21 +927,829 +256,78 +1091,275 +400,826 +349,681 +64,105 +1205,78 +353,254 +565,502 +413,390 +802,145 +1225,44 +354,348 +144,74 +154,84 +557,332 +1282,505 +748,246 +676,609 +1084,400 +1190,471 +858,760 +962,332 +810,165 +460,401 +85,156 +125,784 +1059,120 +89,763 +1218,246 +803,387 +1233,890 +468,320 +734,614 +427,707 +254,501 +1307,732 +634,760 +720,441 +87,252 +371,369 +416,261 +331,386 +355,493 +1032,829 +498,742 +888,12 +257,264 +395,425 +373,444 +373,2 +518,236 +468,126 +520,183 +1061,198 +321,530 +651,870 +883,873 +396,565 +1297,302 +85,24 +569,626 +1295,275 +1128,386 +499,455 +517,764 +562,246 +590,453 +1278,134 +659,212 +1058,294 +748,106 +1061,116 +1278,582 +644,324 +917,434 +1268,583 +1186,382 +288,750 +336,84 +802,749 +132,360 +144,60 +1260,114 +400,68 +920,400 +191,885 +845,574 +10,122 +725,553 +845,798 +877,816 +221,575 +348,718 +605,334 +70,340 +508,523 +1133,389 +845,102 +378,218 +517,700 +137,764 +980,642 +547,401 +688,65 +674,166 +13,673 +1246,553 +130,648 +92,246 +529,800 +905,778 +1029,2 +251,147 +847,877 +25,416 +1153,252 +333,530 +174,613 +13,205 +1178,322 +989,82 +1004,332 +700,742 +802,371 +80,480 +433,296 +107,652 +1086,164 +828,613 +922,662 +370,165 +811,478 +78,728 +1178,502 +704,829 +363,245 +258,812 +1304,709 +624,493 +910,378 +171,30 +105,78 +741,198 +474,637 +1002,820 +996,236 +150,880 +136,434 +1077,488 +1084,373 +448,389 +580,742 +132,228 +366,302 +1089,598 +577,106 +155,7 +808,484 +400,378 +836,889 +606,65 +365,133 +185,773 +445,647 +32,760 +507,837 +542,80 +967,471 +915,655 +77,646 +218,703 +1046,400 +694,134 +70,541 +282,836 +632,96 +227,873 +372,58 +413,464 +87,792 +405,778 +504,831 +631,436 +763,208 +208,742 +213,334 +877,296 +271,513 +1304,261 +811,887 +1183,459 +937,659 +994,884 +251,550 +358,493 +1295,124 +925,816 +599,18 +1143,863 +599,782 +1178,696 +1302,393 +306,582 +750,537 +120,613 +266,739 +949,268 +291,211 +249,659 +32,582 +725,341 +1238,617 +582,166 +1151,808 +845,14 +172,810 +957,879 +271,575 +378,114 +44,152 +662,185 +1004,760 +905,548 +1180,470 +343,423 +224,554 +651,24 +773,459 +189,555 +246,862 +515,431 +821,343 +811,455 +671,695 +1255,316 +622,582 +629,116 +1011,493 +1293,301 +1295,674 +373,781 +787,782 +1163,225 +435,238 +64,789 +1185,89 +720,453 +1033,121 +517,115 +927,448 +1197,364 +1307,610 +232,89 +641,750 +249,198 +1302,501 +763,561 +182,386 +957,204 +289,324 +72,169 +18,280 +517,779 +1174,658 +560,434 +1289,661 +3,732 +1160,831 +435,208 +72,614 +403,147 +753,684 +1089,35 +1039,381 +6,261 +674,614 +1138,281 +1178,198 +764,191 +219,619 +1078,208 +70,788 +1002,614 +388,155 +448,200 +1077,833 +1186,751 +937,113 +21,661 +965,77 +214,366 +937,322 +152,484 +1223,792 +1186,326 +502,634 +884,453 +751,593 +733,198 +1298,236 +700,612 +172,165 +1004,382 +426,553 +1304,152 +144,596 +713,864 +617,598 +1215,681 +229,546 +155,439 +972,772 +590,889 +1246,105 +413,504 +1238,169 +405,452 +145,413 +679,660 +345,817 +1173,764 +662,152 +1057,56 +33,197 +1285,612 +892,56 +780,760 +232,658 +589,36 +465,466 +694,750 +1130,889 +7,887 +105,190 +574,862 +855,490 +157,642 +430,164 +341,414 +1027,189 +793,764 +182,140 +504,98 +77,442 +579,344 +1160,82 +139,611 +701,647 +209,695 +508,665 +1125,773 +236,385 +1166,834 +1079,113 +144,834 +1166,326 +961,213 +1121,555 +780,597 +124,745 +1238,725 +221,859 +77,807 +721,423 +947,469 +392,441 +94,460 +117,98 +808,738 +397,264 +508,749 +681,478 +1300,772 +316,772 +1126,339 +197,141 +648,70 +150,530 +226,521 +281,113 +251,568 +764,87 +915,239 +801,481 +945,133 +426,817 +136,303 +364,164 +959,555 +1274,170 +377,560 +577,128 +825,662 +159,586 +251,102 +741,738 +565,278 +365,374 +956,348 +110,808 +125,313 +15,124 +309,369 +488,553 +512,339 +1091,686 +649,364 +793,130 +1216,441 +68,266 +271,764 +1186,303 +564,180 +1084,176 +1217,742 +353,879 +189,798 +711,876 +582,725 +93,742 +467,859 +25,612 +989,812 +812,747 +140,350 +77,890 +788,493 +885,135 +12,306 +763,493 +577,788 +1183,480 +1166,820 +927,513 +945,72 +301,339 +132,502 +910,280 +673,817 +711,158 +276,442 +226,400 +830,234 +1262,65 +724,807 +373,25 +811,416 +288,582 +453,464 +750,607 +1255,831 +1297,689 +219,337 +55,831 +1027,369 +25,127 +1298,684 +1210,297 +1285,478 +30,829 +1074,390 +1232,728 +1123,25 +1215,21 +87,102 +350,238 +1242,359 +323,284 +37,150 +1190,613 +1196,289 +473,481 +246,32 +139,463 +1091,337 +1081,124 +524,126 +925,819 +856,626 +662,70 +676,134 +303,691 +1232,614 +65,434 +887,781 +642,82 +932,80 +428,25 +1057,838 +555,257 +428,421 +454,814 +421,161 +530,120 +238,261 +68,87 +736,32 +1285,339 +314,236 +262,889 +884,341 +1210,128 +508,371 +303,150 +141,793 +648,96 +102,329 +306,134 +676,382 +323,198 +1047,637 +750,210 +524,470 +674,449 +38,46 +1260,619 +678,381 +495,508 +373,869 +808,290 +1128,728 +1009,339 +1191,894 +938,500 +950,14 +811,450 +150,14 +708,100 +125,374 +1029,113 +291,263 +756,297 +1238,501 +1071,344 +1238,614 +969,480 +232,359 +992,126 +823,278 +1020,836 +405,442 +701,361 +842,126 +864,742 +70,312 +125,112 +108,359 +281,781 +301,92 +500,165 +1200,808 +1285,767 +117,572 +947,873 +743,792 +249,211 +1233,646 + +fold along x=655 +fold along y=447 +fold along x=327 +fold along y=223 +fold along x=163 +fold along y=111 +fold along x=81 +fold along y=55 +fold along x=40 +fold along y=27 +fold along y=13 +fold along y=6 -- cgit v1.2.3-70-g09d2