From 082e46a5a37fc23063f892e4b1c8f5baff28b34b Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Thu, 1 Dec 2022 00:06:28 -0500 Subject: [PATCH] Move last year's solutions to 2021 directory --- 01/README | 6 ------ 01/a.c | 16 ---------------- 01/a.py | 12 ------------ 01/b.c | 26 -------------------------- 01/b.py | 23 ----------------------- 01/input | 2000 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 01/sol.scm | 35 ----------------------------------- 02/a.c | 24 ------------------------ 02/a.py | 18 ------------------ 02/b.c | 26 -------------------------- 02/b.py | 20 -------------------- 02/input | 1000 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 02/sol.scm | 41 ----------------------------------------- 03/a.c | 55 ------------------------------------------------------- 03/a.py | 28 ---------------------------- 03/b.py | 33 --------------------------------- 03/input | 1000 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 04/a.py | 42 ------------------------------------------ 04/b.py | 47 ----------------------------------------------- 04/common.py | 37 ------------------------------------- 04/input | 601 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 05/a.c | 36 ------------------------------------ 05/a.py | 31 ------------------------------- 05/b.c | 36 ------------------------------------ 05/b.py | 38 -------------------------------------- 05/input | 500 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 06/a.c | 37 ------------------------------------- 06/a.py | 28 ---------------------------- 06/b.c | 39 --------------------------------------- 06/b.py | 16 ---------------- 06/input | 1 - 07/a.py | 22 ---------------------- 07/b.py | 24 ------------------------ 07/input | 1 - 08/a.py | 15 --------------- 08/b.py | 108 ------------------------------------------------------------------------------------------------------------ 08/input | 200 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 08/input2 | 309 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 09/a.py | 28 ---------------------------- 09/b.py | 40 ---------------------------------------- 09/input | 100 ---------------------------------------------------------------------------------------------------- 09/input2 | 5 ----- 10/a.py | 30 ------------------------------ 10/b.py | 58 ---------------------------------------------------------- 10/input | 90 ------------------------------------------------------------------------------------------ 11/a.py | 77 ----------------------------------------------------------------------------- 11/b.py | 79 ------------------------------------------------------------------------------- 11/example | 10 ---------- 11/input | 10 ---------- 12/a.py | 32 -------------------------------- 12/b.py | 38 -------------------------------------- 12/ex2 | 7 ------- 12/example | 18 ------------------ 12/input | 19 ------------------- 13/a.py | 51 --------------------------------------------------- 13/b.py | 59 ----------------------------------------------------------- 13/example | 21 --------------------- 13/input | 874 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 2021/01/README | 6 ++++++ 2021/01/a.c | 16 ++++++++++++++++ 2021/01/a.py | 12 ++++++++++++ 2021/01/b.c | 26 ++++++++++++++++++++++++++ 2021/01/b.py | 23 +++++++++++++++++++++++ 2021/01/input | 2000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2021/01/sol.scm | 35 +++++++++++++++++++++++++++++++++++ 2021/02/a.c | 24 ++++++++++++++++++++++++ 2021/02/a.py | 18 ++++++++++++++++++ 2021/02/b.c | 26 ++++++++++++++++++++++++++ 2021/02/b.py | 20 ++++++++++++++++++++ 2021/02/input | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2021/02/sol.scm | 41 +++++++++++++++++++++++++++++++++++++++++ 2021/03/a.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2021/03/a.py | 28 ++++++++++++++++++++++++++++ 2021/03/b.py | 33 +++++++++++++++++++++++++++++++++ 2021/03/input | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2021/04/a.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 2021/04/b.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2021/04/common.py | 37 +++++++++++++++++++++++++++++++++++++ 2021/04/input | 601 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2021/05/a.c | 36 ++++++++++++++++++++++++++++++++++++ 2021/05/a.py | 31 +++++++++++++++++++++++++++++++ 2021/05/b.c | 36 ++++++++++++++++++++++++++++++++++++ 2021/05/b.py | 38 ++++++++++++++++++++++++++++++++++++++ 2021/05/input | 500 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2021/06/a.c | 37 +++++++++++++++++++++++++++++++++++++ 2021/06/a.py | 28 ++++++++++++++++++++++++++++ 2021/06/b.c | 39 +++++++++++++++++++++++++++++++++++++++ 2021/06/b.py | 16 ++++++++++++++++ 2021/06/input | 1 + 2021/07/a.py | 22 ++++++++++++++++++++++ 2021/07/b.py | 24 ++++++++++++++++++++++++ 2021/07/input | 1 + 2021/08/a.py | 15 +++++++++++++++ 2021/08/b.py | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2021/08/input | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2021/08/input2 | 309 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2021/09/a.py | 28 ++++++++++++++++++++++++++++ 2021/09/b.py | 40 ++++++++++++++++++++++++++++++++++++++++ 2021/09/input | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2021/09/input2 | 5 +++++ 2021/10/a.py | 30 ++++++++++++++++++++++++++++++ 2021/10/b.py | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2021/10/input | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2021/11/a.py | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2021/11/b.py | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2021/11/example | 10 ++++++++++ 2021/11/input | 10 ++++++++++ 2021/12/a.py | 32 ++++++++++++++++++++++++++++++++ 2021/12/b.py | 38 ++++++++++++++++++++++++++++++++++++++ 2021/12/ex2 | 7 +++++++ 2021/12/example | 18 ++++++++++++++++++ 2021/12/input | 19 +++++++++++++++++++ 2021/13/a.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2021/13/b.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2021/13/example | 21 +++++++++++++++++++++ 2021/13/input | 874 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2021/Makefile | 36 ++++++++++++++++++++++++++++++++++++ 2021/README.md | 22 ++++++++++++++++++++++ LICENSE | 2 +- Makefile | 36 ------------------------------------ README.md | 24 +++--------------------- 121 files changed, 8239 insertions(+), 8235 deletions(-) delete mode 100644 01/README delete mode 100644 01/a.c delete mode 100755 01/a.py delete mode 100644 01/b.c delete mode 100755 01/b.py delete mode 100644 01/input delete mode 100644 01/sol.scm delete mode 100644 02/a.c delete mode 100755 02/a.py delete mode 100644 02/b.c delete mode 100755 02/b.py delete mode 100644 02/input delete mode 100644 02/sol.scm delete mode 100644 03/a.c delete mode 100755 03/a.py delete mode 100755 03/b.py delete mode 100644 03/input delete mode 100755 04/a.py delete mode 100755 04/b.py delete mode 100644 04/common.py delete mode 100644 04/input delete mode 100644 05/a.c delete mode 100755 05/a.py delete mode 100644 05/b.c delete mode 100755 05/b.py delete mode 100644 05/input delete mode 100644 06/a.c delete mode 100755 06/a.py delete mode 100644 06/b.c delete mode 100755 06/b.py delete mode 100644 06/input delete mode 100755 07/a.py delete mode 100755 07/b.py delete mode 100644 07/input delete mode 100755 08/a.py delete mode 100755 08/b.py delete mode 100644 08/input delete mode 100644 08/input2 delete mode 100755 09/a.py delete mode 100755 09/b.py delete mode 100644 09/input delete mode 100644 09/input2 delete mode 100755 10/a.py delete mode 100755 10/b.py delete mode 100644 10/input delete mode 100755 11/a.py delete mode 100755 11/b.py delete mode 100644 11/example delete mode 100644 11/input delete mode 100755 12/a.py delete mode 100755 12/b.py delete mode 100644 12/ex2 delete mode 100644 12/example delete mode 100644 12/input delete mode 100755 13/a.py delete mode 100755 13/b.py delete mode 100644 13/example delete mode 100644 13/input create mode 100644 2021/01/README create mode 100644 2021/01/a.c create mode 100755 2021/01/a.py create mode 100644 2021/01/b.c create mode 100755 2021/01/b.py create mode 100644 2021/01/input create mode 100644 2021/01/sol.scm create mode 100644 2021/02/a.c create mode 100755 2021/02/a.py create mode 100644 2021/02/b.c create mode 100755 2021/02/b.py create mode 100644 2021/02/input create mode 100644 2021/02/sol.scm create mode 100644 2021/03/a.c create mode 100755 2021/03/a.py create mode 100755 2021/03/b.py create mode 100644 2021/03/input create mode 100755 2021/04/a.py create mode 100755 2021/04/b.py create mode 100644 2021/04/common.py create mode 100644 2021/04/input create mode 100644 2021/05/a.c create mode 100755 2021/05/a.py create mode 100644 2021/05/b.c create mode 100755 2021/05/b.py create mode 100644 2021/05/input create mode 100644 2021/06/a.c create mode 100755 2021/06/a.py create mode 100644 2021/06/b.c create mode 100755 2021/06/b.py create mode 100644 2021/06/input create mode 100755 2021/07/a.py create mode 100755 2021/07/b.py create mode 100644 2021/07/input create mode 100755 2021/08/a.py create mode 100755 2021/08/b.py create mode 100644 2021/08/input create mode 100644 2021/08/input2 create mode 100755 2021/09/a.py create mode 100755 2021/09/b.py create mode 100644 2021/09/input create mode 100644 2021/09/input2 create mode 100755 2021/10/a.py create mode 100755 2021/10/b.py create mode 100644 2021/10/input create mode 100755 2021/11/a.py create mode 100755 2021/11/b.py create mode 100644 2021/11/example create mode 100644 2021/11/input create mode 100755 2021/12/a.py create mode 100755 2021/12/b.py create mode 100644 2021/12/ex2 create mode 100644 2021/12/example create mode 100644 2021/12/input create mode 100755 2021/13/a.py create mode 100755 2021/13/b.py create mode 100644 2021/13/example create mode 100644 2021/13/input create mode 100644 2021/Makefile create mode 100644 2021/README.md delete mode 100644 Makefile diff --git a/01/README b/01/README deleted file mode 100644 index 7f1ead0..0000000 --- a/01/README +++ /dev/null @@ -1,6 +0,0 @@ -For both languages, pass the file to stdin: - -make -C c -./c/a < input - -./py/a.py < input diff --git a/01/a.c b/01/a.c deleted file mode 100644 index f593356..0000000 --- a/01/a.c +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include - -int main(void) { - int count = 0; - int curr; - int prev = 0; - while(scanf("%d\n", &curr) != EOF) { - if (prev && curr > prev) { - count++; - } - prev = curr; - } - printf("%d\n", count); - return 0; -} diff --git a/01/a.py b/01/a.py deleted file mode 100755 index f0e9883..0000000 --- a/01/a.py +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python3 -import sys - -prev = None -count = 0 -for l in sys.stdin: - curr = int(l.strip()) - if prev and curr > prev: - count += 1 - prev = curr - -print(count) diff --git a/01/b.c b/01/b.c deleted file mode 100644 index 93f6153..0000000 --- a/01/b.c +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include - -int mem[] = {0, 0, 0}; -int sum() { - return mem[0] + mem[1] + mem[2]; -} - -int main(void) { - int count = 0; - int curr; - int prev = 0; - int i = 0; - while(scanf("%d\n", &curr) != EOF) { - mem[i++ % 3] = curr; - if (i > 3) { - if (prev && sum() > prev) { - count++; - } - prev = sum(); - } - i++; - } - printf("%d\n", count); - return 0; -} diff --git a/01/b.py b/01/b.py deleted file mode 100755 index 45dfac3..0000000 --- a/01/b.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python3 -import sys - -prev = None -mem = [] -count = 0 -i = 0 -for l in sys.stdin: - curr = int(l.strip()) - - if len(mem) < 3: - mem.append(curr) - continue - else: - mem[i % 3] = curr - i += 1 - - s = sum(mem) - if prev and s > prev: - count += 1 - prev = s - -print(count) diff --git a/01/input b/01/input deleted file mode 100644 index b6a7329..0000000 --- a/01/input +++ /dev/null @@ -1,2000 +0,0 @@ -157 -148 -149 -146 -144 -145 -162 -163 -164 -166 -173 -186 -183 -164 -168 -175 -176 -172 -170 -183 -196 -204 -216 -224 -225 -228 -231 -215 -218 -225 -229 -230 -232 -238 -237 -240 -261 -263 -262 -257 -270 -278 -279 -280 -284 -299 -300 -311 -312 -311 -312 -326 -327 -326 -336 -338 -344 -350 -351 -352 -354 -373 -376 -382 -383 -381 -390 -396 -400 -408 -421 -422 -423 -428 -431 -432 -444 -437 -438 -458 -427 -413 -423 -425 -426 -424 -428 -443 -446 -459 -465 -478 -482 -485 -498 -522 -528 -535 -536 -528 -507 -525 -526 -528 -523 -527 -524 -525 -532 -534 -552 -551 -561 -563 -562 -568 -575 -577 -587 -588 -593 -594 -597 -600 -605 -607 -615 -611 -617 -618 -622 -644 -646 -634 -631 -635 -633 -636 -641 -643 -644 -645 -641 -659 -661 -659 -660 -683 -695 -696 -704 -705 -719 -720 -707 -722 -723 -727 -728 -730 -731 -740 -744 -733 -718 -711 -712 -720 -719 -729 -739 -748 -754 -759 -781 -797 -796 -802 -811 -812 -819 -815 -826 -828 -841 -844 -849 -888 -893 -895 -900 -901 -904 -905 -922 -921 -922 -938 -963 -971 -973 -983 -991 -994 -1001 -1023 -1027 -1035 -1059 -1060 -1089 -1098 -1124 -1125 -1128 -1122 -1123 -1113 -1115 -1113 -1141 -1146 -1150 -1151 -1152 -1153 -1143 -1144 -1146 -1162 -1154 -1153 -1154 -1165 -1169 -1168 -1171 -1178 -1179 -1180 -1172 -1176 -1186 -1188 -1189 -1188 -1187 -1192 -1190 -1189 -1184 -1194 -1195 -1200 -1194 -1206 -1207 -1216 -1218 -1186 -1187 -1184 -1187 -1190 -1214 -1239 -1240 -1250 -1249 -1277 -1278 -1279 -1314 -1316 -1321 -1345 -1344 -1351 -1364 -1367 -1368 -1370 -1373 -1365 -1361 -1355 -1354 -1365 -1360 -1358 -1356 -1357 -1363 -1364 -1373 -1377 -1387 -1381 -1392 -1396 -1397 -1399 -1406 -1410 -1429 -1430 -1431 -1437 -1443 -1448 -1449 -1465 -1466 -1461 -1462 -1464 -1471 -1488 -1489 -1490 -1500 -1502 -1528 -1549 -1551 -1552 -1551 -1543 -1544 -1543 -1546 -1547 -1551 -1555 -1563 -1539 -1525 -1524 -1523 -1548 -1513 -1522 -1508 -1507 -1515 -1498 -1505 -1504 -1505 -1506 -1507 -1510 -1516 -1520 -1540 -1547 -1548 -1547 -1522 -1523 -1533 -1561 -1588 -1589 -1591 -1592 -1594 -1596 -1608 -1624 -1628 -1638 -1639 -1641 -1625 -1627 -1629 -1648 -1653 -1678 -1679 -1699 -1703 -1697 -1700 -1698 -1699 -1715 -1714 -1716 -1717 -1720 -1722 -1721 -1722 -1716 -1720 -1742 -1765 -1767 -1757 -1756 -1755 -1761 -1784 -1785 -1789 -1798 -1806 -1809 -1821 -1822 -1831 -1826 -1818 -1817 -1814 -1815 -1818 -1819 -1820 -1827 -1830 -1831 -1832 -1840 -1841 -1842 -1848 -1849 -1850 -1851 -1861 -1863 -1860 -1861 -1855 -1863 -1862 -1864 -1865 -1887 -1902 -1925 -1939 -1945 -1944 -1943 -1947 -1964 -1986 -1987 -1986 -1989 -1979 -1984 -1986 -1994 -1996 -2001 -2002 -2005 -2009 -2022 -2024 -2025 -2029 -2013 -2014 -2017 -2018 -2017 -2019 -2020 -2009 -2007 -2006 -1982 -1984 -1986 -1991 -1994 -1982 -1991 -1989 -1995 -1996 -1997 -1998 -1997 -2004 -2005 -2030 -2062 -2064 -2076 -2077 -2079 -2080 -2084 -2103 -2104 -2110 -2104 -2105 -2106 -2118 -2124 -2127 -2125 -2121 -2127 -2133 -2135 -2141 -2139 -2136 -2138 -2146 -2140 -2141 -2156 -2172 -2181 -2170 -2173 -2195 -2194 -2199 -2203 -2228 -2230 -2234 -2204 -2212 -2214 -2200 -2201 -2200 -2197 -2201 -2204 -2230 -2240 -2242 -2255 -2263 -2271 -2273 -2274 -2273 -2277 -2278 -2285 -2286 -2297 -2298 -2297 -2310 -2313 -2309 -2311 -2314 -2322 -2320 -2316 -2317 -2339 -2338 -2350 -2378 -2379 -2387 -2391 -2390 -2391 -2396 -2398 -2406 -2425 -2433 -2430 -2421 -2422 -2440 -2449 -2445 -2466 -2479 -2477 -2479 -2485 -2481 -2490 -2491 -2492 -2496 -2508 -2505 -2487 -2492 -2493 -2482 -2499 -2515 -2516 -2543 -2574 -2575 -2577 -2578 -2569 -2556 -2554 -2557 -2559 -2562 -2571 -2595 -2596 -2598 -2599 -2603 -2602 -2615 -2614 -2610 -2623 -2632 -2626 -2642 -2643 -2675 -2681 -2689 -2706 -2708 -2713 -2714 -2703 -2691 -2692 -2693 -2700 -2710 -2711 -2712 -2711 -2712 -2716 -2673 -2674 -2694 -2715 -2723 -2736 -2759 -2768 -2773 -2767 -2757 -2752 -2749 -2752 -2758 -2753 -2752 -2754 -2760 -2791 -2792 -2803 -2804 -2797 -2800 -2797 -2807 -2811 -2814 -2816 -2819 -2837 -2838 -2843 -2841 -2848 -2853 -2859 -2868 -2854 -2864 -2845 -2848 -2831 -2830 -2829 -2840 -2838 -2831 -2836 -2856 -2854 -2870 -2863 -2865 -2866 -2867 -2895 -2892 -2893 -2911 -2909 -2918 -2923 -2924 -2893 -2888 -2892 -2893 -2898 -2893 -2920 -2930 -2931 -2930 -2926 -2933 -2939 -2957 -2964 -2968 -2969 -2971 -2985 -2986 -2990 -2988 -2977 -2971 -2970 -2978 -2964 -2997 -3007 -3015 -3013 -3015 -2998 -3000 -3024 -3034 -3045 -3067 -3073 -3074 -3075 -3076 -3084 -3091 -3089 -3088 -3095 -3082 -3085 -3086 -3082 -3080 -3096 -3110 -3113 -3114 -3117 -3120 -3125 -3128 -3129 -3131 -3130 -3136 -3130 -3131 -3138 -3141 -3147 -3153 -3152 -3161 -3162 -3180 -3183 -3197 -3203 -3205 -3195 -3202 -3209 -3216 -3217 -3230 -3235 -3238 -3245 -3248 -3269 -3262 -3266 -3267 -3268 -3272 -3265 -3264 -3268 -3275 -3276 -3283 -3277 -3276 -3277 -3278 -3298 -3311 -3314 -3318 -3327 -3330 -3333 -3349 -3353 -3354 -3347 -3357 -3359 -3361 -3390 -3389 -3398 -3411 -3418 -3409 -3422 -3423 -3425 -3426 -3442 -3444 -3457 -3458 -3459 -3471 -3454 -3455 -3457 -3469 -3470 -3496 -3495 -3492 -3509 -3512 -3511 -3514 -3513 -3516 -3519 -3522 -3533 -3539 -3541 -3537 -3547 -3548 -3552 -3554 -3556 -3559 -3560 -3568 -3571 -3580 -3582 -3601 -3602 -3625 -3623 -3625 -3633 -3640 -3655 -3657 -3659 -3660 -3659 -3665 -3666 -3672 -3698 -3707 -3706 -3712 -3713 -3728 -3727 -3724 -3747 -3737 -3733 -3739 -3736 -3757 -3758 -3766 -3768 -3771 -3776 -3785 -3782 -3790 -3792 -3800 -3779 -3781 -3782 -3816 -3824 -3832 -3831 -3842 -3848 -3847 -3848 -3851 -3840 -3848 -3849 -3854 -3871 -3870 -3872 -3877 -3885 -3899 -3908 -3913 -3914 -3910 -3909 -3910 -3926 -3938 -3951 -3952 -3949 -3978 -3980 -3981 -3984 -3980 -3981 -4000 -4001 -4006 -4007 -4024 -4039 -4040 -4048 -4036 -4041 -4040 -4052 -4065 -4068 -4043 -4048 -4037 -4043 -4046 -4048 -4049 -4056 -4059 -4063 -4068 -4080 -4077 -4075 -4076 -4069 -4038 -4037 -4040 -4027 -4028 -4034 -4053 -4057 -4058 -4061 -4059 -4064 -4065 -4069 -4071 -4073 -4075 -4077 -4082 -4096 -4093 -4104 -4112 -4105 -4106 -4109 -4093 -4100 -4108 -4109 -4134 -4135 -4165 -4146 -4152 -4162 -4171 -4173 -4181 -4184 -4185 -4189 -4192 -4196 -4194 -4209 -4221 -4222 -4200 -4217 -4216 -4217 -4216 -4221 -4231 -4227 -4230 -4227 -4240 -4241 -4242 -4222 -4243 -4248 -4245 -4236 -4237 -4256 -4261 -4248 -4250 -4254 -4255 -4258 -4261 -4262 -4266 -4274 -4290 -4291 -4290 -4312 -4323 -4336 -4337 -4333 -4328 -4330 -4293 -4297 -4309 -4327 -4328 -4356 -4358 -4332 -4346 -4347 -4370 -4379 -4382 -4391 -4400 -4398 -4406 -4417 -4422 -4420 -4421 -4426 -4424 -4420 -4421 -4422 -4401 -4402 -4428 -4437 -4444 -4448 -4451 -4452 -4451 -4454 -4463 -4468 -4467 -4476 -4473 -4477 -4478 -4482 -4514 -4515 -4556 -4559 -4560 -4559 -4561 -4563 -4564 -4562 -4568 -4577 -4589 -4590 -4611 -4599 -4607 -4595 -4596 -4583 -4597 -4595 -4601 -4602 -4607 -4608 -4609 -4633 -4636 -4647 -4654 -4655 -4622 -4623 -4625 -4651 -4653 -4654 -4657 -4661 -4670 -4677 -4678 -4679 -4680 -4678 -4679 -4682 -4680 -4678 -4676 -4678 -4680 -4678 -4683 -4689 -4705 -4716 -4725 -4723 -4728 -4729 -4730 -4746 -4757 -4755 -4762 -4791 -4785 -4787 -4792 -4793 -4790 -4793 -4794 -4807 -4813 -4804 -4826 -4827 -4840 -4878 -4880 -4883 -4884 -4875 -4887 -4889 -4922 -4929 -4928 -4933 -4934 -4945 -4943 -4944 -4945 -4947 -4944 -4957 -4955 -4956 -4944 -4946 -4954 -4961 -4967 -4981 -4971 -4980 -4981 -4989 -4991 -5000 -5017 -5016 -5017 -5016 -5018 -5032 -5033 -5038 -5039 -5041 -5043 -5059 -5068 -5070 -5074 -5075 -5076 -5088 -5099 -5100 -5105 -5122 -5123 -5124 -5126 -5118 -5116 -5121 -5115 -5125 -5128 -5133 -5143 -5142 -5143 -5150 -5145 -5146 -5148 -5154 -5155 -5166 -5164 -5180 -5173 -5168 -5167 -5169 -5175 -5176 -5204 -5203 -5204 -5206 -5210 -5204 -5205 -5206 -5207 -5205 -5226 -5233 -5235 -5239 -5241 -5242 -5261 -5266 -5260 -5268 -5272 -5278 -5280 -5281 -5290 -5295 -5296 -5306 -5319 -5344 -5362 -5364 -5377 -5381 -5385 -5368 -5391 -5392 -5381 -5397 -5398 -5405 -5385 -5395 -5396 -5401 -5407 -5408 -5402 -5400 -5401 -5404 -5414 -5415 -5418 -5427 -5413 -5408 -5419 -5440 -5445 -5444 -5439 -5443 -5448 -5449 -5448 -5475 -5477 -5481 -5474 -5476 -5480 -5497 -5494 -5496 -5505 -5506 -5509 -5517 -5518 -5521 -5510 -5511 -5513 -5514 -5513 -5528 -5536 -5523 -5525 -5526 -5524 -5525 -5527 -5528 -5534 -5538 -5554 -5560 -5563 -5564 -5571 -5586 -5590 -5596 -5597 -5603 -5624 -5599 -5609 -5599 -5618 -5620 -5608 -5623 -5627 -5629 -5630 -5632 -5640 -5637 -5638 -5643 -5653 -5650 -5649 -5658 -5656 -5654 -5673 -5672 -5673 -5675 -5676 -5677 -5672 -5682 -5681 -5680 -5671 -5674 -5679 -5685 -5687 -5691 -5694 -5718 -5720 -5721 -5719 -5716 -5717 -5719 -5711 -5712 -5713 -5712 -5711 -5712 -5711 -5704 -5709 -5710 -5723 -5720 -5719 -5720 -5725 -5724 -5728 -5729 -5747 -5745 -5747 -5748 -5752 -5749 -5763 -5766 -5767 -5775 -5782 -5784 -5785 -5787 -5788 -5787 -5792 -5787 -5788 -5787 -5789 -5792 -5793 -5820 -5827 -5843 -5844 -5864 -5875 -5877 -5890 -5895 -5896 -5909 -5932 -5944 -5951 -5960 -5983 -5996 -6003 -6028 -6043 -6046 -6038 -6053 -6056 -6069 -6063 -6059 -6064 -6065 -6077 -6075 -6074 -6075 -6091 -6108 -6109 -6103 -6100 -6108 -6130 -6131 -6158 -6162 -6176 -6166 -6168 -6170 -6181 -6180 -6179 -6180 -6183 -6184 -6187 -6186 -6185 -6182 -6194 -6190 -6193 -6222 -6241 -6243 -6233 -6222 -6248 -6250 -6251 -6265 -6269 -6270 -6272 -6285 -6284 -6280 -6273 -6286 -6287 -6292 -6307 -6311 -6317 -6316 -6317 -6316 -6317 -6314 -6316 -6291 -6293 -6323 -6327 -6328 -6327 -6322 -6321 -6330 -6332 -6335 -6333 -6351 -6349 -6346 -6347 -6346 -6364 -6374 -6383 -6395 -6398 -6406 -6418 -6419 -6418 -6413 -6414 -6415 -6416 -6399 -6400 -6401 -6399 -6382 -6379 -6380 -6386 -6387 -6373 -6372 -6396 -6397 -6415 -6423 -6424 -6433 -6438 -6445 -6446 -6447 -6448 -6450 -6446 -6464 -6447 -6452 -6464 -6466 -6477 -6491 -6489 -6490 -6503 -6528 -6562 -6564 -6581 -6579 -6580 -6594 -6595 -6609 -6619 -6621 -6641 -6648 -6693 -6686 -6693 -6677 -6700 -6706 -6707 -6710 -6735 -6745 -6746 -6747 -6748 -6750 -6753 -6755 -6756 -6759 -6760 -6771 -6770 -6775 -6785 -6788 -6793 -6796 -6797 -6806 -6814 -6821 -6822 -6823 -6825 -6827 -6841 -6846 -6841 -6834 -6836 -6837 -6815 -6824 -6830 -6837 -6841 -6834 -6835 -6836 -6826 -6841 -6835 -6795 -6794 -6795 -6793 -6794 -6795 -6804 -6816 -6817 -6819 -6830 -6835 -6840 -6845 -6853 -6897 -6896 -6894 -6896 -6899 -6897 -6903 -6886 -6889 -6890 -6891 -6890 -6891 -6894 -6888 -6905 -6906 -6916 -6917 -6921 -6920 -6924 -6925 -6939 -6958 -6968 -6969 -6974 -6977 -6975 -6971 -6963 -6964 -6974 -6975 -6976 -6977 -6971 -6969 -6977 -7003 -6985 -6993 -6997 -6999 -7000 -7001 -6999 -7000 -7004 -7003 -7017 -7033 -7053 -7058 -7066 -7067 -7064 -7066 -7062 -7063 -7088 -7093 -7096 -7106 -7110 -7116 -7124 -7125 -7128 -7150 -7152 -7154 -7159 -7161 -7162 -7144 -7176 -7183 -7185 -7172 -7208 -7207 -7222 -7225 -7226 -7222 -7210 -7211 -7212 -7238 -7231 -7221 -7236 -7237 -7234 -7235 -7253 -7249 -7253 -7263 -7260 -7259 -7260 -7261 -7263 -7241 -7243 -7257 -7260 -7261 -7275 -7258 -7263 -7274 -7279 -7280 -7289 -7307 -7289 -7301 -7307 -7309 -7317 -7337 -7360 -7364 -7375 -7373 -7377 -7403 -7415 -7438 -7439 -7438 -7442 -7445 -7446 -7450 -7452 -7453 -7460 -7468 -7472 -7478 -7474 -7487 -7486 -7487 -7488 -7492 -7510 -7509 -7506 -7507 -7512 -7516 -7519 -7514 -7525 -7545 -7553 -7554 -7560 -7561 -7560 -7561 -7564 -7571 -7601 -7605 -7628 -7629 -7642 -7651 -7682 -7684 -7685 -7698 -7699 -7713 -7734 -7753 -7755 -7760 -7767 -7775 -7776 -7777 -7760 -7763 -7770 -7758 -7769 -7765 -7772 -7777 -7774 -7780 -7781 -7785 -7783 -7800 -7801 -7799 -7804 -7805 -7814 -7815 -7801 -7802 -7803 -7806 -7808 -7810 -7816 -7821 -7796 -7795 -7793 -7792 -7769 -7770 -7777 -7771 -7772 -7773 -7775 -7776 -7778 -7766 -7767 -7768 -7774 -7775 -7780 -7781 -7782 -7788 -7791 -7796 -7798 -7813 -7814 -7817 -7824 -7825 -7826 -7828 -7843 -7867 -7870 -7872 -7875 -7877 -7878 -7888 -7893 -7902 -7904 -7911 -7914 -7915 -7919 -7915 -7945 -7946 -7952 -7954 -7931 -7935 -7936 -7900 -7915 -7920 -7911 -7914 -7925 -7937 -7942 -7974 -7976 -7989 -7993 -8006 -8007 -8010 -8016 -8020 -8026 diff --git a/01/sol.scm b/01/sol.scm deleted file mode 100644 index 94100b7..0000000 --- a/01/sol.scm +++ /dev/null @@ -1,35 +0,0 @@ -(import (chicken io)) - -(define (read-num port) - (let ((line (read-line port))) - (if (eof-object? line) - #f - (string->number line)))) - -(define (part-1 port) - (let loop ((total 0) (prev #f) (num (read-num port))) - (define (next) - (loop total num (read-num port))) - (cond ((not num) total) - ((not prev) (next)) - ((< prev num) (loop (add1 total) num (read-num port))) - (else (next))))) - -(define (winsum vect) - (apply + (vector->list vect))) - -(define (part-2 port) - (let loop ((i 0) (total 0) (window #(0 0 0)) (num (read-num port))) - (if (not num) - total - (let ((old-val (winsum window))) - (vector-set! window (modulo i 3) num) - (if (and (> i 2) (< old-val (winsum window))) - (loop (add1 i) (add1 total) window (read-num port)) - (loop (add1 i) total window (read-num port))))))) - -(call-with-input-file "input" - (lambda (p) (print (part-1 p)))) - -(call-with-input-file "input" - (lambda (p) (print (part-2 p)))) diff --git a/02/a.c b/02/a.c deleted file mode 100644 index dcab638..0000000 --- a/02/a.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include - -int main(void) { - int depth = 0; - int pos = 0; - int val; - char comm[256]; - while(scanf("%255s %d\n", comm, &val) != EOF) { - if (!strcmp(comm, "forward")) { - pos += val; - } else if (!strcmp(comm, "up")) { - depth -= val; - } else if (!strcmp(comm, "down")) { - depth += val; - } else { - fprintf(stderr, "bad command: %s\n", comm); - exit(1); - } - } - printf("%d\n", pos * depth); - return 0; -} diff --git a/02/a.py b/02/a.py deleted file mode 100755 index 274ddfe..0000000 --- a/02/a.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python3 -import sys - -depth = 0 -horiz = 0 - -for l in sys.stdin: - comm, val = l.split() - if comm == "down": - depth += int(val) - elif comm == "up": - depth -= int(val) - elif comm == "forward": - horiz += int(val) - else: - raise Exception(f"bad comm: {comm}") - -print(horiz * depth) diff --git a/02/b.c b/02/b.c deleted file mode 100644 index 3f3faee..0000000 --- a/02/b.c +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include -#include - -int main(void) { - int depth = 0; - int pos = 0; - int aim = 0; - int val; - char comm[256]; - while(scanf("%255s %d\n", comm, &val) != EOF) { - if (!strcmp(comm, "forward")) { - pos += val; - depth += val * aim; - } else if (!strcmp(comm, "up")) { - aim -= val; - } else if (!strcmp(comm, "down")) { - aim += val; - } else { - fprintf(stderr, "bad command: %s\n", comm); - exit(1); - } - } - printf("%d\n", pos * depth); - return 0; -} diff --git a/02/b.py b/02/b.py deleted file mode 100755 index 27ab67e..0000000 --- a/02/b.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -import sys - -depth = 0 -horiz = 0 -aim = 0 - -for l in sys.stdin: - comm, val = l.split() - if comm == "down": - aim += int(val) - elif comm == "up": - aim -= int(val) - elif comm == "forward": - horiz += int(val) - depth += aim * int(val) - else: - raise Exception(f"bad comm: {comm}") - -print(horiz * depth) diff --git a/02/input b/02/input deleted file mode 100644 index 26e4fc2..0000000 --- a/02/input +++ /dev/null @@ -1,1000 +0,0 @@ -forward 4 -down 7 -down 4 -forward 2 -down 4 -down 9 -down 1 -forward 1 -down 4 -up 5 -forward 5 -down 3 -forward 5 -forward 6 -down 5 -down 3 -forward 8 -up 7 -forward 1 -forward 5 -forward 7 -up 2 -up 7 -down 1 -down 6 -forward 7 -forward 6 -down 7 -up 9 -down 8 -down 3 -down 1 -down 4 -down 3 -forward 7 -down 1 -forward 6 -down 3 -forward 3 -down 6 -forward 5 -down 7 -up 5 -forward 7 -forward 9 -up 1 -forward 5 -down 5 -down 2 -forward 1 -up 7 -down 8 -down 2 -forward 8 -forward 1 -up 1 -up 5 -forward 9 -up 9 -down 5 -down 5 -forward 6 -forward 1 -down 1 -down 3 -up 6 -up 9 -down 6 -down 1 -forward 1 -down 8 -down 3 -down 8 -up 6 -forward 2 -up 8 -down 2 -down 6 -forward 1 -down 2 -down 1 -down 5 -down 8 -forward 8 -down 8 -down 2 -up 1 -up 3 -forward 1 -down 6 -up 5 -forward 5 -up 7 -forward 3 -forward 3 -down 9 -forward 1 -forward 7 -down 1 -down 1 -down 3 -forward 4 -down 4 -forward 2 -up 8 -forward 2 -down 4 -down 2 -up 1 -forward 6 -forward 6 -down 9 -forward 5 -down 3 -forward 5 -down 6 -down 9 -forward 9 -up 6 -down 8 -up 5 -up 2 -forward 5 -down 4 -forward 8 -up 1 -forward 2 -down 9 -down 4 -up 7 -down 1 -down 6 -down 7 -down 7 -down 2 -down 2 -up 7 -down 1 -up 7 -up 4 -forward 9 -down 6 -up 3 -down 5 -forward 8 -up 4 -forward 5 -forward 8 -forward 4 -forward 7 -forward 2 -down 3 -up 4 -forward 7 -forward 3 -down 7 -up 4 -forward 8 -forward 9 -forward 9 -up 6 -up 5 -forward 7 -down 7 -up 5 -down 9 -down 8 -forward 5 -forward 2 -down 1 -down 2 -down 9 -up 5 -down 3 -down 8 -up 6 -forward 9 -down 9 -up 3 -up 9 -forward 3 -forward 9 -down 5 -up 3 -down 6 -forward 5 -down 6 -down 9 -forward 3 -down 7 -down 5 -down 9 -forward 8 -down 8 -forward 8 -forward 2 -up 6 -down 9 -down 7 -down 4 -down 2 -down 9 -forward 7 -up 1 -forward 6 -forward 7 -down 3 -down 5 -down 3 -forward 4 -down 9 -forward 2 -down 1 -forward 4 -up 9 -down 8 -down 9 -forward 5 -up 2 -down 7 -down 2 -down 7 -forward 8 -up 8 -forward 9 -up 8 -down 3 -down 8 -forward 2 -up 7 -forward 4 -up 8 -forward 6 -forward 6 -forward 4 -forward 3 -down 4 -up 7 -down 8 -forward 1 -forward 9 -forward 8 -forward 8 -down 6 -down 6 -down 4 -down 8 -forward 9 -down 8 -down 4 -forward 2 -forward 7 -down 4 -up 1 -down 4 -down 5 -up 5 -up 9 -down 5 -up 5 -forward 2 -down 8 -forward 7 -forward 2 -up 4 -forward 8 -up 7 -down 5 -forward 5 -down 5 -down 6 -down 7 -forward 1 -down 8 -up 8 -up 9 -up 6 -forward 2 -forward 7 -forward 4 -down 6 -up 4 -up 3 -down 3 -forward 7 -up 9 -down 9 -up 5 -forward 1 -up 7 -down 7 -down 7 -up 8 -down 3 -forward 6 -down 6 -down 7 -down 2 -forward 5 -up 8 -up 5 -up 1 -down 5 -forward 9 -forward 9 -forward 2 -forward 6 -up 8 -forward 8 -down 1 -forward 6 -up 7 -up 3 -forward 3 -up 5 -down 8 -forward 2 -down 5 -down 5 -forward 8 -forward 8 -forward 6 -up 7 -up 1 -forward 1 -down 7 -down 1 -up 9 -forward 7 -up 6 -down 2 -down 5 -forward 1 -down 1 -up 1 -forward 7 -forward 7 -forward 1 -up 2 -forward 2 -down 9 -down 8 -forward 9 -forward 8 -up 9 -down 1 -down 3 -up 1 -down 3 -up 9 -down 7 -up 6 -down 1 -down 2 -down 2 -down 4 -forward 4 -forward 3 -down 7 -forward 9 -forward 1 -down 2 -down 2 -down 4 -down 7 -up 7 -forward 6 -forward 2 -down 6 -down 3 -down 3 -down 8 -up 8 -forward 6 -down 8 -down 3 -forward 7 -down 4 -down 4 -up 1 -up 8 -forward 5 -forward 6 -down 8 -down 9 -up 7 -forward 2 -forward 4 -down 4 -forward 6 -forward 5 -down 4 -up 5 -down 5 -forward 1 -down 2 -up 9 -forward 9 -forward 6 -forward 8 -down 2 -down 9 -up 1 -forward 6 -down 3 -forward 6 -forward 7 -down 9 -forward 1 -forward 1 -forward 5 -up 5 -up 6 -forward 8 -forward 6 -forward 6 -forward 8 -down 6 -down 8 -forward 5 -forward 7 -forward 3 -forward 3 -up 5 -forward 8 -up 3 -forward 6 -forward 4 -forward 3 -up 8 -down 1 -down 3 -down 7 -up 8 -forward 5 -down 9 -up 7 -down 2 -down 4 -down 5 -down 2 -up 3 -down 4 -down 4 -forward 4 -forward 6 -up 4 -forward 5 -forward 3 -up 2 -up 3 -down 4 -down 7 -forward 7 -forward 2 -down 2 -forward 5 -up 4 -forward 2 -down 8 -up 5 -up 6 -forward 2 -forward 3 -up 3 -down 2 -forward 7 -down 6 -forward 3 -forward 6 -up 9 -forward 7 -up 1 -forward 1 -forward 2 -down 3 -forward 9 -down 1 -up 5 -up 7 -up 8 -down 5 -up 4 -down 9 -forward 4 -up 8 -forward 3 -forward 7 -down 7 -down 9 -down 5 -up 4 -down 2 -up 5 -down 4 -forward 3 -down 7 -up 5 -forward 9 -forward 9 -forward 7 -up 5 -forward 7 -up 3 -forward 8 -down 1 -down 5 -up 5 -forward 4 -forward 9 -forward 9 -up 5 -down 9 -up 7 -up 3 -forward 5 -down 4 -down 7 -forward 9 -down 9 -up 3 -forward 4 -forward 7 -down 9 -forward 2 -down 2 -forward 1 -down 2 -up 7 -down 6 -forward 9 -forward 1 -down 5 -forward 9 -forward 7 -up 4 -forward 9 -forward 7 -up 4 -down 1 -down 3 -down 3 -down 1 -down 9 -forward 3 -forward 5 -forward 2 -down 1 -forward 9 -down 6 -up 6 -down 7 -down 1 -down 1 -up 1 -up 8 -down 6 -down 3 -down 9 -forward 3 -forward 9 -down 4 -forward 6 -forward 7 -down 3 -forward 5 -up 8 -up 6 -forward 3 -forward 2 -down 6 -up 7 -forward 3 -forward 1 -down 8 -down 1 -forward 1 -forward 2 -up 7 -down 3 -forward 9 -forward 6 -up 8 -forward 3 -down 3 -down 9 -down 3 -down 6 -down 6 -down 2 -forward 8 -down 3 -forward 2 -up 8 -forward 5 -up 6 -down 7 -down 4 -down 2 -up 9 -down 4 -down 9 -down 4 -down 9 -forward 2 -down 5 -down 5 -forward 7 -up 2 -forward 5 -forward 1 -down 4 -forward 6 -forward 9 -down 1 -down 2 -down 6 -forward 5 -up 9 -up 1 -up 9 -up 4 -down 1 -up 3 -down 5 -forward 4 -forward 3 -forward 1 -down 9 -down 9 -down 6 -forward 4 -forward 4 -forward 1 -down 9 -down 8 -down 7 -forward 2 -forward 7 -forward 1 -down 7 -forward 8 -forward 7 -up 4 -down 4 -forward 8 -forward 6 -down 6 -forward 9 -down 2 -forward 7 -forward 1 -down 5 -down 5 -down 3 -down 7 -forward 9 -down 2 -forward 3 -forward 6 -up 4 -up 9 -forward 6 -up 8 -up 2 -forward 9 -forward 3 -forward 9 -down 4 -down 8 -down 1 -down 1 -forward 4 -up 3 -forward 1 -forward 5 -down 5 -down 6 -down 7 -forward 5 -down 3 -up 9 -forward 5 -down 4 -up 9 -forward 1 -down 3 -down 5 -forward 2 -down 7 -up 7 -down 2 -forward 2 -down 2 -down 4 -down 3 -forward 6 -down 7 -down 2 -down 1 -forward 7 -forward 9 -forward 8 -up 8 -forward 5 -down 8 -forward 9 -forward 9 -up 5 -forward 9 -up 8 -up 6 -up 5 -up 3 -down 2 -down 8 -down 4 -up 3 -down 4 -up 8 -down 3 -up 1 -down 4 -down 7 -down 4 -up 7 -down 3 -up 3 -up 8 -forward 3 -down 2 -forward 7 -up 9 -forward 2 -down 1 -down 1 -forward 2 -forward 9 -up 6 -forward 3 -forward 2 -down 1 -down 3 -down 6 -forward 7 -down 4 -forward 2 -down 6 -up 3 -up 5 -forward 6 -up 7 -down 5 -up 5 -forward 5 -down 6 -forward 7 -up 2 -forward 3 -forward 4 -forward 9 -down 4 -down 5 -up 7 -up 1 -down 1 -down 5 -forward 4 -down 2 -down 8 -down 6 -down 3 -down 1 -down 9 -forward 5 -forward 7 -down 5 -forward 7 -down 6 -up 8 -up 9 -down 4 -forward 7 -up 1 -up 5 -down 8 -forward 5 -up 8 -forward 1 -forward 7 -forward 5 -forward 8 -forward 8 -up 1 -down 4 -up 6 -down 1 -down 4 -up 9 -forward 4 -forward 1 -forward 5 -up 7 -forward 5 -forward 7 -up 3 -up 6 -up 3 -forward 4 -down 5 -down 4 -down 2 -down 4 -forward 7 -down 5 -forward 9 -forward 2 -down 3 -up 7 -forward 9 -forward 3 -down 9 -up 8 -forward 1 -forward 3 -up 8 -down 3 -up 9 -down 4 -forward 6 -forward 8 -down 4 -forward 9 -up 1 -forward 3 -forward 1 -up 3 -down 3 -forward 1 -forward 2 -forward 8 -up 3 -down 9 -forward 1 -up 1 -forward 2 -down 4 -forward 7 -up 9 -forward 2 -down 6 -down 8 -up 1 -forward 1 -forward 7 -down 8 -forward 7 -up 9 -up 5 -down 6 -down 2 -down 9 -down 9 -down 7 -down 4 -forward 4 -up 2 -up 8 -forward 5 -down 9 -down 7 -forward 3 -forward 1 -down 3 -down 1 -forward 5 -up 2 -up 9 -up 2 -forward 4 -forward 3 -forward 8 -up 9 -up 6 -up 3 -forward 7 -forward 8 -forward 8 -forward 1 -forward 1 -forward 2 -down 2 -down 7 -forward 4 -up 2 -down 4 -forward 5 -down 3 -forward 1 -down 3 -up 2 -forward 9 -forward 7 -forward 5 -forward 1 -forward 6 -forward 9 -up 3 -down 8 -down 8 -forward 3 -up 4 -up 1 -down 4 -forward 8 -up 9 -down 4 -down 5 -forward 1 -forward 7 -up 2 -down 2 -down 2 -down 1 -up 6 -forward 7 -forward 7 -down 7 -down 8 -forward 1 -forward 8 -down 3 -up 5 -up 9 -down 2 -down 9 -forward 3 -up 8 -up 9 -up 3 -up 3 -forward 9 -up 6 -up 7 -down 6 -down 8 -forward 4 -down 8 -forward 4 -forward 9 -down 9 -forward 4 -up 6 -up 5 -down 2 -forward 6 -down 2 -up 2 -up 4 -forward 4 -forward 6 -down 7 -up 4 -down 8 -forward 1 -down 5 -forward 4 -down 3 -forward 3 -down 5 -forward 7 -down 8 -up 7 -down 7 -forward 1 -forward 6 -up 7 -up 8 -up 2 -forward 1 -forward 1 -down 5 -down 9 -forward 7 -forward 5 -down 7 -up 1 -forward 6 -forward 6 -down 6 -forward 1 -down 1 -down 2 -down 4 -forward 5 -up 7 -up 7 -forward 6 -down 1 -forward 7 diff --git a/02/sol.scm b/02/sol.scm deleted file mode 100644 index c4fb304..0000000 --- a/02/sol.scm +++ /dev/null @@ -1,41 +0,0 @@ -(import (chicken io) - (chicken string)) - -(define (part-1 port) - (let loop ((h 0) (d 0)) - (let ((l (read-line port))) - (if (eof-object? l) - (* h d) - (let* ((parts (string-split l)) - (act (car parts)) - (mag (string->number (cadr parts)))) - (cond ((equal? act "down") - (loop h (+ d mag))) - ((equal? act "up") - (loop h (- d mag))) - ((equal? act "forward") - (loop (+ h mag) d)) - (else (error "Bad action " act)))))))) - -(define (part-2 port) - (let loop ((h 0) (d 0) (a 0)) - (let ((l (read-line port))) - (if (eof-object? l) - (* h d) - (let* ((parts (string-split l)) - (act (car parts)) - (mag (string->number (cadr parts)))) - (cond ((equal? act "down") - (loop h d (+ a mag))) - ((equal? act "up") - (loop h d (- a mag))) - ((equal? act "forward") - (loop (+ h mag) (+ d (* a mag)) a)) - (else (error "Bad action " act)))))))) - - -(call-with-input-file "input" - (lambda (p) (print (part-1 p)))) - -(call-with-input-file "input" - (lambda (p) (print (part-2 p)))) diff --git a/03/a.c b/03/a.c deleted file mode 100644 index b251ca0..0000000 --- a/03/a.c +++ /dev/null @@ -1,55 +0,0 @@ -#include -#include - -#define MAX_WIDTH 32 - -int main(void) { - /* Key takeaway: if think of the input as a matrix, we can - * sum the columns and count the number of entries and know - * that if N entries had X sum, there's X 1's and N-X 0's. - */ - int counts[MAX_WIDTH] = { 0 }; - int c; - int col = 0; - int n = 0; - while ((c = getchar()) != EOF) { - switch (c) { - case '0': - col++; - break; - case '1': - counts[col]++; - col++; - break; - case '\n': - /* reset the column */ - col = 0; - n++; - break; - default: - fprintf(stderr, "bad input"); - exit(1); - break; - } - } - - /* convert counts into a bitmask of 1/0 based on which was max */ - unsigned int gamma = 0; - unsigned int eps = 0; - for (int i = 0; i < MAX_WIDTH; i++) { - if (counts[i] == 0) { - /* assume we see each at least once, so this was the end of width */ - break; - } - /* boost the last value to make room for more! */ - gamma <<= 1; - eps <<= 1; - if (counts[i] > n / 2) { - gamma |= 1; - } else { - eps |= 1; - } - } - printf("%u\n", eps * gamma); - return 0; -} diff --git a/03/a.py b/03/a.py deleted file mode 100755 index 8334139..0000000 --- a/03/a.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python3 -import sys - -# First get the counts of bit by position -counts = [] -first = True -for l in sys.stdin: - i = 0 - for c in l.strip(): - if first: - counts.append([0, 0]) - counts[i][int(c)] += 1 - i += 1 - - first = False - -# Then build up the binary string summaries -gamma = "" -eps = "" -for c in counts: - if c[0] > c[1]: - gamma += "0" - eps += "1" - else: - gamma += "1" - eps += "0" - -print(int(gamma, 2) * int(eps, 2)) diff --git a/03/b.py b/03/b.py deleted file mode 100755 index e8bfdc1..0000000 --- a/03/b.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 -import sys - -def search(nums, maximum): - # idx to consider - i = 0 - while len(nums) > 1: - # count just that digit in the string (rest is garbage) - counts = [0, 0] - for n in nums: - counts[int(n[i])] += 1 - - # filter the list down to most or least common - is_zero = lambda x: x[i] == "0" - is_one = lambda x: x[i] == "1" - if (maximum and counts[0] > counts[1]) or (not maximum and counts[0] <= counts[1]): - nums = list(filter(is_zero, nums)) - else: - nums = list(filter(is_one, nums)) - i+=1 - - return nums[0] - -# We need multiple iterations on this one -- save to mem -if __name__ == '__main__': - nums = [] - for l in sys.stdin: - nums.append(l.strip()) - - oxygen = int(search(nums, maximum=True), 2) - co2 = int(search(nums, maximum=False), 2) - - print(oxygen * co2) diff --git a/03/input b/03/input deleted file mode 100644 index ac22a69..0000000 --- a/03/input +++ /dev/null @@ -1,1000 +0,0 @@ -011001101000 -010101111100 -000000111101 -001001001010 -010011000001 -111111001110 -001011101111 -110011010110 -100011111110 -101110000111 -000011011100 -001111111011 -011101001111 -111001010110 -011100011110 -001011000010 -100010111011 -000101010011 -000001101100 -010001011110 -100010101000 -111101011101 -110000100001 -011011010101 -110101100110 -001101101010 -111010110011 -011111111000 -010001010001 -000001010101 -001001011011 -101111110011 -100011010001 -111010010111 -011010011010 -101111011011 -101010111100 -001111100110 -010100110111 -010110101100 -000111110101 -111110101110 -111010000000 -011111111010 -000101011100 -000001010110 -101000100101 -100001011001 -011101110010 -110111100100 -110011001011 -000010001111 -000100010101 -110111001100 -010001100000 -101111110101 -111000011011 -000100001001 -101101011101 -001001011110 -101100111010 -011011000010 -110010010111 -101001010101 -000000101110 -000011011111 -010001000011 -011011001010 -101101111011 -100010001010 -001001011100 -010011110001 -000001111101 -100001000101 -011101011010 -000010101110 -001010101010 -101010011011 -000111001011 -000011101000 -110100101001 -000111111010 -100111100101 -111010001111 -111100110001 -011111101010 -110101000011 -001111101100 -101000100110 -100101100011 -000011010011 -010101011111 -010000110111 -110011001001 -101011011101 -001011100001 -000001100101 -001001001101 -001101001111 -001110110001 -010110101110 -001100110110 -001000001111 -101101001001 -011111011010 -111111101110 -111001100000 -100101011001 -010101100101 -100000110100 -011001001000 -111100110011 -111011110001 -110011111010 -001101001010 -111110011111 -110101100000 -111001000101 -010001111110 -111011010100 -110011010111 -100100110111 -111111011010 -011110101111 -001011110010 -010111011010 -011101101101 -011010101110 -011000110001 -010110101010 -011110010000 -111111011100 -111011000101 -100110101110 -010101100010 -101100011110 -000010110101 -010010011110 -110000000110 -011111010101 -000110110011 -101011000010 -000011000111 -101011010000 -101101101001 -010000101010 -101001001001 -111010110110 -111000111101 -000001010111 -101110001100 -110010110001 -100000110001 -101100101011 -100000111001 -010110100111 -101011001111 -101010111001 -010010110000 -001110010011 -010101101110 -011000010100 -100111111000 -011110100011 -110100100111 -101110101000 -101010101111 -101001000000 -111010000110 -101001000100 -010001100111 -011011010001 -000101010101 -010110000011 -100000101110 -110010001000 -111000100001 -001001101001 -110010001001 -100001111011 -101010010100 -110011100101 -010101100001 -011101010100 -110100101111 -110100001111 -011000101101 -001011101100 -010010010101 -011011111010 -010101000001 -100101100000 -101001111101 -010000000100 -110000110100 -000000001101 -100100111101 -111100110010 -001011001111 -101100001011 -001111010001 -101100011001 -100110110001 -010111000011 -011010110101 -100111100011 -000111110011 -010101111101 -010010000000 -011000011011 -001100011001 -001011001001 -101110101101 -101111110111 -101011100100 -000100110100 -110000101111 -011001111101 -000000000111 -111001001010 -110100001100 -000001001110 -111001101011 -100011011111 -110000001000 -110101011011 -001010000101 -001011111001 -011011111100 -010100110101 -110101111001 -010110010101 -010010001000 -001001110111 -011111111111 -100011100010 -000110001101 -011111010000 -010111110010 -110010100011 -101011110101 -110011011110 -010000000101 -011101100100 -110010011100 -011101101100 -000010001001 -000011101101 -000101100011 -010111111000 -010111100111 -010101000101 -110111100010 -110001101011 -111010100000 -101010101011 -011101010101 -000100110111 -000111100111 -000100111111 -111100001001 -010000100001 -110101011111 -100010000100 -000011011000 -111011110000 -101000011100 -110001001010 -001000010101 -110110000101 -100000011110 -001101111010 -010111001100 -111011111100 -100101001000 -010111101001 -110010010000 -110011010000 -000010100111 -100101111101 -110101100010 -110100011110 -101111010110 -110001001111 -011101000111 -001011001101 -110001000010 -011110100110 -000101100110 -000110111110 -001010111010 -100110000111 -001000010110 -100001110100 -000111000110 -101100011100 -110100110110 -100011010111 -000101110001 -001010010110 -101000000101 -100101101000 -000111111110 -010010010111 -110010001010 -001100110111 -110110110101 -011111011101 -110101100111 -100100100111 -011011000000 -111101001100 -011101000011 -011101001010 -101101101101 -100100110010 -001000000010 -010010001010 -111110111001 -000111010001 -011100111111 -011111011001 -110101000000 -011110000010 -001111010110 -010011111111 -110101111011 -101110111111 -001001100001 -011100111100 -110111001110 -011000000111 -001100010111 -001011010010 -010010001011 -101110000011 -100000101000 -100010100100 -000111011101 -001000111011 -010010101010 -111011010011 -110100010001 -011110001110 -111010110001 -010000010111 -010110101101 -111101100001 -110011100110 -000101111110 -110010101010 -000001010000 -001101111101 -011011110100 -110001010101 -011001000001 -001101101100 -100011011011 -101011100010 -011011100101 -100110110101 -110111001011 -000100101011 -001101010100 -010000011100 -101100111011 -011001011100 -011011010100 -011100110001 -010010110011 -101000110011 -111101010001 -111000000100 -101101100111 -001011111000 -010100000111 -011110101101 -111011101100 -110101110001 -001110010000 -010010000111 -101001111011 -100100111100 -000101101101 -101111110100 -100000101111 -011001110000 -011110011001 -000101010110 -000000000101 -110010001100 -000111100100 -010010011010 -001111110100 -011010001010 -101100101111 -011001001011 -100011111101 -101100000001 -100100101010 -000000000100 -111001110101 -000010011110 -110110100100 -111010010001 -011101010010 -011100101111 -010110000010 -010000110101 -110101010011 -001110011110 -111010011010 -000110101000 -001111000001 -010110110000 -001100110001 -110011011111 -000100111011 -110001000111 -011010111101 -000010100110 -010100101001 -010001000010 -000101110101 -101100110100 -111000110010 -111011110010 -010111001111 -100000101101 -101100001010 -100100001001 -111111111101 -001010101001 -000011011010 -101011010010 -111001000110 -111100010011 -111010011100 -100000111100 -011100001101 -110001101000 -101111011001 -001100001000 -101110010111 -011111100000 -001011100000 -101011101010 -110010101111 -001110000101 -001111011011 -011110101000 -111000001000 -010100111010 -010010111001 -110000110001 -110011000101 -001110000100 -010100101101 -101010110100 -100001010100 -100011010011 -100000010010 -011101010111 -001000010111 -001100111100 -000110100011 -101111101010 -010001010000 -001100100110 -111001111110 -101000001001 -000010110010 -110111101011 -101011000011 -001000111111 -100011001101 -011010010101 -110011100011 -110010011010 -110001010100 -100010111101 -101110000110 -010111001011 -110011011100 -110001100011 -000100011010 -111011100010 -011110110011 -011111100010 -000100001101 -100010010000 -110000000011 -101001011000 -101100110101 -001010101011 -011001011010 -001010001001 -001111011100 -111100010001 -100011010110 -001000110111 -011011010011 -001100000000 -100001111100 -000011110101 -100010000111 -000010110011 -000010111110 -011110000101 -010000001011 -001111110010 -001110001001 -011101111111 -010110110001 -110000000111 -010101011101 -010111001001 -100100010010 -101001101110 -100001001010 -010001011101 -100111010101 -100000101011 -000100101001 -110111001001 -100100000001 -010111010010 -111101111011 -011010010010 -111101101000 -100110111101 -010010001001 -100111011000 -110101111111 -111010101110 -010011110010 -101001100100 -010000101111 -010011001111 -110010011111 -101110100111 -011010100101 -111111001001 -010101100110 -101001001101 -001000101010 -010001001100 -101001101000 -110110100000 -011101000101 -100101010101 -101110111011 -010010101001 -110100011000 -110101111010 -110000100000 -010011101101 -111011001101 -100100011101 -110100010111 -011100110100 -010111011001 -011101010001 -101000000010 -100111111001 -100100001000 -001000001000 -001000000100 -011110110010 -010101010011 -101101101100 -110111111001 -010000010011 -100010100001 -000110101111 -101010101101 -100101111100 -000111010110 -001101101111 -110010000011 -110100001110 -011111111101 -111011010101 -001010100010 -100010100110 -101101110111 -010110011011 -111001110110 -011110101001 -110011100111 -000100111101 -101100011000 -101101001010 -011111100111 -010000011000 -100001100110 -000000101101 -000111010010 -110000001100 -111111101010 -001000100010 -111111111011 -001011100111 -000101110010 -010111110011 -010000011001 -111001111101 -110100001101 -010001101000 -110000101011 -011011000110 -110010111011 -100111101010 -011001101011 -001101010011 -011000100101 -110111101111 -001000100001 -010010111101 -101101101011 -011111011100 -111111010110 -001110000000 -101011110010 -011101011111 -001001101101 -011101110000 -011100011101 -111101001101 -010111010101 -010111101010 -001000101101 -100000000011 -111110101111 -000111101111 -001110010101 -101111001101 -111100110000 -110010100000 -011101110100 -100011001111 -010110001001 -111100101100 -101001110100 -011010010111 -011000100100 -001100110100 -001001111000 -001000000111 -110100000111 -011000001011 -001011000000 -110110110111 -000010111011 -001001000011 -000011100111 -110011001111 -010000111101 -001110100010 -000011110001 -011001111011 -110111000001 -111111000001 -011001100110 -110010101100 -111101010100 -010010000101 -000011011011 -110110010001 -010111111010 -010000010101 -110000011010 -110001101110 -000110101011 -101111000111 -001101100000 -010100000001 -111110001001 -000011110000 -111100111001 -000001001011 -011000010110 -000001000100 -011100111000 -001011111110 -011100000000 -000101001011 -111111110110 -111010011000 -001000111101 -011001110010 -001101011100 -100110001111 -110110111010 -001110101100 -010000101100 -010011000011 -100101110010 -000000111010 -000001111001 -111101011000 -101000011001 -111110000101 -101111111011 -100110111110 -000110010110 -011011101110 -100000010111 -110111001000 -000010101010 -001010011011 -101010101010 -101100000000 -000101101011 -010110100110 -110010010100 -001010110101 -001110000001 -010001101010 -111111110100 -001101110110 -111101010111 -101011101100 -110001101010 -100111010100 -101101111001 -001011100110 -010010001111 -100101110110 -110011000010 -001111010100 -000101011011 -110000000001 -011011001001 -001001011111 -000111011111 -100001001100 -111011010010 -010101011001 -000001110100 -000010100101 -110110010010 -100010111110 -011110111110 -000001101000 -001011000110 -000010001010 -101101010100 -011011010000 -000011111000 -101000001110 -011110101011 -110100111000 -000011000010 -111111010001 -011101110001 -100000111101 -110100101101 -110000100101 -011001110110 -110001010010 -010010110110 -011110001000 -111010110100 -101111110010 -110000110111 -111101110100 -110111101110 -100110010111 -001001100011 -001110111000 -101110100100 -010000101101 -010111100101 -011001100010 -011100000101 -101001111001 -100011001010 -100010000010 -100101000010 -111111100101 -100001101110 -101001010110 -100000100011 -100000011000 -000110000001 -000000011011 -011000110101 -011010111011 -111110000001 -001001110100 -001011011110 -110111010110 -011101110101 -101111000101 -100001010010 -000001111000 -001110010100 -111111101100 -001011010001 -111001111001 -100101101010 -111000000010 -010101001010 -001010000010 -101011000110 -110011001010 -001000011000 -001010010011 -110000111101 -001001100000 -111101100111 -011001001100 -001100111011 -100001010101 -111010100011 -111000011111 -001000000000 -101110011001 -000000000011 -111011000111 -011010100011 -110000110000 -000011001001 -011000010001 -011110000011 -011101000000 -010100110011 -010110010001 -111001101111 -110111110100 -110111110110 -100111001011 -111100110110 -101010001110 -100110000010 -011011100001 -001101010010 -010001110011 -010011110000 -110010100111 -001101110100 -101010101100 -110000111000 -011101110110 -101011110001 -110011000000 -010000011011 -001011010000 -010111010001 -010100010101 -110101000100 -010011101011 -010110111001 -101111000011 -011011100000 -000010100010 -001100110000 -110000111001 -100100100000 -001101000010 -100000010011 -100010011110 -110101010000 -000100000101 -000111000001 -000001111011 -100111011101 -110111110111 -011101111000 -001001000110 -100110010011 -100011100111 -010011010000 -010011010111 -001101100101 -010000010110 -000101010001 -011111010100 -010010111100 -001010101110 -110000001011 -011001010101 -000001111110 -010111111011 -011110010010 -001001101100 -101100101000 -100000001110 -110001001110 -011110111011 -001000110011 -111100110111 -001101100111 -000110110000 -000010011011 -100110111010 -111110001100 -000000101100 -110000111100 -100110111100 -110111111100 -110000111010 -100001100100 -100010011010 -011011100110 -110100010110 -001001010101 -000110101110 -101001100000 -100010110011 -111000001101 -101110100110 -100010111100 -000101110110 -000011011001 -000001010100 -101100111001 -011101111101 -011110011000 -111010001011 -010101110101 -100001100101 -100110100010 -100110011000 -001010100110 -011001010111 -111111001010 -111111001000 -111110100101 -000101000011 -110101101111 -110100010010 -011100000010 -001000010100 -101100000111 -001010111111 -101001010011 -101011001000 -001100000011 -010010101000 -101101111101 -101001010010 -100101111011 -101110101110 -100000100100 -000000000010 -011101100011 -110000110110 -101000110000 -111011111010 -010111000110 -001111110110 -100111110110 -100110011101 -000000001000 -101110111010 -000101011000 -001011100011 -011101100111 -000011000011 -000101011001 -110101101101 -101000001111 -111000010101 -000011100010 -011010111001 -001100100101 -010111111101 -010101111011 -000101001100 -101010000111 -111100111111 -100000000111 -110111110011 -000110110111 -010011011111 -100110010100 -000100111110 -001000111001 -011111000001 -001010100101 -101010001100 -011100001011 -000101001111 -010010101111 -101000111011 -001101000001 -100100100001 -100010101111 -100111111110 -011011111001 -101000000001 -111001101101 -101011010101 -111111100110 -001010010100 -011101111001 -001100100000 -101001110110 diff --git a/04/a.py b/04/a.py deleted file mode 100755 index 14bd774..0000000 --- a/04/a.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python3 -import sys -import common -from collections import defaultdict - - -def main(boards, N): - # we need an efficient way to find boards with numbers - # get a mapping of num_called -> (board_idx, row, col) - index = common.index(boards) - - # now go through all numbers and keep track of if r/c counts - # by board, if one is 5... - seen = {} - counts = {} - for n in N: - seen[n] = 1 - if n not in index: - continue - for b, r, c in index[n]: - if b not in counts: - counts[b] = defaultdict(int) - counts[b][f"r{r}"] += 1 - counts[b][f"c{c}"] += 1 - - # check win condition - for v in counts[b].values(): - if v == 5: - # find all unmarked in board... - s = 0 - for row in boards[b]: - for x in row: - if x not in seen: - s += x - - print(n * s) - sys.exit(0) - - -if __name__ == '__main__': - N, boards = common.parse() - main(boards, N) diff --git a/04/b.py b/04/b.py deleted file mode 100755 index 9505599..0000000 --- a/04/b.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python3 -import sys -import common -from collections import defaultdict - -def main(boards, N): - # we need an efficient way to find boards with numbers - # get a mapping of num_called -> (board_idx, row, col) - index = common.index(boards) - - # now go through all numbers and keep track of if r/c counts - # by board, if one is 5, we have a winner! - winners = {} - seen = {} - counts = {} - for n in N: - seen[n] = 1 - if n not in index: - continue - for b, r, c in index[n]: - if b in winners: - continue - - if b not in counts: - counts[b] = defaultdict(int) - counts[b][f"r{r}"] += 1 - counts[b][f"c{c}"] += 1 - - # check win condition - for v in counts[b].values(): - if v == 5: - winners[b] = 1 - if len(winners) == len(boards): - # find all unmarked in board... - s = 0 - for row in boards[b]: - for x in row: - if x not in seen: - s += x - - print(n * s) - sys.exit(0) - - -if __name__ == '__main__': - N, boards = common.parse() - main(boards, N) diff --git a/04/common.py b/04/common.py deleted file mode 100644 index d9167b9..0000000 --- a/04/common.py +++ /dev/null @@ -1,37 +0,0 @@ -import sys - -def parse(): - first = True - N = None - boards = [] - board = [] - for l in sys.stdin: - if first: - N = [int(x) for x in l.strip().split(',')] - first = False - else: - l = l.strip() - if l: - row = [int(x) for x in l.split()] - board.append(row) - elif board: - boards.append(board) - board = [] - - return N, boards - -def index(boards): - # Generates a lookup table of: - # num_called => (board, row, column) - index = {} - i = 0 - for b in boards: - for r in range(len(b)): - for c in range(len(b[r])): - x = b[r][c] - if x not in index: - index[x] = [] - index[x].append((i, r, c)) - i+=1 - - return index diff --git a/04/input b/04/input deleted file mode 100644 index c21b9b9..0000000 --- a/04/input +++ /dev/null @@ -1,601 +0,0 @@ -18,99,39,89,0,40,52,72,61,77,69,51,30,83,20,65,93,88,29,22,14,82,53,41,76,79,46,78,56,57,24,36,38,11,50,1,19,26,70,4,54,3,84,33,15,21,9,58,64,85,10,66,17,43,31,27,2,5,95,96,16,97,12,34,74,67,86,23,49,8,59,45,68,91,25,48,13,28,81,94,92,42,7,37,75,32,6,60,63,35,62,98,90,47,87,73,44,71,55,80 - -12 79 33 36 97 -82 38 77 61 84 -55 74 21 65 39 -54 56 95 50 2 -45 68 31 94 14 - -95 26 80 25 62 -79 91 70 76 61 -98 97 17 75 23 -71 30 21 52 29 -20 54 32 12 31 - -35 31 86 36 52 -18 50 79 60 67 -98 3 51 46 25 - 4 61 55 87 70 -94 39 68 27 14 - - 9 49 53 52 2 -65 92 4 73 67 -90 95 39 78 64 -17 27 13 60 51 -25 63 70 77 22 - -33 34 6 58 77 -44 75 54 18 21 -15 25 79 12 70 -90 14 81 22 49 -72 38 59 78 16 - -13 51 94 40 56 - 6 99 9 64 91 -87 73 93 71 31 -39 42 28 24 7 - 1 52 17 85 11 - -95 23 15 29 12 -40 79 2 64 59 -94 93 3 25 10 - 5 58 7 78 82 -62 73 74 16 56 - -17 55 56 14 51 -70 94 66 21 37 -97 90 43 80 89 -50 12 52 46 85 -16 79 60 15 45 - -18 59 37 25 41 -51 61 63 7 53 - 3 21 31 76 72 -29 99 34 6 83 -55 45 93 75 15 - -59 63 4 95 68 -18 47 43 15 26 -66 7 54 22 8 -50 75 91 20 98 -49 61 55 12 1 - -96 74 37 12 66 -10 94 7 29 75 -20 48 26 67 41 -40 99 9 80 35 -72 87 82 76 85 - -60 58 43 17 57 -25 33 85 91 27 -46 36 54 49 64 -86 53 4 63 95 -38 74 84 37 67 - -66 90 73 98 51 -11 94 60 92 14 -82 58 17 63 52 -33 1 18 77 72 -12 76 20 23 10 - -28 69 67 6 32 - 4 17 77 52 33 -26 57 92 56 73 -30 91 50 82 2 -21 31 61 78 99 - -98 63 26 81 75 -23 36 3 88 65 -69 87 33 20 43 - 4 51 47 70 50 -10 91 74 77 66 - -61 47 90 22 63 -26 15 41 8 73 -71 40 82 91 75 -39 95 56 84 55 - 5 76 32 69 34 - -78 77 1 57 39 -70 49 83 90 87 -97 74 26 67 19 -50 21 2 92 60 -82 65 62 31 33 - - 6 46 97 50 2 -48 23 34 24 93 -83 7 31 59 66 -44 18 21 47 77 -69 86 35 72 17 - -78 68 69 4 26 -47 38 15 95 53 -66 46 49 79 59 -82 30 50 7 2 -17 16 34 64 51 - -19 20 13 75 26 -63 28 14 93 50 -27 70 61 29 67 -12 89 71 33 98 -31 25 16 79 69 - -95 23 83 86 16 - 4 50 27 92 62 -42 29 75 88 49 -31 58 39 44 93 -80 19 15 97 96 - -91 60 6 47 63 -51 90 36 11 72 -73 84 50 76 40 -49 75 82 9 35 -71 1 0 67 59 - -48 56 80 24 86 - 4 74 95 53 41 -52 58 36 19 64 -90 87 99 82 25 -35 13 22 26 21 - -68 87 18 23 97 -69 25 40 76 24 -34 33 56 16 51 -49 77 88 75 26 - 2 19 96 35 86 - -29 26 56 49 10 -89 91 95 5 69 -52 1 99 34 20 - 8 74 64 32 61 -25 72 60 22 97 - -39 65 0 91 86 - 9 7 21 62 89 -22 92 63 46 17 -61 66 37 59 52 -93 70 3 97 49 - -29 3 66 4 43 -46 25 7 62 54 -71 26 70 75 5 -17 82 33 51 19 -65 40 91 53 15 - -88 59 14 41 92 -83 74 73 65 12 -95 97 35 47 55 -62 2 3 9 63 -52 44 32 33 72 - -82 12 77 25 60 - 8 93 38 56 97 -59 5 70 33 40 - 9 90 1 41 57 -68 73 26 91 6 - -72 15 64 59 49 -26 12 9 97 80 -84 18 91 20 87 -69 34 14 65 40 -98 74 27 5 31 - -55 99 23 12 76 -57 92 71 83 53 -19 24 39 97 73 -96 91 32 34 28 - 0 72 42 65 1 - -84 50 97 46 99 -90 1 95 64 22 -45 53 55 25 42 -30 70 52 88 72 -29 44 98 51 6 - -70 74 85 78 45 -34 91 82 63 99 -17 3 50 53 87 -38 88 98 6 92 -39 30 10 18 67 - -26 45 13 93 29 -18 51 66 22 17 -55 75 70 9 6 - 3 74 30 42 91 -21 77 57 37 90 - -17 94 74 85 60 - 2 67 97 19 11 -20 32 58 18 56 -10 95 40 51 93 -66 50 15 65 52 - - 7 38 79 77 42 -15 34 13 80 93 -46 54 74 33 17 - 1 4 83 68 35 -70 85 66 63 39 - -22 68 41 2 58 -69 76 14 62 33 -64 39 46 28 59 -60 21 26 13 74 -12 54 99 82 0 - - 9 0 82 4 20 -88 76 18 55 44 -10 53 74 93 58 -49 50 16 42 2 -19 23 66 54 65 - -96 9 42 30 67 - 3 29 94 5 45 -65 62 25 59 17 -21 79 73 44 66 -38 6 86 7 4 - -89 77 17 13 79 -51 10 28 18 36 -59 69 80 61 25 - 0 21 9 91 30 -86 96 2 29 39 - -53 11 27 20 82 -15 38 90 34 98 -69 28 16 14 99 -67 49 48 42 59 -51 2 61 23 3 - -37 60 14 43 49 -66 24 54 96 58 -73 28 48 3 81 -93 35 97 46 52 -75 84 79 1 11 - -48 75 8 88 85 -81 94 3 32 28 -63 49 78 86 90 -67 84 5 4 52 -57 89 29 96 71 - - 3 34 89 15 64 -47 31 57 72 26 -48 75 19 2 65 -42 45 97 54 71 -55 27 87 77 35 - -74 50 53 19 96 -95 89 71 75 26 - 8 11 20 43 38 -78 51 28 65 93 -64 9 84 31 23 - -37 42 65 94 92 -69 35 40 1 71 -63 43 75 59 74 -97 90 67 91 85 -28 58 21 49 52 - -20 62 44 96 74 -18 37 63 54 51 -39 90 1 4 84 - 7 72 57 19 79 -99 66 43 38 36 - - 2 68 67 21 78 -81 86 63 13 69 -74 29 53 56 30 -16 72 7 54 1 -64 50 73 14 45 - -21 47 88 28 32 - 7 43 83 39 27 -95 9 98 45 99 -68 49 94 73 35 -10 36 13 25 37 - -45 2 16 75 9 -66 46 20 91 87 -36 74 64 85 62 -51 39 93 3 57 - 0 37 56 27 50 - - 9 21 37 96 89 -66 4 16 3 56 -58 32 97 76 47 - 7 59 13 0 34 -69 68 95 61 51 - -30 41 60 88 98 -33 94 57 79 40 -14 36 17 56 99 -10 37 62 54 0 -65 32 58 21 23 - -89 47 65 40 18 -25 17 13 0 33 -49 57 26 3 76 -15 71 70 95 61 -67 94 80 77 7 - -92 40 55 95 8 -88 62 4 43 13 -54 1 19 20 87 -11 97 23 27 80 -63 10 66 45 7 - -46 76 10 61 26 -86 55 15 84 25 -12 80 82 83 54 -22 81 69 70 48 -53 89 30 44 20 - -84 62 57 74 30 -96 18 24 9 29 -22 8 56 44 4 -71 85 16 55 73 -25 28 88 61 33 - -60 26 72 28 89 -51 94 24 96 53 -39 0 90 12 22 -92 95 65 34 32 -63 36 48 58 52 - -92 5 32 52 30 - 6 93 73 74 10 -38 62 55 28 79 -88 60 27 7 83 -82 53 39 70 95 - -84 35 58 4 19 -80 96 53 45 7 -31 52 14 8 63 -87 41 75 65 18 - 3 72 79 91 86 - -16 19 42 49 0 -34 18 26 70 98 -45 38 87 17 54 -84 51 7 24 66 -57 46 3 36 43 - -36 13 44 81 48 -93 88 41 77 57 - 6 64 2 3 46 -30 10 8 20 14 -26 76 7 1 90 - -67 74 39 25 78 - 4 96 62 70 30 -22 41 72 47 32 -87 27 77 51 86 -65 35 26 11 85 - -94 42 49 91 12 -78 51 3 95 76 - 0 72 13 30 25 -33 81 32 58 62 -67 5 88 26 1 - -71 21 29 73 75 -39 77 63 66 36 -74 18 80 35 34 -26 5 53 33 6 -19 1 27 25 9 - -72 53 57 24 30 -66 84 68 40 12 -52 48 34 21 26 -73 3 18 81 67 -82 7 17 36 56 - -93 85 42 81 30 -47 4 48 82 96 -28 41 52 0 36 -97 14 35 9 33 -98 11 69 20 87 - -46 67 85 96 34 -90 92 68 56 51 -16 61 29 28 27 -81 57 64 53 26 - 6 49 43 41 65 - -37 82 55 88 27 -43 79 25 5 50 -92 83 81 44 22 -75 74 39 16 41 -48 29 80 77 90 - -57 25 10 61 40 - 1 22 20 81 41 -32 83 43 54 97 -29 47 15 27 8 -79 28 63 77 99 - -62 43 94 24 48 -45 93 14 34 11 -58 31 33 71 97 -10 59 76 30 26 -64 54 79 80 56 - -34 8 49 13 12 -54 57 4 82 46 -84 32 59 55 40 - 0 73 99 38 56 -16 61 36 17 78 - - 7 97 37 81 91 - 3 10 83 48 90 -49 40 72 6 2 -17 39 94 82 66 -58 68 52 64 42 - -30 93 40 75 74 -62 48 47 3 59 -57 10 73 79 86 -71 89 88 5 38 -13 6 56 80 81 - -58 54 52 83 88 -12 84 87 28 46 -42 6 27 39 4 -47 72 93 64 66 -79 71 44 18 3 - -60 72 89 35 17 -77 66 68 59 9 - 2 43 18 14 33 -20 30 82 31 52 -81 64 56 45 27 - -64 9 44 23 99 -40 75 55 29 86 -94 46 45 84 97 -92 25 30 13 10 -90 87 61 53 70 - - 6 49 41 40 37 -65 24 47 33 55 -51 4 72 16 85 -56 5 25 98 14 -32 26 50 17 34 - -24 78 72 40 31 - 3 12 33 87 71 -99 91 8 59 34 -50 90 63 45 29 -75 96 7 22 44 - -81 94 61 41 10 -23 5 66 27 70 -62 82 4 74 52 -19 55 67 59 49 -48 77 35 33 45 - - 7 86 81 93 19 -90 57 64 45 36 -75 13 2 28 39 -46 10 83 80 47 - 1 91 94 24 56 - -20 18 0 49 44 -77 72 31 61 46 -66 95 73 8 76 - 3 13 99 94 96 -59 97 43 85 86 - -34 78 54 37 0 -12 85 86 93 70 -53 10 59 8 55 -63 20 29 36 32 -76 75 43 96 61 - -62 55 26 17 74 -10 15 47 38 20 -41 66 59 58 9 -34 52 40 93 82 -45 43 21 11 24 - -85 90 47 75 50 -51 12 8 54 11 -73 19 3 37 28 -25 24 84 67 87 -44 94 6 20 45 - -36 99 81 96 75 -89 90 29 33 55 -40 25 10 32 92 -51 27 70 0 15 -76 50 44 22 24 - -31 63 21 13 24 -42 87 53 5 38 - 8 50 30 73 83 -95 91 15 41 52 -23 99 10 67 60 - -88 49 2 4 85 -22 25 6 30 62 -34 53 74 96 64 -77 80 93 65 63 -37 27 26 68 56 - -86 90 40 79 7 -57 2 34 91 35 -85 74 52 97 93 -63 32 38 1 12 -29 46 56 84 25 - -38 26 22 49 24 -56 84 2 18 62 - 3 90 17 73 37 -55 95 92 35 29 - 7 51 42 5 39 - -14 0 19 53 69 - 2 22 65 78 31 -43 88 37 93 46 -12 30 83 26 29 -92 68 62 7 44 - -38 65 61 93 36 -53 43 11 12 54 -97 99 48 24 21 -84 33 3 23 31 -56 4 87 90 7 - - 0 61 67 13 56 -24 69 94 85 73 -78 35 89 55 72 -21 4 90 80 83 -64 99 5 16 36 - -55 72 7 83 35 -63 73 96 21 75 - 8 79 59 62 37 -15 89 28 80 82 -34 61 97 23 0 - -48 21 43 36 15 -97 65 91 6 83 -84 64 98 31 90 -72 58 5 70 92 -52 71 25 41 51 - -14 32 70 8 73 -71 75 95 29 68 -22 27 65 7 78 -21 37 47 19 6 -60 83 2 80 98 - -59 90 57 29 68 -54 31 13 61 28 -65 37 17 53 1 -25 38 20 46 69 -23 18 77 98 96 - -20 38 79 65 16 -93 77 14 97 47 -34 42 8 18 54 -91 64 0 58 75 -25 67 37 6 56 - -88 81 6 8 65 -30 51 95 12 97 -70 16 55 54 73 -75 64 93 1 52 -82 77 24 50 36 - -41 59 17 76 95 -51 58 61 73 56 - 1 5 53 20 21 -22 14 37 28 0 -43 35 26 96 32 - -17 86 68 23 20 -41 88 75 58 64 -94 90 3 0 26 -30 51 13 95 10 -97 77 83 57 21 diff --git a/05/a.c b/05/a.c deleted file mode 100644 index 7770b68..0000000 --- a/05/a.c +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include - -int main(void) { - int grid[1000][1000] = {0}; - - int x1, y1, x2, y2; - while (scanf("%d,%d -> %d,%d\n", &x1, &y1, &x2, &y2) != EOF) { - /* key: for vert/horiz lines doesn't matter which one you - * start at (since you draw the same line either way */ - if (x1 == x2) { - int dist = abs(y1 - y2); - int start = y1 < y2 ? y1 : y2; - for (int i = start; i <= start + dist; i++) { - grid[x1][i]++; - } - } else if (y1 == y2) { - int dist = abs(x1 - x2); - int start = x1 < x2 ? x1 : x2; - for (int i = start; i <= start + dist; i++) { - grid[i][y1]++; - } - } - } - - int count = 0; - for (int r = 0; r < 1000; r++) { - for (int c = 0; c < 1000; c++) { - if (grid[r][c] > 1) { - count++; - } - } - } - printf("%d\n", count); - return 0; -} diff --git a/05/a.py b/05/a.py deleted file mode 100755 index 83e7979..0000000 --- a/05/a.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python3 -import sys -import pdb -from collections import defaultdict - -grid = defaultdict(lambda: defaultdict(int)) - -def bigrange(a, b): - if a > b: - return range(b, a + 1) - else: - return range(a, b + 1) - -for l in sys.stdin: - a, arrow, b = l.split() - x1, y1 = [int(x) for x in a.split(',')] - x2, y2 = [int(x) for x in b.split(',')] - if x1 == x2: - for y in bigrange(y1, y2): - grid[x1][y] += 1 - elif y1 == y2: - for x in bigrange(x1, x2): - grid[x][y1] += 1 - -count = 0 -for x in grid.keys(): - for y in grid[x].keys(): - if grid[x][y] > 1: - count += 1 - -print(count) diff --git a/05/b.c b/05/b.c deleted file mode 100644 index cb6295e..0000000 --- a/05/b.c +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include - -int grid[1000][1000] = {0}; - -void draw(int x1, int y1, int x2, int y2) { - int r = x1; - int c = y1; - int rstep = x1 == x2 ? 0 : (x1 < x2 ? 1 : -1); - int cstep = y1 == y2 ? 0 : (y1 < y2 ? 1 : -1); - while (r != x2 || c != y2) { - grid[r][c]++; - r += rstep; - c += cstep; - } - /* loop stops before marking last point! */ - grid[x2][y2]++; -} - -int main(void) { - int x1, y1, x2, y2; - while (scanf("%d,%d -> %d,%d\n", &x1, &y1, &x2, &y2) != EOF) { - draw(x1, y1, x2, y2); - } - - int count = 0; - for (int r = 0; r < 1000; r++) { - for (int c = 0; c < 1000; c++) { - if (grid[r][c] > 1) { - count++; - } - } - } - printf("%d\n", count); - return 0; -} diff --git a/05/b.py b/05/b.py deleted file mode 100755 index cf8627d..0000000 --- a/05/b.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python3 -import sys -import pdb -from collections import defaultdict - -grid = defaultdict(lambda: defaultdict(int)) - -def bigrange(a, b): - # NOTE: unlike a.py, reversed is impt! - if a > b: - return reversed(range(b, a + 1)) - else: - return range(a, b + 1) - -for l in sys.stdin: - a, arrow, b = l.split() - x1, y1 = [int(x) for x in a.split(',')] - x2, y2 = [int(x) for x in b.split(',')] - if x1 == x2: - for y in bigrange(y1, y2): - grid[x1][y] += 1 - elif y1 == y2: - for x in bigrange(x1, x2): - grid[x][y1] += 1 - else: - xr = bigrange(x1, x2) - yr = bigrange(y1, y2) - coords = zip(xr, yr) - for x, y in coords: - grid[x][y] += 1 - -count = 0 -for x in grid.keys(): - for y in grid[x].keys(): - if grid[x][y] > 1: - count += 1 - -print(count) diff --git a/05/input b/05/input deleted file mode 100644 index 1b5dab7..0000000 --- a/05/input +++ /dev/null @@ -1,500 +0,0 @@ -781,721 -> 781,611 -334,551 -> 119,551 -25,153 -> 765,893 -588,619 -> 588,683 -167,63 -> 439,335 -340,129 -> 35,129 -578,712 -> 509,712 -855,426 -> 855,649 -778,71 -> 778,411 -21,314 -> 631,924 -552,148 -> 148,552 -531,889 -> 789,889 -85,963 -> 986,62 -914,140 -> 257,797 -520,721 -> 794,721 -49,936 -> 960,25 -458,941 -> 839,560 -113,797 -> 113,604 -554,136 -> 554,655 -112,208 -> 112,504 -78,410 -> 169,319 -176,148 -> 906,878 -56,98 -> 835,877 -538,981 -> 178,621 -553,102 -> 553,688 -452,761 -> 452,70 -487,574 -> 487,589 -356,406 -> 154,406 -11,646 -> 11,416 -543,19 -> 924,400 -862,773 -> 929,773 -292,901 -> 292,97 -985,236 -> 667,236 -745,572 -> 667,572 -752,794 -> 775,817 -269,649 -> 269,198 -928,327 -> 469,786 -284,937 -> 755,466 -308,876 -> 308,790 -201,94 -> 988,881 -233,958 -> 903,288 -210,879 -> 91,879 -760,48 -> 133,675 -55,79 -> 956,980 -988,15 -> 15,988 -25,974 -> 966,33 -903,671 -> 292,60 -587,770 -> 403,954 -83,379 -> 432,728 -30,121 -> 334,425 -375,516 -> 375,409 -72,370 -> 72,152 -575,595 -> 575,363 -248,64 -> 896,712 -703,421 -> 395,421 -66,978 -> 977,67 -450,961 -> 450,773 -830,895 -> 830,661 -373,58 -> 442,58 -739,383 -> 739,712 -510,188 -> 510,99 -350,880 -> 248,880 -771,278 -> 549,278 -266,434 -> 266,838 -315,490 -> 884,490 -360,651 -> 428,583 -333,452 -> 333,109 -313,414 -> 713,14 -23,982 -> 989,16 -196,201 -> 889,894 -485,761 -> 99,375 -288,918 -> 50,680 -912,206 -> 142,976 -242,10 -> 841,609 -972,11 -> 16,967 -859,142 -> 390,611 -48,348 -> 212,348 -246,514 -> 726,34 -29,754 -> 29,706 -617,296 -> 224,689 -671,487 -> 397,213 -913,898 -> 155,140 -437,688 -> 18,269 -150,150 -> 869,869 -386,873 -> 940,319 -57,326 -> 148,417 -847,12 -> 319,540 -741,640 -> 520,640 -111,458 -> 111,754 -595,615 -> 861,881 -244,722 -> 905,722 -323,394 -> 323,304 -560,562 -> 560,678 -48,750 -> 48,228 -80,40 -> 80,723 -730,839 -> 191,300 -300,773 -> 977,96 -619,892 -> 827,892 -22,226 -> 656,226 -125,968 -> 125,637 -116,923 -> 512,923 -59,741 -> 59,499 -484,930 -> 487,930 -362,175 -> 362,778 -960,986 -> 53,79 -170,748 -> 576,748 -810,291 -> 743,291 -761,924 -> 339,502 -730,850 -> 920,850 -778,949 -> 778,766 -254,724 -> 254,394 -685,177 -> 685,441 -442,290 -> 833,290 -181,209 -> 72,100 -91,924 -> 953,62 -318,880 -> 318,659 -570,632 -> 570,966 -955,227 -> 667,227 -439,666 -> 439,224 -276,385 -> 276,56 -544,521 -> 544,867 -187,626 -> 187,13 -307,235 -> 859,235 -759,416 -> 668,416 -357,882 -> 981,882 -651,71 -> 651,457 -615,711 -> 615,502 -474,162 -> 305,162 -320,33 -> 320,48 -799,420 -> 799,389 -448,46 -> 313,46 -925,141 -> 925,928 -332,101 -> 332,373 -41,948 -> 749,948 -276,672 -> 207,672 -315,736 -> 86,736 -844,688 -> 466,688 -357,199 -> 107,199 -902,950 -> 14,62 -277,251 -> 923,251 -963,38 -> 34,967 -71,389 -> 577,389 -712,911 -> 712,573 -186,976 -> 148,938 -407,389 -> 637,619 -917,118 -> 917,960 -988,571 -> 362,571 -845,941 -> 189,285 -686,537 -> 306,537 -915,929 -> 946,960 -447,30 -> 447,364 -832,833 -> 832,888 -957,953 -> 203,199 -982,73 -> 400,655 -159,704 -> 159,844 -284,347 -> 159,347 -903,280 -> 93,280 -769,961 -> 140,332 -899,145 -> 293,751 -850,643 -> 148,643 -580,870 -> 739,870 -686,250 -> 686,237 -142,528 -> 142,936 -827,224 -> 827,287 -972,946 -> 155,946 -706,851 -> 862,851 -564,231 -> 564,428 -511,662 -> 511,752 -838,842 -> 585,842 -60,871 -> 870,61 -719,824 -> 719,648 -183,232 -> 936,985 -131,56 -> 953,878 -406,952 -> 80,952 -884,518 -> 945,518 -427,439 -> 662,439 -829,920 -> 829,634 -966,262 -> 966,933 -813,27 -> 813,934 -784,101 -> 784,160 -744,313 -> 744,850 -969,213 -> 206,976 -957,56 -> 28,985 -312,620 -> 312,680 -454,131 -> 454,776 -360,174 -> 175,359 -711,114 -> 692,95 -452,839 -> 938,839 -641,56 -> 641,334 -566,890 -> 51,890 -869,109 -> 869,102 -119,36 -> 119,796 -301,583 -> 301,451 -733,603 -> 733,714 -718,703 -> 581,566 -709,513 -> 915,513 -405,13 -> 572,13 -782,26 -> 391,26 -15,74 -> 858,917 -975,978 -> 38,41 -11,316 -> 982,316 -303,367 -> 303,129 -847,143 -> 847,158 -856,687 -> 856,870 -715,524 -> 715,812 -451,288 -> 272,467 -576,179 -> 119,179 -10,623 -> 10,44 -652,631 -> 796,775 -930,613 -> 913,613 -803,746 -> 803,566 -306,602 -> 306,137 -582,491 -> 582,296 -181,116 -> 231,116 -802,646 -> 802,884 -75,623 -> 75,424 -370,680 -> 370,923 -806,497 -> 939,497 -301,331 -> 818,331 -912,916 -> 27,31 -24,82 -> 683,741 -862,205 -> 316,751 -245,842 -> 383,842 -544,946 -> 518,920 -129,192 -> 18,303 -831,915 -> 31,115 -306,824 -> 454,676 -851,341 -> 125,341 -790,154 -> 790,988 -407,586 -> 477,656 -144,988 -> 925,207 -264,391 -> 264,466 -901,651 -> 646,651 -865,936 -> 390,461 -631,737 -> 631,166 -103,939 -> 937,105 -505,813 -> 505,218 -260,457 -> 141,457 -52,762 -> 54,762 -26,95 -> 889,958 -638,41 -> 330,41 -612,775 -> 191,354 -863,224 -> 863,287 -674,87 -> 674,110 -189,76 -> 954,841 -372,483 -> 503,483 -166,75 -> 619,75 -938,983 -> 18,63 -442,573 -> 858,157 -681,590 -> 878,590 -276,465 -> 500,241 -644,703 -> 651,710 -848,363 -> 254,363 -204,109 -> 216,97 -81,529 -> 81,674 -74,44 -> 978,948 -929,237 -> 598,237 -298,644 -> 298,712 -678,367 -> 360,685 -413,27 -> 413,799 -684,403 -> 684,500 -188,601 -> 972,601 -33,257 -> 33,897 -278,299 -> 278,635 -261,983 -> 804,440 -216,324 -> 216,526 -399,332 -> 399,613 -826,702 -> 826,332 -137,203 -> 624,203 -326,552 -> 36,262 -142,927 -> 343,927 -21,330 -> 410,719 -721,768 -> 289,336 -807,715 -> 807,287 -775,678 -> 62,678 -771,10 -> 491,10 -287,829 -> 287,599 -589,947 -> 767,947 -160,348 -> 798,986 -699,264 -> 108,855 -605,145 -> 568,145 -264,615 -> 545,615 -633,111 -> 11,733 -589,886 -> 589,897 -728,839 -> 78,189 -739,924 -> 948,924 -140,354 -> 830,354 -619,662 -> 332,662 -592,960 -> 592,290 -510,908 -> 510,828 -792,518 -> 792,749 -148,20 -> 832,704 -529,837 -> 863,503 -802,371 -> 301,371 -682,429 -> 682,537 -885,918 -> 38,71 -590,229 -> 795,24 -782,704 -> 244,704 -936,71 -> 981,71 -27,272 -> 27,253 -558,48 -> 558,69 -661,422 -> 661,145 -152,335 -> 152,362 -516,407 -> 26,407 -449,731 -> 592,731 -187,456 -> 594,863 -145,290 -> 15,290 -667,213 -> 214,666 -660,872 -> 660,605 -649,617 -> 986,954 -86,914 -> 959,41 -895,967 -> 24,96 -40,154 -> 762,154 -27,106 -> 855,934 -929,913 -> 319,303 -749,314 -> 387,676 -76,380 -> 824,380 -632,329 -> 632,436 -154,496 -> 154,528 -127,958 -> 127,613 -592,606 -> 363,606 -929,228 -> 929,890 -832,596 -> 801,565 -824,978 -> 134,978 -638,485 -> 638,291 -783,848 -> 783,77 -646,877 -> 646,117 -461,279 -> 850,668 -300,450 -> 115,265 -916,205 -> 145,976 -510,760 -> 124,760 -884,668 -> 884,153 -285,370 -> 705,790 -845,42 -> 17,870 -784,59 -> 71,772 -627,268 -> 333,562 -731,403 -> 22,403 -980,43 -> 43,980 -16,988 -> 973,31 -720,881 -> 300,881 -23,182 -> 723,882 -129,887 -> 51,887 -186,934 -> 186,452 -114,815 -> 39,815 -868,777 -> 868,222 -554,218 -> 911,218 -247,408 -> 777,938 -391,69 -> 285,69 -239,472 -> 614,847 -422,918 -> 422,245 -852,905 -> 852,634 -631,164 -> 17,778 -987,988 -> 11,12 -435,891 -> 435,136 -564,409 -> 767,612 -611,508 -> 611,535 -744,965 -> 631,965 -308,604 -> 509,604 -77,250 -> 589,762 -505,950 -> 685,950 -907,222 -> 850,222 -700,674 -> 754,620 -238,294 -> 53,479 -875,130 -> 875,544 -368,547 -> 368,965 -618,206 -> 311,206 -127,972 -> 852,247 -561,192 -> 982,613 -573,399 -> 573,464 -311,109 -> 764,562 -69,813 -> 809,813 -195,594 -> 317,594 -900,467 -> 638,467 -806,810 -> 806,918 -451,17 -> 128,17 -93,837 -> 878,52 -299,726 -> 531,958 -968,984 -> 18,34 -957,38 -> 14,38 -283,583 -> 32,332 -922,822 -> 953,853 -589,466 -> 753,466 -203,791 -> 933,791 -122,739 -> 778,83 -294,658 -> 289,658 -365,200 -> 365,513 -611,941 -> 701,941 -927,111 -> 107,931 -754,529 -> 181,529 -364,933 -> 567,933 -717,960 -> 717,11 -612,472 -> 612,807 -971,252 -> 531,252 -88,911 -> 387,911 -885,837 -> 75,27 -222,289 -> 714,781 -754,40 -> 293,501 -866,517 -> 949,517 -858,586 -> 331,586 -157,21 -> 731,595 -173,216 -> 822,865 -353,206 -> 353,318 -68,88 -> 957,88 -370,645 -> 200,815 -981,83 -> 89,975 -259,112 -> 259,435 -184,920 -> 825,279 -252,357 -> 252,56 -722,349 -> 368,703 -928,973 -> 597,973 -677,656 -> 788,545 -222,766 -> 527,461 -870,787 -> 972,889 -11,986 -> 986,11 -163,918 -> 748,333 -111,75 -> 823,75 -603,250 -> 375,478 -338,582 -> 338,454 -372,179 -> 452,179 -571,96 -> 571,723 -243,460 -> 267,460 -850,63 -> 43,870 -837,863 -> 113,139 -21,886 -> 709,198 -154,650 -> 181,650 -320,506 -> 320,706 -983,722 -> 983,657 -830,225 -> 190,865 -924,12 -> 11,925 -838,827 -> 258,247 -690,792 -> 690,582 -465,658 -> 146,977 -790,935 -> 39,184 -318,627 -> 318,125 -245,939 -> 291,939 -803,219 -> 254,768 -262,476 -> 441,476 -790,225 -> 790,372 -250,722 -> 613,722 -368,326 -> 368,474 -148,666 -> 394,912 -813,588 -> 238,13 -84,323 -> 84,957 -566,716 -> 822,716 -794,633 -> 459,633 -355,634 -> 237,634 -950,755 -> 950,867 -292,696 -> 340,696 -121,391 -> 361,631 -58,516 -> 624,516 -859,37 -> 184,712 -686,819 -> 428,819 -11,12 -> 988,989 -718,679 -> 280,679 -515,524 -> 515,664 -136,459 -> 136,56 -703,763 -> 703,858 -290,733 -> 290,33 -910,928 -> 910,21 -570,937 -> 570,808 -462,215 -> 462,747 -388,181 -> 712,505 -933,705 -> 933,601 -605,492 -> 188,492 -737,818 -> 564,818 -214,629 -> 735,108 -139,942 -> 598,942 -708,187 -> 541,187 -646,611 -> 325,611 -788,356 -> 718,426 -267,250 -> 267,930 -94,819 -> 94,191 -661,537 -> 661,363 -464,290 -> 471,297 -656,68 -> 337,68 -31,515 -> 797,515 -876,21 -> 81,21 -630,932 -> 21,323 -259,58 -> 542,58 -703,523 -> 703,949 -470,310 -> 470,20 -69,983 -> 977,75 -569,908 -> 569,931 -645,718 -> 645,665 -819,371 -> 819,705 -772,709 -> 772,736 -330,870 -> 382,818 -982,317 -> 982,778 -626,411 -> 626,887 -466,33 -> 466,635 -519,939 -> 519,131 -402,253 -> 402,300 -180,712 -> 826,66 -55,764 -> 941,764 -659,859 -> 659,944 -346,374 -> 346,500 -880,333 -> 880,767 -42,969 -> 983,28 -363,688 -> 363,148 -645,880 -> 265,500 diff --git a/06/a.c b/06/a.c deleted file mode 100644 index bfe4f66..0000000 --- a/06/a.c +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include -#include - -int main(void) { - int counts[9] = {0}; - - /* Wow, the parser is more complex than the algorithm :( */ - char *line = NULL; - size_t linesize = 0; - getline(&line, &linesize, stdin); - char *p; - for (p = strtok(line, ","); p; p = strtok(NULL, ",")) { - counts[atoi(p)]++; - } - free(line); - - /* Phew, made it */ - for (int i = 0; i < 80; i++) { - /* Rather than pop & append, just edit in place and rotate - * the start index in use; i.e. on day 2, idx 1 is '0'. - * - * In fact, really all we need to do is add the current - * "populating fish" (mod 0) to the 7th index (which will - * be the 6th index on the next "lifecycle". - * */ - counts[(i + 7) % 9] += counts[i % 9]; - } - - int sum = 0; - for (int i = 0; i < 9; i++) { - sum += counts[i]; - } - printf("%d\n", sum); - - return 0; -} diff --git a/06/a.py b/06/a.py deleted file mode 100755 index 0e1c18e..0000000 --- a/06/a.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python3 - -# XXX: This solution is totally not scalable, and could -# EASILY use the solution to pt B for a faster solution. -# I'm keeping it for posterity to show that I brute forced -# pt A :) -import sys - -fish = [] - -def repro(fish): - new = [] - for f in fish: - if f == 0: - new += [6, 8] - else: - new.append(f - 1) - - return new - -for l in sys.stdin: - # just keep the last one (only one) - fish = [int(x) for x in l.split(',')] - -for i in range(80): - fish = repro(fish) - -print(len(fish)) diff --git a/06/b.c b/06/b.c deleted file mode 100644 index 1f9c485..0000000 --- a/06/b.c +++ /dev/null @@ -1,39 +0,0 @@ -/* NOTE: only diff from a.c is the 256 rotation and use of a long long for - * big vals (tm). Duplicated for the sake of the build system :) */ -#include -#include -#include - -int main(void) { - unsigned long long counts[9] = {0}; - - /* Wow, the parser is more complex than the algorithm :( */ - char *line = NULL; - size_t linesize = 0; - getline(&line, &linesize, stdin); - char *p; - for (p = strtok(line, ","); p; p = strtok(NULL, ",")) { - counts[atoi(p)]++; - } - free(line); - - /* Phew, made it */ - for (int i = 0; i < 256; i++) { - /* Rather than pop & append, just edit in place and rotate - * the start index in use; i.e. on day 2, idx 1 is '0'. - * - * In fact, really all we need to do is add the current - * "populating fish" (mod 0) to the 7th index (which will - * be the 6th index on the next "lifecycle". - * */ - counts[(i + 7) % 9] += counts[i % 9]; - } - - unsigned long long sum = 0; - for (int i = 0; i < 9; i++) { - sum += counts[i]; - } - printf("%llu\n", sum); - - return 0; -} diff --git a/06/b.py b/06/b.py deleted file mode 100755 index 3f0c4b9..0000000 --- a/06/b.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env python3 -import sys - -# rather than keep a raw list, count number of each type! -counts = [0] * 9 - -for l in sys.stdin: - for f in l.split(","): - counts[int(f)] += 1 - -for i in range(256): - ready = counts.pop(0) - counts[6] += ready - counts.append(ready) - -print(sum(counts)) diff --git a/06/input b/06/input deleted file mode 100644 index e2e33f5..0000000 --- a/06/input +++ /dev/null @@ -1 +0,0 @@ -1,4,1,1,1,1,5,1,1,5,1,4,2,5,1,2,3,1,1,1,1,5,4,2,1,1,3,1,1,1,1,1,1,1,2,1,1,1,1,1,5,1,1,1,1,1,1,1,1,1,4,1,1,1,1,5,1,4,1,1,4,1,1,1,1,4,1,1,5,5,1,1,1,4,1,1,1,1,1,3,2,1,1,1,1,1,2,3,1,1,2,1,1,1,3,1,1,1,2,1,2,1,1,2,1,1,3,1,1,1,3,3,5,1,4,1,1,5,1,1,4,1,5,3,3,5,1,1,1,4,1,1,1,1,1,1,5,5,1,1,4,1,2,1,1,1,1,2,2,2,1,1,2,2,4,1,1,1,1,3,1,2,3,4,1,1,1,4,4,1,1,1,1,1,1,1,4,2,5,2,1,1,4,1,1,5,1,1,5,1,5,5,1,3,5,1,1,5,1,1,2,2,1,1,1,1,1,1,1,4,3,1,1,4,1,4,1,1,1,1,4,1,4,4,4,3,1,1,3,2,1,1,1,1,1,1,1,4,1,3,1,1,1,1,1,1,1,5,2,4,2,1,4,4,1,5,1,1,3,1,3,1,1,1,1,1,4,2,3,2,1,1,2,1,5,2,1,1,4,1,4,1,1,1,4,4,1,1,1,1,1,1,4,1,1,1,2,1,1,2 diff --git a/07/a.py b/07/a.py deleted file mode 100755 index eb86ec2..0000000 --- a/07/a.py +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env python3 -# In a "all fuel is equal" situation, the optimal solution will -# be the median, since it's effectively the closest to the "middle" -# one can get. I forget the proof, but it works. Something like -# -# T = |x1 - m| + ... + |xi - m| -# -# If m is the median, there are i/2 points on each side. If m -# was NOT the median, it might get "closer" to a subset of points -# but the "larger" split will be >i/2 points, and it is getting -# "farther" from those points. The # of points farther > # closer, -# so it's a less optimal positioning. -import sys - -crabs = [] -for l in sys.stdin: - crabs = [int(x) for x in l.split(",")] - -s = sorted(crabs) -m = s[int(len(crabs) / 2)] - -print(sum([abs(x - m) for x in crabs])) diff --git a/07/b.py b/07/b.py deleted file mode 100755 index 47a7db4..0000000 --- a/07/b.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python3 -# In the "non-linear fuel cost" situation, we suddenly know -# the median is definitely not optimal. Consider 1,2,100. A -# median of 2 means you'd incur a huge penalty (100 + 99..) -# for the 100 term, 4851 to be exact (plus 1 more for the 1) -# -# A better solution is to optimize for the least number of -# far-out points by using the average. We see 34 is would -# give us 3300 instead, which is significantly better. -import sys - - -def cost(a, b): - # Distance 3 = 1 + 2 + 3 = sum(range(abs))) - return sum(range(abs(a - b) + 1)) - - -crabs = [] -for l in sys.stdin: - crabs = [int(x) for x in l.split(",")] - -avg = round(sum(crabs) / len(crabs)) - -print(sum([cost(x, avg) for x in crabs])) diff --git a/07/input b/07/input deleted file mode 100644 index a2cb8f5..0000000 --- a/07/input +++ /dev/null @@ -1 +0,0 @@ -1101,1,29,67,1102,0,1,65,1008,65,35,66,1005,66,28,1,67,65,20,4,0,1001,65,1,65,1106,0,8,99,35,67,101,99,105,32,110,39,101,115,116,32,112,97,115,32,117,110,101,32,105,110,116,99,111,100,101,32,112,114,111,103,114,97,109,10,14,94,153,512,1778,1219,522,207,112,148,1185,380,530,502,957,898,71,10,719,47,51,188,188,1277,446,156,188,990,370,549,1086,49,150,42,50,976,456,24,526,183,206,887,3,487,11,111,933,1059,51,439,30,258,901,19,1207,718,404,498,79,83,58,520,267,109,933,4,174,748,66,463,514,378,708,103,1073,364,224,254,28,196,95,30,567,633,943,3,63,1369,1754,342,651,139,8,10,535,1,841,89,306,86,621,51,872,806,212,926,930,390,665,163,291,357,724,861,106,793,222,33,215,81,1100,641,813,1073,276,1416,991,318,505,1112,1556,1309,1222,504,72,126,1143,261,347,1022,668,146,111,982,250,247,589,42,99,305,722,1286,732,16,248,234,140,492,1229,342,204,113,137,597,44,78,484,285,431,502,258,1329,1143,364,814,0,489,1070,837,56,17,784,636,809,342,50,713,71,280,674,1586,321,255,143,47,184,62,1133,4,24,470,5,269,11,316,2,472,535,1011,854,1543,614,605,404,1010,757,129,91,889,10,30,429,625,816,107,1367,69,272,466,335,851,723,574,121,37,23,256,920,4,1280,405,731,249,930,135,306,448,1027,27,932,4,352,703,258,652,1121,89,478,189,75,1204,33,869,1483,191,64,136,1622,651,294,458,944,819,68,1635,29,301,591,1195,82,783,1411,841,96,1370,272,403,10,87,1233,71,108,430,992,19,258,171,1812,509,671,212,228,252,22,1477,344,359,639,351,1187,44,300,318,92,189,153,1141,606,679,710,148,62,335,138,1074,1131,658,533,356,462,434,759,1036,436,4,1031,387,80,223,1152,125,515,32,243,239,31,1277,1151,252,565,12,700,117,90,83,194,22,196,73,460,560,133,351,237,167,21,694,9,287,114,128,130,190,1271,382,652,834,261,907,1697,377,854,241,1019,959,945,1397,1095,1009,1337,647,631,1019,83,1691,540,544,648,685,133,64,283,1599,55,10,37,25,614,93,98,503,7,200,376,64,636,471,110,491,402,795,388,1453,713,717,122,680,297,942,117,88,1467,123,1056,1295,1100,1343,956,133,6,498,1687,35,959,380,97,2,351,1556,749,246,700,157,1216,571,448,730,1515,47,535,102,1550,486,551,387,0,430,434,205,351,701,421,536,308,247,88,25,329,264,464,1441,77,18,1712,353,1672,56,220,328,74,973,249,489,815,589,607,927,158,63,13,49,573,280,350,66,553,233,69,314,78,961,469,821,605,959,48,1346,968,222,1365,473,917,137,782,322,603,989,277,45,73,265,276,242,342,257,699,221,334,259,806,812,54,89,1551,109,271,1642,151,1158,228,109,10,306,1308,817,1618,1430,839,146,33,650,241,83,644,109,120,637,317,190,48,1113,1547,68,765,230,422,1066,421,22,189,1060,375,907,363,1051,34,465,572,611,629,535,1097,1015,915,616,13,448,36,29,129,195,1423,839,56,125,430,571,747,449,435,446,387,569,22,1721,90,978,1659,93,1826,115,334,219,333,122,725,162,707,17,1103,38,172,65,438,1143,763,115,328,13,257,117,383,912,673,130,128,222,318,785,1505,887,110,1706,786,192,524,1265,40,276,408,63,86,315,648,222,17,1127,460,341,414,204,991,14,68,354,201,110,1613,477,345,1991,452,5,446,68,456,683,144,336,149,1204,736,934,1256,112,26,478,185,1361,997,220,292,52,385,130,107,61,39,368,757,466,120,787,576,355,701,52,212,448,103,712,679,94,465,788,93,884,29,214,470,120,216,406,662,642,452,704,156,484,29,41,1639,286,1325,535,101,53,408,1727,684,276,314,36,1393,1448,34,12,158,118,433,1320,617,68,395,174,83,549,1032,871,239,325,454,923,1324,470,532,214,1308,278,213,155,94,514,18,1278,467,481,194,932,122,619,796,1296,979,884,1176,230,457,61,162,571,1246,631,840,135,76,293,517,789,314,772,674,406,1302,9,86,53,1019,376,1688,203,1328,840,322,17,249,1192,5,353,304,476,739,299,1495,162,49,226,421,19,20,1179,4,438,244,298,117,46,107,133,407,190,146,1063,485,132,348,15,804,343,227,1108,29,1141,1413,1412,181,489,146,227,1136,86,612,1256,862,120,3,129,373,1240,428,1119,13,168,34,609,655,260,94,634,1136,1567,165,0,1079,11,39,27,456,391,79,1908,1062,141,6,1081,209,642,1726,83,141,2,254,393,83,246,1355,1085,786,453,213,1536,756,351,405,1925,3,1,12,615,303,423,10,1365,181,1510 diff --git a/08/a.py b/08/a.py deleted file mode 100755 index 4d87c18..0000000 --- a/08/a.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python3 -import sys - -count = 0 -for l in sys.stdin: - seen = False - for sig in l.strip().split(" "): - if sig == "|": - seen = True - elif not seen: - continue - if len(sig) == 2 or len(sig) == 7 or len(sig) == 4 or len(sig) == 3: - count += 1 - -print(count) diff --git a/08/b.py b/08/b.py deleted file mode 100755 index 7a58648..0000000 --- a/08/b.py +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/env python3 -import sys - - -# Map abcdefg -> 1234567 (orig positions) -def mapit(preface): - M = {} - - def mset(sig, val): - if val in M: - print(val) - print(M) - raise Exception("val already in M!") - else: - M[val] = set(sig) - - todo = preface[:] - while todo: - sig = todo.pop(0) - if len(sig) == 2: - mset(sig, "1") - continue - elif len(sig) == 3: - mset(sig, "7") - continue - elif len(sig) == 4: - mset(sig, "4") - continue - elif len(sig) == 7: - mset(sig, "8") - continue - elif len(sig) == 6: - # either 0/6/9 - if contains(sig, M, "4"): - mset(sig, "9") - continue - elif "4" in M and contains(sig, M, "7"): - mset(sig, "0") - continue - elif "4" in M and "7" in M: - mset(sig, "6") - continue - elif len(sig) == 5: - # either 2/3/5 - if contains(sig, M, "1"): - mset(sig, "3") - continue - if "1" in M and ("6" in M or "9" in M): - if contained(sig, M, "6") or contained(sig, M, "9"): - mset(sig, "5") - continue - else: - mset(sig, "2") - continue - - # unfound, retry - todo.append(sig) - - return M - - -def contains(sig, M, query): - if query not in M: - return False - - for c in M[query]: - if c not in sig: - return False - return True - - -def contained(sig, M, query): - if query not in M: - return False - - for c in sig: - if c not in M[query]: - return False - return True - - -total = 0 -for l in sys.stdin: - # Sort into two buckets per line - seen = False - preface = [] - output = [] - for sig in l.strip().split(" "): - if sig == "|": - seen = True - continue - if seen: - output.append(sig) - else: - preface.append(sig) - - # Now get a mapping... - M = mapit(preface) - - out = "" - for o in output: - s = set(o) - for m, v in M.items(): - if s == v: - out += m - total += int(out) - -print(total) diff --git a/08/input b/08/input deleted file mode 100644 index 3396836..0000000 --- a/08/input +++ /dev/null @@ -1,200 +0,0 @@ -dac abcf ac fdbcga dgcbae gcbfde fgcbd agfed adcgf cdbgfea | cbfa bcafdg cbfa bafcgd -abfgd baedc feb fgde fbagcd facbdge agcbfe bgafde fe ebdfa | bef fe dgfe feb -dfc dc afegbc bcafe fcead agefd cafdeb fcbeadg cbed cabdfg | cd geadf cfd bfaec -efacdgb abefdg efagbc af afe gdeab dbfa dgefa acegbd cdegf | cfdge gefda ecbgdfa eaf -feg gdbea edgbca gefdab caefdbg egfda afdgc fe cgfdeb efba | edafbg bdefgc egdfa gbead -bfeac becfd cbgdf gfabed gdefcab dcae edb de bgfaec fdeabc | bcfdg eagbfd fedbc cefdb -bgecd cea acegfbd ac gbefad cgdae fcag dfega abfedc gecdfa | gfdbae gcaf caedg ac -acbdfeg bfea agfed cedbg gedfba bfg dcgfea bf agfcbd gebfd | fgedb aefb gebdf fcgeda -gdcbfa agdfebc ecb fgcba ecgab efgcbd degca egfbac efba eb | egbfdc bfgcda ebaf gecda -gfcade fgedc agcfeb agdcbf dcae cgefbad ce ecg cdgfa dbfge | ebgdf fgcda gec feacbg -gcade fcdbea afegcb eafgc acfdbg aecfb fag dgcbafe gf bfge | decga gfeac gebf ecgbfa -fd dceabg bcgdef dcefag agcbf gcbfd gbceafd cdf dgebc fdeb | cgafde bdgec aegfdc gcabf -edgafbc bgaedf dbefcg efg fg acfeb bdega adgf cdeabg fbgae | dgacfeb egdfbac fbeca dabceg -dfecgb ecagbfd ceagd dgb dcfb bcegf abgedf cgbde db facgeb | efabgc ebfgc gdbce bdg -bcg dbcgea cg eadfcb agfbe cagd dacbe fcbdge abcge cedagfb | dbacgfe agdc dbcfgae bcg -dgf dfea cbadg gbeafdc fgcbae fgacde gcafe dgfac dfcbeg df | egdbcf eadf agcfd gefac -da dcgfae dac afcdg edaf fgbaec ebgadc gcfea cabgdfe dgbcf | dac fbaecgd fead ad -ecd bdecf bgdefac bafcd gdacbf eafd bcgdea bgfec bcadef ed | fgbec ebcfg fedcb cfdba -edacgb df gaedf gacfe dbegcfa dfg bfegda begad dafb cedgbf | faceg ebadfg fbdcge abfd -dgeca ebdfa dacegf cgba bcd bc acdbeg edacbgf edcab gedbcf | bc ecdag cb edagc -facbde deabfg daf gdbac efcd abecgfd cgafeb facdb fd bacef | baefgc edabcf dfce cfdbea -bafg gdfeb agbdfe ag adfge aedfc dbecag cfgedba bgedcf dga | ga dgefa gbaedcf fgebd -bcfed cafe cgbefd edfcab fa bgade dabfegc efabd fda gacdbf | bgade ebfdc decbf cbadgf -fcbgdae agef bcgda af cfbaed gdefc cfa dfcgeb gafcde fdgca | dafceb dbagc adgcbfe cdbafe -aebdfc dgcf aedgcb acdeg cfe fc dcfega bfage fgace cgfeabd | aefgc dbgefac egbfa egafbdc -bfgde bcdagf bga ga gfea abcde eafbgd edgab ecdbfag fecdgb | eacbgfd egbfda cdabe ebdgaf -fbcead afcdgb fbadgce fdabge ea adec aef afcbd ebgcf fbcae | afdebgc bafedg efa dfbca -gedafb fad gfeabc dgcf dfgabc bdaefgc dfcab abedc df gbacf | fagecb abgfc df gbacf -gcdeab efadg dfbc cebad ecafd efc bfcaedg acgefb dcaefb cf | ecfgba acedb fbeagc dacfe -gdfbc aefg adbceg fgabd fdcbea fa abfedgc bdaeg baf debgfa | fba debafc gaef cdbfg -cgbed dce gdebf fdecgab caedgb ec fagced bcae dbagc agdfbc | beafdgc edc efgdb edfcga -gdcbf fcga dcfbeg acfdbg cda agebd dabcg edbacf ca afdegbc | dac cfdbg bfecad bfcedga -gbacdf agef ebf gcedb cfgedba cagbf begafc gecbf ef cafdeb | bfe bdefgac ebf fadbgce -fdacg efdacb ebgd fdagb bfd dgbfaec efgbad cbaefg bd eagbf | baefg gecafdb ebcfgda cefagb -degcf ea afecgd fecgbd fecbdag cfaeg deabfg acde bgcaf fea | ecdgf eaf agefc gefcad -afegbc dbcfea bgefdc gadbc fbeac df dfb adbgcfe fcdab aefd | aegdcfb cdagb efabcd ecafb -cbagdf efgadb db bdg fbgeac dfcb daceg acbgf fbgaced dagcb | dgb dgebfa dgb faebgd -fcedb dcbage bc cfadeb dcb degacf gfcadbe dacef fabc gbfed | gfedb dbacef dbc dabcef -gefad ebdcfag ebcgd cgefdb abcdge ebf bf cgfeab dfcb ebgfd | dgbef afdge gfdae bdgec -dgbca bg gdb ecabfd efcdgba cgead begfad bcfg fcdba cadfgb | agdcb cdgfeab fdcgaeb gdafecb -egbdac gab edacb ag bgdfcea dbega agce agfcbd aebfdc debgf | fgbadc bag cbaegdf cdeagb -gafced agdf cdefa agfceb cbgaefd gecda agc debgc beacdf ag | dgcbe fgda gfad bgcefa -afegcd gc afecgdb bgfcd gfc fgdcbe bdfca gcbe begdf eabdgf | cgdfbe cg dcbfg gecb -afb bf afbced aefbc dgceab edabc fbcd befdga ecbadfg fcaeg | fb fdabce fbdc cbfd -fedba efdbgc fecagd dbc gdfacb ecdfbag bceg bc bcfde cgdef | cbdfge bgcfde acfgdb bdc -fd efacdb bcdgef fcegb fdb dfegb egadb ecabfg fbgcdae fgcd | dcgf gfdbe gdfc efacgb -cfbea gdbceaf bdafge fge gf afgd dacgeb dbgfec abdeg gbfea | gdaf dfcgbe fdga febac -bdgeaf gacedf gedafbc cgebfd cf fdcb cbage cfe fedbg bfceg | gbaec decagf ecf cf -eacfdb fb gcabf gbdf gfbcade afb dcfag gcabe acgbfd dgcefa | bgdf dabcegf gbafc acfgb -dbeafg fac degfc fgcbad dgbaf gfaecbd bfecda bacg dfagc ca | adbgf dgaefb acbg ac -fbdagc dfcea defgc fad faeg debfgc baecd af bgfcade agfced | ecdba dgface abdec gabdcf -dcabef gcefdab cadg dbfgae ceadb gd bdgce gdb dgceab efbcg | ecfbad dcaeb gbd adbcfge -cbegf ef cebfgd gdfabe cbagefd efg baecdg cfabg efcd gbedc | debgfc gdafbe baecdg agfecdb -fagbce aefbg eafdb gebcfd ga gaf eagcfbd ceag fbdcag cbgfe | cbgafd ga gfcbda ga -aecdf bgfadce eb acgbf dagfcb ecbagf defcbg cbfae fbe gbea | egbfca cafbe ebf bfe -bcgeda cb bcaf dbfgeca cdegf fdbeag ebc dcfbae bfcde daefb | efadcb gefcd fabedg cafebd -bcf fdgcb fdaecg gfcda dbcge fb cfegab afdb fdcbage acbdfg | cdgbf fb dgbec gcafeb -dfac bgefca ebdacf gdefabc gafebd fc dbcef bcdge fbead fce | abdfge dabfe cf afebcdg -dfabcg eagd cdegb caefb cad da adbec degfcb gdecba afgebcd | edgfcab adcbgf egad defgcb -gbefc fd becadg dfg abdfgc cfgbd afdc afdebgc gcbad bdgefa | bfcdg fbcdg cgbda abcgd -ce cebdgf aceb feacg bfecga fce aebfg ecdgafb dgbafe gdcfa | cfage fdcga fcaeg gcafe -gbac fceagb gadecfb ebagf gefbc cdebf feagdb gcf cg fadegc | agbc cfg fbdgea feabg -cd eacgfb facbe cfdeab afgbd bdfac caed dbgfaec bgdcfe cdf | acdfb afbdc cdf eacd -dbfgae geabf aefcg ebcgdfa eb feb agbdcf degb bfadce fgdab | fbdga gbdefa agbfd be -cdaef bdgc agceb becgad egfcbad cabde bda efbgac bd dbegaf | befagc bd ebcgda gabdce -ae gabdfe agdbf deabf febcd acegfb edga adegfcb fcgbad bae | dcabegf dgea geda abe -eg agec cadgf fbcdeg adgfe dcegbaf efg dfcagb fedba cfgade | adcgf gdcaf gef gbcafde -gfe cfgdab gafdb geda gefbd bfdgea bfaceg fedbc eg aedbfcg | gaebcfd cdafbg afgbcd ecdfb -fgbca dbf fd ebgad gafdb bgdaef fedgcab dbegac fged dbcafe | afdgb bfd dagbe befdag -dfgca aegdfc da fcdgaeb ebdcaf deag gfeac bgfdc ceafbg afd | daf adf gacfde cbdefa -adb gcabd cbged fgdceab cbgfa bdcfae da bgcfda dagf befgca | fgcab ad bda gcbad -edgfbc fbgecda bgcfe dc aecbgf dgbc cdbfae gfedc gdaef cde | cde fegbc edc befcgd -cebdg dfc bfde cagfe edcbfg fegcd cdbfgea afcgdb ecdbag fd | fd cfd gcbde feacg -dbgfc ebcfa gfbac aegf cfbage ag feabdc gdcafeb agb dcbgea | fabce afeg bacgefd gab -abgec cefbgad gfabdc feagc fag fgdce fbae af acgbfe bdgcea | decbgaf gfecd fcabgd fecdg -fgdcb fbagde fdgeb daefgc begdcaf baeg feg ge efbda dcfabe | dgcebfa eacdfg fdegb abeg -fdaecb gebad baedcfg gcde beg dbeac ge bgfeca bgdfa egbadc | egb gaedbc aebdc fbgda -becfdag gaefbd fcga ebcgda egafcb bgeaf gbefc gc cbdef bcg | ebgacf defcb acfg fcbaegd -fdgbea fecbd ebc ecdgf bgefdca cdbfae cb daebf ebgdca bacf | decfab bce cdgfeba ceb -bgc gfeba dcagfb bdfc eabgdcf dfgca gcefda cbgdae gfacb cb | agcdbf daegcfb fdcb bfcd -adefgc dc dbcage dcgf adc fdaec cbdgfae afebc abdfge fgead | dfbgae fcdg edafc cad -egca bfcade ga dag eadcf fdebg adfcgb dacgef egfda egdafbc | cfabgd gbdcaf cabfed bdfgac -dfgacbe ae ceafd cdgafe aec cbfda edcfg cagfbe dgea fgecbd | bcafd fdagce ace ea -fgbade bfedcag gdceba bf cedafb afb becda adfcg fdacb cefb | bf fba dcabe cfbad -acgeb dabc db cdebgf adgef gbd cafegb ebadcg aebdg fcbdaeg | gabec gebca abcge dagceb -egdcf fbgdec fb gdeacf gbfd bef bfcde becda egfcba gafbdec | dbgf fcdeb bdecf bfe -af ebdac dgacef abgf ecdbfg gefbd eaf abgcfed fadbge dfbae | fgaedb efa edfcga ecbad -ge fdbge dbgfec aecgfd gef bcge gfcabd befdgca cbdfg fedab | bedfcg gdcabf fge fge -cdbgea dge fcgabd deacbgf fdcea dcagb eg caedg bgae bfdegc | adgebc cegbfd dge egba -bgcfade bgedaf bfgc edfac ecgba efb bf dgaecb caefb aebgfc | cgeba efb abedcg gefacb -dfgec baedg egbdcf egbafdc egacfb efdcag gca cgade cfda ac | ac cdegf deacfbg edcag -dfeabc ag afbcge bag bfcdg adeg fgdcabe edcab dcgab edcabg | fgbecad bdcea bacefgd bdcafe -febdg fgdcba afdbgec gaefb aecb afcge ba abf abfcge cafged | afb gcafe fbgea aegfb -dab caedbg baecfg bafed db dbefag efbcgda afbge ceadf gfbd | bd ebfad cgbeaf db -fbg dabefcg dgfc gf fadegb ebgcf cgaeb bafdec befdc fdbgce | fgb bafdgce dgcf fabdge -gdfebac gdceb fcadge fgac cbeafd gaedfb dcfae age aegcd ga | deafgc acdef ga adfcge -begcfd cgf cg gcbd agedcf cbfaed bcfge cefdb aebgf eafgbcd | fcbde fgbea febcg gcdb -befcag befdcg fcdg bcefdga gebfd bfgec geabd fd bcefda fed | cegbf cgbeaf aebfdc geabcf -cdfeba cgabdf afbdceg bea decba ea eadf bcfda fegcab begdc | ebcgd eba ea baced -bcedg ac dca gcaedf bfdae dafgcbe dbgeac egfcdb bacg abecd | daefcg acgb ac bgefcda -bfegca bf edgbacf agcef feb fdcgea cbaf becdg cegbf afbdge | bef cbaf bacf fcebga -edg afbcdeg cafed cafged geca degfa gbafd ecdfbg ge eabcfd | bdfga dgafb deabfc dface -gfa afcgb cfgdea ga fdbcg febcad aecbfg aegb fcbae dgbafec | cfbea afgecd fcgab ga -edgfbc adbcgef gdabec egf dfega fdabe fg dfcage afgc cadge | dabfe cdaeg fge befgdc -dagecb ed cdgfb edcgb becag adbe egdafc cgabfed ced ecabfg | egbdc cgeab efgcdba cbfdg -afg egdacb gf dfgca fegcab cdaef dgabc afdcgb gdbf fdgbace | dcgfba cefdgab bfaedgc ecfad -ace agbecd eagf gfbdca cefda fdbec dacfge gfdca ea cbdgafe | gbdcaf deagfbc cafgd ea -efa baedg dcgaeb febdga efagd adgbcef dfba fedgc gabcfe af | dgafcbe dfba egbda edfag -fageb edgab da cgdeb fbedag ade afgecd begcfa acfegdb bdaf | ebgfca da ad gcdbe -ebfac dfbeg ecgfab acfg cg baedfc gce gfbdeac agedcb bfecg | gfeabdc fdbge ebacfd gacf -abfcg bgfea gbc bdgefca bdacf efcg gecbaf cg gbdafe bdegca | gadebc aebdfg bdefga gc -cedgb ebfa edcba dab defcab dfeca gacedf bgdefac cbgadf ba | abced abfecdg ba cgdfba -abcde aedcf afe bcfgdae fbec adcfbe ebdgca ef dbgaef dfgac | cbfe adebc adegcb aebdgcf -fdgcea aebdgcf egdabc defcbg efcba acbed gcdae bagd db edb | eafbc eabdc eacfb fcedbg -cefbd gefcb gf becafgd cfdbag gaef cagbe bgf dcaegb efgcba | bgf fage gefa fbg -ceafb fcegda fcbead cabfg dcgfbea aecfd eb bdcefg bef adbe | fedcag fgcaed gafbc cdfae -efcabgd fbcda efcad cfeg fde adbegc deagc aefdgc fe dbfaeg | dfe ecgf abfdc eagcd -dcebga afgbc gfbad efdbcag ca cfea efgcb eabgcf gcbfed cga | afcebg gecfb ac ac -gceaf dafgceb afcbeg geacfd fbcead bfa fb gbef acbfg acdbg | acgedfb fb gbdac fab -gbf bgecfd adgfcbe bfgec bfcgda efdcab gf defg bdcef gecba | dgfabec bfg fg becdf -dg dgb gbacd bdagfc gafd gaceb dbacfe fgebcd gfdaecb cbfad | gbecfd cagbe bdg abdcg -cdgbe eadcg dcb db bgecfa cegbdfa fdeb acgdbf becfg decgfb | febcg cgbde gfbcae edcbg -gcfdbae dgf dgeca dcfge dcegbf fcdeba fedcb gfbc afbdeg gf | edfcb dbafec dcgfabe fg -dfbaceg ab edcfb adb egabcd dgfbac fbag cfbad fagcd gedacf | fgdabc ab feacgd ab -debga ec edc gfdca agdce afegbd aecdgb bcea cbefgd baefcgd | gadfc defgcb caeb abce -edabfc fdaeg dgacfe bdacfg cfabdge efcda fgd gdce dg gfbae | abcdfg dfeag edcg acegdf -bagcfe afedc dbec fadecb fbdega ed afdcg aefcb efagcdb dae | cbedgaf gefabc decb ed -abe fadecg bfcage bcdafe ecfad afdgb afbde be bedc bfeacdg | bgfad fcdgeab be bcfgead -bf decgb efb bfegdca bgfd adfce fcdeb gabefc cdaegb fecbgd | decbg fb gdebc gdfb -gfcbed efdcb dafbcg db gedb deacf cgfbe bdf abfecg defcagb | bdfec cfdeb bd adecf -gceab gefbda bdegafc fgbd bedacf egd agdeb daefb fagedc dg | dg dacebgf bafegd edg -abecfg dgbca egc aegcb acgdfe agefdb bfec ce ebcdagf bfgae | bcfe bcfe acgbef gfedcab -bfacg eafdb cadbge fecbad gcbdafe ge dabegf egfd gae abgfe | ge efgba faebcd dafeb -gebd db gbcdfea fbd acebgf fedab agcbfd afecd befadg gbfea | bdeaf febag fgecab afcebdg -defac gdbfce dfbga deagbfc geadfb cbag cdafgb facdg cgf cg | eabgdf caefd cbag gfc -dafbc fgead edgfac cae gdabec fgeabcd ec acdef debafg cgef | ebcdga cgfeda efdgac cgeafd -ec dcbafe gbafcd dfgbc dec baedfcg faedg egbc egbfcd dgcfe | dce gbcefd gabcfde adcfeb -cbegdf ad aecgf befcad agdfc gcbdf adc cfgdbae dabfcg agdb | bdga bagd fcgad ad -edcbafg ab eafgcb ecdba egfdcb fcabed debcf abdf eba dagce | aeb dbcegf geadcfb aeb -bg gcefa aefbdc bcgae fbegacd cadeb fcegdb bgc eagcbd badg | bcgea adbfcge cebda cdegab -ebgad gf edfcb cegdab dbaegf agfd dgbcefa efdgb fbg gabecf | fcadbeg bcedagf dfbge gdaf -gbcfea ecdbga cgebf bdefcg fdbe de acgfd gedcf fecdbag ced | edfgcb fbde beagcfd gecabd -gfdceb aegbc ca cbdafg daebcg bac edac gcdbe abegf ceadfbg | ca bca gdebc decgb -cbfea fgadbe eacgf daefcb fgdeabc acdb ba bgecdf fba fedcb | cdfbega bcfea ba badc -cbfge bdca dgeba dce ebgcd dc gdebac fcgeadb beafgd fdceag | ebgcd gcdfae begdc agbde -acg cagdfe cebfdg dgcfa fdbac gdcef baegfc acdegbf ag dgae | cadfg efgabc egcfad dbcaf -bfae ea eadcfgb dcgba dacefb dcfaeg dae bdcef decba egbfcd | dgcba cdbeaf cedbf fcaegd -fcga agbedf edcgaf ca dabcef fegadbc ecgda eca gcdbe gefad | ca ca dgebc eca -bcead fd gbedfa adcgefb fdgcba bagfce adf fdbae dgfe abfeg | ebafgc fegd dfabe edgf -bca cbfgea cdabfe cedfa fdbc cgabefd cagdef eacbd cb bgdea | dcbaef cb bfcd cab -baedgf debaf edga bgafedc bda ecfbd ad bgdfac afgbe abcfge | aged bfedc abd cdebf -acgdb agcdef egc baefcd cfead fbdgeca ge dgace gaef dgcfeb | cbeafd acfed ebfdgc fdceag -dbegfa ef fbagce dcgfab efb agfbc cegdfab fecg dcbae aefcb | bgdfea afcgbe fe bafcg -eabdf fegb aecfgbd fg cabdgf agf dgeca adegbf dacfbe dgefa | bdecafg fgbe agbefd fabed -gdbec facbeg gbedf egabc dgaebc dcb adgc baecfd cd ceadgbf | dc dc cbaefd cgdbeaf -ef cfgab fegbc bdecg adbcfge agebfc bafcgd acfe ebf dfaegb | fbdgae ecfbg feac afec -agdebfc dae ecdf bfacge fegca dabcg de gdace gdabfe cfgead | egbdaf gabcd dea gfbace -ecg gabce fdecbg edacgb eacbf aegdb cg fcbeadg abgfed dgac | dbgae gec geabc ebcgdf -fabec fd egdfca dcf dcfgbe dgeabc dgecb febgacd bfdg dfbec | beacf df egacfd fbcae -eacf gfebad cefgad adcgf af bceadg dfa bfdgc gfeadbc ecadg | adf aefc dfagce caegd -afgbec fbgdc ag gaebcd agc gfdeacb bcefa ebcfda fgbac fgae | fbgdc bdgfc agc dacbef -bc bfcad cbgfed baec cbd fdacg fdbae aedgfbc faegbd cdbfea | ecgbdf gfbdea dfcag beca -bedgafc fbdea efgdbc edg cefg fbgdc eg cgafdb febdg egdabc | fcbgda ge cbagdfe gbdcf -bgdeca fadcegb adg cfaegd bdae edcbg ad bcgfa cadgb fecgdb | dafgce gecdba dbfegc edbgfc -ecgafd faebg gbce defbacg ebfagc eab fadecb be aecgf dfgba | bfgae dfabgec efacg ebgfa -edfg fad bgead cgaebd bcdgaf fdebgac dafgbe ebfac badfe df | eabfc begfad dgbea dbeaf -cdaeb acdbfg gfeac aefcd gecfad gefd bfgcae fd beacgdf daf | egcaf gbdafc bagecf fedg -gf aefcd adegbc fecdgb gcebd fcbg cgdef edfabg eadbfgc dgf | bfgc bgecd gdcefba abcdeg -gfdcbae cegdab ecgbf dcabef cegdb caegf fbgd bf bfe edfbcg | bf cbfeg ecfag bef -befdga bcagdef ebgaf bcfega ce cbge gfacd cae cfaebd eagfc | fdgeab cgeaf fgceab eacfg -adgbe gcadbef gbfe befadc fdbga agced bde acbfgd fgbeda eb | abefcd dfcaeb gaecd decga -gdbfec fbdce fgcade ebadfgc cb eacdgb bcd edfba fgbc edgfc | gfeadcb bfead fgbc cbd -dfaegc deabgc fabdceg gcf fc fdbcag cfde gacfe fbeag aegcd | afedgc gcf cfed fdec -acdfb dfaec bdcfga ceafbg gedabc fbgd bf cgbad cbf fdgcabe | bfegcda gadbc cdefa caedf -cfgae dcfageb gbdf gebacd edcfg cdg cdbef dg cdfeab bcefdg | geacf dfgb dg facge -gcdab dabgec fecadg ae cbadgf ade cbaed beag cebdf cbdfgae | bacdg eda facbedg gfbdac -fd dfgbcae bdf fgbda cgabf beagd cbadfe gdabfe dbaceg fdeg | fbd gdbae cdebgaf fadgb -ecgdb bfdgec fce caebgd fc fageb fcedga gcebadf cbdf egcbf | decgb cdgfea edcafg cfdebg -bafgd abcedf egb bdacge fageb adecfgb febcag fecab cefg ge | ge bafec ge ge -agcbd dac dcebfga ac ceba bcged gaedfc ebgdca adgbf cbfged | bgfad bace fecbgd adc -agcfd cag gbecfad agdfe gcedfb cbad ac cgbfae bdgcf acfbgd | gbafcd eafbcg gdafe cgefab -geadfc bfeg bf bcf bdgca ceadgbf eabfcg bgcfa cfedab afgce | acefg gacdb agecf cgbfa -aecbd afced af dfcge afbc edfcab cgbeda gabfde afd faegcdb | fgedc dfaec bdfaec cdegf -dcbfge ab bdgeca bae gcba debcg dagbfe gdeacfb acedb acdfe | cdbgea adgceb ebdca aegdfb -ecfadg agfce da cfbgea dae aedcg bfaced cgdbefa debgc dfga | eacdg afcebd faegc bafegc -df fdg dfcega gfbce aebdg bdafge bfad egbdf dbafgec acdgeb | afgedb egfdb df fbad -eafbc egbac fcb cf cgbadf becdagf cbdaeg efagcb aefbd ecfg | cf cf cgfe acegb -fceab cedfabg fc fadc cgbea bdfea egfadb gecfdb fbc abcefd | bfc ebafc aefcdgb bcafe -gb efadb dcefba fdcga fgbaed fadgb feagcb ebdg beacgfd gab | gb feagcb gb acbdegf -ebc acgedbf gcfeb edcabf bc bcgefd bcdg gcefd gdfeac egbfa | gcdb gcdfe cdbg dbafce -bgdc efacdg dabce begad cgbaed fabeg baefdc fabecdg gd edg | edabc gd geabf gafeb -gaecdf fabc fgaec bc bgc gcfbe bgcdea dgebcfa efgbd afebcg | afcbeg adgfbec gcb gebafc -aef facedg fdgbce cade fegcd fbacgde faecg gfabc egdfab ae | bfdeacg edac eaf fgedacb -eafcgd cebgf fdc debcfg dbcfg afbgec dc fdbga dbce cedfabg | cgeabf facedg bcaegf bdfgc -afegbdc bcaefg decba gdfb aedgfb efb adfge bfade agefcd fb | cfaegd gcdafe ebadf gecfad -afcb bgdcfe bacdfe ceadf cbefd caged bgedaf af egfdbca fda | adf ecbfd efdbc adefgb -cgdaef eagfb afdbge gfedb ecfbd agbd cbgefa gd agcbefd dfg | agcfbe fgcdae fdg fgd -ed afbge fbcaeg bcdfa gfeabd gfed egbfcad geadcb adbfe ead | begadc abefg dea dea -fceba deafbc aegc edbgafc bfdcg ag dbafge cfbeag abg cafgb | gab agb abfegd ecga -fcedg cfdaegb dbfg egcfbd bgc cgbefa cebgd ecbad bg dceafg | cgb fcbgae ecbda gebcd diff --git a/08/input2 b/08/input2 deleted file mode 100644 index aefdff2..0000000 --- a/08/input2 +++ /dev/null @@ -1,309 +0,0 @@ -cbfa -cbfa -bef -fe -dgfe -feb -cd -cfd -ecbgdfa -eaf -gcaf -ac -aefb -ebaf -gec -gebf -dgacfeb -egdfbac -bdg -dbacgfe -agdc -dbcfgae -bcg -eadf -dac -fbaecgd -fead -ad -abfd -bc -cb -dfce -ga -gbaedcf -adgcbfe -dbgefac -egafbdc -eacbgfd -afdebgc -efa -df -fba -gaef -beafdgc -edc -dac -bfcedga -bfe -bdefgac -ebf -fadbgce -gecafdb -ebcfgda -eaf -aegdcfb -dgb -dgb -dbc -cdgfeab -fdcgaeb -gdafecb -bag -cbaegdf -fgda -gfad -cg -gecb -fb -fbdc -cbfd -bdc -dcgf -gdfc -gdaf -fdga -ecf -cf -bgdf -dabcegf -acbg -ac -gbd -adbcfge -agfecdb -ga -ga -ebf -bfe -fb -cf -afebcdg -edgfcab -egad -agbc -cfg -cdf -eacd -be -bd -dcabegf -dgea -geda -abe -gef -gbcafde -gaebcfd -bfd -daf -adf -ad -bda -cde -edc -fd -cfd -afeg -bacgefd -gab -decbgaf -dgcebfa -abeg -egb -acfg -fcbaegd -bce -cdgfeba -ceb -daegcfb -fdcb -bfcd -fcdg -cad -ace -ea -bf -fba -dbgf -bfe -efa -fge -fge -dge -egba -efb -ac -deacfbg -fgbecad -bacefgd -afb -bd -db -fgb -bafdgce -dgcf -ga -gcdb -eba -ea -acgb -ac -bgefcda -bef -cbaf -bacf -ga -fge -efgcdba -cefdgab -bfaedgc -deagfbc -ea -dgafcbe -dfba -gfeabdc -gacf -gc -abfecdg -ba -cbfe -aebdgcf -bgf -fage -gefa -fbg -dfe -ecgf -acgedfb -fb -fab -dgfabec -bfg -fg -bdg -dcgfabe -fg -ab -ab -caeb -abce -edcg -cbedgaf -decb -ed -fcdgeab -be -bcfgead -fb -gdfb -bd -dg -dacebgf -edg -bcfe -bcfe -gfedcab -ge -afcebdg -cbag -gfc -dce -gabcfde -bdga -bagd -ad -aeb -geadcfb -aeb -adbfcge -fcadbeg -bcedagf -gdaf -fbde -beagcfd -ca -bca -cdfbega -ba -badc -eca -fegd -edgf -cb -bfcd -cab -aged -abd -fe -bdecafg -fgbe -cgdbeaf -feac -afec -dea -gec -df -adf -aefc -agc -beca -ge -cbagdfe -dfabgec -fedg -bfgc -gdcefba -bf -bef -gfeadcb -fgbc -cbd -gcf -cfed -fdec -bfegcda -dfgb -dg -eda -facbedg -fbd -cdebgaf -ge -bace -adc -df -fbad -cgfe -bfc -aefcdgb -gb -gb -acbdegf -gcdb -cdbg -gd -adgfbec -gcb -bfdeacg -edac -eaf -fgedacb -adf -fdg -fgd -dea -dea -gab -agb -ecga -cgb diff --git a/09/a.py b/09/a.py deleted file mode 100755 index 7dad784..0000000 --- a/09/a.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python3 -import sys - -grid = [] -for l in sys.stdin: - grid.append([int(x) for x in l.strip()]) - - -def lowest(r, c): - pt = grid[r][c] - if r > 0 and grid[r - 1][c] <= pt: - return False - if c > 0 and grid[r][c - 1] <= pt: - return False - if c < 99 and grid[r][c + 1] <= pt: - return False - if r < 99 and grid[r + 1][c] <= pt: - return False - return True - - -risk = 0 -for r in range(100): - for c in range(100): - if lowest(r, c): - risk += grid[r][c] + 1 - -print(risk) diff --git a/09/b.py b/09/b.py deleted file mode 100755 index bb41cc9..0000000 --- a/09/b.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python3 -import sys -from collections import defaultdict - -seen = {} -grid = [] - -for l in sys.stdin: - grid.append([int(x) for x in l.strip()]) - - -def search(r, c, color): - if (r, c) in seen or grid[r][c] == 9: - return - - seen[(r, c)] = color - if r > 0: - search(r - 1, c, color) - if c > 0: - search(r, c - 1, color) - if c < 99: - search(r, c + 1, color) - if r < 99: - search(r + 1, c, color) - - -# Search from each point (no-op once seen once)! -i = 1 -for r in range(100): - for c in range(100): - search(r, c, i) - i += 1 - -# Finally, count the colors -G = defaultdict(int) -for v in seen.values(): - G[v] += 1 - -top = sorted(G.values(), reverse=True) -print(top[0] * top[1] * top[2]) diff --git a/09/input b/09/input deleted file mode 100644 index dc2701e..0000000 --- a/09/input +++ /dev/null @@ -1,100 +0,0 @@ -6769876887698999876367898543212378997654321291098765432398767667989976543210123456987678999766598921 -5456965476567999985457897654301456989743210989989898540987656545678987654323634679876569998757387892 -4349864345476889876778999864323699879654329879878987659876543434569998789434545798765459879543296989 -3298753212345678989889298765459989768965498764567898899865432523459999998587657987654365965654135678 -4349432101346789999992169876798778957896796553456789956976921012367899987699788998543234984321015789 -5498763212457899999743456989987667945997985432377894344989854323456789998989999987642149765632134899 -6569854343568999897654599797898543234589876545688943243498765434678999999878891298753259898543236789 -7679878987699598789775988676987632123578987656799654102349876545678999898566789987654345997654545678 -8999989398789699678989876545698821014567898787898743212357987656789998787355679999965456789765656799 -9889895459893987565699876123799935223698979898987654523456898967899987676234589999876767899878767898 -8679789599912398434989765234899876434899765989998765634567989978969876535123467892987878944989878987 -7567678989101995429878984349998989545999854677899876749879878989656998321012678921298989432192989656 -5434569878919876998767895498987987656789543456789987857998767898945987633234567899349999543943496545 -6323498767899989897656789987676698767898632355678998998987654567932398545345678988999987659894965436 -3210997856789998756545679878534569898987321234567899799999543656891239659459789467989998798769876547 -4329896545456987643334789964323457989876320125688965679898932345994398798998994359878999987756987678 -5679765432346987532123458953212345678985431234599954398767921256789459987987893249867899876545698789 -6789874321234597645634567894101558789996563545999895987656890127899569876546789197757598765434569896 -9892983210145698656747698943212467893987854559886789998967892234568978965435678986543459876545678945 -4921294929236798787958999656543569912398967699775698999878964345878999974324567996432345987676899432 -3210239898947899898767898769654578923999878987654567896989875458989999865435678987320123498787976561 -9854398787898999999898999898765689439899989299985898995490986567899989978947799987431434569898997610 -8769987676799998789969899949976896598789890199876789989321299678978978599656789876532345678979989891 -9898787545598987683456789534987897989678789987987895878932398789569765498767894987673476789764678989 -9987655633467896542347892124998949876565678976598934567893499893488964349878923498784587890123699875 -9996543212356789451234589039899934965454567895439123456954987942567899219999436569895698921234589964 -8987654101236893210123478949767899876323458987321012345699876543478988998999987678976789434345678943 -7898987654345789345234569998656787998434767896542324556789987654789876787898799789987896545756789432 -6789698895676997656745699887545476899547898987955456789895698765698765456789678999899998787867894321 -5456569989987898767896789786431265987656999099876689892934569876987762347896569878768989898978943210 -4343459878998939898987897654320123498767892129998994921012489989876543456789398765457679999999976731 -3232349767899323989998999865434634569979943398999323932125678997989654567893219854324587899989895432 -2101298956789219878999999979548795997898954997678919865434589876598785678954109543213456789878789543 -3432397545694398767899989987656989886887899876567899876745789985419876789865998432101578898769698956 -4563498434989459856989879998769878765976789965456789989899899954323987999999876563234567987654567897 -5654984323878998768978568999898965654365678974345678991998987895439999548789997696549699876543476998 -6979876412767899979765457989987654321254569893234789890987896989598965434598998989698989985432345699 -9899865401256789989987679878698765410123456789123456789896645878987654324687899878987679876321234589 -9798763212346894394399899859569896521434567893256599898795434767999743212356898767496589986410124679 -8679954323567989239212999743456985432545778965346789987654323456789894101234987656325498765421235678 -6569865434689678998909998632109876543656889876657899876543213456898765213456976543212349975434547899 -5450976545696567997898976543238989656767996987768976998654354567897654324587987643201467986545698945 -7321987968789459876567897654347898767898965498979895349765455678998765437678998754312588997656789323 -5432398979899598765498989765956999979939654329296789239878567889549876548789898765423678999869893219 -6543459989998679876989878979897898989529873210145892145989678999932987679896789876739789896978954998 -7656569998999789989876967898799967895434998721234799259998789878893498989945678989849898765989969897 -8767678967899994598765458945679656976565987632465678998999896566789599799434567899956987654197898776 -9898989656789543459884301236789745697878998543456789987899975465698987678923459989878998543236789545 -3999898745897692196543212345678956789989987657578899896789764314567898567894569878989999664545678934 -1298769896789989987654523898789879891099898968689998765699995423458965498789679768999989775656799224 -0989899999899878999765674789899998932198769989789349954569876534567894349678998957899879876767891012 -9878989998998769899876785678998797893239654399895456967678987687678943254567987846789954987898932199 -9767679987865456789989876789989686789398763212976769878789798798789652123979876535678893298999943988 -7754579876764345678999989899876545678909854323989878989897679899898761019899987621236789129498769877 -6543569885323236567897899999998656789212965439992999999978568999987653198789987540345891012389879656 -7632398764210123489965458998798767896369879598901298998769456789999964987667895431456789325478998945 -5421449875521238567896367987659988965456998987892987569954345678999899876543976432347895434567987934 -6530123985434347678963219876545699896567997676789645459893234569989789987659876545456976765679876321 -6521234596545458789954398987632346789679876585878932398789345698875678998789987678967897876789985410 -8434345987657679899899987654321456898789965434567891987695467987764567899897698789598998998993494321 -7545656798788789935678998985490123499999987323458989876569568996543456921976549896459789219654976452 -7658769899899892123789109876989234989898765434568969875458979987632345890987698965345678929769876543 -8769878987956921094599212989878949876769876745878957987567894596543456791998987654234567899878989655 -9878989896545699989698993498769998765456988656789345699678943987654567899899698754345678923989898767 -0989998787435678978987889987758789876323499767891234798789432398789878998765539965476989919899789878 -1296987658324234569896569876646678987212349898910147899896541019899989799654429876567896798788678989 -2345698943210123698765456985434568998101236989321256789987893223978998688943212989778945987666567899 -3459987654321235987654329876523457899212345678932347899998987654567897567892101497989239876555456789 -4598998796532349898543512987212678954393456789765478999899998785678943459983212345990198765436345999 -9987889987643498765432109832103589976989569898997567898788999899889012599876364587891239876521234789 -8956776798754569876543498765412367899878998946789678987657899910994123989765456698992946983210345678 -7842365679897678987674987654323456789967987897896989498746989329873249878976767899989897894323458989 -6531234589998989199876799985476567896754976789945799395439978998765398767897878901978789987434567899 -7810123478999899012987899876587678975463465678935678989598768989887469898998989329765679876545678998 -8921335567897778943498987987998789764322234569024599878987659879998567979999699498974598987656789347 -9432456678976567894999976598939897653210123478934988767998545568989878967894578987653987998968991236 -6543467789865478999899865439123998965323234569549878542987632459976989457993567987542196569879210145 -7656569898976567898767974321045679879434545678998765431298756567895490346989879898943987899989323234 -9867878967987689989856985434756789989565676789459976530459767878989321259978998789764598998996545345 -9878989456798789876549876545969891297678797892345987321346998989878932498767897678975989987987675456 -9989992345699899995432989658998992998789898901239876434456789596567893998654343487899879896598786568 -9898943458789989989321298767987989869896969912345987545589895433456789876543212396789868789439897678 -8797899879899879878934569879896878954945457893957897656678985322457899987752101245678947678921998789 -7656789989998664767895699999765767893234356789898998767989876301367999898943212386789234567892369893 -7545691099876543456789989987654456789101299895789459989999989212479998789654563498992123679965456921 -5434593198767552325699878999732345898999989954678969899998765323589987698765678989893234567896567890 -0125989987654321014598765987621234567988978912389998799879876494999896539898789678794347678987699921 -3234978998798775123987654599434348979876767923498999689765989989898797921999894545689956989998989932 -4549767899899654234599743398765457899765456895987698578954598875654689892988953236568897899989877893 -5998456789999874345987652109979567987854345679998567467895987654343456789877542123456798999875766789 -9876587893298765659876543212398999996543234567895432358999897543232345698765431012345689898754345899 -4997678954109878767987676378987678987642123458789521235798765432101256789876542123456998799343234789 -3498789543299989878999785459876567995431012345678944345699896953632367892987853234569877679210145678 -6569899654989597989239876569985479876532123456899765656789979876543456943498964348798963458921234567 -9699998799878456899123998698794321987843234569999876767898767987854567894579875499987654567894345789 -8989219987656345678934599987653210198967347678989987898987654398765679965679876989999965878965756899 -7478909876544234567895678998764321239878456789679998969898321239989989876989989878989876789879867998 -6367899998432123456789899219965432346989767896568999656789432387895491987893498767678989894989878987 -5256789987641015667899964329876563456799898965457898547896543456954320198912987654567899953492989876 -4345896595432124588998765545987674567899999876345987658987659767896431239109876543456789432101299965 diff --git a/09/input2 b/09/input2 deleted file mode 100644 index 6dee4a4..0000000 --- a/09/input2 +++ /dev/null @@ -1,5 +0,0 @@ -2199943210 -3987894921 -9856789892 -8767896789 -9899965678 diff --git a/10/a.py b/10/a.py deleted file mode 100755 index 7af6418..0000000 --- a/10/a.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env python3 -import sys -from collections import defaultdict - -match = { - "}": "{", - ")": "(", - ">": "<", - "]": "[", -} - -bad = defaultdict(int) -for l in sys.stdin: - mem = [] - for c in l.strip(): - if c in ["{", "(", "<", "["]: - mem.append(c) - elif c in ["}", ")", ">", "]"]: - m = match[c] - if mem.pop() != m: - bad[c] += 1 - break - else: - raise Exception(f"Bad char: {c}") - -# ): 3 points. -# ]: 57 points. -# }: 1197 points. -# >: 25137 points. -print(bad["}"] * 1197 + bad[")"] * 3 + bad[">"] * 25137 + bad["]"] * 57) diff --git a/10/b.py b/10/b.py deleted file mode 100755 index 4758311..0000000 --- a/10/b.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python3 -import sys -from collections import defaultdict - -match = { - "}": "{", - ")": "(", - ">": "<", - "]": "[", -} - -rmatch = { - "{": "}", - "(": ")", - "<": ">", - "[": "]", -} - -pts = { - ")": 1, - "]": 2, - "}": 3, - ">": 4, -} - - -def score(seq): - score = 0 - for c in seq: - score *= 5 - score += pts[c] - return score - - -scores = [] -for l in sys.stdin: - mem = [] - corrupt = False - for c in l.strip(): - if c in ["{", "(", "<", "["]: - mem.append(c) - elif c in ["}", ")", ">", "]"]: - m = match[c] - if mem.pop() != m: - # this is an corrupt line, skip it! - corrupt = True - break - else: - raise Exception(f"Bad char: {c}") - - # Figure out and score the remaining chars! - if not corrupt: - mem.reverse() - remaining = [rmatch[c] for c in mem] - scores.append(score(remaining)) - -ss = sorted(scores) -print(ss[int(len(ss) / 2)]) diff --git a/10/input b/10/input deleted file mode 100644 index 88ead12..0000000 --- a/10/input +++ /dev/null @@ -1,90 +0,0 @@ -(((<(([{{((<[[<><>]<()[]>]{[{}()]<(){}>}>[<([]{})>])(<<(<><>>[<><>]>(<{}()><(){}>)>[(([])<[]()>)])){<((<{}() -{(({({<[[[{[{({}{})[[]{}]}[{(){}}((){})]][{((){}){[]{}}}<(()())<<><>>>]}]]]{([<{<<()()>([][])>({[]()}[{}< -[[{<(([<<{(<[[()()]]{[[]()]<{}>}><{{{}()}<<>[]>><(())[()[]]>>)([{[[][]][()()]}{{()()}}](<{{}()}>))}[([{<< -{<[{<{[({[[[[{<>{}}<{}()>]<{<><>}{[][]}>](<<<>[]>[()()]>[{[]{}>[<>()]])]{{{[()()][<><>]}<[{}()][{}{}] -(<[{[{[((<{[[<()()><{}{}>][(<>{}){{}{}}]]{<[<><>]>{{{}[]}(<>[])}}}(<[[[]{}](<>{})]{[[][]][[][]]}>)>)){<{ -<<<(<(<[[[<[{{[]<>}([]())}([[]])]([[[]<>][()()]]{<()()>([]{})])>]{[[<{[]{}}([]{})>{(<>[]){{}{}}}]]{({{<>[] -[{<(({(<{<{<<{<><>}>({<><>}<<><>>)}{[{[]<>}[[][]]][<()<>>]}}<[[[()()]{<><>}]((<>)[{}()])]{<{()<>} -<[([{{{({<({(<(){}><[]()>)((()())[[]()})})[<{<<>>((){})}<[<><>]{(){}}>>{{(<>[])({}[])}(<()<>>)}]>})}({{({ -{[{{(<[[[<(((([]())[[]<>]){(()())[[]<>]})[{([]<>)[<><>]}<({}{})>])>{[(<<<>{}>(()<>)>)]<{([<><>]<[]()>><<{}[ -(<<[<({[(<{[({<><>}<{}<>>)]}<<([<>[]])(<{}{}>[[]{}])>>>(([{[<>[]][{}[])}<(<><>)({}[])>](<<() -{{[<(((<([{(<[<>{}]({}())>){{[{}]<[][]>}[{<>()}{<><>}]}}][<<{<[]<>>[{}<>]}[<{}{}>]>[<[[]<>]<()()>>[[[] -<<<([([{{<({[{[][]}[{}<>]]}<[(()<>)[{}<>]]>){{{[()<>]}(<<>>({}[]))}(([[]()][[]{}])<([]<>)[<>< -({[[[([[([<{<{{}()}{<><>}>}>])[{(({([][])[{}()]}{(<><>)[[][]]})<<<{}>[{}[]]>(({}())<()<>>)>) -<[{[[[<({<<[{<<>>{{}{}}}{[()[]]}]<[<[]<>>{<>{}}]>>>((<{{[]{}}{<><>}}>[{({}{})<{}<>>}]))}[({ -<({[<{(([[[{<<()<>>((){})><{()[]}<{}()>}}[([<>{}][()<>])]]<(([(){}])<{(){}}[[]()]>)<{[(){}](<>[ -[<<{{[<<{[<{({<>[]})({{}<>})}><<<<()[]>(()<>)>>[{{[][]}[[][]]}((<>)<<><>>)]>][(<{[[][]]<[]<>>}>(<((){}){[]< -({[({(<{<<<<{({}())(()<>)}><({{}[]}<<><>>){[{}<>]}>>]<((([{}{}]<[][]>)({[][]}<{}()>)))<<{[[]<>][[]()]}{<<>< -<[<<([<[(<<{[[(){}]<[][]>]<({}<>)[(){}]>}<[({}[]){()()}]({{}[]}[()()])>>><(<({{}<>}{[]()})[(<> -[[[([<<[<[<{[[(){}]((){})][(()<>)<()>]}(<{[]{}}{[]}>)>]{{[{{<><>}<()<>>}{[(){}]<<>{}>}]([[[]< -((([[[{<{[<{[{<>{}}]}({<[]>[{}{}]}<({}{})([][])>}>(((({}{})<{}()>){<<>{}>{{}<>}})(<{{}<>}{{}} -[<[{[({<[({{{<<>{}><()[]>}}{([<>()]{{}[]})({()[]}[<>[]])}}[{(<()[]>([]{}))<<()<>><[]()>>}{[<<> -<{{([({<{([<<(()<>)[[]{}]><{()()}<<><>>>>]){{<{{()()}<()<>>}>[{(<><>)<[]()>}]}[((<{}()>){[()[]]{()()}})] -<{[([{{[[[<<[<()<>><[]()>][(<>())(()<>)]>(([{}{}]([][])){<[]<>>([]{})})>{[[<{}[]>((){})]{<<> -{[<([{({{({({[[]()]{(){}}}<([]{})[<>{}]>)<<[()[]]>([()[]])>}{[(({}<>)<()()>)[{(){}}<{}{}>]]}>{[[{ -<<({{<<{<[{[{({}{})[()]}(<{}{}><[]()})]<{[[][]]({}[])}{(<>{})<()[]>}>}<[({{}<>}{<>()}){({}[ -([[[<<{<([[(({<>()}{[][]})[[()<>][()]]){{{()[]}(<>[])}<([]<>)[[]<>]>}]])>{(({{{[<>{}]{[][]}}}}<[(({}[])<<><> -[<(({<[[{([{<<()()>(()<>)><<[]{}>{()<>}>}{<<{}>>{{[]{}}<()<>>}}]{<{[{}<>]([][])}}<{[()()][{}]}>})(([[<{} -<{(<{(((<{<<(<<>>{<>{}})[([]<>)(()[])]><[([]{})((){})}<<{}[]>(<><>)>>><{{{<>{}}(<>[])}{[()()][() -<{<[<<[({<[[<{{}[]}><({}{})({}[])>]]<[<{{}<>}>]({[{}]{<>[]}})>>[<(([{}<>]){<<>[]>[<><>]})[(<{}()>{[ -(([[(([<<(<(<{()()}(<><>)><(<>{})<[][]>>)[<((){})<{}{}>>{{()()}{<>{}}}]>[<<<()()>(<>[])><(()[ -<{({{({<[(<{<(<>{})<<>{}>>(({}[]))}(((<>())<{}<>>)(<()>))>([[([]<>)<{}[]>][[<><>]<(){}>]][{<(){}>( -<<{(<(({[<<{[(<><>)[<>{}]]{<[]()>({}{})}}<(<{}[]>)[{<>()}<[]<>>])>>]{((({(<>[]){()<>}}[{[][ -(([((<([[([<[{[]{}}({}[])][<{}{}>[()[]]]>(<<{}[]>>)])([{(<[]{}>([]<>))}<[{<>}[{}<>]]([(){}][{}[]})>] -(([{(([{[<{<<<[][]><()<>>>(({}[]){{}<>})>}({{<[]()>({}[])}([(){}][{}<>])}(([[]<>][[][]])[{{}()}<<> -([(<<([{<[<(<<(){}>{[]()}>((()<>){[]<>}))[{([][])}<[<><>]{{}{}}>]>(({(<>[])[(){}]}(({}[])<<>()>)))]>{{[{[[ -{(((([<{({[(<[<>[]][[]]><(()[])[[][]]>)]({{{(){}}[<>[]]}((()[])<[][]>)}{{<()<>>([][])}<{()>>})}<<(({< -<[({<<{{(({<{{[]{}}(<><>)}<[()[]]<{}()>>)<<{{}[]}>([()[]]({}{}))>}){({{[(){}][<>()]}[[()()][()[ -{<([[{((([[{([[][]]<()<>>)<[<>{}]<{}()>>}]]((<[([]{})[<>()]][<[]>{<>}]><({{}<>}{[]()})(<()()>(<>{}))>)))){(([ -{(([{([{((({[{()[]}((){})]{{[]()}[()()]}}<<<{}[]>>({()()}{[]()})>)((({<>[]}[<>{}])(([]{})))[[{()[]}{<>{} -(<(<[[(((<[<<{{}[]}[[]{}]>[{()[]}<(){}>]>]>)[[([[{()<>}<<>()>]<({}{})<{}{}>>]){{[{<>[]}{()()} -(([[(([(<{([[<()()>[{}{}]][<[]{}><[]()}]]{<<{}<>>>})[[{([]())<[]()>}[<{}{}>[<>{}]]][((()())([]()))([[] -[<([<{({({[[({()<>}[{}{}>)]{([{}()]{{}})[[[]{}]<{}{}>]}]})<{{{{(<>)([]{})}[<[]()><{}{}>]}}{{<[{}()]{{} -<([{[([<(([[(<{}()>([]{}))({{}}(<>()))][{(()<>]([]{})}[[[]<>]{()[]}]]]((<[[]<>][<>]><{{}{} -<<([[<{[[([[{<[]<>><[]{}>}][([<><>]([]()))<[()()]([]<>)>]][[<[()<>][<>[]]>({<>{})[<>{}])]< -<{([[(<(({{<({()}[{}[]])(<[]<>>)>}{{[([][])({}<>)]<<{}{}>{<>[]}>}[[[[]()]({}())]((())[[][]])]>}( -{[[{[<[<<(<{<(<>()){{}<>}>}[<<{}[]>[[][]]>((()[])[()()])]}[{<{{}{}}[{}{}]><[[][]][(){}]>}[[[<>{}]< -{<<{[(<{{[[([<[]()>{{}()}][{<>{}}[<>()]])]({(<[]{}>){{[][]}([]())}}<[[<>]<<>{}>]<{[]()}({}{})>>)]( -[<[[[{<[{[(([{<>[]}<{}<>>][{()<>}[[]<>]]){([[]()]<()>)<[{}{}][{}{}]>})[((<{}{}><<>()>){([]<>]<[][]>})({<< -{<(((<{<{{{<[([]{}){[]{}}]<[[]<>][<>()]>>(<[<><>][<>{}]><[(){}][()()]>)}((<{{}<>}<()[]>>{{[]{}}{ -(<<[[[[{[{{(<(<>{}){[]}>{<[]<>>([][])}){{([]())(()())}}}}){[[{(<<><>><()<>>)<(()[])<{}()>>}]]}}({[(<{[[]() -{({(<{<<<<((<[()<>]((){})>)){<<{<>}([][])>>(<<()()>([]())><[{}{}][{}<>]>)}>>([([[[[]<>]<[]()>]{<()[]><<>() -<{[(({{([(({<<[]<>]>{<<><>>[<><>]}}<(<()()>)[(()<>)]>){[(<{}{}>[{}<>])]})]{(<<[[[][]]([]{})]>>)[<([[()] -{({{<(<<{[([((()<>)<{}<>>)<[<>[]]{{}<>}>](<([][])(<><>}>))[[([[]{}][<><>]){[{}()]({}{})}]<([{}[]]{<><>} -<({[(([[[<<((([]{})<()[]>)((<>)<[]>))(<({}<>)[()()]>[([]<>){{}<>}])>[{[([])([]())]<[()()]<{}<>>>} -{{{[[<{{{[[[(({}[]))]{([{}()][[][]])[[[]<>]([]<>)]}]]((([[<>]{[]{}}]<[<>()]<(){}>>)({[(){}][ -[{{([{{<(<<({[(){}]{()()}}[[[]{}]<<>[]>])>>[<<<{{}()}({}[])>><(<()()>(()()))({[]{}})>><{({<>{}}{<>[]})[<{} -<<<<{{<<[[<[((()[])<{}{}>)<(()[])({}())>](({<>}{{}[]}}{[(){}]{()<>}})>({(<{}<>>(()[]))<<{}[]>{{}[]}>}<{{[][]} -<<((({[{[{<([([]())<()()>][<{}[]>([])]){({()}<()()>)<([]())(<><>}>}><<<{{}<>}[[]<>]>[[()](<><>)]> -(<{[[[[([([[<{<>{}}<[]()>>{<<>[]>}]{((<>{}){[]<>})<(()())([]{})>}](<[([]<>)(<><>)]{<[]<>>(< -[{<(<<<[(<{<[[[][]](<>())][<{}{}><{}()>]><{<[][]><<>[]>}{({}<>)}>}<<[({}())([]())]<<{}{}><()<>>>>[( -[[([({[{([[(<[(){}]<[]{}>>((())(()()))]]((({<><>}(()())){{{}()}}){{[<>()]{{}()}}<[[]<>]<{}()>>})]<(({<[][]> -<<{[(<({{({(<{{}<>}(()<>)><{[]{}}[[]{}]>){[<<>()>{{}}]((()[])[[]{}])}}[((({}<>)[()()])<[{}[]]<<>[]>> -[<{<({{({{{({{()[]}[()[]]})<{(<><>)[()<>]}{{<>{}}}>}<<{({}{})({}<>)}[[()<>][[]{}]]>[([{}[]](()))(<<> -{{({{{[[[(<[<{<>()><{}[]>>{<[]<>>[<>]}]>[<<[<>()]([]{})>{(<>)(<><>)}>(<(<>{})([]<>)>(<(){}>[{}[]])) -<{[{[{[(<<({[({})([][])][[(){}]([][])]}<{<{}<>>{[][]}}{((){}){{}{}}}>)[<{[[]{}][{}{}]}({()()}([]{}))>[[[< -({<<{[<(({[[([[][]])[(<>[])[{}()]]]<{<{}<>><[]<>>}<({}{})<{}()>>>}(<(<()[]>[{}[]])<([])<<>[]>>>{<[<>()] -<<{<{{([(({([{[]<>}[{}{}]]([()()][[]{}]))}[<{{[][]>{{}[]}}{[<>[]]{{}()}}>{((()<>)[(){}])}]))][({[<(<[] -({<[[{((<[[[({<>[]}{[]{}})({{}[]][<>[]])](({()<>}<{}[]>)(({}<>)<[]<>>))][<<<(){}>>{(<>{}){( -({(((<{[([{[(([][])([]<>))[{[][]}<[][]>]]}((<((){})(<><>)>(([][]){<>}))([({}[])<[]()>]{<<>[]>{(){}}}))]({<< -([[[[[([<<{<[<[]<>>([]())]{{<>{}}<<><>>}>[<[()[]][[]<>]>({<>{}}<()})]}[[[(()[])({}())]](((( -([(<<{<(<{<{[[<>]]<[<>[]]({}())>}><<{(()<>)(<><>)}{(<>[])<{}[]>}><<[<>()]<<>>><{{}{}}>>>}>)>}>{{ -({<<{([({{([{{<>}({}{})}([[]()]{[]()})][{<<>()>([])}<[[]{}]}])(([[[]{}]{()[]}]([{}()]<()<>>)) -(<{<[{[(<{([(((){}))[((){})<()()>]]{{[[][]]<(){}>}((<><>)<[][]>)})}{((<([]{})<<>[]>>{<[]{}>{{}<>}}))[({{<>( -<<<{{([[[{[{(((){})[<>[]])([{}()){()<>})}{{({}())}{{<><>}}}][<<[[]<>](<>)>{[()()]{{}()}}>[[<{}{ -<(<[{[([[(({[<{}<>>](([]{})([]()))}({<{}[]><()<>>}<[[][]]<[][]>>))<{[<()()><(){}>]([<><>]({}[]))}>)[[ -<({<<[(({{{([{{}<>}<()()>](({}{})<()<>>))((<(){}>([]{}))([<><>]))}{{<{{}{}}{<>[]}>[{(){}}<(){}>]}( -{{{([[([[<[(<<[]{}><[]()>>(<{}>(<>{})))[([[]{}](()<>))((<><>)[{}()])]]>]<([<((<>[])(<>))[{()()}({})]>] -{[<{((([<[({{{()[]}{()()}}((<>{})[[]<>])>){(<[[][]]>[(()())(<>[])])[<{<>[]}({}<>)>]}][(([[{}()]({} -{<{[(({{[({[[[()()][(){}]]{<[]()>(()[])}]<(<<>()>({}{}))>})<(<<([]<>)(()())>{((){}){<>()}}>)>]{{([[[{}]]]((<< -<<{({[{[[<[({(<>{})({}[])}<([]())[(){}]>)<<{(){}}(()<>)>{({}{})<{}<>>}>]{<[[()()]{{}<>}]({{}}<()()>)>[< -({([{<<{[{(({(()())([][])}({{}[]}((){}))))}([{<{()[]}({}())>[({})[[]{}}]}<([<><>]([]()))>](<{(<>())( -([<{{({<{[[{<{[]<>}>}([{[][]}[[][]]])]({[{[]<>}[[]<>]](({}[])[()()])}{({()()))<{{}[]}{[]{}}>})][[([<() -((({<<(({(<{[<<>[]>]{[(){}]<()()>}}{<{[]}{<><>>>([<>[]]<<><>>)}>{<({(){}})[({}{})([]{})]>({{<>[]}<{}[]>}<<[ -[{<({[[([<<[(({}[])((){}))]({[[][]][[][]]})>(([{[][]}[<>()]]{{<>()}(<>)}){<{<><>}){[()[]]{{}[]}}})>])]({( -{(<(([{{<{[[[(()[])(()<>)][{<>{}}[[][]]]]][{{<{}<>>{{}[]}}({()<>}[[]{}])}{[<{}{}>[[]<>]](<<>{}><(){}> -[(<[<<<({{[<(({}())<()()>){[[]{}]}>({({}())([]{})}([[]()]))]{[[<{}{}><[][]>]<<{}[]>({}())>]{{{()[]}{[][]} -([{[{<<<[{{({[{}()]}<<<>[]>{<>[]}>)((([]<>))([<>{}]))}{{[([]{})<(){}>}((()[])<[]()>)}({[(){} -[({[<[[[(((<<[[]]<[]<>>>>{{([]<>){()[]}}})(({(<><>)({}())})<({{}[]}{[]()})[{()<>}([][])]>) -<[[{[[{{[[[<<{()[]}<[][]>>{<<><>>[{}]}>{[<{}<>><[]<>>](((){}))}]{{<((){}){<>{}}>{(<>())[<>[]]}}<<{{}()}(( -(<[{(<<([[([[<{}{}>[<>[]]]][[{{}()}]<[<>()][()<>]>])<{[(<>{})(()[])]{[{}()][<>()]}}<((<>[]){<>()})(<() diff --git a/11/a.py b/11/a.py deleted file mode 100755 index e304503..0000000 --- a/11/a.py +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env python3 -import sys - -G = [[0] * 10 for i in range(10)] -flashes = 0 - - -def debug(i=0): - print(f"--- {i} ---") - for r in G: - print("".join([str(i) for i in r])) - - -def step(): - flashed = [[False] * 10 for i in range(10)] - - def flash(r, c): - global flashes - - # At minimum, receive += 1 - G[r][c] += 1 - - # Now flash neighbors - if G[r][c] > 9 and not flashed[r][c]: - flashed[r][c] = True - flashes += 1 - # Neighbors - if r > 0: - flash(r - 1, c) - if c > 0: - flash(r, c - 1) - if r < 9: - flash(r + 1, c) - if c < 9: - flash(r, c + 1) - # corners - if r > 0 and c > 0: - flash(r - 1, c - 1) - if r < 9 and c < 9: - flash(r + 1, c + 1) - if r > 0 and c < 9: - flash(r - 1, c + 1) - if r < 9 and c > 0: - flash(r + 1, c - 1) - - # increase everyone first - for r in range(10): - for c in range(10): - G[r][c] += 1 - - # now flash it up - for r in range(10): - for c in range(10): - if G[r][c] > 9: - flash(r, c) - - # now, reset - for r in range(10): - for c in range(10): - if G[r][c] > 9: - G[r][c] = 0 - - -# Read in the grid -r = 0 -for l in sys.stdin: - c = 0 - for n in l.strip(): - G[r][c] = int(n) - c += 1 - r += 1 - -for i in range(100): - # debug(i) - step() - -print(flashes) diff --git a/11/b.py b/11/b.py deleted file mode 100755 index 0e02478..0000000 --- a/11/b.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python3 -import sys - -G = [[0] * 10 for i in range(10)] - - -def debug(i=0): - print(f"--- {i} ---") - for r in G: - print("".join([str(i) for i in r])) - - -def step(): - flashed = [[False] * 10 for i in range(10)] - - def flash(r, c): - # At minimum, receive += 1 - G[r][c] += 1 - - # Now flash neighbors - if G[r][c] > 9 and not flashed[r][c]: - flashed[r][c] = True - # Neighbors - if r > 0: - flash(r - 1, c) - if c > 0: - flash(r, c - 1) - if r < 9: - flash(r + 1, c) - if c < 9: - flash(r, c + 1) - # corners - if r > 0 and c > 0: - flash(r - 1, c - 1) - if r < 9 and c < 9: - flash(r + 1, c + 1) - if r > 0 and c < 9: - flash(r - 1, c + 1) - if r < 9 and c > 0: - flash(r + 1, c - 1) - - # increase everyone first - for r in range(10): - for c in range(10): - G[r][c] += 1 - - # now flash it up - for r in range(10): - for c in range(10): - if G[r][c] > 9: - flash(r, c) - - # now, reset - flashes = 0 - for r in range(10): - for c in range(10): - if G[r][c] > 9: - G[r][c] = 0 - flashes += 1 - - # Return ! is sync - return flashes != 100 - - -# Read in the grid -r = 0 -for l in sys.stdin: - c = 0 - for n in l.strip(): - G[r][c] = int(n) - c += 1 - r += 1 - -i = 1 -while step(): - i += 1 - - -print(i) diff --git a/11/example b/11/example deleted file mode 100644 index 03743f6..0000000 --- a/11/example +++ /dev/null @@ -1,10 +0,0 @@ -5483143223 -2745854711 -5264556173 -6141336146 -6357385478 -4167524645 -2176841721 -6882881134 -4846848554 -5283751526 diff --git a/11/input b/11/input deleted file mode 100644 index efb0e67..0000000 --- a/11/input +++ /dev/null @@ -1,10 +0,0 @@ -5651341452 -1381541252 -1878435224 -6814831535 -3883547383 -6473548464 -1885833658 -3732584752 -1881546128 -5121717776 diff --git a/12/a.py b/12/a.py deleted file mode 100755 index 04ed1e0..0000000 --- a/12/a.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python3 -import sys -import re -from collections import defaultdict - -E = defaultdict(list) - - -# Parse in edges -for l in sys.stdin: - a, b = l.strip().split('-') - E[a].append(b) - E[b].append(a) - -smallre = re.compile('[a-z]+') -def issmall(n): - return smallre.match(n) - -paths = 0 -def search(n, path): - global paths - if n == 'end': - paths += 1 - return - if issmall(n) and n in path: - return - for c in E[n]: - search(c, path + n) - -search("start", "") - -print(paths) diff --git a/12/b.py b/12/b.py deleted file mode 100755 index da634fe..0000000 --- a/12/b.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python3 -import sys -import re -from collections import defaultdict - -E = defaultdict(list) - - -# Parse in edges -for l in sys.stdin: - a, b = l.strip().split('-') - E[a].append(b) - E[b].append(a) - -smallre = re.compile('[a-z]+') -def issmall(n): - return smallre.match(n) - -paths = 0 -P = [] -def search(n, path, has_doubled): - global paths - global P - if n == 'end': - paths += 1 - P.append(path + n) - return - if issmall(n) and n in path: - if has_doubled: - return - else: - has_doubled = True - for c in E[n]: - if c != 'start': - search(c, path + n, has_doubled) - -search("start", "", False) -print(paths) diff --git a/12/ex2 b/12/ex2 deleted file mode 100644 index 6fd8c41..0000000 --- a/12/ex2 +++ /dev/null @@ -1,7 +0,0 @@ -start-A -start-b -A-c -A-b -b-d -A-end -b-end diff --git a/12/example b/12/example deleted file mode 100644 index 65f3833..0000000 --- a/12/example +++ /dev/null @@ -1,18 +0,0 @@ -fs-end -he-DX -fs-he -start-DX -pj-DX -end-zg -zg-sl -zg-pj -pj-he -RW-he -fs-DX -pj-RW -zg-RW -start-pj -he-WI -zg-he -pj-fs -start-RW diff --git a/12/input b/12/input deleted file mode 100644 index 262ee68..0000000 --- a/12/input +++ /dev/null @@ -1,19 +0,0 @@ -lg-GW -pt-start -pt-uq -nx-lg -ve-GW -start-nx -GW-start -GW-nx -pt-SM -sx-GW -lg-end -nx-SM -lg-SM -pt-nx -end-ve -ve-SM -TG-uq -end-SM -SM-uq diff --git a/13/a.py b/13/a.py deleted file mode 100755 index bad3906..0000000 --- a/13/a.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python3 -import sys -import re - -coord = re.compile("\d+,\d+") -fold = re.compile("fold along") - -coords = [] -folds = [] - -for l in sys.stdin: - l = l.strip() - if coord.match(l): - coords.append([int(x) for x in l.split(",")]) - elif fold.match(l): - split = l.split() - # x=8 - folds.append(split[2].split("=")) - -# Pt A we only care about the first split -# Assuming all points are originally unique, we just need to -# dedupe them after the fold! -d, v = folds[0] -v = int(v) - -folded = {} - -for c in coords: - x, y = c - if d == "x": - if x == v: - # lost to the fold - pass - elif x > v: - newx = v - (x - v) - folded[(newx, y)] = 1 - else: - folded[(x, y)] = 1 - elif d == "y": - if y == v: - # lost to the fold - pass - elif y > v: - newy = v - (y - v) - folded[(x, newy)] = 1 - else: - folded[(x, y)] = 1 - else: - raise Exception(f"Bad dir: {d}") - -print(len(folded.keys())) diff --git a/13/b.py b/13/b.py deleted file mode 100755 index efb284e..0000000 --- a/13/b.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python3 -import sys -import re - -coord = re.compile("\d+,\d+") -fold = re.compile("fold along") - -coords = [] -folds = [] - -for l in sys.stdin: - l = l.strip() - if coord.match(l): - coords.append([int(x) for x in l.split(",")]) - elif fold.match(l): - split = l.split() - # x=8 - folds.append(split[2].split("=")) - - -prev_folded = {} -for d, v in folds: - v = int(v) - folded = {} - for c in coords: - x, y = c - if d == "x": - if x == v: - # lost to the fold - pass - elif x > v: - newx = v - (x - v) - folded[(newx, y)] = 1 - else: - folded[(x, y)] = 1 - elif d == "y": - if y == v: - # lost to the fold - pass - elif y > v: - newy = v - (y - v) - folded[(x, newy)] = 1 - else: - folded[(x, y)] = 1 - else: - raise Exception(f"Bad dir: {d}") - - coords = folded.keys() - prev_folded = folded - -# Just hope they fit on a terminal! -print() -for y in range(6): - for x in range(120): - if (x, y) in prev_folded: - print("#", end="") - else: - print(" ", end="") - print() diff --git a/13/example b/13/example deleted file mode 100644 index 282114c..0000000 --- a/13/example +++ /dev/null @@ -1,21 +0,0 @@ -6,10 -0,14 -9,10 -0,3 -10,4 -4,11 -6,0 -6,12 -4,1 -0,13 -10,12 -3,4 -3,0 -8,4 -1,10 -2,14 -8,10 -9,0 - -fold along y=7 -fold along x=5 diff --git a/13/input b/13/input deleted file mode 100644 index f0b79e5..0000000 --- a/13/input +++ /dev/null @@ -1,874 +0,0 @@ -1101,291 -221,448 -1098,383 -217,399 -507,191 -410,240 -1036,449 -208,241 -469,548 -1064,838 -189,72 -1198,812 -107,483 -900,206 -902,325 -430,7 -801,834 -1009,890 -263,65 -1255,379 -328,502 -537,703 -724,763 -126,521 -788,127 -544,484 -110,36 -243,28 -1183,215 -242,420 -811,373 -1228,325 -567,880 -798,250 -5,264 -165,362 -140,126 -915,596 -835,806 -1047,157 -1123,222 -72,654 -1111,863 -114,411 -212,511 -1071,603 -1123,672 -704,707 -1191,558 -944,137 -1168,879 -55,379 -773,74 -36,227 -36,560 -1048,856 -209,151 -1016,355 -1012,428 -528,616 -902,390 -489,532 -350,528 -790,18 -666,759 -224,191 -761,560 -571,602 -329,698 -330,806 -1310,883 -919,855 -1250,119 -1069,305 -754,486 -574,632 -411,418 -423,410 -329,180 -823,781 -499,521 -902,530 -316,778 -649,355 -581,672 -1101,603 -1110,224 -601,47 -977,264 -1297,340 -743,294 -463,343 -652,134 -73,446 -5,508 -946,891 -698,609 -1015,343 -440,792 -221,670 -597,894 -1153,763 -798,187 -946,521 -1297,365 -212,383 -157,763 -1228,894 -939,494 -1039,227 -463,551 -132,16 -536,241 -1071,561 -1027,876 -567,462 -199,438 -1009,789 -271,299 -1170,350 -557,613 -360,847 -1309,84 -58,474 -1184,0 -709,847 -711,47 -885,613 -179,75 -87,630 -577,677 -1098,511 -1086,7 -145,284 -939,176 -33,301 -373,736 -733,217 -841,346 -192,445 -147,311 -192,837 -818,653 -330,866 -610,628 -306,66 -850,497 -246,812 -162,784 -207,227 -1084,131 -738,424 -728,318 -900,318 -851,217 -1086,66 -684,169 -391,407 -798,431 -1121,341 -189,588 -441,845 -736,184 -999,582 -1061,417 -406,168 -773,820 -715,458 -649,386 -1215,529 -773,191 -960,528 -1111,438 -67,29 -946,821 -126,392 -268,868 -897,305 -1196,35 -1119,551 -60,319 -72,128 -126,278 -1305,264 -1243,522 -455,438 -393,281 -552,319 -1280,838 -733,677 -30,61 -800,819 -412,756 -246,504 -507,759 -776,114 -73,224 -1305,284 -984,872 -1233,604 -835,75 -692,334 -254,240 -1310,358 -144,371 -1066,123 -1078,810 -509,386 -1245,710 -107,819 -114,483 -678,308 -873,847 -1103,227 -463,327 -1168,250 -889,147 -830,402 -522,127 -107,115 -0,883 -805,620 -559,60 -1176,298 -897,133 -1059,758 -0,252 -985,322 -30,838 -1282,101 -1102,241 -1028,653 -1175,327 -957,378 -42,733 -1145,625 -373,343 -763,411 -459,343 -338,436 -360,47 -246,437 -907,86 -77,677 -594,575 -801,386 -723,29 -283,876 -189,621 -1110,866 -408,156 -475,88 -251,758 -738,31 -643,315 -301,4 -739,154 -728,206 -1247,487 -644,211 -330,200 -507,583 -333,182 -5,91 -294,399 -848,57 -609,191 -343,311 -995,252 -221,224 -1208,663 -406,138 -1163,311 -1230,88 -393,165 -5,162 -1064,530 -43,3 -653,628 -985,362 -1183,255 -974,267 -290,331 -1299,362 -266,775 -1064,122 -1093,47 -392,38 -65,184 -572,613 -571,544 -520,428 -1067,866 -470,19 -783,886 -363,86 -311,70 -320,527 -1066,206 -221,560 -1233,677 -1049,165 -1042,868 -1143,333 -1158,268 -472,96 -1256,894 -224,887 -565,821 -391,65 -1081,505 -925,334 -131,665 -1094,410 -761,224 -818,205 -609,43 -677,700 -738,613 -927,719 -582,318 -808,716 -960,472 -28,437 -946,563 -803,311 -33,593 -850,311 -364,521 -502,884 -856,614 -1310,232 -661,284 -212,35 -924,868 -502,626 -107,523 -445,79 -808,570 -803,703 -877,334 -181,22 -980,28 -1245,415 -502,716 -947,86 -107,380 -1039,595 -743,880 -271,595 -745,73 -559,529 -1173,889 -78,829 -105,782 -115,369 -1118,389 -917,707 -364,378 -813,131 -405,229 -321,264 -492,653 -11,362 -633,700 -408,738 -510,371 -537,815 -1277,749 -187,222 -50,497 -875,16 -599,827 -1086,255 -1064,156 -1064,604 -902,569 -454,280 -639,70 -1200,36 -107,878 -986,806 -137,374 -1102,149 -739,292 -830,626 -191,439 -221,446 -455,863 -1173,247 -1069,589 -624,838 -1176,876 -880,35 -499,373 -353,82 -632,808 -1206,68 -541,397 -321,179 -30,232 -879,122 -241,305 -1061,5 -295,343 -512,879 -937,343 -164,43 -1305,539 -610,266 -551,548 -454,28 -661,386 -994,340 -1280,61 -671,70 -618,373 -462,718 -980,638 -281,36 -460,497 -338,884 -1295,824 -393,729 -879,772 -502,268 -1009,154 -386,868 -447,227 -1138,542 -296,609 -1310,11 -408,530 -897,761 -192,53 -981,698 -54,166 -1064,390 -147,415 -587,29 -1064,856 -537,596 -1173,647 -1020,563 -774,241 -684,457 -654,11 -1111,86 -798,879 -559,813 -1158,716 -192,176 -415,732 -842,752 -115,77 -82,325 -1097,621 -966,598 -423,92 -1119,119 -60,575 -1071,499 -539,817 -395,596 -1280,662 -383,609 -873,822 -1215,813 -162,241 -857,840 -763,859 -1305,162 -728,240 -350,586 -231,81 -739,740 -242,868 -534,114 -877,448 -453,840 -1215,386 -1265,407 -487,781 -152,716 -629,516 -353,890 -1256,0 -1285,452 -902,156 -502,324 -1228,613 -706,588 -115,817 -576,513 -1086,120 -1129,834 -919,289 -629,442 -950,47 -686,838 -1183,568 -994,100 -498,815 -334,880 -373,372 -830,268 -1071,268 -137,520 -869,845 -599,515 -599,47 -577,604 -348,828 -902,290 -430,828 -440,515 -1168,431 -339,252 -957,82 -971,252 -710,894 -333,732 -838,96 -1272,332 -102,127 -1145,849 -1019,826 -217,495 -119,558 -1268,733 -1039,609 -377,551 -701,43 -982,683 -325,572 -1260,812 -1274,112 -290,597 -1068,138 -547,563 -1237,672 -343,70 -137,140 -50,588 -454,614 -118,205 -498,367 -353,378 -835,88 -114,859 -1158,772 -1145,362 -1183,639 -169,67 -711,67 -1226,868 -1268,833 -301,789 -677,642 -995,763 -582,576 -316,554 -904,138 -339,642 -1304,527 -22,422 -1129,872 -460,728 -454,168 -1196,411 -763,331 -58,292 -1227,350 -65,483 -848,841 -729,0 -634,427 -1195,77 -1149,84 -140,544 -933,551 -200,728 -985,124 -656,11 -545,616 -459,677 -957,341 -1103,652 -1119,455 -107,688 -104,826 -1101,74 -325,124 -1227,740 -502,10 -1203,523 -527,7 -1158,570 -290,821 -1207,346 -1242,763 -1064,56 -194,728 -431,122 -1068,868 -435,16 -611,242 -462,53 -115,525 -161,84 -462,885 -541,497 -788,654 -1123,224 -1120,567 -249,5 -771,817 -1154,544 -405,889 -561,572 -994,794 -396,91 -729,672 -869,273 -542,306 -644,759 -1247,381 -1020,73 -1165,508 -1094,415 -736,595 -801,60 -907,534 -1308,246 -872,31 -207,652 -1118,837 -30,609 -887,92 -595,458 -895,732 -1064,38 -82,613 -1128,544 -325,362 -85,122 -1146,43 -454,224 -517,199 -433,446 -1212,408 -1163,583 -5,732 -589,710 -364,891 -1203,75 -1033,679 -480,626 -865,255 -246,200 -316,359 -1052,131 -438,484 -15,70 -982,470 -609,851 -609,372 -194,807 -900,688 -981,124 -957,553 -1247,183 -507,31 -1233,290 -1232,392 -1089,560 -982,502 -134,428 -600,0 -1193,752 -459,665 -1020,740 -316,100 -328,22 -1305,508 -126,894 -895,716 -328,424 -550,516 -880,66 -1265,191 -1274,821 -446,653 -393,184 -902,604 -787,665 -856,280 -1068,26 -1310,502 -1056,206 -1174,786 -1091,155 -855,438 -348,380 -927,623 -759,548 -972,458 -191,775 -792,786 -648,73 -851,677 -604,588 -1280,659 -986,190 -1119,775 -455,326 -187,224 -1086,319 -165,700 -612,61 -705,215 -582,654 -581,224 -1196,483 -364,331 -441,49 -831,26 -902,255 -488,306 -869,621 -371,204 -878,516 -107,75 -768,515 -835,523 -989,264 -117,703 -971,28 -221,672 -678,586 -745,821 -599,399 -1274,597 -273,47 -145,386 -1066,0 -1200,31 -135,327 -986,88 -328,683 -589,483 -1260,497 -59,458 -1195,525 -1304,821 -1091,739 -957,452 -358,733 -1170,544 -1110,222 -856,149 -1168,655 -788,543 -664,715 -1089,448 -118,653 -960,250 -22,472 -485,60 -373,522 -888,532 -244,894 -576,138 -728,576 -147,479 -324,88 -28,101 -681,292 -612,833 -209,291 -387,346 -898,756 -1279,439 -967,824 -371,718 -1111,120 -893,73 -1089,224 -698,61 -261,710 -316,116 -1168,239 -315,642 -1225,122 -1195,817 -246,738 -224,639 -1121,247 -581,222 -1223,630 -338,564 -152,10 -271,609 -594,270 -242,474 -350,250 -194,280 -261,165 -222,378 -493,717 -410,771 -743,462 -739,544 -423,372 -358,609 -1278,623 -662,73 -1252,602 -224,774 -469,346 -213,621 -224,319 -454,390 -1039,299 -263,39 -1274,521 -570,302 -788,351 -177,274 -229,389 -36,521 -773,703 -763,819 -527,886 -986,28 -656,883 -137,72 -855,86 -711,515 -1203,483 -423,81 -946,292 -541,845 -1019,516 -329,250 -142,879 -1111,422 -1158,535 -463,439 -165,208 -848,885 -480,402 -25,442 -432,516 -145,162 -221,334 -25,292 -95,365 -98,408 -1193,372 -565,73 - -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 diff --git a/2021/01/README b/2021/01/README new file mode 100644 index 0000000..7f1ead0 --- /dev/null +++ b/2021/01/README @@ -0,0 +1,6 @@ +For both languages, pass the file to stdin: + +make -C c +./c/a < input + +./py/a.py < input diff --git a/2021/01/a.c b/2021/01/a.c new file mode 100644 index 0000000..f593356 --- /dev/null +++ b/2021/01/a.c @@ -0,0 +1,16 @@ +#include +#include + +int main(void) { + int count = 0; + int curr; + int prev = 0; + while(scanf("%d\n", &curr) != EOF) { + if (prev && curr > prev) { + count++; + } + prev = curr; + } + printf("%d\n", count); + return 0; +} diff --git a/2021/01/a.py b/2021/01/a.py new file mode 100755 index 0000000..f0e9883 --- /dev/null +++ b/2021/01/a.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 +import sys + +prev = None +count = 0 +for l in sys.stdin: + curr = int(l.strip()) + if prev and curr > prev: + count += 1 + prev = curr + +print(count) diff --git a/2021/01/b.c b/2021/01/b.c new file mode 100644 index 0000000..93f6153 --- /dev/null +++ b/2021/01/b.c @@ -0,0 +1,26 @@ +#include +#include + +int mem[] = {0, 0, 0}; +int sum() { + return mem[0] + mem[1] + mem[2]; +} + +int main(void) { + int count = 0; + int curr; + int prev = 0; + int i = 0; + while(scanf("%d\n", &curr) != EOF) { + mem[i++ % 3] = curr; + if (i > 3) { + if (prev && sum() > prev) { + count++; + } + prev = sum(); + } + i++; + } + printf("%d\n", count); + return 0; +} diff --git a/2021/01/b.py b/2021/01/b.py new file mode 100755 index 0000000..45dfac3 --- /dev/null +++ b/2021/01/b.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +import sys + +prev = None +mem = [] +count = 0 +i = 0 +for l in sys.stdin: + curr = int(l.strip()) + + if len(mem) < 3: + mem.append(curr) + continue + else: + mem[i % 3] = curr + i += 1 + + s = sum(mem) + if prev and s > prev: + count += 1 + prev = s + +print(count) diff --git a/2021/01/input b/2021/01/input new file mode 100644 index 0000000..b6a7329 --- /dev/null +++ b/2021/01/input @@ -0,0 +1,2000 @@ +157 +148 +149 +146 +144 +145 +162 +163 +164 +166 +173 +186 +183 +164 +168 +175 +176 +172 +170 +183 +196 +204 +216 +224 +225 +228 +231 +215 +218 +225 +229 +230 +232 +238 +237 +240 +261 +263 +262 +257 +270 +278 +279 +280 +284 +299 +300 +311 +312 +311 +312 +326 +327 +326 +336 +338 +344 +350 +351 +352 +354 +373 +376 +382 +383 +381 +390 +396 +400 +408 +421 +422 +423 +428 +431 +432 +444 +437 +438 +458 +427 +413 +423 +425 +426 +424 +428 +443 +446 +459 +465 +478 +482 +485 +498 +522 +528 +535 +536 +528 +507 +525 +526 +528 +523 +527 +524 +525 +532 +534 +552 +551 +561 +563 +562 +568 +575 +577 +587 +588 +593 +594 +597 +600 +605 +607 +615 +611 +617 +618 +622 +644 +646 +634 +631 +635 +633 +636 +641 +643 +644 +645 +641 +659 +661 +659 +660 +683 +695 +696 +704 +705 +719 +720 +707 +722 +723 +727 +728 +730 +731 +740 +744 +733 +718 +711 +712 +720 +719 +729 +739 +748 +754 +759 +781 +797 +796 +802 +811 +812 +819 +815 +826 +828 +841 +844 +849 +888 +893 +895 +900 +901 +904 +905 +922 +921 +922 +938 +963 +971 +973 +983 +991 +994 +1001 +1023 +1027 +1035 +1059 +1060 +1089 +1098 +1124 +1125 +1128 +1122 +1123 +1113 +1115 +1113 +1141 +1146 +1150 +1151 +1152 +1153 +1143 +1144 +1146 +1162 +1154 +1153 +1154 +1165 +1169 +1168 +1171 +1178 +1179 +1180 +1172 +1176 +1186 +1188 +1189 +1188 +1187 +1192 +1190 +1189 +1184 +1194 +1195 +1200 +1194 +1206 +1207 +1216 +1218 +1186 +1187 +1184 +1187 +1190 +1214 +1239 +1240 +1250 +1249 +1277 +1278 +1279 +1314 +1316 +1321 +1345 +1344 +1351 +1364 +1367 +1368 +1370 +1373 +1365 +1361 +1355 +1354 +1365 +1360 +1358 +1356 +1357 +1363 +1364 +1373 +1377 +1387 +1381 +1392 +1396 +1397 +1399 +1406 +1410 +1429 +1430 +1431 +1437 +1443 +1448 +1449 +1465 +1466 +1461 +1462 +1464 +1471 +1488 +1489 +1490 +1500 +1502 +1528 +1549 +1551 +1552 +1551 +1543 +1544 +1543 +1546 +1547 +1551 +1555 +1563 +1539 +1525 +1524 +1523 +1548 +1513 +1522 +1508 +1507 +1515 +1498 +1505 +1504 +1505 +1506 +1507 +1510 +1516 +1520 +1540 +1547 +1548 +1547 +1522 +1523 +1533 +1561 +1588 +1589 +1591 +1592 +1594 +1596 +1608 +1624 +1628 +1638 +1639 +1641 +1625 +1627 +1629 +1648 +1653 +1678 +1679 +1699 +1703 +1697 +1700 +1698 +1699 +1715 +1714 +1716 +1717 +1720 +1722 +1721 +1722 +1716 +1720 +1742 +1765 +1767 +1757 +1756 +1755 +1761 +1784 +1785 +1789 +1798 +1806 +1809 +1821 +1822 +1831 +1826 +1818 +1817 +1814 +1815 +1818 +1819 +1820 +1827 +1830 +1831 +1832 +1840 +1841 +1842 +1848 +1849 +1850 +1851 +1861 +1863 +1860 +1861 +1855 +1863 +1862 +1864 +1865 +1887 +1902 +1925 +1939 +1945 +1944 +1943 +1947 +1964 +1986 +1987 +1986 +1989 +1979 +1984 +1986 +1994 +1996 +2001 +2002 +2005 +2009 +2022 +2024 +2025 +2029 +2013 +2014 +2017 +2018 +2017 +2019 +2020 +2009 +2007 +2006 +1982 +1984 +1986 +1991 +1994 +1982 +1991 +1989 +1995 +1996 +1997 +1998 +1997 +2004 +2005 +2030 +2062 +2064 +2076 +2077 +2079 +2080 +2084 +2103 +2104 +2110 +2104 +2105 +2106 +2118 +2124 +2127 +2125 +2121 +2127 +2133 +2135 +2141 +2139 +2136 +2138 +2146 +2140 +2141 +2156 +2172 +2181 +2170 +2173 +2195 +2194 +2199 +2203 +2228 +2230 +2234 +2204 +2212 +2214 +2200 +2201 +2200 +2197 +2201 +2204 +2230 +2240 +2242 +2255 +2263 +2271 +2273 +2274 +2273 +2277 +2278 +2285 +2286 +2297 +2298 +2297 +2310 +2313 +2309 +2311 +2314 +2322 +2320 +2316 +2317 +2339 +2338 +2350 +2378 +2379 +2387 +2391 +2390 +2391 +2396 +2398 +2406 +2425 +2433 +2430 +2421 +2422 +2440 +2449 +2445 +2466 +2479 +2477 +2479 +2485 +2481 +2490 +2491 +2492 +2496 +2508 +2505 +2487 +2492 +2493 +2482 +2499 +2515 +2516 +2543 +2574 +2575 +2577 +2578 +2569 +2556 +2554 +2557 +2559 +2562 +2571 +2595 +2596 +2598 +2599 +2603 +2602 +2615 +2614 +2610 +2623 +2632 +2626 +2642 +2643 +2675 +2681 +2689 +2706 +2708 +2713 +2714 +2703 +2691 +2692 +2693 +2700 +2710 +2711 +2712 +2711 +2712 +2716 +2673 +2674 +2694 +2715 +2723 +2736 +2759 +2768 +2773 +2767 +2757 +2752 +2749 +2752 +2758 +2753 +2752 +2754 +2760 +2791 +2792 +2803 +2804 +2797 +2800 +2797 +2807 +2811 +2814 +2816 +2819 +2837 +2838 +2843 +2841 +2848 +2853 +2859 +2868 +2854 +2864 +2845 +2848 +2831 +2830 +2829 +2840 +2838 +2831 +2836 +2856 +2854 +2870 +2863 +2865 +2866 +2867 +2895 +2892 +2893 +2911 +2909 +2918 +2923 +2924 +2893 +2888 +2892 +2893 +2898 +2893 +2920 +2930 +2931 +2930 +2926 +2933 +2939 +2957 +2964 +2968 +2969 +2971 +2985 +2986 +2990 +2988 +2977 +2971 +2970 +2978 +2964 +2997 +3007 +3015 +3013 +3015 +2998 +3000 +3024 +3034 +3045 +3067 +3073 +3074 +3075 +3076 +3084 +3091 +3089 +3088 +3095 +3082 +3085 +3086 +3082 +3080 +3096 +3110 +3113 +3114 +3117 +3120 +3125 +3128 +3129 +3131 +3130 +3136 +3130 +3131 +3138 +3141 +3147 +3153 +3152 +3161 +3162 +3180 +3183 +3197 +3203 +3205 +3195 +3202 +3209 +3216 +3217 +3230 +3235 +3238 +3245 +3248 +3269 +3262 +3266 +3267 +3268 +3272 +3265 +3264 +3268 +3275 +3276 +3283 +3277 +3276 +3277 +3278 +3298 +3311 +3314 +3318 +3327 +3330 +3333 +3349 +3353 +3354 +3347 +3357 +3359 +3361 +3390 +3389 +3398 +3411 +3418 +3409 +3422 +3423 +3425 +3426 +3442 +3444 +3457 +3458 +3459 +3471 +3454 +3455 +3457 +3469 +3470 +3496 +3495 +3492 +3509 +3512 +3511 +3514 +3513 +3516 +3519 +3522 +3533 +3539 +3541 +3537 +3547 +3548 +3552 +3554 +3556 +3559 +3560 +3568 +3571 +3580 +3582 +3601 +3602 +3625 +3623 +3625 +3633 +3640 +3655 +3657 +3659 +3660 +3659 +3665 +3666 +3672 +3698 +3707 +3706 +3712 +3713 +3728 +3727 +3724 +3747 +3737 +3733 +3739 +3736 +3757 +3758 +3766 +3768 +3771 +3776 +3785 +3782 +3790 +3792 +3800 +3779 +3781 +3782 +3816 +3824 +3832 +3831 +3842 +3848 +3847 +3848 +3851 +3840 +3848 +3849 +3854 +3871 +3870 +3872 +3877 +3885 +3899 +3908 +3913 +3914 +3910 +3909 +3910 +3926 +3938 +3951 +3952 +3949 +3978 +3980 +3981 +3984 +3980 +3981 +4000 +4001 +4006 +4007 +4024 +4039 +4040 +4048 +4036 +4041 +4040 +4052 +4065 +4068 +4043 +4048 +4037 +4043 +4046 +4048 +4049 +4056 +4059 +4063 +4068 +4080 +4077 +4075 +4076 +4069 +4038 +4037 +4040 +4027 +4028 +4034 +4053 +4057 +4058 +4061 +4059 +4064 +4065 +4069 +4071 +4073 +4075 +4077 +4082 +4096 +4093 +4104 +4112 +4105 +4106 +4109 +4093 +4100 +4108 +4109 +4134 +4135 +4165 +4146 +4152 +4162 +4171 +4173 +4181 +4184 +4185 +4189 +4192 +4196 +4194 +4209 +4221 +4222 +4200 +4217 +4216 +4217 +4216 +4221 +4231 +4227 +4230 +4227 +4240 +4241 +4242 +4222 +4243 +4248 +4245 +4236 +4237 +4256 +4261 +4248 +4250 +4254 +4255 +4258 +4261 +4262 +4266 +4274 +4290 +4291 +4290 +4312 +4323 +4336 +4337 +4333 +4328 +4330 +4293 +4297 +4309 +4327 +4328 +4356 +4358 +4332 +4346 +4347 +4370 +4379 +4382 +4391 +4400 +4398 +4406 +4417 +4422 +4420 +4421 +4426 +4424 +4420 +4421 +4422 +4401 +4402 +4428 +4437 +4444 +4448 +4451 +4452 +4451 +4454 +4463 +4468 +4467 +4476 +4473 +4477 +4478 +4482 +4514 +4515 +4556 +4559 +4560 +4559 +4561 +4563 +4564 +4562 +4568 +4577 +4589 +4590 +4611 +4599 +4607 +4595 +4596 +4583 +4597 +4595 +4601 +4602 +4607 +4608 +4609 +4633 +4636 +4647 +4654 +4655 +4622 +4623 +4625 +4651 +4653 +4654 +4657 +4661 +4670 +4677 +4678 +4679 +4680 +4678 +4679 +4682 +4680 +4678 +4676 +4678 +4680 +4678 +4683 +4689 +4705 +4716 +4725 +4723 +4728 +4729 +4730 +4746 +4757 +4755 +4762 +4791 +4785 +4787 +4792 +4793 +4790 +4793 +4794 +4807 +4813 +4804 +4826 +4827 +4840 +4878 +4880 +4883 +4884 +4875 +4887 +4889 +4922 +4929 +4928 +4933 +4934 +4945 +4943 +4944 +4945 +4947 +4944 +4957 +4955 +4956 +4944 +4946 +4954 +4961 +4967 +4981 +4971 +4980 +4981 +4989 +4991 +5000 +5017 +5016 +5017 +5016 +5018 +5032 +5033 +5038 +5039 +5041 +5043 +5059 +5068 +5070 +5074 +5075 +5076 +5088 +5099 +5100 +5105 +5122 +5123 +5124 +5126 +5118 +5116 +5121 +5115 +5125 +5128 +5133 +5143 +5142 +5143 +5150 +5145 +5146 +5148 +5154 +5155 +5166 +5164 +5180 +5173 +5168 +5167 +5169 +5175 +5176 +5204 +5203 +5204 +5206 +5210 +5204 +5205 +5206 +5207 +5205 +5226 +5233 +5235 +5239 +5241 +5242 +5261 +5266 +5260 +5268 +5272 +5278 +5280 +5281 +5290 +5295 +5296 +5306 +5319 +5344 +5362 +5364 +5377 +5381 +5385 +5368 +5391 +5392 +5381 +5397 +5398 +5405 +5385 +5395 +5396 +5401 +5407 +5408 +5402 +5400 +5401 +5404 +5414 +5415 +5418 +5427 +5413 +5408 +5419 +5440 +5445 +5444 +5439 +5443 +5448 +5449 +5448 +5475 +5477 +5481 +5474 +5476 +5480 +5497 +5494 +5496 +5505 +5506 +5509 +5517 +5518 +5521 +5510 +5511 +5513 +5514 +5513 +5528 +5536 +5523 +5525 +5526 +5524 +5525 +5527 +5528 +5534 +5538 +5554 +5560 +5563 +5564 +5571 +5586 +5590 +5596 +5597 +5603 +5624 +5599 +5609 +5599 +5618 +5620 +5608 +5623 +5627 +5629 +5630 +5632 +5640 +5637 +5638 +5643 +5653 +5650 +5649 +5658 +5656 +5654 +5673 +5672 +5673 +5675 +5676 +5677 +5672 +5682 +5681 +5680 +5671 +5674 +5679 +5685 +5687 +5691 +5694 +5718 +5720 +5721 +5719 +5716 +5717 +5719 +5711 +5712 +5713 +5712 +5711 +5712 +5711 +5704 +5709 +5710 +5723 +5720 +5719 +5720 +5725 +5724 +5728 +5729 +5747 +5745 +5747 +5748 +5752 +5749 +5763 +5766 +5767 +5775 +5782 +5784 +5785 +5787 +5788 +5787 +5792 +5787 +5788 +5787 +5789 +5792 +5793 +5820 +5827 +5843 +5844 +5864 +5875 +5877 +5890 +5895 +5896 +5909 +5932 +5944 +5951 +5960 +5983 +5996 +6003 +6028 +6043 +6046 +6038 +6053 +6056 +6069 +6063 +6059 +6064 +6065 +6077 +6075 +6074 +6075 +6091 +6108 +6109 +6103 +6100 +6108 +6130 +6131 +6158 +6162 +6176 +6166 +6168 +6170 +6181 +6180 +6179 +6180 +6183 +6184 +6187 +6186 +6185 +6182 +6194 +6190 +6193 +6222 +6241 +6243 +6233 +6222 +6248 +6250 +6251 +6265 +6269 +6270 +6272 +6285 +6284 +6280 +6273 +6286 +6287 +6292 +6307 +6311 +6317 +6316 +6317 +6316 +6317 +6314 +6316 +6291 +6293 +6323 +6327 +6328 +6327 +6322 +6321 +6330 +6332 +6335 +6333 +6351 +6349 +6346 +6347 +6346 +6364 +6374 +6383 +6395 +6398 +6406 +6418 +6419 +6418 +6413 +6414 +6415 +6416 +6399 +6400 +6401 +6399 +6382 +6379 +6380 +6386 +6387 +6373 +6372 +6396 +6397 +6415 +6423 +6424 +6433 +6438 +6445 +6446 +6447 +6448 +6450 +6446 +6464 +6447 +6452 +6464 +6466 +6477 +6491 +6489 +6490 +6503 +6528 +6562 +6564 +6581 +6579 +6580 +6594 +6595 +6609 +6619 +6621 +6641 +6648 +6693 +6686 +6693 +6677 +6700 +6706 +6707 +6710 +6735 +6745 +6746 +6747 +6748 +6750 +6753 +6755 +6756 +6759 +6760 +6771 +6770 +6775 +6785 +6788 +6793 +6796 +6797 +6806 +6814 +6821 +6822 +6823 +6825 +6827 +6841 +6846 +6841 +6834 +6836 +6837 +6815 +6824 +6830 +6837 +6841 +6834 +6835 +6836 +6826 +6841 +6835 +6795 +6794 +6795 +6793 +6794 +6795 +6804 +6816 +6817 +6819 +6830 +6835 +6840 +6845 +6853 +6897 +6896 +6894 +6896 +6899 +6897 +6903 +6886 +6889 +6890 +6891 +6890 +6891 +6894 +6888 +6905 +6906 +6916 +6917 +6921 +6920 +6924 +6925 +6939 +6958 +6968 +6969 +6974 +6977 +6975 +6971 +6963 +6964 +6974 +6975 +6976 +6977 +6971 +6969 +6977 +7003 +6985 +6993 +6997 +6999 +7000 +7001 +6999 +7000 +7004 +7003 +7017 +7033 +7053 +7058 +7066 +7067 +7064 +7066 +7062 +7063 +7088 +7093 +7096 +7106 +7110 +7116 +7124 +7125 +7128 +7150 +7152 +7154 +7159 +7161 +7162 +7144 +7176 +7183 +7185 +7172 +7208 +7207 +7222 +7225 +7226 +7222 +7210 +7211 +7212 +7238 +7231 +7221 +7236 +7237 +7234 +7235 +7253 +7249 +7253 +7263 +7260 +7259 +7260 +7261 +7263 +7241 +7243 +7257 +7260 +7261 +7275 +7258 +7263 +7274 +7279 +7280 +7289 +7307 +7289 +7301 +7307 +7309 +7317 +7337 +7360 +7364 +7375 +7373 +7377 +7403 +7415 +7438 +7439 +7438 +7442 +7445 +7446 +7450 +7452 +7453 +7460 +7468 +7472 +7478 +7474 +7487 +7486 +7487 +7488 +7492 +7510 +7509 +7506 +7507 +7512 +7516 +7519 +7514 +7525 +7545 +7553 +7554 +7560 +7561 +7560 +7561 +7564 +7571 +7601 +7605 +7628 +7629 +7642 +7651 +7682 +7684 +7685 +7698 +7699 +7713 +7734 +7753 +7755 +7760 +7767 +7775 +7776 +7777 +7760 +7763 +7770 +7758 +7769 +7765 +7772 +7777 +7774 +7780 +7781 +7785 +7783 +7800 +7801 +7799 +7804 +7805 +7814 +7815 +7801 +7802 +7803 +7806 +7808 +7810 +7816 +7821 +7796 +7795 +7793 +7792 +7769 +7770 +7777 +7771 +7772 +7773 +7775 +7776 +7778 +7766 +7767 +7768 +7774 +7775 +7780 +7781 +7782 +7788 +7791 +7796 +7798 +7813 +7814 +7817 +7824 +7825 +7826 +7828 +7843 +7867 +7870 +7872 +7875 +7877 +7878 +7888 +7893 +7902 +7904 +7911 +7914 +7915 +7919 +7915 +7945 +7946 +7952 +7954 +7931 +7935 +7936 +7900 +7915 +7920 +7911 +7914 +7925 +7937 +7942 +7974 +7976 +7989 +7993 +8006 +8007 +8010 +8016 +8020 +8026 diff --git a/2021/01/sol.scm b/2021/01/sol.scm new file mode 100644 index 0000000..94100b7 --- /dev/null +++ b/2021/01/sol.scm @@ -0,0 +1,35 @@ +(import (chicken io)) + +(define (read-num port) + (let ((line (read-line port))) + (if (eof-object? line) + #f + (string->number line)))) + +(define (part-1 port) + (let loop ((total 0) (prev #f) (num (read-num port))) + (define (next) + (loop total num (read-num port))) + (cond ((not num) total) + ((not prev) (next)) + ((< prev num) (loop (add1 total) num (read-num port))) + (else (next))))) + +(define (winsum vect) + (apply + (vector->list vect))) + +(define (part-2 port) + (let loop ((i 0) (total 0) (window #(0 0 0)) (num (read-num port))) + (if (not num) + total + (let ((old-val (winsum window))) + (vector-set! window (modulo i 3) num) + (if (and (> i 2) (< old-val (winsum window))) + (loop (add1 i) (add1 total) window (read-num port)) + (loop (add1 i) total window (read-num port))))))) + +(call-with-input-file "input" + (lambda (p) (print (part-1 p)))) + +(call-with-input-file "input" + (lambda (p) (print (part-2 p)))) diff --git a/2021/02/a.c b/2021/02/a.c new file mode 100644 index 0000000..dcab638 --- /dev/null +++ b/2021/02/a.c @@ -0,0 +1,24 @@ +#include +#include +#include + +int main(void) { + int depth = 0; + int pos = 0; + int val; + char comm[256]; + while(scanf("%255s %d\n", comm, &val) != EOF) { + if (!strcmp(comm, "forward")) { + pos += val; + } else if (!strcmp(comm, "up")) { + depth -= val; + } else if (!strcmp(comm, "down")) { + depth += val; + } else { + fprintf(stderr, "bad command: %s\n", comm); + exit(1); + } + } + printf("%d\n", pos * depth); + return 0; +} diff --git a/2021/02/a.py b/2021/02/a.py new file mode 100755 index 0000000..274ddfe --- /dev/null +++ b/2021/02/a.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +import sys + +depth = 0 +horiz = 0 + +for l in sys.stdin: + comm, val = l.split() + if comm == "down": + depth += int(val) + elif comm == "up": + depth -= int(val) + elif comm == "forward": + horiz += int(val) + else: + raise Exception(f"bad comm: {comm}") + +print(horiz * depth) diff --git a/2021/02/b.c b/2021/02/b.c new file mode 100644 index 0000000..3f3faee --- /dev/null +++ b/2021/02/b.c @@ -0,0 +1,26 @@ +#include +#include +#include + +int main(void) { + int depth = 0; + int pos = 0; + int aim = 0; + int val; + char comm[256]; + while(scanf("%255s %d\n", comm, &val) != EOF) { + if (!strcmp(comm, "forward")) { + pos += val; + depth += val * aim; + } else if (!strcmp(comm, "up")) { + aim -= val; + } else if (!strcmp(comm, "down")) { + aim += val; + } else { + fprintf(stderr, "bad command: %s\n", comm); + exit(1); + } + } + printf("%d\n", pos * depth); + return 0; +} diff --git a/2021/02/b.py b/2021/02/b.py new file mode 100755 index 0000000..27ab67e --- /dev/null +++ b/2021/02/b.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +import sys + +depth = 0 +horiz = 0 +aim = 0 + +for l in sys.stdin: + comm, val = l.split() + if comm == "down": + aim += int(val) + elif comm == "up": + aim -= int(val) + elif comm == "forward": + horiz += int(val) + depth += aim * int(val) + else: + raise Exception(f"bad comm: {comm}") + +print(horiz * depth) diff --git a/2021/02/input b/2021/02/input new file mode 100644 index 0000000..26e4fc2 --- /dev/null +++ b/2021/02/input @@ -0,0 +1,1000 @@ +forward 4 +down 7 +down 4 +forward 2 +down 4 +down 9 +down 1 +forward 1 +down 4 +up 5 +forward 5 +down 3 +forward 5 +forward 6 +down 5 +down 3 +forward 8 +up 7 +forward 1 +forward 5 +forward 7 +up 2 +up 7 +down 1 +down 6 +forward 7 +forward 6 +down 7 +up 9 +down 8 +down 3 +down 1 +down 4 +down 3 +forward 7 +down 1 +forward 6 +down 3 +forward 3 +down 6 +forward 5 +down 7 +up 5 +forward 7 +forward 9 +up 1 +forward 5 +down 5 +down 2 +forward 1 +up 7 +down 8 +down 2 +forward 8 +forward 1 +up 1 +up 5 +forward 9 +up 9 +down 5 +down 5 +forward 6 +forward 1 +down 1 +down 3 +up 6 +up 9 +down 6 +down 1 +forward 1 +down 8 +down 3 +down 8 +up 6 +forward 2 +up 8 +down 2 +down 6 +forward 1 +down 2 +down 1 +down 5 +down 8 +forward 8 +down 8 +down 2 +up 1 +up 3 +forward 1 +down 6 +up 5 +forward 5 +up 7 +forward 3 +forward 3 +down 9 +forward 1 +forward 7 +down 1 +down 1 +down 3 +forward 4 +down 4 +forward 2 +up 8 +forward 2 +down 4 +down 2 +up 1 +forward 6 +forward 6 +down 9 +forward 5 +down 3 +forward 5 +down 6 +down 9 +forward 9 +up 6 +down 8 +up 5 +up 2 +forward 5 +down 4 +forward 8 +up 1 +forward 2 +down 9 +down 4 +up 7 +down 1 +down 6 +down 7 +down 7 +down 2 +down 2 +up 7 +down 1 +up 7 +up 4 +forward 9 +down 6 +up 3 +down 5 +forward 8 +up 4 +forward 5 +forward 8 +forward 4 +forward 7 +forward 2 +down 3 +up 4 +forward 7 +forward 3 +down 7 +up 4 +forward 8 +forward 9 +forward 9 +up 6 +up 5 +forward 7 +down 7 +up 5 +down 9 +down 8 +forward 5 +forward 2 +down 1 +down 2 +down 9 +up 5 +down 3 +down 8 +up 6 +forward 9 +down 9 +up 3 +up 9 +forward 3 +forward 9 +down 5 +up 3 +down 6 +forward 5 +down 6 +down 9 +forward 3 +down 7 +down 5 +down 9 +forward 8 +down 8 +forward 8 +forward 2 +up 6 +down 9 +down 7 +down 4 +down 2 +down 9 +forward 7 +up 1 +forward 6 +forward 7 +down 3 +down 5 +down 3 +forward 4 +down 9 +forward 2 +down 1 +forward 4 +up 9 +down 8 +down 9 +forward 5 +up 2 +down 7 +down 2 +down 7 +forward 8 +up 8 +forward 9 +up 8 +down 3 +down 8 +forward 2 +up 7 +forward 4 +up 8 +forward 6 +forward 6 +forward 4 +forward 3 +down 4 +up 7 +down 8 +forward 1 +forward 9 +forward 8 +forward 8 +down 6 +down 6 +down 4 +down 8 +forward 9 +down 8 +down 4 +forward 2 +forward 7 +down 4 +up 1 +down 4 +down 5 +up 5 +up 9 +down 5 +up 5 +forward 2 +down 8 +forward 7 +forward 2 +up 4 +forward 8 +up 7 +down 5 +forward 5 +down 5 +down 6 +down 7 +forward 1 +down 8 +up 8 +up 9 +up 6 +forward 2 +forward 7 +forward 4 +down 6 +up 4 +up 3 +down 3 +forward 7 +up 9 +down 9 +up 5 +forward 1 +up 7 +down 7 +down 7 +up 8 +down 3 +forward 6 +down 6 +down 7 +down 2 +forward 5 +up 8 +up 5 +up 1 +down 5 +forward 9 +forward 9 +forward 2 +forward 6 +up 8 +forward 8 +down 1 +forward 6 +up 7 +up 3 +forward 3 +up 5 +down 8 +forward 2 +down 5 +down 5 +forward 8 +forward 8 +forward 6 +up 7 +up 1 +forward 1 +down 7 +down 1 +up 9 +forward 7 +up 6 +down 2 +down 5 +forward 1 +down 1 +up 1 +forward 7 +forward 7 +forward 1 +up 2 +forward 2 +down 9 +down 8 +forward 9 +forward 8 +up 9 +down 1 +down 3 +up 1 +down 3 +up 9 +down 7 +up 6 +down 1 +down 2 +down 2 +down 4 +forward 4 +forward 3 +down 7 +forward 9 +forward 1 +down 2 +down 2 +down 4 +down 7 +up 7 +forward 6 +forward 2 +down 6 +down 3 +down 3 +down 8 +up 8 +forward 6 +down 8 +down 3 +forward 7 +down 4 +down 4 +up 1 +up 8 +forward 5 +forward 6 +down 8 +down 9 +up 7 +forward 2 +forward 4 +down 4 +forward 6 +forward 5 +down 4 +up 5 +down 5 +forward 1 +down 2 +up 9 +forward 9 +forward 6 +forward 8 +down 2 +down 9 +up 1 +forward 6 +down 3 +forward 6 +forward 7 +down 9 +forward 1 +forward 1 +forward 5 +up 5 +up 6 +forward 8 +forward 6 +forward 6 +forward 8 +down 6 +down 8 +forward 5 +forward 7 +forward 3 +forward 3 +up 5 +forward 8 +up 3 +forward 6 +forward 4 +forward 3 +up 8 +down 1 +down 3 +down 7 +up 8 +forward 5 +down 9 +up 7 +down 2 +down 4 +down 5 +down 2 +up 3 +down 4 +down 4 +forward 4 +forward 6 +up 4 +forward 5 +forward 3 +up 2 +up 3 +down 4 +down 7 +forward 7 +forward 2 +down 2 +forward 5 +up 4 +forward 2 +down 8 +up 5 +up 6 +forward 2 +forward 3 +up 3 +down 2 +forward 7 +down 6 +forward 3 +forward 6 +up 9 +forward 7 +up 1 +forward 1 +forward 2 +down 3 +forward 9 +down 1 +up 5 +up 7 +up 8 +down 5 +up 4 +down 9 +forward 4 +up 8 +forward 3 +forward 7 +down 7 +down 9 +down 5 +up 4 +down 2 +up 5 +down 4 +forward 3 +down 7 +up 5 +forward 9 +forward 9 +forward 7 +up 5 +forward 7 +up 3 +forward 8 +down 1 +down 5 +up 5 +forward 4 +forward 9 +forward 9 +up 5 +down 9 +up 7 +up 3 +forward 5 +down 4 +down 7 +forward 9 +down 9 +up 3 +forward 4 +forward 7 +down 9 +forward 2 +down 2 +forward 1 +down 2 +up 7 +down 6 +forward 9 +forward 1 +down 5 +forward 9 +forward 7 +up 4 +forward 9 +forward 7 +up 4 +down 1 +down 3 +down 3 +down 1 +down 9 +forward 3 +forward 5 +forward 2 +down 1 +forward 9 +down 6 +up 6 +down 7 +down 1 +down 1 +up 1 +up 8 +down 6 +down 3 +down 9 +forward 3 +forward 9 +down 4 +forward 6 +forward 7 +down 3 +forward 5 +up 8 +up 6 +forward 3 +forward 2 +down 6 +up 7 +forward 3 +forward 1 +down 8 +down 1 +forward 1 +forward 2 +up 7 +down 3 +forward 9 +forward 6 +up 8 +forward 3 +down 3 +down 9 +down 3 +down 6 +down 6 +down 2 +forward 8 +down 3 +forward 2 +up 8 +forward 5 +up 6 +down 7 +down 4 +down 2 +up 9 +down 4 +down 9 +down 4 +down 9 +forward 2 +down 5 +down 5 +forward 7 +up 2 +forward 5 +forward 1 +down 4 +forward 6 +forward 9 +down 1 +down 2 +down 6 +forward 5 +up 9 +up 1 +up 9 +up 4 +down 1 +up 3 +down 5 +forward 4 +forward 3 +forward 1 +down 9 +down 9 +down 6 +forward 4 +forward 4 +forward 1 +down 9 +down 8 +down 7 +forward 2 +forward 7 +forward 1 +down 7 +forward 8 +forward 7 +up 4 +down 4 +forward 8 +forward 6 +down 6 +forward 9 +down 2 +forward 7 +forward 1 +down 5 +down 5 +down 3 +down 7 +forward 9 +down 2 +forward 3 +forward 6 +up 4 +up 9 +forward 6 +up 8 +up 2 +forward 9 +forward 3 +forward 9 +down 4 +down 8 +down 1 +down 1 +forward 4 +up 3 +forward 1 +forward 5 +down 5 +down 6 +down 7 +forward 5 +down 3 +up 9 +forward 5 +down 4 +up 9 +forward 1 +down 3 +down 5 +forward 2 +down 7 +up 7 +down 2 +forward 2 +down 2 +down 4 +down 3 +forward 6 +down 7 +down 2 +down 1 +forward 7 +forward 9 +forward 8 +up 8 +forward 5 +down 8 +forward 9 +forward 9 +up 5 +forward 9 +up 8 +up 6 +up 5 +up 3 +down 2 +down 8 +down 4 +up 3 +down 4 +up 8 +down 3 +up 1 +down 4 +down 7 +down 4 +up 7 +down 3 +up 3 +up 8 +forward 3 +down 2 +forward 7 +up 9 +forward 2 +down 1 +down 1 +forward 2 +forward 9 +up 6 +forward 3 +forward 2 +down 1 +down 3 +down 6 +forward 7 +down 4 +forward 2 +down 6 +up 3 +up 5 +forward 6 +up 7 +down 5 +up 5 +forward 5 +down 6 +forward 7 +up 2 +forward 3 +forward 4 +forward 9 +down 4 +down 5 +up 7 +up 1 +down 1 +down 5 +forward 4 +down 2 +down 8 +down 6 +down 3 +down 1 +down 9 +forward 5 +forward 7 +down 5 +forward 7 +down 6 +up 8 +up 9 +down 4 +forward 7 +up 1 +up 5 +down 8 +forward 5 +up 8 +forward 1 +forward 7 +forward 5 +forward 8 +forward 8 +up 1 +down 4 +up 6 +down 1 +down 4 +up 9 +forward 4 +forward 1 +forward 5 +up 7 +forward 5 +forward 7 +up 3 +up 6 +up 3 +forward 4 +down 5 +down 4 +down 2 +down 4 +forward 7 +down 5 +forward 9 +forward 2 +down 3 +up 7 +forward 9 +forward 3 +down 9 +up 8 +forward 1 +forward 3 +up 8 +down 3 +up 9 +down 4 +forward 6 +forward 8 +down 4 +forward 9 +up 1 +forward 3 +forward 1 +up 3 +down 3 +forward 1 +forward 2 +forward 8 +up 3 +down 9 +forward 1 +up 1 +forward 2 +down 4 +forward 7 +up 9 +forward 2 +down 6 +down 8 +up 1 +forward 1 +forward 7 +down 8 +forward 7 +up 9 +up 5 +down 6 +down 2 +down 9 +down 9 +down 7 +down 4 +forward 4 +up 2 +up 8 +forward 5 +down 9 +down 7 +forward 3 +forward 1 +down 3 +down 1 +forward 5 +up 2 +up 9 +up 2 +forward 4 +forward 3 +forward 8 +up 9 +up 6 +up 3 +forward 7 +forward 8 +forward 8 +forward 1 +forward 1 +forward 2 +down 2 +down 7 +forward 4 +up 2 +down 4 +forward 5 +down 3 +forward 1 +down 3 +up 2 +forward 9 +forward 7 +forward 5 +forward 1 +forward 6 +forward 9 +up 3 +down 8 +down 8 +forward 3 +up 4 +up 1 +down 4 +forward 8 +up 9 +down 4 +down 5 +forward 1 +forward 7 +up 2 +down 2 +down 2 +down 1 +up 6 +forward 7 +forward 7 +down 7 +down 8 +forward 1 +forward 8 +down 3 +up 5 +up 9 +down 2 +down 9 +forward 3 +up 8 +up 9 +up 3 +up 3 +forward 9 +up 6 +up 7 +down 6 +down 8 +forward 4 +down 8 +forward 4 +forward 9 +down 9 +forward 4 +up 6 +up 5 +down 2 +forward 6 +down 2 +up 2 +up 4 +forward 4 +forward 6 +down 7 +up 4 +down 8 +forward 1 +down 5 +forward 4 +down 3 +forward 3 +down 5 +forward 7 +down 8 +up 7 +down 7 +forward 1 +forward 6 +up 7 +up 8 +up 2 +forward 1 +forward 1 +down 5 +down 9 +forward 7 +forward 5 +down 7 +up 1 +forward 6 +forward 6 +down 6 +forward 1 +down 1 +down 2 +down 4 +forward 5 +up 7 +up 7 +forward 6 +down 1 +forward 7 diff --git a/2021/02/sol.scm b/2021/02/sol.scm new file mode 100644 index 0000000..c4fb304 --- /dev/null +++ b/2021/02/sol.scm @@ -0,0 +1,41 @@ +(import (chicken io) + (chicken string)) + +(define (part-1 port) + (let loop ((h 0) (d 0)) + (let ((l (read-line port))) + (if (eof-object? l) + (* h d) + (let* ((parts (string-split l)) + (act (car parts)) + (mag (string->number (cadr parts)))) + (cond ((equal? act "down") + (loop h (+ d mag))) + ((equal? act "up") + (loop h (- d mag))) + ((equal? act "forward") + (loop (+ h mag) d)) + (else (error "Bad action " act)))))))) + +(define (part-2 port) + (let loop ((h 0) (d 0) (a 0)) + (let ((l (read-line port))) + (if (eof-object? l) + (* h d) + (let* ((parts (string-split l)) + (act (car parts)) + (mag (string->number (cadr parts)))) + (cond ((equal? act "down") + (loop h d (+ a mag))) + ((equal? act "up") + (loop h d (- a mag))) + ((equal? act "forward") + (loop (+ h mag) (+ d (* a mag)) a)) + (else (error "Bad action " act)))))))) + + +(call-with-input-file "input" + (lambda (p) (print (part-1 p)))) + +(call-with-input-file "input" + (lambda (p) (print (part-2 p)))) diff --git a/2021/03/a.c b/2021/03/a.c new file mode 100644 index 0000000..b251ca0 --- /dev/null +++ b/2021/03/a.c @@ -0,0 +1,55 @@ +#include +#include + +#define MAX_WIDTH 32 + +int main(void) { + /* Key takeaway: if think of the input as a matrix, we can + * sum the columns and count the number of entries and know + * that if N entries had X sum, there's X 1's and N-X 0's. + */ + int counts[MAX_WIDTH] = { 0 }; + int c; + int col = 0; + int n = 0; + while ((c = getchar()) != EOF) { + switch (c) { + case '0': + col++; + break; + case '1': + counts[col]++; + col++; + break; + case '\n': + /* reset the column */ + col = 0; + n++; + break; + default: + fprintf(stderr, "bad input"); + exit(1); + break; + } + } + + /* convert counts into a bitmask of 1/0 based on which was max */ + unsigned int gamma = 0; + unsigned int eps = 0; + for (int i = 0; i < MAX_WIDTH; i++) { + if (counts[i] == 0) { + /* assume we see each at least once, so this was the end of width */ + break; + } + /* boost the last value to make room for more! */ + gamma <<= 1; + eps <<= 1; + if (counts[i] > n / 2) { + gamma |= 1; + } else { + eps |= 1; + } + } + printf("%u\n", eps * gamma); + return 0; +} diff --git a/2021/03/a.py b/2021/03/a.py new file mode 100755 index 0000000..8334139 --- /dev/null +++ b/2021/03/a.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +import sys + +# First get the counts of bit by position +counts = [] +first = True +for l in sys.stdin: + i = 0 + for c in l.strip(): + if first: + counts.append([0, 0]) + counts[i][int(c)] += 1 + i += 1 + + first = False + +# Then build up the binary string summaries +gamma = "" +eps = "" +for c in counts: + if c[0] > c[1]: + gamma += "0" + eps += "1" + else: + gamma += "1" + eps += "0" + +print(int(gamma, 2) * int(eps, 2)) diff --git a/2021/03/b.py b/2021/03/b.py new file mode 100755 index 0000000..e8bfdc1 --- /dev/null +++ b/2021/03/b.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +import sys + +def search(nums, maximum): + # idx to consider + i = 0 + while len(nums) > 1: + # count just that digit in the string (rest is garbage) + counts = [0, 0] + for n in nums: + counts[int(n[i])] += 1 + + # filter the list down to most or least common + is_zero = lambda x: x[i] == "0" + is_one = lambda x: x[i] == "1" + if (maximum and counts[0] > counts[1]) or (not maximum and counts[0] <= counts[1]): + nums = list(filter(is_zero, nums)) + else: + nums = list(filter(is_one, nums)) + i+=1 + + return nums[0] + +# We need multiple iterations on this one -- save to mem +if __name__ == '__main__': + nums = [] + for l in sys.stdin: + nums.append(l.strip()) + + oxygen = int(search(nums, maximum=True), 2) + co2 = int(search(nums, maximum=False), 2) + + print(oxygen * co2) diff --git a/2021/03/input b/2021/03/input new file mode 100644 index 0000000..ac22a69 --- /dev/null +++ b/2021/03/input @@ -0,0 +1,1000 @@ +011001101000 +010101111100 +000000111101 +001001001010 +010011000001 +111111001110 +001011101111 +110011010110 +100011111110 +101110000111 +000011011100 +001111111011 +011101001111 +111001010110 +011100011110 +001011000010 +100010111011 +000101010011 +000001101100 +010001011110 +100010101000 +111101011101 +110000100001 +011011010101 +110101100110 +001101101010 +111010110011 +011111111000 +010001010001 +000001010101 +001001011011 +101111110011 +100011010001 +111010010111 +011010011010 +101111011011 +101010111100 +001111100110 +010100110111 +010110101100 +000111110101 +111110101110 +111010000000 +011111111010 +000101011100 +000001010110 +101000100101 +100001011001 +011101110010 +110111100100 +110011001011 +000010001111 +000100010101 +110111001100 +010001100000 +101111110101 +111000011011 +000100001001 +101101011101 +001001011110 +101100111010 +011011000010 +110010010111 +101001010101 +000000101110 +000011011111 +010001000011 +011011001010 +101101111011 +100010001010 +001001011100 +010011110001 +000001111101 +100001000101 +011101011010 +000010101110 +001010101010 +101010011011 +000111001011 +000011101000 +110100101001 +000111111010 +100111100101 +111010001111 +111100110001 +011111101010 +110101000011 +001111101100 +101000100110 +100101100011 +000011010011 +010101011111 +010000110111 +110011001001 +101011011101 +001011100001 +000001100101 +001001001101 +001101001111 +001110110001 +010110101110 +001100110110 +001000001111 +101101001001 +011111011010 +111111101110 +111001100000 +100101011001 +010101100101 +100000110100 +011001001000 +111100110011 +111011110001 +110011111010 +001101001010 +111110011111 +110101100000 +111001000101 +010001111110 +111011010100 +110011010111 +100100110111 +111111011010 +011110101111 +001011110010 +010111011010 +011101101101 +011010101110 +011000110001 +010110101010 +011110010000 +111111011100 +111011000101 +100110101110 +010101100010 +101100011110 +000010110101 +010010011110 +110000000110 +011111010101 +000110110011 +101011000010 +000011000111 +101011010000 +101101101001 +010000101010 +101001001001 +111010110110 +111000111101 +000001010111 +101110001100 +110010110001 +100000110001 +101100101011 +100000111001 +010110100111 +101011001111 +101010111001 +010010110000 +001110010011 +010101101110 +011000010100 +100111111000 +011110100011 +110100100111 +101110101000 +101010101111 +101001000000 +111010000110 +101001000100 +010001100111 +011011010001 +000101010101 +010110000011 +100000101110 +110010001000 +111000100001 +001001101001 +110010001001 +100001111011 +101010010100 +110011100101 +010101100001 +011101010100 +110100101111 +110100001111 +011000101101 +001011101100 +010010010101 +011011111010 +010101000001 +100101100000 +101001111101 +010000000100 +110000110100 +000000001101 +100100111101 +111100110010 +001011001111 +101100001011 +001111010001 +101100011001 +100110110001 +010111000011 +011010110101 +100111100011 +000111110011 +010101111101 +010010000000 +011000011011 +001100011001 +001011001001 +101110101101 +101111110111 +101011100100 +000100110100 +110000101111 +011001111101 +000000000111 +111001001010 +110100001100 +000001001110 +111001101011 +100011011111 +110000001000 +110101011011 +001010000101 +001011111001 +011011111100 +010100110101 +110101111001 +010110010101 +010010001000 +001001110111 +011111111111 +100011100010 +000110001101 +011111010000 +010111110010 +110010100011 +101011110101 +110011011110 +010000000101 +011101100100 +110010011100 +011101101100 +000010001001 +000011101101 +000101100011 +010111111000 +010111100111 +010101000101 +110111100010 +110001101011 +111010100000 +101010101011 +011101010101 +000100110111 +000111100111 +000100111111 +111100001001 +010000100001 +110101011111 +100010000100 +000011011000 +111011110000 +101000011100 +110001001010 +001000010101 +110110000101 +100000011110 +001101111010 +010111001100 +111011111100 +100101001000 +010111101001 +110010010000 +110011010000 +000010100111 +100101111101 +110101100010 +110100011110 +101111010110 +110001001111 +011101000111 +001011001101 +110001000010 +011110100110 +000101100110 +000110111110 +001010111010 +100110000111 +001000010110 +100001110100 +000111000110 +101100011100 +110100110110 +100011010111 +000101110001 +001010010110 +101000000101 +100101101000 +000111111110 +010010010111 +110010001010 +001100110111 +110110110101 +011111011101 +110101100111 +100100100111 +011011000000 +111101001100 +011101000011 +011101001010 +101101101101 +100100110010 +001000000010 +010010001010 +111110111001 +000111010001 +011100111111 +011111011001 +110101000000 +011110000010 +001111010110 +010011111111 +110101111011 +101110111111 +001001100001 +011100111100 +110111001110 +011000000111 +001100010111 +001011010010 +010010001011 +101110000011 +100000101000 +100010100100 +000111011101 +001000111011 +010010101010 +111011010011 +110100010001 +011110001110 +111010110001 +010000010111 +010110101101 +111101100001 +110011100110 +000101111110 +110010101010 +000001010000 +001101111101 +011011110100 +110001010101 +011001000001 +001101101100 +100011011011 +101011100010 +011011100101 +100110110101 +110111001011 +000100101011 +001101010100 +010000011100 +101100111011 +011001011100 +011011010100 +011100110001 +010010110011 +101000110011 +111101010001 +111000000100 +101101100111 +001011111000 +010100000111 +011110101101 +111011101100 +110101110001 +001110010000 +010010000111 +101001111011 +100100111100 +000101101101 +101111110100 +100000101111 +011001110000 +011110011001 +000101010110 +000000000101 +110010001100 +000111100100 +010010011010 +001111110100 +011010001010 +101100101111 +011001001011 +100011111101 +101100000001 +100100101010 +000000000100 +111001110101 +000010011110 +110110100100 +111010010001 +011101010010 +011100101111 +010110000010 +010000110101 +110101010011 +001110011110 +111010011010 +000110101000 +001111000001 +010110110000 +001100110001 +110011011111 +000100111011 +110001000111 +011010111101 +000010100110 +010100101001 +010001000010 +000101110101 +101100110100 +111000110010 +111011110010 +010111001111 +100000101101 +101100001010 +100100001001 +111111111101 +001010101001 +000011011010 +101011010010 +111001000110 +111100010011 +111010011100 +100000111100 +011100001101 +110001101000 +101111011001 +001100001000 +101110010111 +011111100000 +001011100000 +101011101010 +110010101111 +001110000101 +001111011011 +011110101000 +111000001000 +010100111010 +010010111001 +110000110001 +110011000101 +001110000100 +010100101101 +101010110100 +100001010100 +100011010011 +100000010010 +011101010111 +001000010111 +001100111100 +000110100011 +101111101010 +010001010000 +001100100110 +111001111110 +101000001001 +000010110010 +110111101011 +101011000011 +001000111111 +100011001101 +011010010101 +110011100011 +110010011010 +110001010100 +100010111101 +101110000110 +010111001011 +110011011100 +110001100011 +000100011010 +111011100010 +011110110011 +011111100010 +000100001101 +100010010000 +110000000011 +101001011000 +101100110101 +001010101011 +011001011010 +001010001001 +001111011100 +111100010001 +100011010110 +001000110111 +011011010011 +001100000000 +100001111100 +000011110101 +100010000111 +000010110011 +000010111110 +011110000101 +010000001011 +001111110010 +001110001001 +011101111111 +010110110001 +110000000111 +010101011101 +010111001001 +100100010010 +101001101110 +100001001010 +010001011101 +100111010101 +100000101011 +000100101001 +110111001001 +100100000001 +010111010010 +111101111011 +011010010010 +111101101000 +100110111101 +010010001001 +100111011000 +110101111111 +111010101110 +010011110010 +101001100100 +010000101111 +010011001111 +110010011111 +101110100111 +011010100101 +111111001001 +010101100110 +101001001101 +001000101010 +010001001100 +101001101000 +110110100000 +011101000101 +100101010101 +101110111011 +010010101001 +110100011000 +110101111010 +110000100000 +010011101101 +111011001101 +100100011101 +110100010111 +011100110100 +010111011001 +011101010001 +101000000010 +100111111001 +100100001000 +001000001000 +001000000100 +011110110010 +010101010011 +101101101100 +110111111001 +010000010011 +100010100001 +000110101111 +101010101101 +100101111100 +000111010110 +001101101111 +110010000011 +110100001110 +011111111101 +111011010101 +001010100010 +100010100110 +101101110111 +010110011011 +111001110110 +011110101001 +110011100111 +000100111101 +101100011000 +101101001010 +011111100111 +010000011000 +100001100110 +000000101101 +000111010010 +110000001100 +111111101010 +001000100010 +111111111011 +001011100111 +000101110010 +010111110011 +010000011001 +111001111101 +110100001101 +010001101000 +110000101011 +011011000110 +110010111011 +100111101010 +011001101011 +001101010011 +011000100101 +110111101111 +001000100001 +010010111101 +101101101011 +011111011100 +111111010110 +001110000000 +101011110010 +011101011111 +001001101101 +011101110000 +011100011101 +111101001101 +010111010101 +010111101010 +001000101101 +100000000011 +111110101111 +000111101111 +001110010101 +101111001101 +111100110000 +110010100000 +011101110100 +100011001111 +010110001001 +111100101100 +101001110100 +011010010111 +011000100100 +001100110100 +001001111000 +001000000111 +110100000111 +011000001011 +001011000000 +110110110111 +000010111011 +001001000011 +000011100111 +110011001111 +010000111101 +001110100010 +000011110001 +011001111011 +110111000001 +111111000001 +011001100110 +110010101100 +111101010100 +010010000101 +000011011011 +110110010001 +010111111010 +010000010101 +110000011010 +110001101110 +000110101011 +101111000111 +001101100000 +010100000001 +111110001001 +000011110000 +111100111001 +000001001011 +011000010110 +000001000100 +011100111000 +001011111110 +011100000000 +000101001011 +111111110110 +111010011000 +001000111101 +011001110010 +001101011100 +100110001111 +110110111010 +001110101100 +010000101100 +010011000011 +100101110010 +000000111010 +000001111001 +111101011000 +101000011001 +111110000101 +101111111011 +100110111110 +000110010110 +011011101110 +100000010111 +110111001000 +000010101010 +001010011011 +101010101010 +101100000000 +000101101011 +010110100110 +110010010100 +001010110101 +001110000001 +010001101010 +111111110100 +001101110110 +111101010111 +101011101100 +110001101010 +100111010100 +101101111001 +001011100110 +010010001111 +100101110110 +110011000010 +001111010100 +000101011011 +110000000001 +011011001001 +001001011111 +000111011111 +100001001100 +111011010010 +010101011001 +000001110100 +000010100101 +110110010010 +100010111110 +011110111110 +000001101000 +001011000110 +000010001010 +101101010100 +011011010000 +000011111000 +101000001110 +011110101011 +110100111000 +000011000010 +111111010001 +011101110001 +100000111101 +110100101101 +110000100101 +011001110110 +110001010010 +010010110110 +011110001000 +111010110100 +101111110010 +110000110111 +111101110100 +110111101110 +100110010111 +001001100011 +001110111000 +101110100100 +010000101101 +010111100101 +011001100010 +011100000101 +101001111001 +100011001010 +100010000010 +100101000010 +111111100101 +100001101110 +101001010110 +100000100011 +100000011000 +000110000001 +000000011011 +011000110101 +011010111011 +111110000001 +001001110100 +001011011110 +110111010110 +011101110101 +101111000101 +100001010010 +000001111000 +001110010100 +111111101100 +001011010001 +111001111001 +100101101010 +111000000010 +010101001010 +001010000010 +101011000110 +110011001010 +001000011000 +001010010011 +110000111101 +001001100000 +111101100111 +011001001100 +001100111011 +100001010101 +111010100011 +111000011111 +001000000000 +101110011001 +000000000011 +111011000111 +011010100011 +110000110000 +000011001001 +011000010001 +011110000011 +011101000000 +010100110011 +010110010001 +111001101111 +110111110100 +110111110110 +100111001011 +111100110110 +101010001110 +100110000010 +011011100001 +001101010010 +010001110011 +010011110000 +110010100111 +001101110100 +101010101100 +110000111000 +011101110110 +101011110001 +110011000000 +010000011011 +001011010000 +010111010001 +010100010101 +110101000100 +010011101011 +010110111001 +101111000011 +011011100000 +000010100010 +001100110000 +110000111001 +100100100000 +001101000010 +100000010011 +100010011110 +110101010000 +000100000101 +000111000001 +000001111011 +100111011101 +110111110111 +011101111000 +001001000110 +100110010011 +100011100111 +010011010000 +010011010111 +001101100101 +010000010110 +000101010001 +011111010100 +010010111100 +001010101110 +110000001011 +011001010101 +000001111110 +010111111011 +011110010010 +001001101100 +101100101000 +100000001110 +110001001110 +011110111011 +001000110011 +111100110111 +001101100111 +000110110000 +000010011011 +100110111010 +111110001100 +000000101100 +110000111100 +100110111100 +110111111100 +110000111010 +100001100100 +100010011010 +011011100110 +110100010110 +001001010101 +000110101110 +101001100000 +100010110011 +111000001101 +101110100110 +100010111100 +000101110110 +000011011001 +000001010100 +101100111001 +011101111101 +011110011000 +111010001011 +010101110101 +100001100101 +100110100010 +100110011000 +001010100110 +011001010111 +111111001010 +111111001000 +111110100101 +000101000011 +110101101111 +110100010010 +011100000010 +001000010100 +101100000111 +001010111111 +101001010011 +101011001000 +001100000011 +010010101000 +101101111101 +101001010010 +100101111011 +101110101110 +100000100100 +000000000010 +011101100011 +110000110110 +101000110000 +111011111010 +010111000110 +001111110110 +100111110110 +100110011101 +000000001000 +101110111010 +000101011000 +001011100011 +011101100111 +000011000011 +000101011001 +110101101101 +101000001111 +111000010101 +000011100010 +011010111001 +001100100101 +010111111101 +010101111011 +000101001100 +101010000111 +111100111111 +100000000111 +110111110011 +000110110111 +010011011111 +100110010100 +000100111110 +001000111001 +011111000001 +001010100101 +101010001100 +011100001011 +000101001111 +010010101111 +101000111011 +001101000001 +100100100001 +100010101111 +100111111110 +011011111001 +101000000001 +111001101101 +101011010101 +111111100110 +001010010100 +011101111001 +001100100000 +101001110110 diff --git a/2021/04/a.py b/2021/04/a.py new file mode 100755 index 0000000..14bd774 --- /dev/null +++ b/2021/04/a.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +import sys +import common +from collections import defaultdict + + +def main(boards, N): + # we need an efficient way to find boards with numbers + # get a mapping of num_called -> (board_idx, row, col) + index = common.index(boards) + + # now go through all numbers and keep track of if r/c counts + # by board, if one is 5... + seen = {} + counts = {} + for n in N: + seen[n] = 1 + if n not in index: + continue + for b, r, c in index[n]: + if b not in counts: + counts[b] = defaultdict(int) + counts[b][f"r{r}"] += 1 + counts[b][f"c{c}"] += 1 + + # check win condition + for v in counts[b].values(): + if v == 5: + # find all unmarked in board... + s = 0 + for row in boards[b]: + for x in row: + if x not in seen: + s += x + + print(n * s) + sys.exit(0) + + +if __name__ == '__main__': + N, boards = common.parse() + main(boards, N) diff --git a/2021/04/b.py b/2021/04/b.py new file mode 100755 index 0000000..9505599 --- /dev/null +++ b/2021/04/b.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 +import sys +import common +from collections import defaultdict + +def main(boards, N): + # we need an efficient way to find boards with numbers + # get a mapping of num_called -> (board_idx, row, col) + index = common.index(boards) + + # now go through all numbers and keep track of if r/c counts + # by board, if one is 5, we have a winner! + winners = {} + seen = {} + counts = {} + for n in N: + seen[n] = 1 + if n not in index: + continue + for b, r, c in index[n]: + if b in winners: + continue + + if b not in counts: + counts[b] = defaultdict(int) + counts[b][f"r{r}"] += 1 + counts[b][f"c{c}"] += 1 + + # check win condition + for v in counts[b].values(): + if v == 5: + winners[b] = 1 + if len(winners) == len(boards): + # find all unmarked in board... + s = 0 + for row in boards[b]: + for x in row: + if x not in seen: + s += x + + print(n * s) + sys.exit(0) + + +if __name__ == '__main__': + N, boards = common.parse() + main(boards, N) diff --git a/2021/04/common.py b/2021/04/common.py new file mode 100644 index 0000000..d9167b9 --- /dev/null +++ b/2021/04/common.py @@ -0,0 +1,37 @@ +import sys + +def parse(): + first = True + N = None + boards = [] + board = [] + for l in sys.stdin: + if first: + N = [int(x) for x in l.strip().split(',')] + first = False + else: + l = l.strip() + if l: + row = [int(x) for x in l.split()] + board.append(row) + elif board: + boards.append(board) + board = [] + + return N, boards + +def index(boards): + # Generates a lookup table of: + # num_called => (board, row, column) + index = {} + i = 0 + for b in boards: + for r in range(len(b)): + for c in range(len(b[r])): + x = b[r][c] + if x not in index: + index[x] = [] + index[x].append((i, r, c)) + i+=1 + + return index diff --git a/2021/04/input b/2021/04/input new file mode 100644 index 0000000..c21b9b9 --- /dev/null +++ b/2021/04/input @@ -0,0 +1,601 @@ +18,99,39,89,0,40,52,72,61,77,69,51,30,83,20,65,93,88,29,22,14,82,53,41,76,79,46,78,56,57,24,36,38,11,50,1,19,26,70,4,54,3,84,33,15,21,9,58,64,85,10,66,17,43,31,27,2,5,95,96,16,97,12,34,74,67,86,23,49,8,59,45,68,91,25,48,13,28,81,94,92,42,7,37,75,32,6,60,63,35,62,98,90,47,87,73,44,71,55,80 + +12 79 33 36 97 +82 38 77 61 84 +55 74 21 65 39 +54 56 95 50 2 +45 68 31 94 14 + +95 26 80 25 62 +79 91 70 76 61 +98 97 17 75 23 +71 30 21 52 29 +20 54 32 12 31 + +35 31 86 36 52 +18 50 79 60 67 +98 3 51 46 25 + 4 61 55 87 70 +94 39 68 27 14 + + 9 49 53 52 2 +65 92 4 73 67 +90 95 39 78 64 +17 27 13 60 51 +25 63 70 77 22 + +33 34 6 58 77 +44 75 54 18 21 +15 25 79 12 70 +90 14 81 22 49 +72 38 59 78 16 + +13 51 94 40 56 + 6 99 9 64 91 +87 73 93 71 31 +39 42 28 24 7 + 1 52 17 85 11 + +95 23 15 29 12 +40 79 2 64 59 +94 93 3 25 10 + 5 58 7 78 82 +62 73 74 16 56 + +17 55 56 14 51 +70 94 66 21 37 +97 90 43 80 89 +50 12 52 46 85 +16 79 60 15 45 + +18 59 37 25 41 +51 61 63 7 53 + 3 21 31 76 72 +29 99 34 6 83 +55 45 93 75 15 + +59 63 4 95 68 +18 47 43 15 26 +66 7 54 22 8 +50 75 91 20 98 +49 61 55 12 1 + +96 74 37 12 66 +10 94 7 29 75 +20 48 26 67 41 +40 99 9 80 35 +72 87 82 76 85 + +60 58 43 17 57 +25 33 85 91 27 +46 36 54 49 64 +86 53 4 63 95 +38 74 84 37 67 + +66 90 73 98 51 +11 94 60 92 14 +82 58 17 63 52 +33 1 18 77 72 +12 76 20 23 10 + +28 69 67 6 32 + 4 17 77 52 33 +26 57 92 56 73 +30 91 50 82 2 +21 31 61 78 99 + +98 63 26 81 75 +23 36 3 88 65 +69 87 33 20 43 + 4 51 47 70 50 +10 91 74 77 66 + +61 47 90 22 63 +26 15 41 8 73 +71 40 82 91 75 +39 95 56 84 55 + 5 76 32 69 34 + +78 77 1 57 39 +70 49 83 90 87 +97 74 26 67 19 +50 21 2 92 60 +82 65 62 31 33 + + 6 46 97 50 2 +48 23 34 24 93 +83 7 31 59 66 +44 18 21 47 77 +69 86 35 72 17 + +78 68 69 4 26 +47 38 15 95 53 +66 46 49 79 59 +82 30 50 7 2 +17 16 34 64 51 + +19 20 13 75 26 +63 28 14 93 50 +27 70 61 29 67 +12 89 71 33 98 +31 25 16 79 69 + +95 23 83 86 16 + 4 50 27 92 62 +42 29 75 88 49 +31 58 39 44 93 +80 19 15 97 96 + +91 60 6 47 63 +51 90 36 11 72 +73 84 50 76 40 +49 75 82 9 35 +71 1 0 67 59 + +48 56 80 24 86 + 4 74 95 53 41 +52 58 36 19 64 +90 87 99 82 25 +35 13 22 26 21 + +68 87 18 23 97 +69 25 40 76 24 +34 33 56 16 51 +49 77 88 75 26 + 2 19 96 35 86 + +29 26 56 49 10 +89 91 95 5 69 +52 1 99 34 20 + 8 74 64 32 61 +25 72 60 22 97 + +39 65 0 91 86 + 9 7 21 62 89 +22 92 63 46 17 +61 66 37 59 52 +93 70 3 97 49 + +29 3 66 4 43 +46 25 7 62 54 +71 26 70 75 5 +17 82 33 51 19 +65 40 91 53 15 + +88 59 14 41 92 +83 74 73 65 12 +95 97 35 47 55 +62 2 3 9 63 +52 44 32 33 72 + +82 12 77 25 60 + 8 93 38 56 97 +59 5 70 33 40 + 9 90 1 41 57 +68 73 26 91 6 + +72 15 64 59 49 +26 12 9 97 80 +84 18 91 20 87 +69 34 14 65 40 +98 74 27 5 31 + +55 99 23 12 76 +57 92 71 83 53 +19 24 39 97 73 +96 91 32 34 28 + 0 72 42 65 1 + +84 50 97 46 99 +90 1 95 64 22 +45 53 55 25 42 +30 70 52 88 72 +29 44 98 51 6 + +70 74 85 78 45 +34 91 82 63 99 +17 3 50 53 87 +38 88 98 6 92 +39 30 10 18 67 + +26 45 13 93 29 +18 51 66 22 17 +55 75 70 9 6 + 3 74 30 42 91 +21 77 57 37 90 + +17 94 74 85 60 + 2 67 97 19 11 +20 32 58 18 56 +10 95 40 51 93 +66 50 15 65 52 + + 7 38 79 77 42 +15 34 13 80 93 +46 54 74 33 17 + 1 4 83 68 35 +70 85 66 63 39 + +22 68 41 2 58 +69 76 14 62 33 +64 39 46 28 59 +60 21 26 13 74 +12 54 99 82 0 + + 9 0 82 4 20 +88 76 18 55 44 +10 53 74 93 58 +49 50 16 42 2 +19 23 66 54 65 + +96 9 42 30 67 + 3 29 94 5 45 +65 62 25 59 17 +21 79 73 44 66 +38 6 86 7 4 + +89 77 17 13 79 +51 10 28 18 36 +59 69 80 61 25 + 0 21 9 91 30 +86 96 2 29 39 + +53 11 27 20 82 +15 38 90 34 98 +69 28 16 14 99 +67 49 48 42 59 +51 2 61 23 3 + +37 60 14 43 49 +66 24 54 96 58 +73 28 48 3 81 +93 35 97 46 52 +75 84 79 1 11 + +48 75 8 88 85 +81 94 3 32 28 +63 49 78 86 90 +67 84 5 4 52 +57 89 29 96 71 + + 3 34 89 15 64 +47 31 57 72 26 +48 75 19 2 65 +42 45 97 54 71 +55 27 87 77 35 + +74 50 53 19 96 +95 89 71 75 26 + 8 11 20 43 38 +78 51 28 65 93 +64 9 84 31 23 + +37 42 65 94 92 +69 35 40 1 71 +63 43 75 59 74 +97 90 67 91 85 +28 58 21 49 52 + +20 62 44 96 74 +18 37 63 54 51 +39 90 1 4 84 + 7 72 57 19 79 +99 66 43 38 36 + + 2 68 67 21 78 +81 86 63 13 69 +74 29 53 56 30 +16 72 7 54 1 +64 50 73 14 45 + +21 47 88 28 32 + 7 43 83 39 27 +95 9 98 45 99 +68 49 94 73 35 +10 36 13 25 37 + +45 2 16 75 9 +66 46 20 91 87 +36 74 64 85 62 +51 39 93 3 57 + 0 37 56 27 50 + + 9 21 37 96 89 +66 4 16 3 56 +58 32 97 76 47 + 7 59 13 0 34 +69 68 95 61 51 + +30 41 60 88 98 +33 94 57 79 40 +14 36 17 56 99 +10 37 62 54 0 +65 32 58 21 23 + +89 47 65 40 18 +25 17 13 0 33 +49 57 26 3 76 +15 71 70 95 61 +67 94 80 77 7 + +92 40 55 95 8 +88 62 4 43 13 +54 1 19 20 87 +11 97 23 27 80 +63 10 66 45 7 + +46 76 10 61 26 +86 55 15 84 25 +12 80 82 83 54 +22 81 69 70 48 +53 89 30 44 20 + +84 62 57 74 30 +96 18 24 9 29 +22 8 56 44 4 +71 85 16 55 73 +25 28 88 61 33 + +60 26 72 28 89 +51 94 24 96 53 +39 0 90 12 22 +92 95 65 34 32 +63 36 48 58 52 + +92 5 32 52 30 + 6 93 73 74 10 +38 62 55 28 79 +88 60 27 7 83 +82 53 39 70 95 + +84 35 58 4 19 +80 96 53 45 7 +31 52 14 8 63 +87 41 75 65 18 + 3 72 79 91 86 + +16 19 42 49 0 +34 18 26 70 98 +45 38 87 17 54 +84 51 7 24 66 +57 46 3 36 43 + +36 13 44 81 48 +93 88 41 77 57 + 6 64 2 3 46 +30 10 8 20 14 +26 76 7 1 90 + +67 74 39 25 78 + 4 96 62 70 30 +22 41 72 47 32 +87 27 77 51 86 +65 35 26 11 85 + +94 42 49 91 12 +78 51 3 95 76 + 0 72 13 30 25 +33 81 32 58 62 +67 5 88 26 1 + +71 21 29 73 75 +39 77 63 66 36 +74 18 80 35 34 +26 5 53 33 6 +19 1 27 25 9 + +72 53 57 24 30 +66 84 68 40 12 +52 48 34 21 26 +73 3 18 81 67 +82 7 17 36 56 + +93 85 42 81 30 +47 4 48 82 96 +28 41 52 0 36 +97 14 35 9 33 +98 11 69 20 87 + +46 67 85 96 34 +90 92 68 56 51 +16 61 29 28 27 +81 57 64 53 26 + 6 49 43 41 65 + +37 82 55 88 27 +43 79 25 5 50 +92 83 81 44 22 +75 74 39 16 41 +48 29 80 77 90 + +57 25 10 61 40 + 1 22 20 81 41 +32 83 43 54 97 +29 47 15 27 8 +79 28 63 77 99 + +62 43 94 24 48 +45 93 14 34 11 +58 31 33 71 97 +10 59 76 30 26 +64 54 79 80 56 + +34 8 49 13 12 +54 57 4 82 46 +84 32 59 55 40 + 0 73 99 38 56 +16 61 36 17 78 + + 7 97 37 81 91 + 3 10 83 48 90 +49 40 72 6 2 +17 39 94 82 66 +58 68 52 64 42 + +30 93 40 75 74 +62 48 47 3 59 +57 10 73 79 86 +71 89 88 5 38 +13 6 56 80 81 + +58 54 52 83 88 +12 84 87 28 46 +42 6 27 39 4 +47 72 93 64 66 +79 71 44 18 3 + +60 72 89 35 17 +77 66 68 59 9 + 2 43 18 14 33 +20 30 82 31 52 +81 64 56 45 27 + +64 9 44 23 99 +40 75 55 29 86 +94 46 45 84 97 +92 25 30 13 10 +90 87 61 53 70 + + 6 49 41 40 37 +65 24 47 33 55 +51 4 72 16 85 +56 5 25 98 14 +32 26 50 17 34 + +24 78 72 40 31 + 3 12 33 87 71 +99 91 8 59 34 +50 90 63 45 29 +75 96 7 22 44 + +81 94 61 41 10 +23 5 66 27 70 +62 82 4 74 52 +19 55 67 59 49 +48 77 35 33 45 + + 7 86 81 93 19 +90 57 64 45 36 +75 13 2 28 39 +46 10 83 80 47 + 1 91 94 24 56 + +20 18 0 49 44 +77 72 31 61 46 +66 95 73 8 76 + 3 13 99 94 96 +59 97 43 85 86 + +34 78 54 37 0 +12 85 86 93 70 +53 10 59 8 55 +63 20 29 36 32 +76 75 43 96 61 + +62 55 26 17 74 +10 15 47 38 20 +41 66 59 58 9 +34 52 40 93 82 +45 43 21 11 24 + +85 90 47 75 50 +51 12 8 54 11 +73 19 3 37 28 +25 24 84 67 87 +44 94 6 20 45 + +36 99 81 96 75 +89 90 29 33 55 +40 25 10 32 92 +51 27 70 0 15 +76 50 44 22 24 + +31 63 21 13 24 +42 87 53 5 38 + 8 50 30 73 83 +95 91 15 41 52 +23 99 10 67 60 + +88 49 2 4 85 +22 25 6 30 62 +34 53 74 96 64 +77 80 93 65 63 +37 27 26 68 56 + +86 90 40 79 7 +57 2 34 91 35 +85 74 52 97 93 +63 32 38 1 12 +29 46 56 84 25 + +38 26 22 49 24 +56 84 2 18 62 + 3 90 17 73 37 +55 95 92 35 29 + 7 51 42 5 39 + +14 0 19 53 69 + 2 22 65 78 31 +43 88 37 93 46 +12 30 83 26 29 +92 68 62 7 44 + +38 65 61 93 36 +53 43 11 12 54 +97 99 48 24 21 +84 33 3 23 31 +56 4 87 90 7 + + 0 61 67 13 56 +24 69 94 85 73 +78 35 89 55 72 +21 4 90 80 83 +64 99 5 16 36 + +55 72 7 83 35 +63 73 96 21 75 + 8 79 59 62 37 +15 89 28 80 82 +34 61 97 23 0 + +48 21 43 36 15 +97 65 91 6 83 +84 64 98 31 90 +72 58 5 70 92 +52 71 25 41 51 + +14 32 70 8 73 +71 75 95 29 68 +22 27 65 7 78 +21 37 47 19 6 +60 83 2 80 98 + +59 90 57 29 68 +54 31 13 61 28 +65 37 17 53 1 +25 38 20 46 69 +23 18 77 98 96 + +20 38 79 65 16 +93 77 14 97 47 +34 42 8 18 54 +91 64 0 58 75 +25 67 37 6 56 + +88 81 6 8 65 +30 51 95 12 97 +70 16 55 54 73 +75 64 93 1 52 +82 77 24 50 36 + +41 59 17 76 95 +51 58 61 73 56 + 1 5 53 20 21 +22 14 37 28 0 +43 35 26 96 32 + +17 86 68 23 20 +41 88 75 58 64 +94 90 3 0 26 +30 51 13 95 10 +97 77 83 57 21 diff --git a/2021/05/a.c b/2021/05/a.c new file mode 100644 index 0000000..7770b68 --- /dev/null +++ b/2021/05/a.c @@ -0,0 +1,36 @@ +#include +#include + +int main(void) { + int grid[1000][1000] = {0}; + + int x1, y1, x2, y2; + while (scanf("%d,%d -> %d,%d\n", &x1, &y1, &x2, &y2) != EOF) { + /* key: for vert/horiz lines doesn't matter which one you + * start at (since you draw the same line either way */ + if (x1 == x2) { + int dist = abs(y1 - y2); + int start = y1 < y2 ? y1 : y2; + for (int i = start; i <= start + dist; i++) { + grid[x1][i]++; + } + } else if (y1 == y2) { + int dist = abs(x1 - x2); + int start = x1 < x2 ? x1 : x2; + for (int i = start; i <= start + dist; i++) { + grid[i][y1]++; + } + } + } + + int count = 0; + for (int r = 0; r < 1000; r++) { + for (int c = 0; c < 1000; c++) { + if (grid[r][c] > 1) { + count++; + } + } + } + printf("%d\n", count); + return 0; +} diff --git a/2021/05/a.py b/2021/05/a.py new file mode 100755 index 0000000..83e7979 --- /dev/null +++ b/2021/05/a.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +import sys +import pdb +from collections import defaultdict + +grid = defaultdict(lambda: defaultdict(int)) + +def bigrange(a, b): + if a > b: + return range(b, a + 1) + else: + return range(a, b + 1) + +for l in sys.stdin: + a, arrow, b = l.split() + x1, y1 = [int(x) for x in a.split(',')] + x2, y2 = [int(x) for x in b.split(',')] + if x1 == x2: + for y in bigrange(y1, y2): + grid[x1][y] += 1 + elif y1 == y2: + for x in bigrange(x1, x2): + grid[x][y1] += 1 + +count = 0 +for x in grid.keys(): + for y in grid[x].keys(): + if grid[x][y] > 1: + count += 1 + +print(count) diff --git a/2021/05/b.c b/2021/05/b.c new file mode 100644 index 0000000..cb6295e --- /dev/null +++ b/2021/05/b.c @@ -0,0 +1,36 @@ +#include +#include + +int grid[1000][1000] = {0}; + +void draw(int x1, int y1, int x2, int y2) { + int r = x1; + int c = y1; + int rstep = x1 == x2 ? 0 : (x1 < x2 ? 1 : -1); + int cstep = y1 == y2 ? 0 : (y1 < y2 ? 1 : -1); + while (r != x2 || c != y2) { + grid[r][c]++; + r += rstep; + c += cstep; + } + /* loop stops before marking last point! */ + grid[x2][y2]++; +} + +int main(void) { + int x1, y1, x2, y2; + while (scanf("%d,%d -> %d,%d\n", &x1, &y1, &x2, &y2) != EOF) { + draw(x1, y1, x2, y2); + } + + int count = 0; + for (int r = 0; r < 1000; r++) { + for (int c = 0; c < 1000; c++) { + if (grid[r][c] > 1) { + count++; + } + } + } + printf("%d\n", count); + return 0; +} diff --git a/2021/05/b.py b/2021/05/b.py new file mode 100755 index 0000000..cf8627d --- /dev/null +++ b/2021/05/b.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +import sys +import pdb +from collections import defaultdict + +grid = defaultdict(lambda: defaultdict(int)) + +def bigrange(a, b): + # NOTE: unlike a.py, reversed is impt! + if a > b: + return reversed(range(b, a + 1)) + else: + return range(a, b + 1) + +for l in sys.stdin: + a, arrow, b = l.split() + x1, y1 = [int(x) for x in a.split(',')] + x2, y2 = [int(x) for x in b.split(',')] + if x1 == x2: + for y in bigrange(y1, y2): + grid[x1][y] += 1 + elif y1 == y2: + for x in bigrange(x1, x2): + grid[x][y1] += 1 + else: + xr = bigrange(x1, x2) + yr = bigrange(y1, y2) + coords = zip(xr, yr) + for x, y in coords: + grid[x][y] += 1 + +count = 0 +for x in grid.keys(): + for y in grid[x].keys(): + if grid[x][y] > 1: + count += 1 + +print(count) diff --git a/2021/05/input b/2021/05/input new file mode 100644 index 0000000..1b5dab7 --- /dev/null +++ b/2021/05/input @@ -0,0 +1,500 @@ +781,721 -> 781,611 +334,551 -> 119,551 +25,153 -> 765,893 +588,619 -> 588,683 +167,63 -> 439,335 +340,129 -> 35,129 +578,712 -> 509,712 +855,426 -> 855,649 +778,71 -> 778,411 +21,314 -> 631,924 +552,148 -> 148,552 +531,889 -> 789,889 +85,963 -> 986,62 +914,140 -> 257,797 +520,721 -> 794,721 +49,936 -> 960,25 +458,941 -> 839,560 +113,797 -> 113,604 +554,136 -> 554,655 +112,208 -> 112,504 +78,410 -> 169,319 +176,148 -> 906,878 +56,98 -> 835,877 +538,981 -> 178,621 +553,102 -> 553,688 +452,761 -> 452,70 +487,574 -> 487,589 +356,406 -> 154,406 +11,646 -> 11,416 +543,19 -> 924,400 +862,773 -> 929,773 +292,901 -> 292,97 +985,236 -> 667,236 +745,572 -> 667,572 +752,794 -> 775,817 +269,649 -> 269,198 +928,327 -> 469,786 +284,937 -> 755,466 +308,876 -> 308,790 +201,94 -> 988,881 +233,958 -> 903,288 +210,879 -> 91,879 +760,48 -> 133,675 +55,79 -> 956,980 +988,15 -> 15,988 +25,974 -> 966,33 +903,671 -> 292,60 +587,770 -> 403,954 +83,379 -> 432,728 +30,121 -> 334,425 +375,516 -> 375,409 +72,370 -> 72,152 +575,595 -> 575,363 +248,64 -> 896,712 +703,421 -> 395,421 +66,978 -> 977,67 +450,961 -> 450,773 +830,895 -> 830,661 +373,58 -> 442,58 +739,383 -> 739,712 +510,188 -> 510,99 +350,880 -> 248,880 +771,278 -> 549,278 +266,434 -> 266,838 +315,490 -> 884,490 +360,651 -> 428,583 +333,452 -> 333,109 +313,414 -> 713,14 +23,982 -> 989,16 +196,201 -> 889,894 +485,761 -> 99,375 +288,918 -> 50,680 +912,206 -> 142,976 +242,10 -> 841,609 +972,11 -> 16,967 +859,142 -> 390,611 +48,348 -> 212,348 +246,514 -> 726,34 +29,754 -> 29,706 +617,296 -> 224,689 +671,487 -> 397,213 +913,898 -> 155,140 +437,688 -> 18,269 +150,150 -> 869,869 +386,873 -> 940,319 +57,326 -> 148,417 +847,12 -> 319,540 +741,640 -> 520,640 +111,458 -> 111,754 +595,615 -> 861,881 +244,722 -> 905,722 +323,394 -> 323,304 +560,562 -> 560,678 +48,750 -> 48,228 +80,40 -> 80,723 +730,839 -> 191,300 +300,773 -> 977,96 +619,892 -> 827,892 +22,226 -> 656,226 +125,968 -> 125,637 +116,923 -> 512,923 +59,741 -> 59,499 +484,930 -> 487,930 +362,175 -> 362,778 +960,986 -> 53,79 +170,748 -> 576,748 +810,291 -> 743,291 +761,924 -> 339,502 +730,850 -> 920,850 +778,949 -> 778,766 +254,724 -> 254,394 +685,177 -> 685,441 +442,290 -> 833,290 +181,209 -> 72,100 +91,924 -> 953,62 +318,880 -> 318,659 +570,632 -> 570,966 +955,227 -> 667,227 +439,666 -> 439,224 +276,385 -> 276,56 +544,521 -> 544,867 +187,626 -> 187,13 +307,235 -> 859,235 +759,416 -> 668,416 +357,882 -> 981,882 +651,71 -> 651,457 +615,711 -> 615,502 +474,162 -> 305,162 +320,33 -> 320,48 +799,420 -> 799,389 +448,46 -> 313,46 +925,141 -> 925,928 +332,101 -> 332,373 +41,948 -> 749,948 +276,672 -> 207,672 +315,736 -> 86,736 +844,688 -> 466,688 +357,199 -> 107,199 +902,950 -> 14,62 +277,251 -> 923,251 +963,38 -> 34,967 +71,389 -> 577,389 +712,911 -> 712,573 +186,976 -> 148,938 +407,389 -> 637,619 +917,118 -> 917,960 +988,571 -> 362,571 +845,941 -> 189,285 +686,537 -> 306,537 +915,929 -> 946,960 +447,30 -> 447,364 +832,833 -> 832,888 +957,953 -> 203,199 +982,73 -> 400,655 +159,704 -> 159,844 +284,347 -> 159,347 +903,280 -> 93,280 +769,961 -> 140,332 +899,145 -> 293,751 +850,643 -> 148,643 +580,870 -> 739,870 +686,250 -> 686,237 +142,528 -> 142,936 +827,224 -> 827,287 +972,946 -> 155,946 +706,851 -> 862,851 +564,231 -> 564,428 +511,662 -> 511,752 +838,842 -> 585,842 +60,871 -> 870,61 +719,824 -> 719,648 +183,232 -> 936,985 +131,56 -> 953,878 +406,952 -> 80,952 +884,518 -> 945,518 +427,439 -> 662,439 +829,920 -> 829,634 +966,262 -> 966,933 +813,27 -> 813,934 +784,101 -> 784,160 +744,313 -> 744,850 +969,213 -> 206,976 +957,56 -> 28,985 +312,620 -> 312,680 +454,131 -> 454,776 +360,174 -> 175,359 +711,114 -> 692,95 +452,839 -> 938,839 +641,56 -> 641,334 +566,890 -> 51,890 +869,109 -> 869,102 +119,36 -> 119,796 +301,583 -> 301,451 +733,603 -> 733,714 +718,703 -> 581,566 +709,513 -> 915,513 +405,13 -> 572,13 +782,26 -> 391,26 +15,74 -> 858,917 +975,978 -> 38,41 +11,316 -> 982,316 +303,367 -> 303,129 +847,143 -> 847,158 +856,687 -> 856,870 +715,524 -> 715,812 +451,288 -> 272,467 +576,179 -> 119,179 +10,623 -> 10,44 +652,631 -> 796,775 +930,613 -> 913,613 +803,746 -> 803,566 +306,602 -> 306,137 +582,491 -> 582,296 +181,116 -> 231,116 +802,646 -> 802,884 +75,623 -> 75,424 +370,680 -> 370,923 +806,497 -> 939,497 +301,331 -> 818,331 +912,916 -> 27,31 +24,82 -> 683,741 +862,205 -> 316,751 +245,842 -> 383,842 +544,946 -> 518,920 +129,192 -> 18,303 +831,915 -> 31,115 +306,824 -> 454,676 +851,341 -> 125,341 +790,154 -> 790,988 +407,586 -> 477,656 +144,988 -> 925,207 +264,391 -> 264,466 +901,651 -> 646,651 +865,936 -> 390,461 +631,737 -> 631,166 +103,939 -> 937,105 +505,813 -> 505,218 +260,457 -> 141,457 +52,762 -> 54,762 +26,95 -> 889,958 +638,41 -> 330,41 +612,775 -> 191,354 +863,224 -> 863,287 +674,87 -> 674,110 +189,76 -> 954,841 +372,483 -> 503,483 +166,75 -> 619,75 +938,983 -> 18,63 +442,573 -> 858,157 +681,590 -> 878,590 +276,465 -> 500,241 +644,703 -> 651,710 +848,363 -> 254,363 +204,109 -> 216,97 +81,529 -> 81,674 +74,44 -> 978,948 +929,237 -> 598,237 +298,644 -> 298,712 +678,367 -> 360,685 +413,27 -> 413,799 +684,403 -> 684,500 +188,601 -> 972,601 +33,257 -> 33,897 +278,299 -> 278,635 +261,983 -> 804,440 +216,324 -> 216,526 +399,332 -> 399,613 +826,702 -> 826,332 +137,203 -> 624,203 +326,552 -> 36,262 +142,927 -> 343,927 +21,330 -> 410,719 +721,768 -> 289,336 +807,715 -> 807,287 +775,678 -> 62,678 +771,10 -> 491,10 +287,829 -> 287,599 +589,947 -> 767,947 +160,348 -> 798,986 +699,264 -> 108,855 +605,145 -> 568,145 +264,615 -> 545,615 +633,111 -> 11,733 +589,886 -> 589,897 +728,839 -> 78,189 +739,924 -> 948,924 +140,354 -> 830,354 +619,662 -> 332,662 +592,960 -> 592,290 +510,908 -> 510,828 +792,518 -> 792,749 +148,20 -> 832,704 +529,837 -> 863,503 +802,371 -> 301,371 +682,429 -> 682,537 +885,918 -> 38,71 +590,229 -> 795,24 +782,704 -> 244,704 +936,71 -> 981,71 +27,272 -> 27,253 +558,48 -> 558,69 +661,422 -> 661,145 +152,335 -> 152,362 +516,407 -> 26,407 +449,731 -> 592,731 +187,456 -> 594,863 +145,290 -> 15,290 +667,213 -> 214,666 +660,872 -> 660,605 +649,617 -> 986,954 +86,914 -> 959,41 +895,967 -> 24,96 +40,154 -> 762,154 +27,106 -> 855,934 +929,913 -> 319,303 +749,314 -> 387,676 +76,380 -> 824,380 +632,329 -> 632,436 +154,496 -> 154,528 +127,958 -> 127,613 +592,606 -> 363,606 +929,228 -> 929,890 +832,596 -> 801,565 +824,978 -> 134,978 +638,485 -> 638,291 +783,848 -> 783,77 +646,877 -> 646,117 +461,279 -> 850,668 +300,450 -> 115,265 +916,205 -> 145,976 +510,760 -> 124,760 +884,668 -> 884,153 +285,370 -> 705,790 +845,42 -> 17,870 +784,59 -> 71,772 +627,268 -> 333,562 +731,403 -> 22,403 +980,43 -> 43,980 +16,988 -> 973,31 +720,881 -> 300,881 +23,182 -> 723,882 +129,887 -> 51,887 +186,934 -> 186,452 +114,815 -> 39,815 +868,777 -> 868,222 +554,218 -> 911,218 +247,408 -> 777,938 +391,69 -> 285,69 +239,472 -> 614,847 +422,918 -> 422,245 +852,905 -> 852,634 +631,164 -> 17,778 +987,988 -> 11,12 +435,891 -> 435,136 +564,409 -> 767,612 +611,508 -> 611,535 +744,965 -> 631,965 +308,604 -> 509,604 +77,250 -> 589,762 +505,950 -> 685,950 +907,222 -> 850,222 +700,674 -> 754,620 +238,294 -> 53,479 +875,130 -> 875,544 +368,547 -> 368,965 +618,206 -> 311,206 +127,972 -> 852,247 +561,192 -> 982,613 +573,399 -> 573,464 +311,109 -> 764,562 +69,813 -> 809,813 +195,594 -> 317,594 +900,467 -> 638,467 +806,810 -> 806,918 +451,17 -> 128,17 +93,837 -> 878,52 +299,726 -> 531,958 +968,984 -> 18,34 +957,38 -> 14,38 +283,583 -> 32,332 +922,822 -> 953,853 +589,466 -> 753,466 +203,791 -> 933,791 +122,739 -> 778,83 +294,658 -> 289,658 +365,200 -> 365,513 +611,941 -> 701,941 +927,111 -> 107,931 +754,529 -> 181,529 +364,933 -> 567,933 +717,960 -> 717,11 +612,472 -> 612,807 +971,252 -> 531,252 +88,911 -> 387,911 +885,837 -> 75,27 +222,289 -> 714,781 +754,40 -> 293,501 +866,517 -> 949,517 +858,586 -> 331,586 +157,21 -> 731,595 +173,216 -> 822,865 +353,206 -> 353,318 +68,88 -> 957,88 +370,645 -> 200,815 +981,83 -> 89,975 +259,112 -> 259,435 +184,920 -> 825,279 +252,357 -> 252,56 +722,349 -> 368,703 +928,973 -> 597,973 +677,656 -> 788,545 +222,766 -> 527,461 +870,787 -> 972,889 +11,986 -> 986,11 +163,918 -> 748,333 +111,75 -> 823,75 +603,250 -> 375,478 +338,582 -> 338,454 +372,179 -> 452,179 +571,96 -> 571,723 +243,460 -> 267,460 +850,63 -> 43,870 +837,863 -> 113,139 +21,886 -> 709,198 +154,650 -> 181,650 +320,506 -> 320,706 +983,722 -> 983,657 +830,225 -> 190,865 +924,12 -> 11,925 +838,827 -> 258,247 +690,792 -> 690,582 +465,658 -> 146,977 +790,935 -> 39,184 +318,627 -> 318,125 +245,939 -> 291,939 +803,219 -> 254,768 +262,476 -> 441,476 +790,225 -> 790,372 +250,722 -> 613,722 +368,326 -> 368,474 +148,666 -> 394,912 +813,588 -> 238,13 +84,323 -> 84,957 +566,716 -> 822,716 +794,633 -> 459,633 +355,634 -> 237,634 +950,755 -> 950,867 +292,696 -> 340,696 +121,391 -> 361,631 +58,516 -> 624,516 +859,37 -> 184,712 +686,819 -> 428,819 +11,12 -> 988,989 +718,679 -> 280,679 +515,524 -> 515,664 +136,459 -> 136,56 +703,763 -> 703,858 +290,733 -> 290,33 +910,928 -> 910,21 +570,937 -> 570,808 +462,215 -> 462,747 +388,181 -> 712,505 +933,705 -> 933,601 +605,492 -> 188,492 +737,818 -> 564,818 +214,629 -> 735,108 +139,942 -> 598,942 +708,187 -> 541,187 +646,611 -> 325,611 +788,356 -> 718,426 +267,250 -> 267,930 +94,819 -> 94,191 +661,537 -> 661,363 +464,290 -> 471,297 +656,68 -> 337,68 +31,515 -> 797,515 +876,21 -> 81,21 +630,932 -> 21,323 +259,58 -> 542,58 +703,523 -> 703,949 +470,310 -> 470,20 +69,983 -> 977,75 +569,908 -> 569,931 +645,718 -> 645,665 +819,371 -> 819,705 +772,709 -> 772,736 +330,870 -> 382,818 +982,317 -> 982,778 +626,411 -> 626,887 +466,33 -> 466,635 +519,939 -> 519,131 +402,253 -> 402,300 +180,712 -> 826,66 +55,764 -> 941,764 +659,859 -> 659,944 +346,374 -> 346,500 +880,333 -> 880,767 +42,969 -> 983,28 +363,688 -> 363,148 +645,880 -> 265,500 diff --git a/2021/06/a.c b/2021/06/a.c new file mode 100644 index 0000000..bfe4f66 --- /dev/null +++ b/2021/06/a.c @@ -0,0 +1,37 @@ +#include +#include +#include + +int main(void) { + int counts[9] = {0}; + + /* Wow, the parser is more complex than the algorithm :( */ + char *line = NULL; + size_t linesize = 0; + getline(&line, &linesize, stdin); + char *p; + for (p = strtok(line, ","); p; p = strtok(NULL, ",")) { + counts[atoi(p)]++; + } + free(line); + + /* Phew, made it */ + for (int i = 0; i < 80; i++) { + /* Rather than pop & append, just edit in place and rotate + * the start index in use; i.e. on day 2, idx 1 is '0'. + * + * In fact, really all we need to do is add the current + * "populating fish" (mod 0) to the 7th index (which will + * be the 6th index on the next "lifecycle". + * */ + counts[(i + 7) % 9] += counts[i % 9]; + } + + int sum = 0; + for (int i = 0; i < 9; i++) { + sum += counts[i]; + } + printf("%d\n", sum); + + return 0; +} diff --git a/2021/06/a.py b/2021/06/a.py new file mode 100755 index 0000000..0e1c18e --- /dev/null +++ b/2021/06/a.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 + +# XXX: This solution is totally not scalable, and could +# EASILY use the solution to pt B for a faster solution. +# I'm keeping it for posterity to show that I brute forced +# pt A :) +import sys + +fish = [] + +def repro(fish): + new = [] + for f in fish: + if f == 0: + new += [6, 8] + else: + new.append(f - 1) + + return new + +for l in sys.stdin: + # just keep the last one (only one) + fish = [int(x) for x in l.split(',')] + +for i in range(80): + fish = repro(fish) + +print(len(fish)) diff --git a/2021/06/b.c b/2021/06/b.c new file mode 100644 index 0000000..1f9c485 --- /dev/null +++ b/2021/06/b.c @@ -0,0 +1,39 @@ +/* NOTE: only diff from a.c is the 256 rotation and use of a long long for + * big vals (tm). Duplicated for the sake of the build system :) */ +#include +#include +#include + +int main(void) { + unsigned long long counts[9] = {0}; + + /* Wow, the parser is more complex than the algorithm :( */ + char *line = NULL; + size_t linesize = 0; + getline(&line, &linesize, stdin); + char *p; + for (p = strtok(line, ","); p; p = strtok(NULL, ",")) { + counts[atoi(p)]++; + } + free(line); + + /* Phew, made it */ + for (int i = 0; i < 256; i++) { + /* Rather than pop & append, just edit in place and rotate + * the start index in use; i.e. on day 2, idx 1 is '0'. + * + * In fact, really all we need to do is add the current + * "populating fish" (mod 0) to the 7th index (which will + * be the 6th index on the next "lifecycle". + * */ + counts[(i + 7) % 9] += counts[i % 9]; + } + + unsigned long long sum = 0; + for (int i = 0; i < 9; i++) { + sum += counts[i]; + } + printf("%llu\n", sum); + + return 0; +} diff --git a/2021/06/b.py b/2021/06/b.py new file mode 100755 index 0000000..3f0c4b9 --- /dev/null +++ b/2021/06/b.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +import sys + +# rather than keep a raw list, count number of each type! +counts = [0] * 9 + +for l in sys.stdin: + for f in l.split(","): + counts[int(f)] += 1 + +for i in range(256): + ready = counts.pop(0) + counts[6] += ready + counts.append(ready) + +print(sum(counts)) diff --git a/2021/06/input b/2021/06/input new file mode 100644 index 0000000..e2e33f5 --- /dev/null +++ b/2021/06/input @@ -0,0 +1 @@ +1,4,1,1,1,1,5,1,1,5,1,4,2,5,1,2,3,1,1,1,1,5,4,2,1,1,3,1,1,1,1,1,1,1,2,1,1,1,1,1,5,1,1,1,1,1,1,1,1,1,4,1,1,1,1,5,1,4,1,1,4,1,1,1,1,4,1,1,5,5,1,1,1,4,1,1,1,1,1,3,2,1,1,1,1,1,2,3,1,1,2,1,1,1,3,1,1,1,2,1,2,1,1,2,1,1,3,1,1,1,3,3,5,1,4,1,1,5,1,1,4,1,5,3,3,5,1,1,1,4,1,1,1,1,1,1,5,5,1,1,4,1,2,1,1,1,1,2,2,2,1,1,2,2,4,1,1,1,1,3,1,2,3,4,1,1,1,4,4,1,1,1,1,1,1,1,4,2,5,2,1,1,4,1,1,5,1,1,5,1,5,5,1,3,5,1,1,5,1,1,2,2,1,1,1,1,1,1,1,4,3,1,1,4,1,4,1,1,1,1,4,1,4,4,4,3,1,1,3,2,1,1,1,1,1,1,1,4,1,3,1,1,1,1,1,1,1,5,2,4,2,1,4,4,1,5,1,1,3,1,3,1,1,1,1,1,4,2,3,2,1,1,2,1,5,2,1,1,4,1,4,1,1,1,4,4,1,1,1,1,1,1,4,1,1,1,2,1,1,2 diff --git a/2021/07/a.py b/2021/07/a.py new file mode 100755 index 0000000..eb86ec2 --- /dev/null +++ b/2021/07/a.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# In a "all fuel is equal" situation, the optimal solution will +# be the median, since it's effectively the closest to the "middle" +# one can get. I forget the proof, but it works. Something like +# +# T = |x1 - m| + ... + |xi - m| +# +# If m is the median, there are i/2 points on each side. If m +# was NOT the median, it might get "closer" to a subset of points +# but the "larger" split will be >i/2 points, and it is getting +# "farther" from those points. The # of points farther > # closer, +# so it's a less optimal positioning. +import sys + +crabs = [] +for l in sys.stdin: + crabs = [int(x) for x in l.split(",")] + +s = sorted(crabs) +m = s[int(len(crabs) / 2)] + +print(sum([abs(x - m) for x in crabs])) diff --git a/2021/07/b.py b/2021/07/b.py new file mode 100755 index 0000000..47a7db4 --- /dev/null +++ b/2021/07/b.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# In the "non-linear fuel cost" situation, we suddenly know +# the median is definitely not optimal. Consider 1,2,100. A +# median of 2 means you'd incur a huge penalty (100 + 99..) +# for the 100 term, 4851 to be exact (plus 1 more for the 1) +# +# A better solution is to optimize for the least number of +# far-out points by using the average. We see 34 is would +# give us 3300 instead, which is significantly better. +import sys + + +def cost(a, b): + # Distance 3 = 1 + 2 + 3 = sum(range(abs))) + return sum(range(abs(a - b) + 1)) + + +crabs = [] +for l in sys.stdin: + crabs = [int(x) for x in l.split(",")] + +avg = round(sum(crabs) / len(crabs)) + +print(sum([cost(x, avg) for x in crabs])) diff --git a/2021/07/input b/2021/07/input new file mode 100644 index 0000000..a2cb8f5 --- /dev/null +++ b/2021/07/input @@ -0,0 +1 @@ +1101,1,29,67,1102,0,1,65,1008,65,35,66,1005,66,28,1,67,65,20,4,0,1001,65,1,65,1106,0,8,99,35,67,101,99,105,32,110,39,101,115,116,32,112,97,115,32,117,110,101,32,105,110,116,99,111,100,101,32,112,114,111,103,114,97,109,10,14,94,153,512,1778,1219,522,207,112,148,1185,380,530,502,957,898,71,10,719,47,51,188,188,1277,446,156,188,990,370,549,1086,49,150,42,50,976,456,24,526,183,206,887,3,487,11,111,933,1059,51,439,30,258,901,19,1207,718,404,498,79,83,58,520,267,109,933,4,174,748,66,463,514,378,708,103,1073,364,224,254,28,196,95,30,567,633,943,3,63,1369,1754,342,651,139,8,10,535,1,841,89,306,86,621,51,872,806,212,926,930,390,665,163,291,357,724,861,106,793,222,33,215,81,1100,641,813,1073,276,1416,991,318,505,1112,1556,1309,1222,504,72,126,1143,261,347,1022,668,146,111,982,250,247,589,42,99,305,722,1286,732,16,248,234,140,492,1229,342,204,113,137,597,44,78,484,285,431,502,258,1329,1143,364,814,0,489,1070,837,56,17,784,636,809,342,50,713,71,280,674,1586,321,255,143,47,184,62,1133,4,24,470,5,269,11,316,2,472,535,1011,854,1543,614,605,404,1010,757,129,91,889,10,30,429,625,816,107,1367,69,272,466,335,851,723,574,121,37,23,256,920,4,1280,405,731,249,930,135,306,448,1027,27,932,4,352,703,258,652,1121,89,478,189,75,1204,33,869,1483,191,64,136,1622,651,294,458,944,819,68,1635,29,301,591,1195,82,783,1411,841,96,1370,272,403,10,87,1233,71,108,430,992,19,258,171,1812,509,671,212,228,252,22,1477,344,359,639,351,1187,44,300,318,92,189,153,1141,606,679,710,148,62,335,138,1074,1131,658,533,356,462,434,759,1036,436,4,1031,387,80,223,1152,125,515,32,243,239,31,1277,1151,252,565,12,700,117,90,83,194,22,196,73,460,560,133,351,237,167,21,694,9,287,114,128,130,190,1271,382,652,834,261,907,1697,377,854,241,1019,959,945,1397,1095,1009,1337,647,631,1019,83,1691,540,544,648,685,133,64,283,1599,55,10,37,25,614,93,98,503,7,200,376,64,636,471,110,491,402,795,388,1453,713,717,122,680,297,942,117,88,1467,123,1056,1295,1100,1343,956,133,6,498,1687,35,959,380,97,2,351,1556,749,246,700,157,1216,571,448,730,1515,47,535,102,1550,486,551,387,0,430,434,205,351,701,421,536,308,247,88,25,329,264,464,1441,77,18,1712,353,1672,56,220,328,74,973,249,489,815,589,607,927,158,63,13,49,573,280,350,66,553,233,69,314,78,961,469,821,605,959,48,1346,968,222,1365,473,917,137,782,322,603,989,277,45,73,265,276,242,342,257,699,221,334,259,806,812,54,89,1551,109,271,1642,151,1158,228,109,10,306,1308,817,1618,1430,839,146,33,650,241,83,644,109,120,637,317,190,48,1113,1547,68,765,230,422,1066,421,22,189,1060,375,907,363,1051,34,465,572,611,629,535,1097,1015,915,616,13,448,36,29,129,195,1423,839,56,125,430,571,747,449,435,446,387,569,22,1721,90,978,1659,93,1826,115,334,219,333,122,725,162,707,17,1103,38,172,65,438,1143,763,115,328,13,257,117,383,912,673,130,128,222,318,785,1505,887,110,1706,786,192,524,1265,40,276,408,63,86,315,648,222,17,1127,460,341,414,204,991,14,68,354,201,110,1613,477,345,1991,452,5,446,68,456,683,144,336,149,1204,736,934,1256,112,26,478,185,1361,997,220,292,52,385,130,107,61,39,368,757,466,120,787,576,355,701,52,212,448,103,712,679,94,465,788,93,884,29,214,470,120,216,406,662,642,452,704,156,484,29,41,1639,286,1325,535,101,53,408,1727,684,276,314,36,1393,1448,34,12,158,118,433,1320,617,68,395,174,83,549,1032,871,239,325,454,923,1324,470,532,214,1308,278,213,155,94,514,18,1278,467,481,194,932,122,619,796,1296,979,884,1176,230,457,61,162,571,1246,631,840,135,76,293,517,789,314,772,674,406,1302,9,86,53,1019,376,1688,203,1328,840,322,17,249,1192,5,353,304,476,739,299,1495,162,49,226,421,19,20,1179,4,438,244,298,117,46,107,133,407,190,146,1063,485,132,348,15,804,343,227,1108,29,1141,1413,1412,181,489,146,227,1136,86,612,1256,862,120,3,129,373,1240,428,1119,13,168,34,609,655,260,94,634,1136,1567,165,0,1079,11,39,27,456,391,79,1908,1062,141,6,1081,209,642,1726,83,141,2,254,393,83,246,1355,1085,786,453,213,1536,756,351,405,1925,3,1,12,615,303,423,10,1365,181,1510 diff --git a/2021/08/a.py b/2021/08/a.py new file mode 100755 index 0000000..4d87c18 --- /dev/null +++ b/2021/08/a.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 +import sys + +count = 0 +for l in sys.stdin: + seen = False + for sig in l.strip().split(" "): + if sig == "|": + seen = True + elif not seen: + continue + if len(sig) == 2 or len(sig) == 7 or len(sig) == 4 or len(sig) == 3: + count += 1 + +print(count) diff --git a/2021/08/b.py b/2021/08/b.py new file mode 100755 index 0000000..7a58648 --- /dev/null +++ b/2021/08/b.py @@ -0,0 +1,108 @@ +#!/usr/bin/env python3 +import sys + + +# Map abcdefg -> 1234567 (orig positions) +def mapit(preface): + M = {} + + def mset(sig, val): + if val in M: + print(val) + print(M) + raise Exception("val already in M!") + else: + M[val] = set(sig) + + todo = preface[:] + while todo: + sig = todo.pop(0) + if len(sig) == 2: + mset(sig, "1") + continue + elif len(sig) == 3: + mset(sig, "7") + continue + elif len(sig) == 4: + mset(sig, "4") + continue + elif len(sig) == 7: + mset(sig, "8") + continue + elif len(sig) == 6: + # either 0/6/9 + if contains(sig, M, "4"): + mset(sig, "9") + continue + elif "4" in M and contains(sig, M, "7"): + mset(sig, "0") + continue + elif "4" in M and "7" in M: + mset(sig, "6") + continue + elif len(sig) == 5: + # either 2/3/5 + if contains(sig, M, "1"): + mset(sig, "3") + continue + if "1" in M and ("6" in M or "9" in M): + if contained(sig, M, "6") or contained(sig, M, "9"): + mset(sig, "5") + continue + else: + mset(sig, "2") + continue + + # unfound, retry + todo.append(sig) + + return M + + +def contains(sig, M, query): + if query not in M: + return False + + for c in M[query]: + if c not in sig: + return False + return True + + +def contained(sig, M, query): + if query not in M: + return False + + for c in sig: + if c not in M[query]: + return False + return True + + +total = 0 +for l in sys.stdin: + # Sort into two buckets per line + seen = False + preface = [] + output = [] + for sig in l.strip().split(" "): + if sig == "|": + seen = True + continue + if seen: + output.append(sig) + else: + preface.append(sig) + + # Now get a mapping... + M = mapit(preface) + + out = "" + for o in output: + s = set(o) + for m, v in M.items(): + if s == v: + out += m + total += int(out) + +print(total) diff --git a/2021/08/input b/2021/08/input new file mode 100644 index 0000000..3396836 --- /dev/null +++ b/2021/08/input @@ -0,0 +1,200 @@ +dac abcf ac fdbcga dgcbae gcbfde fgcbd agfed adcgf cdbgfea | cbfa bcafdg cbfa bafcgd +abfgd baedc feb fgde fbagcd facbdge agcbfe bgafde fe ebdfa | bef fe dgfe feb +dfc dc afegbc bcafe fcead agefd cafdeb fcbeadg cbed cabdfg | cd geadf cfd bfaec +efacdgb abefdg efagbc af afe gdeab dbfa dgefa acegbd cdegf | cfdge gefda ecbgdfa eaf +feg gdbea edgbca gefdab caefdbg egfda afdgc fe cgfdeb efba | edafbg bdefgc egdfa gbead +bfeac becfd cbgdf gfabed gdefcab dcae edb de bgfaec fdeabc | bcfdg eagbfd fedbc cefdb +bgecd cea acegfbd ac gbefad cgdae fcag dfega abfedc gecdfa | gfdbae gcaf caedg ac +acbdfeg bfea agfed cedbg gedfba bfg dcgfea bf agfcbd gebfd | fgedb aefb gebdf fcgeda +gdcbfa agdfebc ecb fgcba ecgab efgcbd degca egfbac efba eb | egbfdc bfgcda ebaf gecda +gfcade fgedc agcfeb agdcbf dcae cgefbad ce ecg cdgfa dbfge | ebgdf fgcda gec feacbg +gcade fcdbea afegcb eafgc acfdbg aecfb fag dgcbafe gf bfge | decga gfeac gebf ecgbfa +fd dceabg bcgdef dcefag agcbf gcbfd gbceafd cdf dgebc fdeb | cgafde bdgec aegfdc gcabf +edgafbc bgaedf dbefcg efg fg acfeb bdega adgf cdeabg fbgae | dgacfeb egdfbac fbeca dabceg +dfecgb ecagbfd ceagd dgb dcfb bcegf abgedf cgbde db facgeb | efabgc ebfgc gdbce bdg +bcg dbcgea cg eadfcb agfbe cagd dacbe fcbdge abcge cedagfb | dbacgfe agdc dbcfgae bcg +dgf dfea cbadg gbeafdc fgcbae fgacde gcafe dgfac dfcbeg df | egdbcf eadf agcfd gefac +da dcgfae dac afcdg edaf fgbaec ebgadc gcfea cabgdfe dgbcf | dac fbaecgd fead ad +ecd bdecf bgdefac bafcd gdacbf eafd bcgdea bgfec bcadef ed | fgbec ebcfg fedcb cfdba +edacgb df gaedf gacfe dbegcfa dfg bfegda begad dafb cedgbf | faceg ebadfg fbdcge abfd +dgeca ebdfa dacegf cgba bcd bc acdbeg edacbgf edcab gedbcf | bc ecdag cb edagc +facbde deabfg daf gdbac efcd abecgfd cgafeb facdb fd bacef | baefgc edabcf dfce cfdbea +bafg gdfeb agbdfe ag adfge aedfc dbecag cfgedba bgedcf dga | ga dgefa gbaedcf fgebd +bcfed cafe cgbefd edfcab fa bgade dabfegc efabd fda gacdbf | bgade ebfdc decbf cbadgf +fcbgdae agef bcgda af cfbaed gdefc cfa dfcgeb gafcde fdgca | dafceb dbagc adgcbfe cdbafe +aebdfc dgcf aedgcb acdeg cfe fc dcfega bfage fgace cgfeabd | aefgc dbgefac egbfa egafbdc +bfgde bcdagf bga ga gfea abcde eafbgd edgab ecdbfag fecdgb | eacbgfd egbfda cdabe ebdgaf +fbcead afcdgb fbadgce fdabge ea adec aef afcbd ebgcf fbcae | afdebgc bafedg efa dfbca +gedafb fad gfeabc dgcf dfgabc bdaefgc dfcab abedc df gbacf | fagecb abgfc df gbacf +gcdeab efadg dfbc cebad ecafd efc bfcaedg acgefb dcaefb cf | ecfgba acedb fbeagc dacfe +gdfbc aefg adbceg fgabd fdcbea fa abfedgc bdaeg baf debgfa | fba debafc gaef cdbfg +cgbed dce gdebf fdecgab caedgb ec fagced bcae dbagc agdfbc | beafdgc edc efgdb edfcga +gdcbf fcga dcfbeg acfdbg cda agebd dabcg edbacf ca afdegbc | dac cfdbg bfecad bfcedga +gbacdf agef ebf gcedb cfgedba cagbf begafc gecbf ef cafdeb | bfe bdefgac ebf fadbgce +fdacg efdacb ebgd fdagb bfd dgbfaec efgbad cbaefg bd eagbf | baefg gecafdb ebcfgda cefagb +degcf ea afecgd fecgbd fecbdag cfaeg deabfg acde bgcaf fea | ecdgf eaf agefc gefcad +afegbc dbcfea bgefdc gadbc fbeac df dfb adbgcfe fcdab aefd | aegdcfb cdagb efabcd ecafb +cbagdf efgadb db bdg fbgeac dfcb daceg acbgf fbgaced dagcb | dgb dgebfa dgb faebgd +fcedb dcbage bc cfadeb dcb degacf gfcadbe dacef fabc gbfed | gfedb dbacef dbc dabcef +gefad ebdcfag ebcgd cgefdb abcdge ebf bf cgfeab dfcb ebgfd | dgbef afdge gfdae bdgec +dgbca bg gdb ecabfd efcdgba cgead begfad bcfg fcdba cadfgb | agdcb cdgfeab fdcgaeb gdafecb +egbdac gab edacb ag bgdfcea dbega agce agfcbd aebfdc debgf | fgbadc bag cbaegdf cdeagb +gafced agdf cdefa agfceb cbgaefd gecda agc debgc beacdf ag | dgcbe fgda gfad bgcefa +afegcd gc afecgdb bgfcd gfc fgdcbe bdfca gcbe begdf eabdgf | cgdfbe cg dcbfg gecb +afb bf afbced aefbc dgceab edabc fbcd befdga ecbadfg fcaeg | fb fdabce fbdc cbfd +fedba efdbgc fecagd dbc gdfacb ecdfbag bceg bc bcfde cgdef | cbdfge bgcfde acfgdb bdc +fd efacdb bcdgef fcegb fdb dfegb egadb ecabfg fbgcdae fgcd | dcgf gfdbe gdfc efacgb +cfbea gdbceaf bdafge fge gf afgd dacgeb dbgfec abdeg gbfea | gdaf dfcgbe fdga febac +bdgeaf gacedf gedafbc cgebfd cf fdcb cbage cfe fedbg bfceg | gbaec decagf ecf cf +eacfdb fb gcabf gbdf gfbcade afb dcfag gcabe acgbfd dgcefa | bgdf dabcegf gbafc acfgb +dbeafg fac degfc fgcbad dgbaf gfaecbd bfecda bacg dfagc ca | adbgf dgaefb acbg ac +fbdagc dfcea defgc fad faeg debfgc baecd af bgfcade agfced | ecdba dgface abdec gabdcf +dcabef gcefdab cadg dbfgae ceadb gd bdgce gdb dgceab efbcg | ecfbad dcaeb gbd adbcfge +cbegf ef cebfgd gdfabe cbagefd efg baecdg cfabg efcd gbedc | debgfc gdafbe baecdg agfecdb +fagbce aefbg eafdb gebcfd ga gaf eagcfbd ceag fbdcag cbgfe | cbgafd ga gfcbda ga +aecdf bgfadce eb acgbf dagfcb ecbagf defcbg cbfae fbe gbea | egbfca cafbe ebf bfe +bcgeda cb bcaf dbfgeca cdegf fdbeag ebc dcfbae bfcde daefb | efadcb gefcd fabedg cafebd +bcf fdgcb fdaecg gfcda dbcge fb cfegab afdb fdcbage acbdfg | cdgbf fb dgbec gcafeb +dfac bgefca ebdacf gdefabc gafebd fc dbcef bcdge fbead fce | abdfge dabfe cf afebcdg +dfabcg eagd cdegb caefb cad da adbec degfcb gdecba afgebcd | edgfcab adcbgf egad defgcb +gbefc fd becadg dfg abdfgc cfgbd afdc afdebgc gcbad bdgefa | bfcdg fbcdg cgbda abcgd +ce cebdgf aceb feacg bfecga fce aebfg ecdgafb dgbafe gdcfa | cfage fdcga fcaeg gcafe +gbac fceagb gadecfb ebagf gefbc cdebf feagdb gcf cg fadegc | agbc cfg fbdgea feabg +cd eacgfb facbe cfdeab afgbd bdfac caed dbgfaec bgdcfe cdf | acdfb afbdc cdf eacd +dbfgae geabf aefcg ebcgdfa eb feb agbdcf degb bfadce fgdab | fbdga gbdefa agbfd be +cdaef bdgc agceb becgad egfcbad cabde bda efbgac bd dbegaf | befagc bd ebcgda gabdce +ae gabdfe agdbf deabf febcd acegfb edga adegfcb fcgbad bae | dcabegf dgea geda abe +eg agec cadgf fbcdeg adgfe dcegbaf efg dfcagb fedba cfgade | adcgf gdcaf gef gbcafde +gfe cfgdab gafdb geda gefbd bfdgea bfaceg fedbc eg aedbfcg | gaebcfd cdafbg afgbcd ecdfb +fgbca dbf fd ebgad gafdb bgdaef fedgcab dbegac fged dbcafe | afdgb bfd dagbe befdag +dfgca aegdfc da fcdgaeb ebdcaf deag gfeac bgfdc ceafbg afd | daf adf gacfde cbdefa +adb gcabd cbged fgdceab cbgfa bdcfae da bgcfda dagf befgca | fgcab ad bda gcbad +edgfbc fbgecda bgcfe dc aecbgf dgbc cdbfae gfedc gdaef cde | cde fegbc edc befcgd +cebdg dfc bfde cagfe edcbfg fegcd cdbfgea afcgdb ecdbag fd | fd cfd gcbde feacg +dbgfc ebcfa gfbac aegf cfbage ag feabdc gdcafeb agb dcbgea | fabce afeg bacgefd gab +abgec cefbgad gfabdc feagc fag fgdce fbae af acgbfe bdgcea | decbgaf gfecd fcabgd fecdg +fgdcb fbagde fdgeb daefgc begdcaf baeg feg ge efbda dcfabe | dgcebfa eacdfg fdegb abeg +fdaecb gebad baedcfg gcde beg dbeac ge bgfeca bgdfa egbadc | egb gaedbc aebdc fbgda +becfdag gaefbd fcga ebcgda egafcb bgeaf gbefc gc cbdef bcg | ebgacf defcb acfg fcbaegd +fdgbea fecbd ebc ecdgf bgefdca cdbfae cb daebf ebgdca bacf | decfab bce cdgfeba ceb +bgc gfeba dcagfb bdfc eabgdcf dfgca gcefda cbgdae gfacb cb | agcdbf daegcfb fdcb bfcd +adefgc dc dbcage dcgf adc fdaec cbdgfae afebc abdfge fgead | dfbgae fcdg edafc cad +egca bfcade ga dag eadcf fdebg adfcgb dacgef egfda egdafbc | cfabgd gbdcaf cabfed bdfgac +dfgacbe ae ceafd cdgafe aec cbfda edcfg cagfbe dgea fgecbd | bcafd fdagce ace ea +fgbade bfedcag gdceba bf cedafb afb becda adfcg fdacb cefb | bf fba dcabe cfbad +acgeb dabc db cdebgf adgef gbd cafegb ebadcg aebdg fcbdaeg | gabec gebca abcge dagceb +egdcf fbgdec fb gdeacf gbfd bef bfcde becda egfcba gafbdec | dbgf fcdeb bdecf bfe +af ebdac dgacef abgf ecdbfg gefbd eaf abgcfed fadbge dfbae | fgaedb efa edfcga ecbad +ge fdbge dbgfec aecgfd gef bcge gfcabd befdgca cbdfg fedab | bedfcg gdcabf fge fge +cdbgea dge fcgabd deacbgf fdcea dcagb eg caedg bgae bfdegc | adgebc cegbfd dge egba +bgcfade bgedaf bfgc edfac ecgba efb bf dgaecb caefb aebgfc | cgeba efb abedcg gefacb +dfgec baedg egbdcf egbafdc egacfb efdcag gca cgade cfda ac | ac cdegf deacfbg edcag +dfeabc ag afbcge bag bfcdg adeg fgdcabe edcab dcgab edcabg | fgbecad bdcea bacefgd bdcafe +febdg fgdcba afdbgec gaefb aecb afcge ba abf abfcge cafged | afb gcafe fbgea aegfb +dab caedbg baecfg bafed db dbefag efbcgda afbge ceadf gfbd | bd ebfad cgbeaf db +fbg dabefcg dgfc gf fadegb ebgcf cgaeb bafdec befdc fdbgce | fgb bafdgce dgcf fabdge +gdfebac gdceb fcadge fgac cbeafd gaedfb dcfae age aegcd ga | deafgc acdef ga adfcge +begcfd cgf cg gcbd agedcf cbfaed bcfge cefdb aebgf eafgbcd | fcbde fgbea febcg gcdb +befcag befdcg fcdg bcefdga gebfd bfgec geabd fd bcefda fed | cegbf cgbeaf aebfdc geabcf +cdfeba cgabdf afbdceg bea decba ea eadf bcfda fegcab begdc | ebcgd eba ea baced +bcedg ac dca gcaedf bfdae dafgcbe dbgeac egfcdb bacg abecd | daefcg acgb ac bgefcda +bfegca bf edgbacf agcef feb fdcgea cbaf becdg cegbf afbdge | bef cbaf bacf fcebga +edg afbcdeg cafed cafged geca degfa gbafd ecdfbg ge eabcfd | bdfga dgafb deabfc dface +gfa afcgb cfgdea ga fdbcg febcad aecbfg aegb fcbae dgbafec | cfbea afgecd fcgab ga +edgfbc adbcgef gdabec egf dfega fdabe fg dfcage afgc cadge | dabfe cdaeg fge befgdc +dagecb ed cdgfb edcgb becag adbe egdafc cgabfed ced ecabfg | egbdc cgeab efgcdba cbfdg +afg egdacb gf dfgca fegcab cdaef dgabc afdcgb gdbf fdgbace | dcgfba cefdgab bfaedgc ecfad +ace agbecd eagf gfbdca cefda fdbec dacfge gfdca ea cbdgafe | gbdcaf deagfbc cafgd ea +efa baedg dcgaeb febdga efagd adgbcef dfba fedgc gabcfe af | dgafcbe dfba egbda edfag +fageb edgab da cgdeb fbedag ade afgecd begcfa acfegdb bdaf | ebgfca da ad gcdbe +ebfac dfbeg ecgfab acfg cg baedfc gce gfbdeac agedcb bfecg | gfeabdc fdbge ebacfd gacf +abfcg bgfea gbc bdgefca bdacf efcg gecbaf cg gbdafe bdegca | gadebc aebdfg bdefga gc +cedgb ebfa edcba dab defcab dfeca gacedf bgdefac cbgadf ba | abced abfecdg ba cgdfba +abcde aedcf afe bcfgdae fbec adcfbe ebdgca ef dbgaef dfgac | cbfe adebc adegcb aebdgcf +fdgcea aebdgcf egdabc defcbg efcba acbed gcdae bagd db edb | eafbc eabdc eacfb fcedbg +cefbd gefcb gf becafgd cfdbag gaef cagbe bgf dcaegb efgcba | bgf fage gefa fbg +ceafb fcegda fcbead cabfg dcgfbea aecfd eb bdcefg bef adbe | fedcag fgcaed gafbc cdfae +efcabgd fbcda efcad cfeg fde adbegc deagc aefdgc fe dbfaeg | dfe ecgf abfdc eagcd +dcebga afgbc gfbad efdbcag ca cfea efgcb eabgcf gcbfed cga | afcebg gecfb ac ac +gceaf dafgceb afcbeg geacfd fbcead bfa fb gbef acbfg acdbg | acgedfb fb gbdac fab +gbf bgecfd adgfcbe bfgec bfcgda efdcab gf defg bdcef gecba | dgfabec bfg fg becdf +dg dgb gbacd bdagfc gafd gaceb dbacfe fgebcd gfdaecb cbfad | gbecfd cagbe bdg abdcg +cdgbe eadcg dcb db bgecfa cegbdfa fdeb acgdbf becfg decgfb | febcg cgbde gfbcae edcbg +gcfdbae dgf dgeca dcfge dcegbf fcdeba fedcb gfbc afbdeg gf | edfcb dbafec dcgfabe fg +dfbaceg ab edcfb adb egabcd dgfbac fbag cfbad fagcd gedacf | fgdabc ab feacgd ab +debga ec edc gfdca agdce afegbd aecdgb bcea cbefgd baefcgd | gadfc defgcb caeb abce +edabfc fdaeg dgacfe bdacfg cfabdge efcda fgd gdce dg gfbae | abcdfg dfeag edcg acegdf +bagcfe afedc dbec fadecb fbdega ed afdcg aefcb efagcdb dae | cbedgaf gefabc decb ed +abe fadecg bfcage bcdafe ecfad afdgb afbde be bedc bfeacdg | bgfad fcdgeab be bcfgead +bf decgb efb bfegdca bgfd adfce fcdeb gabefc cdaegb fecbgd | decbg fb gdebc gdfb +gfcbed efdcb dafbcg db gedb deacf cgfbe bdf abfecg defcagb | bdfec cfdeb bd adecf +gceab gefbda bdegafc fgbd bedacf egd agdeb daefb fagedc dg | dg dacebgf bafegd edg +abecfg dgbca egc aegcb acgdfe agefdb bfec ce ebcdagf bfgae | bcfe bcfe acgbef gfedcab +bfacg eafdb cadbge fecbad gcbdafe ge dabegf egfd gae abgfe | ge efgba faebcd dafeb +gebd db gbcdfea fbd acebgf fedab agcbfd afecd befadg gbfea | bdeaf febag fgecab afcebdg +defac gdbfce dfbga deagbfc geadfb cbag cdafgb facdg cgf cg | eabgdf caefd cbag gfc +dafbc fgead edgfac cae gdabec fgeabcd ec acdef debafg cgef | ebcdga cgfeda efdgac cgeafd +ec dcbafe gbafcd dfgbc dec baedfcg faedg egbc egbfcd dgcfe | dce gbcefd gabcfde adcfeb +cbegdf ad aecgf befcad agdfc gcbdf adc cfgdbae dabfcg agdb | bdga bagd fcgad ad +edcbafg ab eafgcb ecdba egfdcb fcabed debcf abdf eba dagce | aeb dbcegf geadcfb aeb +bg gcefa aefbdc bcgae fbegacd cadeb fcegdb bgc eagcbd badg | bcgea adbfcge cebda cdegab +ebgad gf edfcb cegdab dbaegf agfd dgbcefa efdgb fbg gabecf | fcadbeg bcedagf dfbge gdaf +gbcfea ecdbga cgebf bdefcg fdbe de acgfd gedcf fecdbag ced | edfgcb fbde beagcfd gecabd +gfdceb aegbc ca cbdafg daebcg bac edac gcdbe abegf ceadfbg | ca bca gdebc decgb +cbfea fgadbe eacgf daefcb fgdeabc acdb ba bgecdf fba fedcb | cdfbega bcfea ba badc +cbfge bdca dgeba dce ebgcd dc gdebac fcgeadb beafgd fdceag | ebgcd gcdfae begdc agbde +acg cagdfe cebfdg dgcfa fdbac gdcef baegfc acdegbf ag dgae | cadfg efgabc egcfad dbcaf +bfae ea eadcfgb dcgba dacefb dcfaeg dae bdcef decba egbfcd | dgcba cdbeaf cedbf fcaegd +fcga agbedf edcgaf ca dabcef fegadbc ecgda eca gcdbe gefad | ca ca dgebc eca +bcead fd gbedfa adcgefb fdgcba bagfce adf fdbae dgfe abfeg | ebafgc fegd dfabe edgf +bca cbfgea cdabfe cedfa fdbc cgabefd cagdef eacbd cb bgdea | dcbaef cb bfcd cab +baedgf debaf edga bgafedc bda ecfbd ad bgdfac afgbe abcfge | aged bfedc abd cdebf +acgdb agcdef egc baefcd cfead fbdgeca ge dgace gaef dgcfeb | cbeafd acfed ebfdgc fdceag +dbegfa ef fbagce dcgfab efb agfbc cegdfab fecg dcbae aefcb | bgdfea afcgbe fe bafcg +eabdf fegb aecfgbd fg cabdgf agf dgeca adegbf dacfbe dgefa | bdecafg fgbe agbefd fabed +gdbec facbeg gbedf egabc dgaebc dcb adgc baecfd cd ceadgbf | dc dc cbaefd cgdbeaf +ef cfgab fegbc bdecg adbcfge agebfc bafcgd acfe ebf dfaegb | fbdgae ecfbg feac afec +agdebfc dae ecdf bfacge fegca dabcg de gdace gdabfe cfgead | egbdaf gabcd dea gfbace +ecg gabce fdecbg edacgb eacbf aegdb cg fcbeadg abgfed dgac | dbgae gec geabc ebcgdf +fabec fd egdfca dcf dcfgbe dgeabc dgecb febgacd bfdg dfbec | beacf df egacfd fbcae +eacf gfebad cefgad adcgf af bceadg dfa bfdgc gfeadbc ecadg | adf aefc dfagce caegd +afgbec fbgdc ag gaebcd agc gfdeacb bcefa ebcfda fgbac fgae | fbgdc bdgfc agc dacbef +bc bfcad cbgfed baec cbd fdacg fdbae aedgfbc faegbd cdbfea | ecgbdf gfbdea dfcag beca +bedgafc fbdea efgdbc edg cefg fbgdc eg cgafdb febdg egdabc | fcbgda ge cbagdfe gbdcf +bgdeca fadcegb adg cfaegd bdae edcbg ad bcgfa cadgb fecgdb | dafgce gecdba dbfegc edbgfc +ecgafd faebg gbce defbacg ebfagc eab fadecb be aecgf dfgba | bfgae dfabgec efacg ebgfa +edfg fad bgead cgaebd bcdgaf fdebgac dafgbe ebfac badfe df | eabfc begfad dgbea dbeaf +cdaeb acdbfg gfeac aefcd gecfad gefd bfgcae fd beacgdf daf | egcaf gbdafc bagecf fedg +gf aefcd adegbc fecdgb gcebd fcbg cgdef edfabg eadbfgc dgf | bfgc bgecd gdcefba abcdeg +gfdcbae cegdab ecgbf dcabef cegdb caegf fbgd bf bfe edfbcg | bf cbfeg ecfag bef +befdga bcagdef ebgaf bcfega ce cbge gfacd cae cfaebd eagfc | fdgeab cgeaf fgceab eacfg +adgbe gcadbef gbfe befadc fdbga agced bde acbfgd fgbeda eb | abefcd dfcaeb gaecd decga +gdbfec fbdce fgcade ebadfgc cb eacdgb bcd edfba fgbc edgfc | gfeadcb bfead fgbc cbd +dfaegc deabgc fabdceg gcf fc fdbcag cfde gacfe fbeag aegcd | afedgc gcf cfed fdec +acdfb dfaec bdcfga ceafbg gedabc fbgd bf cgbad cbf fdgcabe | bfegcda gadbc cdefa caedf +cfgae dcfageb gbdf gebacd edcfg cdg cdbef dg cdfeab bcefdg | geacf dfgb dg facge +gcdab dabgec fecadg ae cbadgf ade cbaed beag cebdf cbdfgae | bacdg eda facbedg gfbdac +fd dfgbcae bdf fgbda cgabf beagd cbadfe gdabfe dbaceg fdeg | fbd gdbae cdebgaf fadgb +ecgdb bfdgec fce caebgd fc fageb fcedga gcebadf cbdf egcbf | decgb cdgfea edcafg cfdebg +bafgd abcedf egb bdacge fageb adecfgb febcag fecab cefg ge | ge bafec ge ge +agcbd dac dcebfga ac ceba bcged gaedfc ebgdca adgbf cbfged | bgfad bace fecbgd adc +agcfd cag gbecfad agdfe gcedfb cbad ac cgbfae bdgcf acfbgd | gbafcd eafbcg gdafe cgefab +geadfc bfeg bf bcf bdgca ceadgbf eabfcg bgcfa cfedab afgce | acefg gacdb agecf cgbfa +aecbd afced af dfcge afbc edfcab cgbeda gabfde afd faegcdb | fgedc dfaec bdfaec cdegf +dcbfge ab bdgeca bae gcba debcg dagbfe gdeacfb acedb acdfe | cdbgea adgceb ebdca aegdfb +ecfadg agfce da cfbgea dae aedcg bfaced cgdbefa debgc dfga | eacdg afcebd faegc bafegc +df fdg dfcega gfbce aebdg bdafge bfad egbdf dbafgec acdgeb | afgedb egfdb df fbad +eafbc egbac fcb cf cgbadf becdagf cbdaeg efagcb aefbd ecfg | cf cf cgfe acegb +fceab cedfabg fc fadc cgbea bdfea egfadb gecfdb fbc abcefd | bfc ebafc aefcdgb bcafe +gb efadb dcefba fdcga fgbaed fadgb feagcb ebdg beacgfd gab | gb feagcb gb acbdegf +ebc acgedbf gcfeb edcabf bc bcgefd bcdg gcefd gdfeac egbfa | gcdb gcdfe cdbg dbafce +bgdc efacdg dabce begad cgbaed fabeg baefdc fabecdg gd edg | edabc gd geabf gafeb +gaecdf fabc fgaec bc bgc gcfbe bgcdea dgebcfa efgbd afebcg | afcbeg adgfbec gcb gebafc +aef facedg fdgbce cade fegcd fbacgde faecg gfabc egdfab ae | bfdeacg edac eaf fgedacb +eafcgd cebgf fdc debcfg dbcfg afbgec dc fdbga dbce cedfabg | cgeabf facedg bcaegf bdfgc +afegbdc bcaefg decba gdfb aedgfb efb adfge bfade agefcd fb | cfaegd gcdafe ebadf gecfad +afcb bgdcfe bacdfe ceadf cbefd caged bgedaf af egfdbca fda | adf ecbfd efdbc adefgb +cgdaef eagfb afdbge gfedb ecfbd agbd cbgefa gd agcbefd dfg | agcfbe fgcdae fdg fgd +ed afbge fbcaeg bcdfa gfeabd gfed egbfcad geadcb adbfe ead | begadc abefg dea dea +fceba deafbc aegc edbgafc bfdcg ag dbafge cfbeag abg cafgb | gab agb abfegd ecga +fcedg cfdaegb dbfg egcfbd bgc cgbefa cebgd ecbad bg dceafg | cgb fcbgae ecbda gebcd diff --git a/2021/08/input2 b/2021/08/input2 new file mode 100644 index 0000000..aefdff2 --- /dev/null +++ b/2021/08/input2 @@ -0,0 +1,309 @@ +cbfa +cbfa +bef +fe +dgfe +feb +cd +cfd +ecbgdfa +eaf +gcaf +ac +aefb +ebaf +gec +gebf +dgacfeb +egdfbac +bdg +dbacgfe +agdc +dbcfgae +bcg +eadf +dac +fbaecgd +fead +ad +abfd +bc +cb +dfce +ga +gbaedcf +adgcbfe +dbgefac +egafbdc +eacbgfd +afdebgc +efa +df +fba +gaef +beafdgc +edc +dac +bfcedga +bfe +bdefgac +ebf +fadbgce +gecafdb +ebcfgda +eaf +aegdcfb +dgb +dgb +dbc +cdgfeab +fdcgaeb +gdafecb +bag +cbaegdf +fgda +gfad +cg +gecb +fb +fbdc +cbfd +bdc +dcgf +gdfc +gdaf +fdga +ecf +cf +bgdf +dabcegf +acbg +ac +gbd +adbcfge +agfecdb +ga +ga +ebf +bfe +fb +cf +afebcdg +edgfcab +egad +agbc +cfg +cdf +eacd +be +bd +dcabegf +dgea +geda +abe +gef +gbcafde +gaebcfd +bfd +daf +adf +ad +bda +cde +edc +fd +cfd +afeg +bacgefd +gab +decbgaf +dgcebfa +abeg +egb +acfg +fcbaegd +bce +cdgfeba +ceb +daegcfb +fdcb +bfcd +fcdg +cad +ace +ea +bf +fba +dbgf +bfe +efa +fge +fge +dge +egba +efb +ac +deacfbg +fgbecad +bacefgd +afb +bd +db +fgb +bafdgce +dgcf +ga +gcdb +eba +ea +acgb +ac +bgefcda +bef +cbaf +bacf +ga +fge +efgcdba +cefdgab +bfaedgc +deagfbc +ea +dgafcbe +dfba +gfeabdc +gacf +gc +abfecdg +ba +cbfe +aebdgcf +bgf +fage +gefa +fbg +dfe +ecgf +acgedfb +fb +fab +dgfabec +bfg +fg +bdg +dcgfabe +fg +ab +ab +caeb +abce +edcg +cbedgaf +decb +ed +fcdgeab +be +bcfgead +fb +gdfb +bd +dg +dacebgf +edg +bcfe +bcfe +gfedcab +ge +afcebdg +cbag +gfc +dce +gabcfde +bdga +bagd +ad +aeb +geadcfb +aeb +adbfcge +fcadbeg +bcedagf +gdaf +fbde +beagcfd +ca +bca +cdfbega +ba +badc +eca +fegd +edgf +cb +bfcd +cab +aged +abd +fe +bdecafg +fgbe +cgdbeaf +feac +afec +dea +gec +df +adf +aefc +agc +beca +ge +cbagdfe +dfabgec +fedg +bfgc +gdcefba +bf +bef +gfeadcb +fgbc +cbd +gcf +cfed +fdec +bfegcda +dfgb +dg +eda +facbedg +fbd +cdebgaf +ge +bace +adc +df +fbad +cgfe +bfc +aefcdgb +gb +gb +acbdegf +gcdb +cdbg +gd +adgfbec +gcb +bfdeacg +edac +eaf +fgedacb +adf +fdg +fgd +dea +dea +gab +agb +ecga +cgb diff --git a/2021/09/a.py b/2021/09/a.py new file mode 100755 index 0000000..7dad784 --- /dev/null +++ b/2021/09/a.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +import sys + +grid = [] +for l in sys.stdin: + grid.append([int(x) for x in l.strip()]) + + +def lowest(r, c): + pt = grid[r][c] + if r > 0 and grid[r - 1][c] <= pt: + return False + if c > 0 and grid[r][c - 1] <= pt: + return False + if c < 99 and grid[r][c + 1] <= pt: + return False + if r < 99 and grid[r + 1][c] <= pt: + return False + return True + + +risk = 0 +for r in range(100): + for c in range(100): + if lowest(r, c): + risk += grid[r][c] + 1 + +print(risk) diff --git a/2021/09/b.py b/2021/09/b.py new file mode 100755 index 0000000..bb41cc9 --- /dev/null +++ b/2021/09/b.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +import sys +from collections import defaultdict + +seen = {} +grid = [] + +for l in sys.stdin: + grid.append([int(x) for x in l.strip()]) + + +def search(r, c, color): + if (r, c) in seen or grid[r][c] == 9: + return + + seen[(r, c)] = color + if r > 0: + search(r - 1, c, color) + if c > 0: + search(r, c - 1, color) + if c < 99: + search(r, c + 1, color) + if r < 99: + search(r + 1, c, color) + + +# Search from each point (no-op once seen once)! +i = 1 +for r in range(100): + for c in range(100): + search(r, c, i) + i += 1 + +# Finally, count the colors +G = defaultdict(int) +for v in seen.values(): + G[v] += 1 + +top = sorted(G.values(), reverse=True) +print(top[0] * top[1] * top[2]) diff --git a/2021/09/input b/2021/09/input new file mode 100644 index 0000000..dc2701e --- /dev/null +++ b/2021/09/input @@ -0,0 +1,100 @@ +6769876887698999876367898543212378997654321291098765432398767667989976543210123456987678999766598921 +5456965476567999985457897654301456989743210989989898540987656545678987654323634679876569998757387892 +4349864345476889876778999864323699879654329879878987659876543434569998789434545798765459879543296989 +3298753212345678989889298765459989768965498764567898899865432523459999998587657987654365965654135678 +4349432101346789999992169876798778957896796553456789956976921012367899987699788998543234984321015789 +5498763212457899999743456989987667945997985432377894344989854323456789998989999987642149765632134899 +6569854343568999897654599797898543234589876545688943243498765434678999999878891298753259898543236789 +7679878987699598789775988676987632123578987656799654102349876545678999898566789987654345997654545678 +8999989398789699678989876545698821014567898787898743212357987656789998787355679999965456789765656799 +9889895459893987565699876123799935223698979898987654523456898967899987676234589999876767899878767898 +8679789599912398434989765234899876434899765989998765634567989978969876535123467892987878944989878987 +7567678989101995429878984349998989545999854677899876749879878989656998321012678921298989432192989656 +5434569878919876998767895498987987656789543456789987857998767898945987633234567899349999543943496545 +6323498767899989897656789987676698767898632355678998998987654567932398545345678988999987659894965436 +3210997856789998756545679878534569898987321234567899799999543656891239659459789467989998798769876547 +4329896545456987643334789964323457989876320125688965679898932345994398798998994359878999987756987678 +5679765432346987532123458953212345678985431234599954398767921256789459987987893249867899876545698789 +6789874321234597645634567894101558789996563545999895987656890127899569876546789197757598765434569896 +9892983210145698656747698943212467893987854559886789998967892234568978965435678986543459876545678945 +4921294929236798787958999656543569912398967699775698999878964345878999974324567996432345987676899432 +3210239898947899898767898769654578923999878987654567896989875458989999865435678987320123498787976561 +9854398787898999999898999898765689439899989299985898995490986567899989978947799987431434569898997610 +8769987676799998789969899949976896598789890199876789989321299678978978599656789876532345678979989891 +9898787545598987683456789534987897989678789987987895878932398789569765498767894987673476789764678989 +9987655633467896542347892124998949876565678976598934567893499893488964349878923498784587890123699875 +9996543212356789451234589039899934965454567895439123456954987942567899219999436569895698921234589964 +8987654101236893210123478949767899876323458987321012345699876543478988998999987678976789434345678943 +7898987654345789345234569998656787998434767896542324556789987654789876787898799789987896545756789432 +6789698895676997656745699887545476899547898987955456789895698765698765456789678999899998787867894321 +5456569989987898767896789786431265987656999099876689892934569876987762347896569878768989898978943210 +4343459878998939898987897654320123498767892129998994921012489989876543456789398765457679999999976731 +3232349767899323989998999865434634569979943398999323932125678997989654567893219854324587899989895432 +2101298956789219878999999979548795997898954997678919865434589876598785678954109543213456789878789543 +3432397545694398767899989987656989886887899876567899876745789985419876789865998432101578898769698956 +4563498434989459856989879998769878765976789965456789989899899954323987999999876563234567987654567897 +5654984323878998768978568999898965654365678974345678991998987895439999548789997696549699876543476998 +6979876412767899979765457989987654321254569893234789890987896989598965434598998989698989985432345699 +9899865401256789989987679878698765410123456789123456789896645878987654324687899878987679876321234589 +9798763212346894394399899859569896521434567893256599898795434767999743212356898767496589986410124679 +8679954323567989239212999743456985432545778965346789987654323456789894101234987656325498765421235678 +6569865434689678998909998632109876543656889876657899876543213456898765213456976543212349975434547899 +5450976545696567997898976543238989656767996987768976998654354567897654324587987643201467986545698945 +7321987968789459876567897654347898767898965498979895349765455678998765437678998754312588997656789323 +5432398979899598765498989765956999979939654329296789239878567889549876548789898765423678999869893219 +6543459989998679876989878979897898989529873210145892145989678999932987679896789876739789896978954998 +7656569998999789989876967898799967895434998721234799259998789878893498989945678989849898765989969897 +8767678967899994598765458945679656976565987632465678998999896566789599799434567899956987654197898776 +9898989656789543459884301236789745697878998543456789987899975465698987678923459989878998543236789545 +3999898745897692196543212345678956789989987657578899896789764314567898567894569878989999664545678934 +1298769896789989987654523898789879891099898968689998765699995423458965498789679768999989775656799224 +0989899999899878999765674789899998932198769989789349954569876534567894349678998957899879876767891012 +9878989998998769899876785678998797893239654399895456967678987687678943254567987846789954987898932199 +9767679987865456789989876789989686789398763212976769878789798798789652123979876535678893298999943988 +7754579876764345678999989899876545678909854323989878989897679899898761019899987621236789129498769877 +6543569885323236567897899999998656789212965439992999999978568999987653198789987540345891012389879656 +7632398764210123489965458998798767896369879598901298998769456789999964987667895431456789325478998945 +5421449875521238567896367987659988965456998987892987569954345678999899876543976432347895434567987934 +6530123985434347678963219876545699896567997676789645459893234569989789987659876545456976765679876321 +6521234596545458789954398987632346789679876585878932398789345698875678998789987678967897876789985410 +8434345987657679899899987654321456898789965434567891987695467987764567899897698789598998998993494321 +7545656798788789935678998985490123499999987323458989876569568996543456921976549896459789219654976452 +7658769899899892123789109876989234989898765434568969875458979987632345890987698965345678929769876543 +8769878987956921094599212989878949876769876745878957987567894596543456791998987654234567899878989655 +9878989896545699989698993498769998765456988656789345699678943987654567899899698754345678923989898767 +0989998787435678978987889987758789876323499767891234798789432398789878998765539965476989919899789878 +1296987658324234569896569876646678987212349898910147899896541019899989799654429876567896798788678989 +2345698943210123698765456985434568998101236989321256789987893223978998688943212989778945987666567899 +3459987654321235987654329876523457899212345678932347899998987654567897567892101497989239876555456789 +4598998796532349898543512987212678954393456789765478999899998785678943459983212345990198765436345999 +9987889987643498765432109832103589976989569898997567898788999899889012599876364587891239876521234789 +8956776798754569876543498765412367899878998946789678987657899910994123989765456698992946983210345678 +7842365679897678987674987654323456789967987897896989498746989329873249878976767899989897894323458989 +6531234589998989199876799985476567896754976789945799395439978998765398767897878901978789987434567899 +7810123478999899012987899876587678975463465678935678989598768989887469898998989329765679876545678998 +8921335567897778943498987987998789764322234569024599878987659879998567979999699498974598987656789347 +9432456678976567894999976598939897653210123478934988767998545568989878967894578987653987998968991236 +6543467789865478999899865439123998965323234569549878542987632459976989457993567987542196569879210145 +7656569898976567898767974321045679879434545678998765431298756567895490346989879898943987899989323234 +9867878967987689989856985434756789989565676789459976530459767878989321259978998789764598998996545345 +9878989456798789876549876545969891297678797892345987321346998989878932498767897678975989987987675456 +9989992345699899995432989658998992998789898901239876434456789596567893998654343487899879896598786568 +9898943458789989989321298767987989869896969912345987545589895433456789876543212396789868789439897678 +8797899879899879878934569879896878954945457893957897656678985322457899987752101245678947678921998789 +7656789989998664767895699999765767893234356789898998767989876301367999898943212386789234567892369893 +7545691099876543456789989987654456789101299895789459989999989212479998789654563498992123679965456921 +5434593198767552325699878999732345898999989954678969899998765323589987698765678989893234567896567890 +0125989987654321014598765987621234567988978912389998799879876494999896539898789678794347678987699921 +3234978998798775123987654599434348979876767923498999689765989989898797921999894545689956989998989932 +4549767899899654234599743398765457899765456895987698578954598875654689892988953236568897899989877893 +5998456789999874345987652109979567987854345679998567467895987654343456789877542123456798999875766789 +9876587893298765659876543212398999996543234567895432358999897543232345698765431012345689898754345899 +4997678954109878767987676378987678987642123458789521235798765432101256789876542123456998799343234789 +3498789543299989878999785459876567995431012345678944345699896953632367892987853234569877679210145678 +6569899654989597989239876569985479876532123456899765656789979876543456943498964348798963458921234567 +9699998799878456899123998698794321987843234569999876767898767987854567894579875499987654567894345789 +8989219987656345678934599987653210198967347678989987898987654398765679965679876989999965878965756899 +7478909876544234567895678998764321239878456789679998969898321239989989876989989878989876789879867998 +6367899998432123456789899219965432346989767896568999656789432387895491987893498767678989894989878987 +5256789987641015667899964329876563456799898965457898547896543456954320198912987654567899953492989876 +4345896595432124588998765545987674567899999876345987658987659767896431239109876543456789432101299965 diff --git a/2021/09/input2 b/2021/09/input2 new file mode 100644 index 0000000..6dee4a4 --- /dev/null +++ b/2021/09/input2 @@ -0,0 +1,5 @@ +2199943210 +3987894921 +9856789892 +8767896789 +9899965678 diff --git a/2021/10/a.py b/2021/10/a.py new file mode 100755 index 0000000..7af6418 --- /dev/null +++ b/2021/10/a.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +import sys +from collections import defaultdict + +match = { + "}": "{", + ")": "(", + ">": "<", + "]": "[", +} + +bad = defaultdict(int) +for l in sys.stdin: + mem = [] + for c in l.strip(): + if c in ["{", "(", "<", "["]: + mem.append(c) + elif c in ["}", ")", ">", "]"]: + m = match[c] + if mem.pop() != m: + bad[c] += 1 + break + else: + raise Exception(f"Bad char: {c}") + +# ): 3 points. +# ]: 57 points. +# }: 1197 points. +# >: 25137 points. +print(bad["}"] * 1197 + bad[")"] * 3 + bad[">"] * 25137 + bad["]"] * 57) diff --git a/2021/10/b.py b/2021/10/b.py new file mode 100755 index 0000000..4758311 --- /dev/null +++ b/2021/10/b.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 +import sys +from collections import defaultdict + +match = { + "}": "{", + ")": "(", + ">": "<", + "]": "[", +} + +rmatch = { + "{": "}", + "(": ")", + "<": ">", + "[": "]", +} + +pts = { + ")": 1, + "]": 2, + "}": 3, + ">": 4, +} + + +def score(seq): + score = 0 + for c in seq: + score *= 5 + score += pts[c] + return score + + +scores = [] +for l in sys.stdin: + mem = [] + corrupt = False + for c in l.strip(): + if c in ["{", "(", "<", "["]: + mem.append(c) + elif c in ["}", ")", ">", "]"]: + m = match[c] + if mem.pop() != m: + # this is an corrupt line, skip it! + corrupt = True + break + else: + raise Exception(f"Bad char: {c}") + + # Figure out and score the remaining chars! + if not corrupt: + mem.reverse() + remaining = [rmatch[c] for c in mem] + scores.append(score(remaining)) + +ss = sorted(scores) +print(ss[int(len(ss) / 2)]) diff --git a/2021/10/input b/2021/10/input new file mode 100644 index 0000000..88ead12 --- /dev/null +++ b/2021/10/input @@ -0,0 +1,90 @@ +(((<(([{{((<[[<><>]<()[]>]{[{}()]<(){}>}>[<([]{})>])(<<(<><>>[<><>]>(<{}()><(){}>)>[(([])<[]()>)])){<((<{}() +{(({({<[[[{[{({}{})[[]{}]}[{(){}}((){})]][{((){}){[]{}}}<(()())<<><>>>]}]]]{([<{<<()()>([][])>({[]()}[{}< +[[{<(([<<{(<[[()()]]{[[]()]<{}>}><{{{}()}<<>[]>><(())[()[]]>>)([{[[][]][()()]}{{()()}}](<{{}()}>))}[([{<< +{<[{<{[({[[[[{<>{}}<{}()>]<{<><>}{[][]}>](<<<>[]>[()()]>[{[]{}>[<>()]])]{{{[()()][<><>]}<[{}()][{}{}] +(<[{[{[((<{[[<()()><{}{}>][(<>{}){{}{}}]]{<[<><>]>{{{}[]}(<>[])}}}(<[[[]{}](<>{})]{[[][]][[][]]}>)>)){<{ +<<<(<(<[[[<[{{[]<>}([]())}([[]])]([[[]<>][()()]]{<()()>([]{})])>]{[[<{[]{}}([]{})>{(<>[]){{}{}}}]]{({{<>[] +[{<(({(<{<{<<{<><>}>({<><>}<<><>>)}{[{[]<>}[[][]]][<()<>>]}}<[[[()()]{<><>}]((<>)[{}()])]{<{()<>} +<[([{{{({<({(<(){}><[]()>)((()())[[]()})})[<{<<>>((){})}<[<><>]{(){}}>>{{(<>[])({}[])}(<()<>>)}]>})}({{({ +{[{{(<[[[<(((([]())[[]<>]){(()())[[]<>]})[{([]<>)[<><>]}<({}{})>])>{[(<<<>{}>(()<>)>)]<{([<><>]<[]()>><<{}[ +(<<[<({[(<{[({<><>}<{}<>>)]}<<([<>[]])(<{}{}>[[]{}])>>>(([{[<>[]][{}[])}<(<><>)({}[])>](<<() +{{[<(((<([{(<[<>{}]({}())>){{[{}]<[][]>}[{<>()}{<><>}]}}][<<{<[]<>>[{}<>]}[<{}{}>]>[<[[]<>]<()()>>[[[] +<<<([([{{<({[{[][]}[{}<>]]}<[(()<>)[{}<>]]>){{{[()<>]}(<<>>({}[]))}(([[]()][[]{}])<([]<>)[<>< +({[[[([[([<{<{{}()}{<><>}>}>])[{(({([][])[{}()]}{(<><>)[[][]]})<<<{}>[{}[]]>(({}())<()<>>)>) +<[{[[[<({<<[{<<>>{{}{}}}{[()[]]}]<[<[]<>>{<>{}}]>>>((<{{[]{}}{<><>}}>[{({}{})<{}<>>}]))}[({ +<({[<{(([[[{<<()<>>((){})><{()[]}<{}()>}}[([<>{}][()<>])]]<(([(){}])<{(){}}[[]()]>)<{[(){}](<>[ +[<<{{[<<{[<{({<>[]})({{}<>})}><<<<()[]>(()<>)>>[{{[][]}[[][]]}((<>)<<><>>)]>][(<{[[][]]<[]<>>}>(<((){}){[]< +({[({(<{<<<<{({}())(()<>)}><({{}[]}<<><>>){[{}<>]}>>]<((([{}{}]<[][]>)({[][]}<{}()>)))<<{[[]<>][[]()]}{<<>< +<[<<([<[(<<{[[(){}]<[][]>]<({}<>)[(){}]>}<[({}[]){()()}]({{}[]}[()()])>>><(<({{}<>}{[]()})[(<> +[[[([<<[<[<{[[(){}]((){})][(()<>)<()>]}(<{[]{}}{[]}>)>]{{[{{<><>}<()<>>}{[(){}]<<>{}>}]([[[]< +((([[[{<{[<{[{<>{}}]}({<[]>[{}{}]}<({}{})([][])>}>(((({}{})<{}()>){<<>{}>{{}<>}})(<{{}<>}{{}} +[<[{[({<[({{{<<>{}><()[]>}}{([<>()]{{}[]})({()[]}[<>[]])}}[{(<()[]>([]{}))<<()<>><[]()>>}{[<<> +<{{([({<{([<<(()<>)[[]{}]><{()()}<<><>>>>]){{<{{()()}<()<>>}>[{(<><>)<[]()>}]}[((<{}()>){[()[]]{()()}})] +<{[([{{[[[<<[<()<>><[]()>][(<>())(()<>)]>(([{}{}]([][])){<[]<>>([]{})})>{[[<{}[]>((){})]{<<> +{[<([{({{({({[[]()]{(){}}}<([]{})[<>{}]>)<<[()[]]>([()[]])>}{[(({}<>)<()()>)[{(){}}<{}{}>]]}>{[[{ +<<({{<<{<[{[{({}{})[()]}(<{}{}><[]()})]<{[[][]]({}[])}{(<>{})<()[]>}>}<[({{}<>}{<>()}){({}[ +([[[<<{<([[(({<>()}{[][]})[[()<>][()]]){{{()[]}(<>[])}<([]<>)[[]<>]>}]])>{(({{{[<>{}]{[][]}}}}<[(({}[])<<><> +[<(({<[[{([{<<()()>(()<>)><<[]{}>{()<>}>}{<<{}>>{{[]{}}<()<>>}}]{<{[{}<>]([][])}}<{[()()][{}]}>})(([[<{} +<{(<{(((<{<<(<<>>{<>{}})[([]<>)(()[])]><[([]{})((){})}<<{}[]>(<><>)>>><{{{<>{}}(<>[])}{[()()][() +<{<[<<[({<[[<{{}[]}><({}{})({}[])>]]<[<{{}<>}>]({[{}]{<>[]}})>>[<(([{}<>]){<<>[]>[<><>]})[(<{}()>{[ +(([[(([<<(<(<{()()}(<><>)><(<>{})<[][]>>)[<((){})<{}{}>>{{()()}{<>{}}}]>[<<<()()>(<>[])><(()[ +<{({{({<[(<{<(<>{})<<>{}>>(({}[]))}(((<>())<{}<>>)(<()>))>([[([]<>)<{}[]>][[<><>]<(){}>]][{<(){}>( +<<{(<(({[<<{[(<><>)[<>{}]]{<[]()>({}{})}}<(<{}[]>)[{<>()}<[]<>>])>>]{((({(<>[]){()<>}}[{[][ +(([((<([[([<[{[]{}}({}[])][<{}{}>[()[]]]>(<<{}[]>>)])([{(<[]{}>([]<>))}<[{<>}[{}<>]]([(){}][{}[]})>] +(([{(([{[<{<<<[][]><()<>>>(({}[]){{}<>})>}({{<[]()>({}[])}([(){}][{}<>])}(([[]<>][[][]])[{{}()}<<> +([(<<([{<[<(<<(){}>{[]()}>((()<>){[]<>}))[{([][])}<[<><>]{{}{}}>]>(({(<>[])[(){}]}(({}[])<<>()>)))]>{{[{[[ +{(((([<{({[(<[<>[]][[]]><(()[])[[][]]>)]({{{(){}}[<>[]]}((()[])<[][]>)}{{<()<>>([][])}<{()>>})}<<(({< +<[({<<{{(({<{{[]{}}(<><>)}<[()[]]<{}()>>)<<{{}[]}>([()[]]({}{}))>}){({{[(){}][<>()]}[[()()][()[ +{<([[{((([[{([[][]]<()<>>)<[<>{}]<{}()>>}]]((<[([]{})[<>()]][<[]>{<>}]><({{}<>}{[]()})(<()()>(<>{}))>)))){(([ +{(([{([{((({[{()[]}((){})]{{[]()}[()()]}}<<<{}[]>>({()()}{[]()})>)((({<>[]}[<>{}])(([]{})))[[{()[]}{<>{} +(<(<[[(((<[<<{{}[]}[[]{}]>[{()[]}<(){}>]>]>)[[([[{()<>}<<>()>]<({}{})<{}{}>>]){{[{<>[]}{()()} +(([[(([(<{([[<()()>[{}{}]][<[]{}><[]()}]]{<<{}<>>>})[[{([]())<[]()>}[<{}{}>[<>{}]]][((()())([]()))([[] +[<([<{({({[[({()<>}[{}{}>)]{([{}()]{{}})[[[]{}]<{}{}>]}]})<{{{{(<>)([]{})}[<[]()><{}{}>]}}{{<[{}()]{{} +<([{[([<(([[(<{}()>([]{}))({{}}(<>()))][{(()<>]([]{})}[[[]<>]{()[]}]]]((<[[]<>][<>]><{{}{} +<<([[<{[[([[{<[]<>><[]{}>}][([<><>]([]()))<[()()]([]<>)>]][[<[()<>][<>[]]>({<>{})[<>{}])]< +<{([[(<(({{<({()}[{}[]])(<[]<>>)>}{{[([][])({}<>)]<<{}{}>{<>[]}>}[[[[]()]({}())]((())[[][]])]>}( +{[[{[<[<<(<{<(<>()){{}<>}>}[<<{}[]>[[][]]>((()[])[()()])]}[{<{{}{}}[{}{}]><[[][]][(){}]>}[[[<>{}]< +{<<{[(<{{[[([<[]()>{{}()}][{<>{}}[<>()]])]({(<[]{}>){{[][]}([]())}}<[[<>]<<>{}>]<{[]()}({}{})>>)]( +[<[[[{<[{[(([{<>[]}<{}<>>][{()<>}[[]<>]]){([[]()]<()>)<[{}{}][{}{}]>})[((<{}{}><<>()>){([]<>]<[][]>})({<< +{<(((<{<{{{<[([]{}){[]{}}]<[[]<>][<>()]>>(<[<><>][<>{}]><[(){}][()()]>)}((<{{}<>}<()[]>>{{[]{}}{ +(<<[[[[{[{{(<(<>{}){[]}>{<[]<>>([][])}){{([]())(()())}}}}){[[{(<<><>><()<>>)<(()[])<{}()>>}]]}}({[(<{[[]() +{({(<{<<<<((<[()<>]((){})>)){<<{<>}([][])>>(<<()()>([]())><[{}{}][{}<>]>)}>>([([[[[]<>]<[]()>]{<()[]><<>() +<{[(({{([(({<<[]<>]>{<<><>>[<><>]}}<(<()()>)[(()<>)]>){[(<{}{}>[{}<>])]})]{(<<[[[][]]([]{})]>>)[<([[()] +{({{<(<<{[([((()<>)<{}<>>)<[<>[]]{{}<>}>](<([][])(<><>}>))[[([[]{}][<><>]){[{}()]({}{})}]<([{}[]]{<><>} +<({[(([[[<<((([]{})<()[]>)((<>)<[]>))(<({}<>)[()()]>[([]<>){{}<>}])>[{[([])([]())]<[()()]<{}<>>>} +{{{[[<{{{[[[(({}[]))]{([{}()][[][]])[[[]<>]([]<>)]}]]((([[<>]{[]{}}]<[<>()]<(){}>>)({[(){}][ +[{{([{{<(<<({[(){}]{()()}}[[[]{}]<<>[]>])>>[<<<{{}()}({}[])>><(<()()>(()()))({[]{}})>><{({<>{}}{<>[]})[<{} +<<<<{{<<[[<[((()[])<{}{}>)<(()[])({}())>](({<>}{{}[]}}{[(){}]{()<>}})>({(<{}<>>(()[]))<<{}[]>{{}[]}>}<{{[][]} +<<((({[{[{<([([]())<()()>][<{}[]>([])]){({()}<()()>)<([]())(<><>}>}><<<{{}<>}[[]<>]>[[()](<><>)]> +(<{[[[[([([[<{<>{}}<[]()>>{<<>[]>}]{((<>{}){[]<>})<(()())([]{})>}](<[([]<>)(<><>)]{<[]<>>(< +[{<(<<<[(<{<[[[][]](<>())][<{}{}><{}()>]><{<[][]><<>[]>}{({}<>)}>}<<[({}())([]())]<<{}{}><()<>>>>[( +[[([({[{([[(<[(){}]<[]{}>>((())(()()))]]((({<><>}(()())){{{}()}}){{[<>()]{{}()}}<[[]<>]<{}()>>})]<(({<[][]> +<<{[(<({{({(<{{}<>}(()<>)><{[]{}}[[]{}]>){[<<>()>{{}}]((()[])[[]{}])}}[((({}<>)[()()])<[{}[]]<<>[]>> +[<{<({{({{{({{()[]}[()[]]})<{(<><>)[()<>]}{{<>{}}}>}<<{({}{})({}<>)}[[()<>][[]{}]]>[([{}[]](()))(<<> +{{({{{[[[(<[<{<>()><{}[]>>{<[]<>>[<>]}]>[<<[<>()]([]{})>{(<>)(<><>)}>(<(<>{})([]<>)>(<(){}>[{}[]])) +<{[{[{[(<<({[({})([][])][[(){}]([][])]}<{<{}<>>{[][]}}{((){}){{}{}}}>)[<{[[]{}][{}{}]}({()()}([]{}))>[[[< +({<<{[<(({[[([[][]])[(<>[])[{}()]]]<{<{}<>><[]<>>}<({}{})<{}()>>>}(<(<()[]>[{}[]])<([])<<>[]>>>{<[<>()] +<<{<{{([(({([{[]<>}[{}{}]]([()()][[]{}]))}[<{{[][]>{{}[]}}{[<>[]]{{}()}}>{((()<>)[(){}])}]))][({[<(<[] +({<[[{((<[[[({<>[]}{[]{}})({{}[]][<>[]])](({()<>}<{}[]>)(({}<>)<[]<>>))][<<<(){}>>{(<>{}){( +({(((<{[([{[(([][])([]<>))[{[][]}<[][]>]]}((<((){})(<><>)>(([][]){<>}))([({}[])<[]()>]{<<>[]>{(){}}}))]({<< +([[[[[([<<{<[<[]<>>([]())]{{<>{}}<<><>>}>[<[()[]][[]<>]>({<>{}}<()})]}[[[(()[])({}())]](((( +([(<<{<(<{<{[[<>]]<[<>[]]({}())>}><<{(()<>)(<><>)}{(<>[])<{}[]>}><<[<>()]<<>>><{{}{}}>>>}>)>}>{{ +({<<{([({{([{{<>}({}{})}([[]()]{[]()})][{<<>()>([])}<[[]{}]}])(([[[]{}]{()[]}]([{}()]<()<>>)) +(<{<[{[(<{([(((){}))[((){})<()()>]]{{[[][]]<(){}>}((<><>)<[][]>)})}{((<([]{})<<>[]>>{<[]{}>{{}<>}}))[({{<>( +<<<{{([[[{[{(((){})[<>[]])([{}()){()<>})}{{({}())}{{<><>}}}][<<[[]<>](<>)>{[()()]{{}()}}>[[<{}{ +<(<[{[([[(({[<{}<>>](([]{})([]()))}({<{}[]><()<>>}<[[][]]<[][]>>))<{[<()()><(){}>]([<><>]({}[]))}>)[[ +<({<<[(({{{([{{}<>}<()()>](({}{})<()<>>))((<(){}>([]{}))([<><>]))}{{<{{}{}}{<>[]}>[{(){}}<(){}>]}( +{{{([[([[<[(<<[]{}><[]()>>(<{}>(<>{})))[([[]{}](()<>))((<><>)[{}()])]]>]<([<((<>[])(<>))[{()()}({})]>] +{[<{((([<[({{{()[]}{()()}}((<>{})[[]<>])>){(<[[][]]>[(()())(<>[])])[<{<>[]}({}<>)>]}][(([[{}()]({} +{<{[(({{[({[[[()()][(){}]]{<[]()>(()[])}]<(<<>()>({}{}))>})<(<<([]<>)(()())>{((){}){<>()}}>)>]{{([[[{}]]]((<< +<<{({[{[[<[({(<>{})({}[])}<([]())[(){}]>)<<{(){}}(()<>)>{({}{})<{}<>>}>]{<[[()()]{{}<>}]({{}}<()()>)>[< +({([{<<{[{(({(()())([][])}({{}[]}((){}))))}([{<{()[]}({}())>[({})[[]{}}]}<([<><>]([]()))>](<{(<>())( +([<{{({<{[[{<{[]<>}>}([{[][]}[[][]]])]({[{[]<>}[[]<>]](({}[])[()()])}{({()()))<{{}[]}{[]{}}>})][[([<() +((({<<(({(<{[<<>[]>]{[(){}]<()()>}}{<{[]}{<><>>>([<>[]]<<><>>)}>{<({(){}})[({}{})([]{})]>({{<>[]}<{}[]>}<<[ +[{<({[[([<<[(({}[])((){}))]({[[][]][[][]]})>(([{[][]}[<>()]]{{<>()}(<>)}){<{<><>}){[()[]]{{}[]}}})>])]({( +{(<(([{{<{[[[(()[])(()<>)][{<>{}}[[][]]]]][{{<{}<>>{{}[]}}({()<>}[[]{}])}{[<{}{}>[[]<>]](<<>{}><(){}> +[(<[<<<({{[<(({}())<()()>){[[]{}]}>({({}())([]{})}([[]()]))]{[[<{}{}><[][]>]<<{}[]>({}())>]{{{()[]}{[][]} +([{[{<<<[{{({[{}()]}<<<>[]>{<>[]}>)((([]<>))([<>{}]))}{{[([]{})<(){}>}((()[])<[]()>)}({[(){} +[({[<[[[(((<<[[]]<[]<>>>>{{([]<>){()[]}}})(({(<><>)({}())})<({{}[]}{[]()})[{()<>}([][])]>) +<[[{[[{{[[[<<{()[]}<[][]>>{<<><>>[{}]}>{[<{}<>><[]<>>](((){}))}]{{<((){}){<>{}}>{(<>())[<>[]]}}<<{{}()}(( +(<[{(<<([[([[<{}{}>[<>[]]]][[{{}()}]<[<>()][()<>]>])<{[(<>{})(()[])]{[{}()][<>()]}}<((<>[]){<>()})(<() diff --git a/2021/11/a.py b/2021/11/a.py new file mode 100755 index 0000000..e304503 --- /dev/null +++ b/2021/11/a.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 +import sys + +G = [[0] * 10 for i in range(10)] +flashes = 0 + + +def debug(i=0): + print(f"--- {i} ---") + for r in G: + print("".join([str(i) for i in r])) + + +def step(): + flashed = [[False] * 10 for i in range(10)] + + def flash(r, c): + global flashes + + # At minimum, receive += 1 + G[r][c] += 1 + + # Now flash neighbors + if G[r][c] > 9 and not flashed[r][c]: + flashed[r][c] = True + flashes += 1 + # Neighbors + if r > 0: + flash(r - 1, c) + if c > 0: + flash(r, c - 1) + if r < 9: + flash(r + 1, c) + if c < 9: + flash(r, c + 1) + # corners + if r > 0 and c > 0: + flash(r - 1, c - 1) + if r < 9 and c < 9: + flash(r + 1, c + 1) + if r > 0 and c < 9: + flash(r - 1, c + 1) + if r < 9 and c > 0: + flash(r + 1, c - 1) + + # increase everyone first + for r in range(10): + for c in range(10): + G[r][c] += 1 + + # now flash it up + for r in range(10): + for c in range(10): + if G[r][c] > 9: + flash(r, c) + + # now, reset + for r in range(10): + for c in range(10): + if G[r][c] > 9: + G[r][c] = 0 + + +# Read in the grid +r = 0 +for l in sys.stdin: + c = 0 + for n in l.strip(): + G[r][c] = int(n) + c += 1 + r += 1 + +for i in range(100): + # debug(i) + step() + +print(flashes) diff --git a/2021/11/b.py b/2021/11/b.py new file mode 100755 index 0000000..0e02478 --- /dev/null +++ b/2021/11/b.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python3 +import sys + +G = [[0] * 10 for i in range(10)] + + +def debug(i=0): + print(f"--- {i} ---") + for r in G: + print("".join([str(i) for i in r])) + + +def step(): + flashed = [[False] * 10 for i in range(10)] + + def flash(r, c): + # At minimum, receive += 1 + G[r][c] += 1 + + # Now flash neighbors + if G[r][c] > 9 and not flashed[r][c]: + flashed[r][c] = True + # Neighbors + if r > 0: + flash(r - 1, c) + if c > 0: + flash(r, c - 1) + if r < 9: + flash(r + 1, c) + if c < 9: + flash(r, c + 1) + # corners + if r > 0 and c > 0: + flash(r - 1, c - 1) + if r < 9 and c < 9: + flash(r + 1, c + 1) + if r > 0 and c < 9: + flash(r - 1, c + 1) + if r < 9 and c > 0: + flash(r + 1, c - 1) + + # increase everyone first + for r in range(10): + for c in range(10): + G[r][c] += 1 + + # now flash it up + for r in range(10): + for c in range(10): + if G[r][c] > 9: + flash(r, c) + + # now, reset + flashes = 0 + for r in range(10): + for c in range(10): + if G[r][c] > 9: + G[r][c] = 0 + flashes += 1 + + # Return ! is sync + return flashes != 100 + + +# Read in the grid +r = 0 +for l in sys.stdin: + c = 0 + for n in l.strip(): + G[r][c] = int(n) + c += 1 + r += 1 + +i = 1 +while step(): + i += 1 + + +print(i) diff --git a/2021/11/example b/2021/11/example new file mode 100644 index 0000000..03743f6 --- /dev/null +++ b/2021/11/example @@ -0,0 +1,10 @@ +5483143223 +2745854711 +5264556173 +6141336146 +6357385478 +4167524645 +2176841721 +6882881134 +4846848554 +5283751526 diff --git a/2021/11/input b/2021/11/input new file mode 100644 index 0000000..efb0e67 --- /dev/null +++ b/2021/11/input @@ -0,0 +1,10 @@ +5651341452 +1381541252 +1878435224 +6814831535 +3883547383 +6473548464 +1885833658 +3732584752 +1881546128 +5121717776 diff --git a/2021/12/a.py b/2021/12/a.py new file mode 100755 index 0000000..04ed1e0 --- /dev/null +++ b/2021/12/a.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +import sys +import re +from collections import defaultdict + +E = defaultdict(list) + + +# Parse in edges +for l in sys.stdin: + a, b = l.strip().split('-') + E[a].append(b) + E[b].append(a) + +smallre = re.compile('[a-z]+') +def issmall(n): + return smallre.match(n) + +paths = 0 +def search(n, path): + global paths + if n == 'end': + paths += 1 + return + if issmall(n) and n in path: + return + for c in E[n]: + search(c, path + n) + +search("start", "") + +print(paths) diff --git a/2021/12/b.py b/2021/12/b.py new file mode 100755 index 0000000..da634fe --- /dev/null +++ b/2021/12/b.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +import sys +import re +from collections import defaultdict + +E = defaultdict(list) + + +# Parse in edges +for l in sys.stdin: + a, b = l.strip().split('-') + E[a].append(b) + E[b].append(a) + +smallre = re.compile('[a-z]+') +def issmall(n): + return smallre.match(n) + +paths = 0 +P = [] +def search(n, path, has_doubled): + global paths + global P + if n == 'end': + paths += 1 + P.append(path + n) + return + if issmall(n) and n in path: + if has_doubled: + return + else: + has_doubled = True + for c in E[n]: + if c != 'start': + search(c, path + n, has_doubled) + +search("start", "", False) +print(paths) diff --git a/2021/12/ex2 b/2021/12/ex2 new file mode 100644 index 0000000..6fd8c41 --- /dev/null +++ b/2021/12/ex2 @@ -0,0 +1,7 @@ +start-A +start-b +A-c +A-b +b-d +A-end +b-end diff --git a/2021/12/example b/2021/12/example new file mode 100644 index 0000000..65f3833 --- /dev/null +++ b/2021/12/example @@ -0,0 +1,18 @@ +fs-end +he-DX +fs-he +start-DX +pj-DX +end-zg +zg-sl +zg-pj +pj-he +RW-he +fs-DX +pj-RW +zg-RW +start-pj +he-WI +zg-he +pj-fs +start-RW diff --git a/2021/12/input b/2021/12/input new file mode 100644 index 0000000..262ee68 --- /dev/null +++ b/2021/12/input @@ -0,0 +1,19 @@ +lg-GW +pt-start +pt-uq +nx-lg +ve-GW +start-nx +GW-start +GW-nx +pt-SM +sx-GW +lg-end +nx-SM +lg-SM +pt-nx +end-ve +ve-SM +TG-uq +end-SM +SM-uq diff --git a/2021/13/a.py b/2021/13/a.py new file mode 100755 index 0000000..bad3906 --- /dev/null +++ b/2021/13/a.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +import sys +import re + +coord = re.compile("\d+,\d+") +fold = re.compile("fold along") + +coords = [] +folds = [] + +for l in sys.stdin: + l = l.strip() + if coord.match(l): + coords.append([int(x) for x in l.split(",")]) + elif fold.match(l): + split = l.split() + # x=8 + folds.append(split[2].split("=")) + +# Pt A we only care about the first split +# Assuming all points are originally unique, we just need to +# dedupe them after the fold! +d, v = folds[0] +v = int(v) + +folded = {} + +for c in coords: + x, y = c + if d == "x": + if x == v: + # lost to the fold + pass + elif x > v: + newx = v - (x - v) + folded[(newx, y)] = 1 + else: + folded[(x, y)] = 1 + elif d == "y": + if y == v: + # lost to the fold + pass + elif y > v: + newy = v - (y - v) + folded[(x, newy)] = 1 + else: + folded[(x, y)] = 1 + else: + raise Exception(f"Bad dir: {d}") + +print(len(folded.keys())) diff --git a/2021/13/b.py b/2021/13/b.py new file mode 100755 index 0000000..efb284e --- /dev/null +++ b/2021/13/b.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 +import sys +import re + +coord = re.compile("\d+,\d+") +fold = re.compile("fold along") + +coords = [] +folds = [] + +for l in sys.stdin: + l = l.strip() + if coord.match(l): + coords.append([int(x) for x in l.split(",")]) + elif fold.match(l): + split = l.split() + # x=8 + folds.append(split[2].split("=")) + + +prev_folded = {} +for d, v in folds: + v = int(v) + folded = {} + for c in coords: + x, y = c + if d == "x": + if x == v: + # lost to the fold + pass + elif x > v: + newx = v - (x - v) + folded[(newx, y)] = 1 + else: + folded[(x, y)] = 1 + elif d == "y": + if y == v: + # lost to the fold + pass + elif y > v: + newy = v - (y - v) + folded[(x, newy)] = 1 + else: + folded[(x, y)] = 1 + else: + raise Exception(f"Bad dir: {d}") + + coords = folded.keys() + prev_folded = folded + +# Just hope they fit on a terminal! +print() +for y in range(6): + for x in range(120): + if (x, y) in prev_folded: + print("#", end="") + else: + print(" ", end="") + print() diff --git a/2021/13/example b/2021/13/example new file mode 100644 index 0000000..282114c --- /dev/null +++ b/2021/13/example @@ -0,0 +1,21 @@ +6,10 +0,14 +9,10 +0,3 +10,4 +4,11 +6,0 +6,12 +4,1 +0,13 +10,12 +3,4 +3,0 +8,4 +1,10 +2,14 +8,10 +9,0 + +fold along y=7 +fold along x=5 diff --git a/2021/13/input b/2021/13/input new file mode 100644 index 0000000..f0b79e5 --- /dev/null +++ b/2021/13/input @@ -0,0 +1,874 @@ +1101,291 +221,448 +1098,383 +217,399 +507,191 +410,240 +1036,449 +208,241 +469,548 +1064,838 +189,72 +1198,812 +107,483 +900,206 +902,325 +430,7 +801,834 +1009,890 +263,65 +1255,379 +328,502 +537,703 +724,763 +126,521 +788,127 +544,484 +110,36 +243,28 +1183,215 +242,420 +811,373 +1228,325 +567,880 +798,250 +5,264 +165,362 +140,126 +915,596 +835,806 +1047,157 +1123,222 +72,654 +1111,863 +114,411 +212,511 +1071,603 +1123,672 +704,707 +1191,558 +944,137 +1168,879 +55,379 +773,74 +36,227 +36,560 +1048,856 +209,151 +1016,355 +1012,428 +528,616 +902,390 +489,532 +350,528 +790,18 +666,759 +224,191 +761,560 +571,602 +329,698 +330,806 +1310,883 +919,855 +1250,119 +1069,305 +754,486 +574,632 +411,418 +423,410 +329,180 +823,781 +499,521 +902,530 +316,778 +649,355 +581,672 +1101,603 +1110,224 +601,47 +977,264 +1297,340 +743,294 +463,343 +652,134 +73,446 +5,508 +946,891 +698,609 +1015,343 +440,792 +221,670 +597,894 +1153,763 +798,187 +946,521 +1297,365 +212,383 +157,763 +1228,894 +939,494 +1039,227 +463,551 +132,16 +536,241 +1071,561 +1027,876 +567,462 +199,438 +1009,789 +271,299 +1170,350 +557,613 +360,847 +1309,84 +58,474 +1184,0 +709,847 +711,47 +885,613 +179,75 +87,630 +577,677 +1098,511 +1086,7 +145,284 +939,176 +33,301 +373,736 +733,217 +841,346 +192,445 +147,311 +192,837 +818,653 +330,866 +610,628 +306,66 +850,497 +246,812 +162,784 +207,227 +1084,131 +738,424 +728,318 +900,318 +851,217 +1086,66 +684,169 +391,407 +798,431 +1121,341 +189,588 +441,845 +736,184 +999,582 +1061,417 +406,168 +773,820 +715,458 +649,386 +1215,529 +773,191 +960,528 +1111,438 +67,29 +946,821 +126,392 +268,868 +897,305 +1196,35 +1119,551 +60,319 +72,128 +126,278 +1305,264 +1243,522 +455,438 +393,281 +552,319 +1280,838 +733,677 +30,61 +800,819 +412,756 +246,504 +507,759 +776,114 +73,224 +1305,284 +984,872 +1233,604 +835,75 +692,334 +254,240 +1310,358 +144,371 +1066,123 +1078,810 +509,386 +1245,710 +107,819 +114,483 +678,308 +873,847 +1103,227 +463,327 +1168,250 +889,147 +830,402 +522,127 +107,115 +0,883 +805,620 +559,60 +1176,298 +897,133 +1059,758 +0,252 +985,322 +30,838 +1282,101 +1102,241 +1028,653 +1175,327 +957,378 +42,733 +1145,625 +373,343 +763,411 +459,343 +338,436 +360,47 +246,437 +907,86 +77,677 +594,575 +801,386 +723,29 +283,876 +189,621 +1110,866 +408,156 +475,88 +251,758 +738,31 +643,315 +301,4 +739,154 +728,206 +1247,487 +644,211 +330,200 +507,583 +333,182 +5,91 +294,399 +848,57 +609,191 +343,311 +995,252 +221,224 +1208,663 +406,138 +1163,311 +1230,88 +393,165 +5,162 +1064,530 +43,3 +653,628 +985,362 +1183,255 +974,267 +290,331 +1299,362 +266,775 +1064,122 +1093,47 +392,38 +65,184 +572,613 +571,544 +520,428 +1067,866 +470,19 +783,886 +363,86 +311,70 +320,527 +1066,206 +221,560 +1233,677 +1049,165 +1042,868 +1143,333 +1158,268 +472,96 +1256,894 +224,887 +565,821 +391,65 +1081,505 +925,334 +131,665 +1094,410 +761,224 +818,205 +609,43 +677,700 +738,613 +927,719 +582,318 +808,716 +960,472 +28,437 +946,563 +803,311 +33,593 +850,311 +364,521 +502,884 +856,614 +1310,232 +661,284 +212,35 +924,868 +502,626 +107,523 +445,79 +808,570 +803,703 +877,334 +181,22 +980,28 +1245,415 +502,716 +947,86 +107,380 +1039,595 +743,880 +271,595 +745,73 +559,529 +1173,889 +78,829 +105,782 +115,369 +1118,389 +917,707 +364,378 +813,131 +405,229 +321,264 +492,653 +11,362 +633,700 +408,738 +510,371 +537,815 +1277,749 +187,222 +50,497 +875,16 +599,827 +1086,255 +1064,156 +1064,604 +902,569 +454,280 +639,70 +1200,36 +107,878 +986,806 +137,374 +1102,149 +739,292 +830,626 +191,439 +221,446 +455,863 +1173,247 +1069,589 +624,838 +1176,876 +880,35 +499,373 +353,82 +632,808 +1206,68 +541,397 +321,179 +30,232 +879,122 +241,305 +1061,5 +295,343 +512,879 +937,343 +164,43 +1305,539 +610,266 +551,548 +454,28 +661,386 +994,340 +1280,61 +671,70 +618,373 +462,718 +980,638 +281,36 +460,497 +338,884 +1295,824 +393,729 +879,772 +502,268 +1009,154 +386,868 +447,227 +1138,542 +296,609 +1310,11 +408,530 +897,761 +192,53 +981,698 +54,166 +1064,390 +147,415 +587,29 +1064,856 +537,596 +1173,647 +1020,563 +774,241 +684,457 +654,11 +1111,86 +798,879 +559,813 +1158,716 +192,176 +415,732 +842,752 +115,77 +82,325 +1097,621 +966,598 +423,92 +1119,119 +60,575 +1071,499 +539,817 +395,596 +1280,662 +383,609 +873,822 +1215,813 +162,241 +857,840 +763,859 +1305,162 +728,240 +350,586 +231,81 +739,740 +242,868 +534,114 +877,448 +453,840 +1215,386 +1265,407 +487,781 +152,716 +629,516 +353,890 +1256,0 +1285,452 +902,156 +502,324 +1228,613 +706,588 +115,817 +576,513 +1086,120 +1129,834 +919,289 +629,442 +950,47 +686,838 +1183,568 +994,100 +498,815 +334,880 +373,372 +830,268 +1071,268 +137,520 +869,845 +599,515 +599,47 +577,604 +348,828 +902,290 +430,828 +440,515 +1168,431 +339,252 +957,82 +971,252 +710,894 +333,732 +838,96 +1272,332 +102,127 +1145,849 +1019,826 +217,495 +119,558 +1268,733 +1039,609 +377,551 +701,43 +982,683 +325,572 +1260,812 +1274,112 +290,597 +1068,138 +547,563 +1237,672 +343,70 +137,140 +50,588 +454,614 +118,205 +498,367 +353,378 +835,88 +114,859 +1158,772 +1145,362 +1183,639 +169,67 +711,67 +1226,868 +1268,833 +301,789 +677,642 +995,763 +582,576 +316,554 +904,138 +339,642 +1304,527 +22,422 +1129,872 +460,728 +454,168 +1196,411 +763,331 +58,292 +1227,350 +65,483 +848,841 +729,0 +634,427 +1195,77 +1149,84 +140,544 +933,551 +200,728 +985,124 +656,11 +545,616 +459,677 +957,341 +1103,652 +1119,455 +107,688 +104,826 +1101,74 +325,124 +1227,740 +502,10 +1203,523 +527,7 +1158,570 +290,821 +1207,346 +1242,763 +1064,56 +194,728 +431,122 +1068,868 +435,16 +611,242 +462,53 +115,525 +161,84 +462,885 +541,497 +788,654 +1123,224 +1120,567 +249,5 +771,817 +1154,544 +405,889 +561,572 +994,794 +396,91 +729,672 +869,273 +542,306 +644,759 +1247,381 +1020,73 +1165,508 +1094,415 +736,595 +801,60 +907,534 +1308,246 +872,31 +207,652 +1118,837 +30,609 +887,92 +595,458 +895,732 +1064,38 +82,613 +1128,544 +325,362 +85,122 +1146,43 +454,224 +517,199 +433,446 +1212,408 +1163,583 +5,732 +589,710 +364,891 +1203,75 +1033,679 +480,626 +865,255 +246,200 +316,359 +1052,131 +438,484 +15,70 +982,470 +609,851 +609,372 +194,807 +900,688 +981,124 +957,553 +1247,183 +507,31 +1233,290 +1232,392 +1089,560 +982,502 +134,428 +600,0 +1193,752 +459,665 +1020,740 +316,100 +328,22 +1305,508 +126,894 +895,716 +328,424 +550,516 +880,66 +1265,191 +1274,821 +446,653 +393,184 +902,604 +787,665 +856,280 +1068,26 +1310,502 +1056,206 +1174,786 +1091,155 +855,438 +348,380 +927,623 +759,548 +972,458 +191,775 +792,786 +648,73 +851,677 +604,588 +1280,659 +986,190 +1119,775 +455,326 +187,224 +1086,319 +165,700 +612,61 +705,215 +582,654 +581,224 +1196,483 +364,331 +441,49 +831,26 +902,255 +488,306 +869,621 +371,204 +878,516 +107,75 +768,515 +835,523 +989,264 +117,703 +971,28 +221,672 +678,586 +745,821 +599,399 +1274,597 +273,47 +145,386 +1066,0 +1200,31 +135,327 +986,88 +328,683 +589,483 +1260,497 +59,458 +1195,525 +1304,821 +1091,739 +957,452 +358,733 +1170,544 +1110,222 +856,149 +1168,655 +788,543 +664,715 +1089,448 +118,653 +960,250 +22,472 +485,60 +373,522 +888,532 +244,894 +576,138 +728,576 +147,479 +324,88 +28,101 +681,292 +612,833 +209,291 +387,346 +898,756 +1279,439 +967,824 +371,718 +1111,120 +893,73 +1089,224 +698,61 +261,710 +316,116 +1168,239 +315,642 +1225,122 +1195,817 +246,738 +224,639 +1121,247 +581,222 +1223,630 +338,564 +152,10 +271,609 +594,270 +242,474 +350,250 +194,280 +261,165 +222,378 +493,717 +410,771 +743,462 +739,544 +423,372 +358,609 +1278,623 +662,73 +1252,602 +224,774 +469,346 +213,621 +224,319 +454,390 +1039,299 +263,39 +1274,521 +570,302 +788,351 +177,274 +229,389 +36,521 +773,703 +763,819 +527,886 +986,28 +656,883 +137,72 +855,86 +711,515 +1203,483 +423,81 +946,292 +541,845 +1019,516 +329,250 +142,879 +1111,422 +1158,535 +463,439 +165,208 +848,885 +480,402 +25,442 +432,516 +145,162 +221,334 +25,292 +95,365 +98,408 +1193,372 +565,73 + +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 diff --git a/2021/Makefile b/2021/Makefile new file mode 100644 index 0000000..6313f14 --- /dev/null +++ b/2021/Makefile @@ -0,0 +1,36 @@ +# Makefile +# +# Targets: +# +# build: builds all C executables +# +# run: runs all found solutions for $DAY +# (default all, example: make DAY=1 run) +# +# clean: removes all C executables +CFLAGS = -g -O2 -Wall -Wpedantic -Wextra +DAY = * + +TARGETS = 01/a 01/b \ + 02/a 02/b \ + 03/a \ + 05/a 05/b \ + 06/a 06/b + +.PHONY: build +build: $(TARGETS) + +.PHONY: run +run: build + @for d in $(DAY)/; do \ + for sol in a.py a b.py b; do \ + [ -e $$d/$$sol ] && printf "%-9s" "$${d}$$sol: " && $$d/$$sol < $$d/input || true; \ + done; \ + done + +.PHONY: clean +clean: + rm -f $(TARGETS) + +%: %.c + $(CC) $(CFLAGS) -o $@ $< diff --git a/2021/README.md b/2021/README.md new file mode 100644 index 0000000..a3c93f8 --- /dev/null +++ b/2021/README.md @@ -0,0 +1,22 @@ +Advent of Code 2021 +=================== +This year I'm attempting at least some of the earlier problems +in C as well as Python (need the dynamic language to get that +super speedy private leaderboard time!). + +Should get interesting once I need hashmaps :) + +If you want to discuss any of my solutions, shoot me an email +at my public inbox: [~akarle/public-inbox@lists.sr.ht][mail] + +[mail]: mailto:~akarle/public-inbox@lists.sr.ht + +Running +------- +The GNU Makefile builds the C code and runs both C and Python +solutions via the `build` and `run` targets respectively. `run` +takes an optional parameter `DAY` that can limit the solutions +run: + + make run # runs all + make DAY=01 run # runs day 1 diff --git a/LICENSE b/LICENSE index 0c89764..5a47f5a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 Alex Karle +Copyright (c) 2021-2022 Alex Karle Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile deleted file mode 100644 index 6313f14..0000000 --- a/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -# Makefile -# -# Targets: -# -# build: builds all C executables -# -# run: runs all found solutions for $DAY -# (default all, example: make DAY=1 run) -# -# clean: removes all C executables -CFLAGS = -g -O2 -Wall -Wpedantic -Wextra -DAY = * - -TARGETS = 01/a 01/b \ - 02/a 02/b \ - 03/a \ - 05/a 05/b \ - 06/a 06/b - -.PHONY: build -build: $(TARGETS) - -.PHONY: run -run: build - @for d in $(DAY)/; do \ - for sol in a.py a b.py b; do \ - [ -e $$d/$$sol ] && printf "%-9s" "$${d}$$sol: " && $$d/$$sol < $$d/input || true; \ - done; \ - done - -.PHONY: clean -clean: - rm -f $(TARGETS) - -%: %.c - $(CC) $(CFLAGS) -o $@ $< diff --git a/README.md b/README.md index a3c93f8..271cae7 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,4 @@ -Advent of Code 2021 -=================== -This year I'm attempting at least some of the earlier problems -in C as well as Python (need the dynamic language to get that -super speedy private leaderboard time!). +# Advent of Code -Should get interesting once I need hashmaps :) - -If you want to discuss any of my solutions, shoot me an email -at my public inbox: [~akarle/public-inbox@lists.sr.ht][mail] - -[mail]: mailto:~akarle/public-inbox@lists.sr.ht - -Running -------- -The GNU Makefile builds the C code and runs both C and Python -solutions via the `build` and `run` targets respectively. `run` -takes an optional parameter `DAY` that can limit the solutions -run: - - make run # runs all - make DAY=01 run # runs day 1 +* [2021](./2021): Mostly Python, some C +* [2022](./2022): Attempting CHICKEN Scheme -- libgit2 1.8.1