summaryrefslogtreecommitdiffstats
path: root/19
diff options
context:
space:
mode:
authorGustav Sörnäs <gusso230@student.liu.se>2019-12-17 20:54:35 +0100
committerGustav Sörnäs <gusso230@student.liu.se>2019-12-17 20:54:35 +0100
commitee96aa7c6ab8f0148e814630e77a726bf61530c0 (patch)
tree444376bc3ecfc235118558cace0de96f3aafd790 /19
parentca4d3b189da7793ce8744246617c793c8640ce71 (diff)
downloadaoc-ee96aa7c6ab8f0148e814630e77a726bf61530c0.tar.gz
Rename 2019
Diffstat (limited to '19')
-rw-r--r--19/cpp/01-1.cpp8
-rw-r--r--19/cpp/01-2.cpp14
-rw-r--r--19/cpp/02-1.cpp47
-rw-r--r--19/cpp/02-2.cpp66
-rw-r--r--19/input/01100
-rw-r--r--19/input/021
-rw-r--r--19/input/032
-rw-r--r--19/input/040
-rw-r--r--19/input/051
-rw-r--r--19/input/061294
-rw-r--r--19/input/071
-rw-r--r--19/input/081
-rw-r--r--19/input/091
-rw-r--r--19/input/1024
-rw-r--r--19/input/112
-rw-r--r--19/input/124
-rw-r--r--19/input/131
-rw-r--r--19/input/1458
-rw-r--r--19/input/151
-rw-r--r--19/input/15-ed1
-rw-r--r--19/input/15-eskil1
-rw-r--r--19/input/161
-rw-r--r--19/input/171
-rw-r--r--19/py/d01.py28
-rw-r--r--19/py/d02.py49
-rw-r--r--19/py/d03.py83
-rw-r--r--19/py/d04.py65
-rw-r--r--19/py/d05.py34
-rw-r--r--19/py/d06.py87
-rw-r--r--19/py/d07.py80
-rw-r--r--19/py/d08.py38
-rw-r--r--19/py/d09.py27
-rw-r--r--19/py/d10.py261
-rw-r--r--19/py/d11.py165
-rw-r--r--19/py/d12.py126
-rw-r--r--19/py/d13.py132
-rw-r--r--19/py/d14.py77
-rw-r--r--19/py/d15.py276
-rw-r--r--19/py/d16.py46
-rw-r--r--19/py/d17.py305
-rw-r--r--19/py/intcode.py153
-rw-r--r--19/py/main.py52
42 files changed, 3714 insertions, 0 deletions
diff --git a/19/cpp/01-1.cpp b/19/cpp/01-1.cpp
new file mode 100644
index 0000000..fcb593a
--- /dev/null
+++ b/19/cpp/01-1.cpp
@@ -0,0 +1,8 @@
+#include<iostream>
+
+int main() {
+ int mass, sum = 0;
+ while (std::cin >> mass) sum += (mass / 3) - 2;
+ std::cout << sum << std::endl;
+}
+
diff --git a/19/cpp/01-2.cpp b/19/cpp/01-2.cpp
new file mode 100644
index 0000000..7ce1a82
--- /dev/null
+++ b/19/cpp/01-2.cpp
@@ -0,0 +1,14 @@
+#include<iostream>
+
+int getFuel(int mass) {
+ int fuel = (mass / 3) - 2;
+ if (fuel <= 0) return 0;
+ return fuel + getFuel(fuel);
+}
+
+int main() {
+ int mass, sum = 0;
+ while (std::cin >> mass) sum += getFuel(mass);
+ std::cout << sum << std::endl;
+}
+
diff --git a/19/cpp/02-1.cpp b/19/cpp/02-1.cpp
new file mode 100644
index 0000000..b6db056
--- /dev/null
+++ b/19/cpp/02-1.cpp
@@ -0,0 +1,47 @@
+#include<fstream>
+#include<iostream>
+#include<vector>
+using namespace std;
+
+int main() {
+ ifstream inFile;
+ inFile.open("02.in");
+
+ vector<int> program;
+ int noun, verb;
+ // enter noun, verb
+ cin >> noun;
+ cin >> verb;
+
+ // read program
+ int n;
+ while (inFile >> n) program.push_back(n);
+ program[1] = noun;
+ program[2] = verb;
+ //cout << "Program: " << endl;
+ //dump(program);
+
+ // copy program to mem
+ vector<int> mem(program);
+
+ // calculate
+ int pointer = 0;
+ int op;
+ do {
+ //cout << "Pointer: " << pointer << endl;
+ //cout << "Memory: " << endl;
+ //dump(mem);
+ op = mem[pointer];
+ switch (op) {
+ case 1:
+ mem[mem[pointer+3]] = mem[mem[pointer+1]] + mem[mem[pointer+2]];
+ pointer += 4;
+ break;
+ case 2:
+ mem[mem[pointer+3]] = mem[mem[pointer+1]] * mem[mem[pointer+2]];
+ pointer += 4;
+ break;
+ }
+ } while (mem[pointer] != 99);
+ cout << mem[0] << endl;
+}
diff --git a/19/cpp/02-2.cpp b/19/cpp/02-2.cpp
new file mode 100644
index 0000000..aab95a8
--- /dev/null
+++ b/19/cpp/02-2.cpp
@@ -0,0 +1,66 @@
+#include<fstream>
+#include<iostream>
+#include<vector>
+#include <chrono>
+using namespace std;
+
+int run(vector<int> prog, int noun, int verb, int pointer, int op) {
+ vector<int> mem(prog);
+ mem[1] = noun;
+ mem[2] = verb;
+
+ // calculate
+ pointer = 0;
+ do {
+ //cout << "Pointer: " << pointer << endl;
+ //cout << "Memory: " << endl;
+ //dump(mem);
+ op = mem[pointer];
+ switch (op) {
+ case 1:
+ mem[mem[pointer+3]] = mem[mem[pointer+1]] + mem[mem[pointer+2]];
+ pointer += 4;
+ break;
+ case 2:
+ mem[mem[pointer+3]] = mem[mem[pointer+1]] * mem[mem[pointer+2]];
+ pointer += 4;
+ break;
+ }
+ } while (mem[pointer] != 99);
+ return mem[0];
+}
+
+int main() {
+ ifstream inFile;
+ inFile.open("02.in");
+
+ vector<int> program;
+ int noun, verb;
+ int pointer;
+ int op;
+
+ // read program
+ int n;
+ while (inFile >> n) program.push_back(n);
+ //cout << "Program: " << endl;
+ //dump(program);
+
+ int res;
+
+ auto t1 = chrono::high_resolution_clock::now();
+
+ for (int n = 0; n < 100; n++) {
+ for (int v = 0; v < 100; v++) {
+ res = run(program, n, v, pointer, op);
+ //cout << n << " " << v << " " << res << endl;
+ if (res == 19690720) {
+ cout << n << " " << v << endl;
+ auto t2 = chrono::high_resolution_clock::now();
+ auto duration = chrono::duration_cast<std::chrono::microseconds>( t2 - t1 ).count();
+ cout << duration << endl;
+ return 0;
+ }
+ }
+ }
+ return 1;
+}
diff --git a/19/input/01 b/19/input/01
new file mode 100644
index 0000000..bcf9d47
--- /dev/null
+++ b/19/input/01
@@ -0,0 +1,100 @@
+137503
+60363
+103031
+141000
+101650
+76081
+139069
+63717
+135021
+66034
+53912
+83417
+125978
+73206
+77497
+108822
+133339
+113618
+91973
+88741
+109942
+96523
+95973
+56595
+118638
+63936
+101635
+149154
+85522
+140962
+108196
+105804
+148464
+68429
+146808
+82541
+85581
+117253
+117900
+83457
+103354
+123875
+88412
+108573
+140651
+103774
+95291
+91290
+98690
+87761
+122907
+91499
+141746
+127300
+114866
+75472
+65369
+50978
+119756
+144115
+92483
+146317
+100770
+124156
+109933
+138037
+101126
+58517
+83653
+135656
+111483
+82784
+107459
+106641
+138030
+53599
+123886
+74425
+96919
+65410
+63823
+148278
+133753
+106661
+51147
+120571
+77900
+131827
+107882
+149359
+127565
+67109
+131547
+114874
+130493
+94905
+138654
+58504
+79591
+133856
diff --git a/19/input/02 b/19/input/02
new file mode 100644
index 0000000..bcebbfa
--- /dev/null
+++ b/19/input/02
@@ -0,0 +1 @@
+1,0,0,3,1,1,2,3,1,3,4,3,1,5,0,3,2,6,1,19,2,19,9,23,1,23,5,27,2,6,27,31,1,31,5,35,1,35,5,39,2,39,6,43,2,43,10,47,1,47,6,51,1,51,6,55,2,55,6,59,1,10,59,63,1,5,63,67,2,10,67,71,1,6,71,75,1,5,75,79,1,10,79,83,2,83,10,87,1,87,9,91,1,91,10,95,2,6,95,99,1,5,99,103,1,103,13,107,1,107,10,111,2,9,111,115,1,115,6,119,2,13,119,123,1,123,6,127,1,5,127,131,2,6,131,135,2,6,135,139,1,139,5,143,1,143,10,147,1,147,2,151,1,151,13,0,99,2,0,14,0
diff --git a/19/input/03 b/19/input/03
new file mode 100644
index 0000000..f9771e4
--- /dev/null
+++ b/19/input/03
@@ -0,0 +1,2 @@
+R990,D362,L316,U101,R352,U798,L314,D564,R961,D634,L203,U601,R973,U227,R996,D639,L868,D135,L977,D201,R911,D486,R906,U719,L546,U324,R302,D200,L879,D206,L872,U681,R628,D272,R511,D827,L929,U915,L399,U696,R412,D640,R234,U487,R789,U354,L620,D914,L7,D228,L55,D591,L250,D228,R816,U935,R553,U98,L833,D418,R582,D793,R804,U283,R859,D206,L842,U663,L935,U495,L995,D181,R75,D33,R126,U489,L894,D675,R33,U239,L623,D931,L830,U63,R77,D576,L85,D415,R443,U603,R654,U495,L273,U583,R10,D648,L840,U904,R489,D655,R997,U559,L614,U917,R809,U540,L41,U519,R256,U111,R29,D603,L931,U518,R443,D51,L788,U483,L665,U890,L392,D701,R907,D125,L438,D107,L266,U766,R743,D343,R898,U293,L318,U417,L23,U44,L668,U614,R83,U31,R452,U823,R16,D418,R68,U823,L53,D638,L394,D714,R992,U196,R913,D526,L458,U428,L412,U901,R610,U348,L904,D815,R274,U439,R207,D81,L20,D507,L179,U249,L221,U603,L897,U490,R127,U99,L709,U925,L818,D777,R292,U935,R801,U331,R412,U759,L698,D53,L969,U492,L502,D137,R513,D999,L808,D618,L240,U378,L284,D726,L609,U530,R537,D36,L504,D26,R244,D692,L186,U767,L690,U182,R559,D926,R706,D132,L325,D846,R494,U238,L519,U655,R57,U658,L471,D717,L964,D346,L448,U286,L457,D504,R614,U652,R583,D780,R882,U417,R573,D297,L144,U347,L254,D589,L387,U309,L88,D510,R435,U636,L640,U801,R774,U678,R247,D846,L775,U527,L225,U798,R577,U897,R11,U153,L297,D748,L284,U806,R512,U906,L181,U39,R264,D47,L561,D441,L181,U210,L278,U998,R256,D278,R350,U466,L335,D310,L4,U298,L531,D423,R851,U285,L235,D139,R209,U882,R801,D36,L777,D153,L63
+L995,D598,R577,U346,L797,D375,R621,D709,R781,U55,R965,U327,L479,U148,L334,U93,R644,U632,L557,D136,L690,D548,R982,D703,L971,U399,R600,D785,L504,U984,R18,U190,L755,D737,L787,D921,R303,U513,L544,U954,L814,U239,R550,D458,R518,D538,R362,D350,L103,U17,L362,D480,L80,U639,L361,D75,L356,D849,R635,U633,R934,U351,L314,U960,R657,U802,L687,U385,L558,D984,L996,U765,L147,D366,R908,U981,R44,U336,R396,U85,R819,D582,L21,D920,L627,D103,R922,U195,L412,D385,L159,U446,L152,U400,L303,U549,R734,D709,R661,U430,R177,U857,L53,U555,R35,D919,L163,D630,L162,U259,R46,D89,R965,D410,R37,U39,R621,D606,L816,D659,L668,D418,L775,D911,R296,U488,L129,U869,L455,U663,L942,U813,L274,D677,R161,D338,R455,D580,R976,D984,L336,U742,R334,U130,L210,U523,R958,U177,R126,U469,L513,D14,L772,D423,L369,D661,R167,D449,L685,U871,L930,U630,L54,D581,L921,U839,R782,D844,L581,D995,R110,U365,L594,D595,R391,D298,R297,U469,L148,D34,R5,D609,L654,U172,R940,D858,L682,D92,R395,D683,R947,U311,L850,U151,R452,U641,L599,D640,R86,U584,L518,D597,L724,D282,L691,D957,L119,U30,L8,D514,R237,U599,R775,U413,R802,D132,R925,U133,L980,D981,R272,U632,R995,U427,R770,D722,L817,D609,R590,D799,L699,U923,L881,U893,R79,U327,L405,D669,L702,D612,R895,D132,R420,U958,L955,U993,L817,D492,R453,D342,L575,D253,R97,U54,R456,U748,L912,U661,L987,D182,L816,U218,R933,D797,L207,D71,R546,U578,L894,D536,L253,D525,L164,D673,R784,U915,L774,U586,R733,D80,L510,U449,L403,D915,L612,D325,L470,U179,L460,U405,R297,D803,R637,U893,R565,U952,R550,U936,R378,D932,L669
diff --git a/19/input/04 b/19/input/04
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/19/input/04
diff --git a/19/input/05 b/19/input/05
new file mode 100644
index 0000000..fe477a1
--- /dev/null
+++ b/19/input/05
@@ -0,0 +1 @@
+3,225,1,225,6,6,1100,1,238,225,104,0,1002,114,46,224,1001,224,-736,224,4,224,1002,223,8,223,1001,224,3,224,1,223,224,223,1,166,195,224,1001,224,-137,224,4,224,102,8,223,223,101,5,224,224,1,223,224,223,1001,169,83,224,1001,224,-90,224,4,224,102,8,223,223,1001,224,2,224,1,224,223,223,101,44,117,224,101,-131,224,224,4,224,1002,223,8,223,101,5,224,224,1,224,223,223,1101,80,17,225,1101,56,51,225,1101,78,89,225,1102,48,16,225,1101,87,78,225,1102,34,33,224,101,-1122,224,224,4,224,1002,223,8,223,101,7,224,224,1,223,224,223,1101,66,53,224,101,-119,224,224,4,224,102,8,223,223,1001,224,5,224,1,223,224,223,1102,51,49,225,1101,7,15,225,2,110,106,224,1001,224,-4539,224,4,224,102,8,223,223,101,3,224,224,1,223,224,223,1102,88,78,225,102,78,101,224,101,-6240,224,224,4,224,1002,223,8,223,101,5,224,224,1,224,223,223,4,223,99,0,0,0,677,0,0,0,0,0,0,0,0,0,0,0,1105,0,99999,1105,227,247,1105,1,99999,1005,227,99999,1005,0,256,1105,1,99999,1106,227,99999,1106,0,265,1105,1,99999,1006,0,99999,1006,227,274,1105,1,99999,1105,1,280,1105,1,99999,1,225,225,225,1101,294,0,0,105,1,0,1105,1,99999,1106,0,300,1105,1,99999,1,225,225,225,1101,314,0,0,106,0,0,1105,1,99999,1107,226,677,224,102,2,223,223,1006,224,329,101,1,223,223,1108,226,677,224,1002,223,2,223,1005,224,344,101,1,223,223,8,226,677,224,102,2,223,223,1006,224,359,1001,223,1,223,1007,226,677,224,1002,223,2,223,1005,224,374,101,1,223,223,1008,677,677,224,1002,223,2,223,1005,224,389,1001,223,1,223,1108,677,226,224,1002,223,2,223,1006,224,404,1001,223,1,223,1007,226,226,224,1002,223,2,223,1005,224,419,1001,223,1,223,1107,677,226,224,1002,223,2,223,1006,224,434,101,1,223,223,108,677,677,224,1002,223,2,223,1005,224,449,1001,223,1,223,1107,677,677,224,102,2,223,223,1005,224,464,1001,223,1,223,108,226,226,224,1002,223,2,223,1006,224,479,1001,223,1,223,1008,226,226,224,102,2,223,223,1005,224,494,101,1,223,223,108,677,226,224,102,2,223,223,1005,224,509,1001,223,1,223,8,677,226,224,1002,223,2,223,1006,224,524,101,1,223,223,7,226,677,224,1002,223,2,223,1006,224,539,101,1,223,223,7,677,226,224,102,2,223,223,1006,224,554,1001,223,1,223,7,226,226,224,1002,223,2,223,1006,224,569,101,1,223,223,107,677,677,224,102,2,223,223,1006,224,584,101,1,223,223,1108,677,677,224,102,2,223,223,1006,224,599,1001,223,1,223,1008,677,226,224,1002,223,2,223,1005,224,614,1001,223,1,223,8,677,677,224,1002,223,2,223,1006,224,629,1001,223,1,223,107,226,677,224,1002,223,2,223,1006,224,644,101,1,223,223,1007,677,677,224,102,2,223,223,1006,224,659,101,1,223,223,107,226,226,224,1002,223,2,223,1006,224,674,1001,223,1,223,4,223,99,226
diff --git a/19/input/06 b/19/input/06
new file mode 100644
index 0000000..b433fcd
--- /dev/null
+++ b/19/input/06
@@ -0,0 +1,1294 @@
+MB5)V1S
+VYJ)JRF
+SLW)9YR
+CPL)8KQ
+Q5P)H7W
+TJT)139
+PYD)XMX
+4S5)K2V
+RWW)JTL
+HNC)81N
+64N)V96
+RRM)FXW
+Y8R)1C1
+VL8)M6N
+G7L)RQJ
+5C3)SC4
+JZL)DGX
+C7B)KSS
+2X5)5YY
+W91)5R1
+KP8)QYY
+NCL)5WX
+HN9)4LZ
+4Z6)15F
+LHJ)B7D
+S3S)J8Z
+ZCW)KC1
+3TJ)2RP
+J9F)SXH
+SHX)WH9
+M4M)6NK
+23F)Q7S
+B7Y)ZM5
+M7H)D8G
+N8F)K1F
+5PV)SXD
+HGX)5BM
+LH8)C2L
+XFM)ZHM
+H1L)XYG
+4VH)W46
+2Q8)6V5
+G41)LNT
+GNY)Y8R
+95L)MJC
+FPR)X8M
+MS4)YL4
+B8B)YL6
+6N4)SWY
+B65)X7B
+N15)C89
+LX4)TBZ
+3W2)JRH
+MVN)34C
+XMX)DW8
+221)5CM
+QPP)14R
+SRB)7SK
+3P9)MKR
+DGX)6FT
+GQG)T3J
+JS4)XTJ
+9MQ)FKR
+B29)PWB
+XHC)NX1
+55D)YCV
+CV2)3FH
+QN1)MFX
+P2B)B51
+Z4D)Z2S
+3MZ)GYC
+LCQ)FF9
+VPZ)CV2
+Z4D)K9P
+9F2)CV6
+NJS)HRR
+W7Z)6CL
+7NL)M9M
+LJG)426
+6LP)24X
+YQ7)CXX
+4RB)BKC
+KNW)2X5
+KCY)4D2
+2GC)GV9
+YWN)DWL
+JML)131
+JHR)3G4
+KBM)BMX
+GWB)S1P
+LMW)2LL
+DS7)8X3
+8KT)ZCW
+MHT)9XZ
+MV8)B7Y
+VPB)KT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+K98)FPX
+Z5F)6N4
+9DN)78H
+W3T)JS4
+7Z1)5G8
+49V)9J8
+Z6D)GGJ
+V9T)MYZ
+SC4)YLW
+NQN)WN2
+MFN)TBW
+KRX)LGD
+9FW)V8T
+8X3)V4T
+4S7)XMW
+Y2J)5PV
+QYY)T26
+GMH)JV2
+H98)Q2Y
+MZ9)2ZP
+ZRM)KBH
+251)Z5K
+KHG)HYN
+5WX)P8Y
+71T)N75
+H37)6PH
+HCL)D3P
+M25)16R
+K39)QL9
+WWZ)8Y2
+PK9)N6H
+LMZ)ZVP
+Z5Q)H98
+JKD)WK2
+JHZ)43X
+PQN)NNW
+J2Y)3H6
+YWW)GWW
+NL6)KKD
+XQ8)TPS
+RWV)8D1
+TDB)RX1
+2PZ)6MR
+NSM)QTK
+GP1)TPV
+ZB6)1V9
+QHG)4F7
+18R)D79
+ZJJ)Z1S
+45D)7QP
+7QV)X42
+M9M)MSS
+TQK)V4V
+Q7S)23K
+TG9)C5D
+VMJ)89G
+7QR)SPB
+RGV)QHG
+3P3)RFS
+GT8)6LP
+P1K)8WD
diff --git a/19/input/07 b/19/input/07
new file mode 100644
index 0000000..016f35f
--- /dev/null
+++ b/19/input/07
@@ -0,0 +1 @@
+3,8,1001,8,10,8,105,1,0,0,21,30,55,80,101,118,199,280,361,442,99999,3,9,101,4,9,9,4,9,99,3,9,101,4,9,9,1002,9,4,9,101,4,9,9,1002,9,5,9,1001,9,2,9,4,9,99,3,9,101,5,9,9,1002,9,2,9,101,3,9,9,102,4,9,9,1001,9,2,9,4,9,99,3,9,102,2,9,9,101,5,9,9,102,3,9,9,101,3,9,9,4,9,99,3,9,1001,9,2,9,102,4,9,9,1001,9,3,9,4,9,99,3,9,1001,9,1,9,4,9,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,1001,9,2,9,4,9,3,9,1002,9,2,9,4,9,3,9,101,2,9,9,4,9,3,9,101,2,9,9,4,9,3,9,101,2,9,9,4,9,99,3,9,101,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,2,9,4,9,3,9,1001,9,2,9,4,9,3,9,1002,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,102,2,9,9,4,9,99,3,9,1001,9,1,9,4,9,3,9,101,1,9,9,4,9,3,9,1001,9,2,9,4,9,3,9,1001,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,102,2,9,9,4,9,99,3,9,1001,9,2,9,4,9,3,9,1001,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,101,1,9,9,4,9,3,9,101,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,101,1,9,9,4,9,3,9,101,2,9,9,4,9,99,3,9,1001,9,2,9,4,9,3,9,101,2,9,9,4,9,3,9,101,1,9,9,4,9,3,9,1001,9,2,9,4,9,3,9,1002,9,2,9,4,9,3,9,101,1,9,9,4,9,3,9,1001,9,2,9,4,9,3,9,1001,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,102,2,9,9,4,9,99
diff --git a/19/input/08 b/19/input/08
new file mode 100644
index 0000000..29390a5
--- /dev/null
+++ b/19/input/08
@@ -0,0 +1 @@
+222222022022200222221110022202222222222222222222222122222222222122202022222222222221212220122221120222222122222222220222220222222222220222222222222222222222222222202222222100222202222222222222222222222122222222222022222222222222222222222221022221022222222222222222220222221222222222222222222222222222222222222122201222222021222212222222222222222222222222222222222022202222222222222221212220122220022222222022222222221212220222222222221222202222222222222222222121221222222210022202222222222222222222222122222222222022222122222222222221202220022222221222222022222222222222221222212222222222212222222222222222122021220222220020022202222222222222222222222022222222222122222222222222222222222221122222020222222122222222220222220222102222222222212222222222222222222022202222222220122200222222222222222222222022222222222222222022222222222222212220122220121222222222222222222202220222002222220222202222222222222222022021212222222022222211222222222222222222222222222222222022222222222222222220212220122222121222222122222222222212222222202222220222202222222222222222222122210222220211022211222222222222222222222122222222222222202022222222222221212220222222021222222122222222220222220222112222221222212222222222222222122122220222220120222210222222222222222222222022222222122022202222222222222221222222022222120222222222222222221212221222022222221222202222222222222222222222212222222102222200222222222222222222222122222222022122222122222222222021202220122220221222222022222222222202220222212222221222222222222222222222122222202222220202222211222222222222222222222122222222222122212022222222222022212220222222122222222122222222220212220222022222220222202222222220222222222220212222221220022222222222222222222222222122222222022022222122222222222122212221222220020222222222222222222202220222202222220222212222222220222222122222202222201000022200222222222222222222222222222222022122212122222222222120212221022220021222222122222222222202222222102222222222202222222221222222022222211222202111122210222222222222222222222022222222022022202222222222222221222222122221020222222222222222222202222222122222222222202222222220222222122222202222222221222211222222222222222222222222222222122222222022222222222022222222222220122222222122222222220222221222122222220222202222222222222222122222221222222011222222222222222222222222222122222222022222202022222222222120222220222222220222222122222222212202221222002222220122212222222222222222022120201222200021222222222222222222222222222122222222122222202222222222222201202222222220021222222022222222212222221222022222221022202221222220222222122120210222220210222210222222222222222222222222222222222022202222222222222202202222122222221222222222222222210212220222022222220222202222222222222222022022210222211120022211222222222222222222222022222222122222202022222222222022202221022221122222222122222222210212221222002222221222202220222221222222122121212222202011222221222222222222222222222222222222122222222222222222220221202222222220020222222222222222212212221222202222221022212220222221222222222021200222201101122211222222222222222222222222222222022022212022222222220202212220122222120222222222222222200202221222102222222022222222222221222222022220222222211001222211222222222222222222222222222222122022202222222222221112202221122220222222222020222222212202221222222222201022222220222221222222222021220222211021122201222122222222222222222022222222022222212122222222220121202222122222222222222121222222220202220222222222220022202221222221222222022120200222200122122211222222222222222222222222222222022222222122222222221110212220122200221222222222222222221222222222212222210222212221222221222222222120212222200000222210222122222222222222222122222222122022202222222222222101212222022222221222222022222222222212222222102222222022222222222222222222222022221222202202222200222122222222222222222222222222122122212122222222220022202220122221222222222120222222200212221222122222202122202222222220222222222022210222222002222210022022222222222222222222222222022222202122222222221122212221022201020222222121222222202212222222012222210022222222222222222222122121200222200202122221022022222222222222222222222222222022212022222222220111222220022222020222222021222222210202220222002222211022212210222221222222022221221222212020022212122022222222222222222022222222022222202222222222222000202222022220220222222021222222200222222222112222220222202220222222222222222122200222200011022211122222222222222222222022222222122222202022222222222002202220022221222222222222222222220202221222222222200122222211222220222222022020112222200210222201122122222222222222222022222220222122212022222222221001202221022201120222222020222222211222221222212222200022202220222221222222222120110222210212022221122122222222222222222222222220122022222222222222220221212221222222020022222120222222210222220222112222221022222201222221222222222020010222202102122200122022222222222222222222222221222222212022222222221221222222122202120122222221222222212222222222012222220222212221222221222222122122001222211001222222222022222222222222222222222221222222202122222222220112212220022222222022222120222212221212220222002222222222212212222222222222122120122222202211022220222222222022222222222022222221222222212222222222221121212221022220220122222022222222212212220222202222200222102212222220222222122122000222211001122221022022222222222222222222222222222222212122222222221210212220122210122120222120222212221222222222022222211122222222222221222222122121102222202111022221122222222222222222222122222222022122222022222222220221212220022200220220022022222202200222222222212222200222122212222220222222122220121222221201222201222222222022222222222122222222222122222022222222022100222221022212122122022221222222222222222222202222212022222201222222222222222020112222220000022201222122222222222222222122222221022022212022222222220220202221122220021021222020222222200212220222202222201022122211222200222222022222020222212201222200222222222022222222221122222221222222212022222222222212212221222211121021122221222202221212221222212222211122222222222202222222122221101222202021022222022222222122222220220122222222222022202022222222222122212222222211022020222120222212200212221222112222201022112202222221222222122122022222201001122211222222222022222220220022222220122222222222222222022000202221122212121220222022222212201202222222112222202222102210222222222222222021201222201121222201222022222222222220221022222220022222202022222222222221222221222220221021022021222222001212222222002222222022122112212220222222122221101222212022122201022122222022222221222122222222022122222222222222222122212221222202122021022122222222021212221222012222201102112221202200222222022221121222210200222221222122222022222222221222222221022222212022222222220100222221122222120021002221222222121222221222102222202122102222212221222222022122212222201211122210220022222022222220220222222222022222002122222222122010222220102222222222202021222202210202220222022222222112102100202221222222022222121222210022122201122202222222222220221222222221022022212122222222120212212221102220120020102221222212212222221222022222221012202000222210222222022122120222211011222212122022222222222221220122222222122222112122222222122101212220102212020122012221222202021212220222002222201002200222202212222222222120121222221100222202022212222222222221220022222220022122112122212222221201212222102211122221112221222212020202220222022222200212021211212200222222222022210222200211222220022212222012222222220022222220122222222222222222121102212201012212120222002022222202000222222222102222211202111220222222222222222220100222220121022210001202222012222221222222222221122222102022202222020202222201002221121120202222222222112212220222112222220222101000212212222222022222002222202120122211020212222212222220220222222220222122122122212222022000202221022221222021212022222202020202221222102222222002222111012212222222022221222222222101122211201102222222222222220022220221122222112222212202122011222200112201220020112222222212010222221222102222220022211101122200222222122020200222211112222220010122222002222220222022220222222022112022202222120211222200022202221220222220202212011202222222002222212102111101002211222222122121112222200001022220121002222102222221222222222221022222022022212212022110212220012212122122102122202202201222220222111222200022012010112210222222222120221222222110222210022222222112222220221022222220222222222222212212021210222202222210020022212022202202221222221222001222200102010021102221222222222020220222222120022220112022222122222220220222222220222222020022212212022121222221222221120222022021202212110212221222102222210212102121002210222222122122102222211011222202012012022222222220221122220221122122112022202202021012222222212201121221212121212222020202220222100222212002022220012211222222022121201222211002022211120102122222222220221022221220022222012122202202021100222201112211220121022120222202210222221022210222212122022021222200222222222221102222212100122212002222022122222222222122220222022022001122202212222212202202022221222022002220222200221222220222211222200202122221022201222222222122000222210122220222121112022002222221221022220221022122021222202212222202212201122211221222212021202221200212220022212222212112002000202211222222222022022222221001020221012022222122222222222122222220122222122122222202021200201202102212021120102022212212012002222022000222210202200111112201222222022220120222202110221220121022122012222220220122221220222022112122222212222102211200122220221122112220202211101022221022011222210122000001002220222222222021210222210112021201101012122102222201220222221220022222112122202212220221221211102211222020012122202222012002222122020222221102110112102221222222122122211222202202120212112222122022222210222022222222022202022022222212122200211202112220122121002021212221220022221222102222220222120122202200222222022222211222221111022212221012022222222202220222221221122002121222212212020200221201212200220222222022212220220112220022222222202022111121112221222222122021020222210111220201102202022122222211200222220221122022120222202210222010202212022210022122100220222201000222222022200222202012002010202212222222222221121222200002020220221212022002222200200122222222022212211122202221021212212222112210120020221222202212010102222222002222210202011100222012222222222121020212220012121200120222122002222212221122221220122122022222202221022201212201002220022120020120222220110112222022221222212202201210012002222222022121111202221221120222011212022122222220220222021221222002020222212202122201222211022201222220002122212202100012220122002222201222211200112012222222222122010222200012022221110122222222222200220222120222022002121022212212220112200211022210022021122122212212201112221022020222211112002210002222222222222022202222212202121200122002222212220202211222222221022201002122222202220221201201022210022020000221222221001002222022120222200122002101022202222222122221222222220201021221021212222222221211222222020220022010200222222200020102202220012202022120222021202211211212221222202222202220202210102112222222222222002202222001220210110112122002221211210022221222122022222122202220020221210221222221021120120220212200000122221222222222220202010102022100222222222021200202211110122220102012022222220200211222220222122120210022202220122120210210002221020020101022202220011012221022112222221200110001022110222222222222201222202001020202110002022202222201220022020220222000111022212220120200210201012221220122210222202212020012220122022222211021020221122220222222122121211202222220221220101012222002221220221122020220022102212012202200020220220201212212122221211221202202120122220122110222211001001002222212222222122022121222201021121220001102022112220210211222220220022111212112222202220221212222202211122121111122222222100102221222102222212011011122022122222202122222120202221201122210112012122102220211221022221220022210112212202222120010210210202210121220112122202200222102220122112222202002221200202020222212022220100211210122020222010112222112222200212022121222222022202002220200221021201212202201120220001222202002010102222122002222202011102202222110221222122211210201212001022202021222122222220222200122221221122002111112222212222002202220122222220022222120102210022202221022020222212000112202122212222222222120020202212002121222001022122002221210222122022222122022100212211210202101202222012212121122002022002011022002220122100222211222010000222201222200222101001201222200122201021202122102220222211222221222222020212002220202102020201222222212222222120220022011122122220022221221200020100201202010122202022211110222200202022201121022022012221220202222121220222122021202222210200212212211112212020222100220202110221202220122100202222110100021202011020201022101002201200010220201112122122112221220221222020020222012222012202211021021201200212210021021000120122221022122221122010221220022101011022210022202222201121212222102120000012022022012222221200022221022122012221202200202212210200210102211120221210122112112111212222221011220200202110002102012222212222000100221220002022210120222122112221202201122220220022012212102222201012122200200202212120221212122002001022122221121120200222101111011012122120222222121211221221002222210201202022012220102221222022121022200002022221210212122221201222211121221120221012012101212222020221221200120212020222222121200222121111210210102122122202002022212221001222022222020122001101112201200100000221202202211011022221222022012121202220022001222200000001221222111120200122200002200200221121022100012102122222211222222120120222221102112222200111212220212002202201021122222222120021022222120021220210000200102212221122221222000001211202201221111001222022112221022120022101220022121202102212212110111211210022211002022001220002120000102222122010221220120110202102120220211122001220202221000120101102102122012221100222122002022222021012002200221210010200222002201001120022122012121010212222021002200212121110022022201122202122222022220212120020110010022122202220222102022111120122221002212211200202110210200202212012222110022002002102020220122120222220220101011222012221210122111222210212201221210100022022102222110102022102122122000210002200222021112201221012220000122212221202112101112221020122212212001222022122200222200122102101200200211022201222222212000221200112212220121222021222112211222001222220221122221011121100122002202202012220122200220202022201022122221122201022012200221202122221212100002012102020111110102111121122111100102221212001200212120112210102122201020122102121120222020111202220120001111022201021220222020212202220002021200200202022102221212102002212222122002122022221211002020210120211202211221211220002212110221220120212212222000201022122011222211122101111211220122021110011012112002221211211002220220122100210102200202212021000000022201100121200221112220120212222120011211202011102020112000221212222102020210221120120020110202222112222122200012210022022021021022220211222110201122210202102122201122112222011202221022112210222122111112012201012122011200022010020210112220212011121222011201010220112012100012111020000121022202001102120101022110120102011122021112100101210010110102002102000210
diff --git a/19/input/09 b/19/input/09
new file mode 100644
index 0000000..27b47ee
--- /dev/null
+++ b/19/input/09
@@ -0,0 +1 @@
+1102,34463338,34463338,63,1007,63,34463338,63,1005,63,53,1101,0,3,1000,109,988,209,12,9,1000,209,6,209,3,203,0,1008,1000,1,63,1005,63,65,1008,1000,2,63,1005,63,904,1008,1000,0,63,1005,63,58,4,25,104,0,99,4,0,104,0,99,4,17,104,0,99,0,0,1101,0,252,1023,1101,0,0,1020,1102,1,39,1013,1102,1,234,1029,1102,26,1,1016,1101,37,0,1005,1101,0,27,1011,1101,21,0,1000,1101,0,29,1019,1101,35,0,1003,1102,22,1,1007,1102,1,32,1001,1101,1,0,1021,1102,1,216,1027,1102,30,1,1012,1102,1,24,1009,1101,36,0,1002,1101,0,31,1010,1101,0,243,1028,1102,787,1,1024,1102,255,1,1022,1102,33,1,1017,1102,1,23,1004,1102,778,1,1025,1102,1,28,1008,1101,0,223,1026,1102,1,25,1015,1101,0,20,1006,1102,34,1,1014,1101,38,0,1018,109,-4,1202,5,1,63,1008,63,32,63,1005,63,203,4,187,1106,0,207,1001,64,1,64,1002,64,2,64,109,37,2106,0,-6,1001,64,1,64,1106,0,225,4,213,1002,64,2,64,109,3,2106,0,-8,4,231,1001,64,1,64,1105,1,243,1002,64,2,64,109,-12,2105,1,-1,1105,1,261,4,249,1001,64,1,64,1002,64,2,64,109,-13,2102,1,-3,63,1008,63,31,63,1005,63,285,1001,64,1,64,1106,0,287,4,267,1002,64,2,64,109,6,21102,40,1,0,1008,1017,40,63,1005,63,313,4,293,1001,64,1,64,1105,1,313,1002,64,2,64,109,-10,2107,31,-6,63,1005,63,331,4,319,1105,1,335,1001,64,1,64,1002,64,2,64,109,-6,2102,1,7,63,1008,63,28,63,1005,63,357,4,341,1105,1,361,1001,64,1,64,1002,64,2,64,109,2,21107,41,40,8,1005,1011,377,1106,0,383,4,367,1001,64,1,64,1002,64,2,64,109,-1,1201,2,0,63,1008,63,26,63,1005,63,403,1106,0,409,4,389,1001,64,1,64,1002,64,2,64,109,22,1205,-4,425,1001,64,1,64,1105,1,427,4,415,1002,64,2,64,109,-9,21101,42,0,3,1008,1018,39,63,1005,63,451,1001,64,1,64,1105,1,453,4,433,1002,64,2,64,109,3,21107,43,44,0,1005,1018,475,4,459,1001,64,1,64,1105,1,475,1002,64,2,64,109,-7,21101,44,0,0,1008,1011,44,63,1005,63,497,4,481,1105,1,501,1001,64,1,64,1002,64,2,64,109,17,1206,-7,513,1105,1,519,4,507,1001,64,1,64,1002,64,2,64,109,-24,1207,5,25,63,1005,63,537,4,525,1105,1,541,1001,64,1,64,1002,64,2,64,109,7,21108,45,43,2,1005,1013,557,1106,0,563,4,547,1001,64,1,64,1002,64,2,64,109,-5,1207,-3,34,63,1005,63,583,1001,64,1,64,1106,0,585,4,569,1002,64,2,64,109,5,21108,46,46,5,1005,1016,607,4,591,1001,64,1,64,1105,1,607,1002,64,2,64,109,-12,2108,20,8,63,1005,63,627,1001,64,1,64,1105,1,629,4,613,1002,64,2,64,109,24,1206,-3,647,4,635,1001,64,1,64,1105,1,647,1002,64,2,64,109,-30,2108,32,8,63,1005,63,665,4,653,1106,0,669,1001,64,1,64,1002,64,2,64,109,22,1208,-9,20,63,1005,63,691,4,675,1001,64,1,64,1106,0,691,1002,64,2,64,109,-4,21102,47,1,3,1008,1014,49,63,1005,63,715,1001,64,1,64,1105,1,717,4,697,1002,64,2,64,109,-10,2101,0,1,63,1008,63,36,63,1005,63,743,4,723,1001,64,1,64,1105,1,743,1002,64,2,64,109,16,1201,-9,0,63,1008,63,28,63,1005,63,769,4,749,1001,64,1,64,1105,1,769,1002,64,2,64,109,2,2105,1,5,4,775,1001,64,1,64,1106,0,787,1002,64,2,64,109,-5,1202,-6,1,63,1008,63,26,63,1005,63,807,1106,0,813,4,793,1001,64,1,64,1002,64,2,64,109,-16,2107,37,4,63,1005,63,833,1001,64,1,64,1105,1,835,4,819,1002,64,2,64,109,2,2101,0,1,63,1008,63,34,63,1005,63,855,1105,1,861,4,841,1001,64,1,64,1002,64,2,64,109,19,1205,2,875,4,867,1105,1,879,1001,64,1,64,1002,64,2,64,109,-2,1208,-8,23,63,1005,63,899,1001,64,1,64,1106,0,901,4,885,4,64,99,21101,0,27,1,21102,915,1,0,1106,0,922,21201,1,61455,1,204,1,99,109,3,1207,-2,3,63,1005,63,964,21201,-2,-1,1,21102,942,1,0,1105,1,922,22102,1,1,-1,21201,-2,-3,1,21102,1,957,0,1105,1,922,22201,1,-1,-2,1106,0,968,22101,0,-2,-2,109,-3,2105,1,0
diff --git a/19/input/10 b/19/input/10
new file mode 100644
index 0000000..8944c53
--- /dev/null
+++ b/19/input/10
@@ -0,0 +1,24 @@
+##.##..#.####...#.#.####
+##.###..##.#######..##..
+..######.###.#.##.######
+.#######.####.##.#.###.#
+..#...##.#.....#####..##
+#..###.#...#..###.#..#..
+###..#.##.####.#..##..##
+.##.##....###.#..#....#.
+########..#####..#######
+##..#..##.#..##.#.#.#..#
+##.#.##.######.#####....
+###.##...#.##...#.######
+###...##.####..##..#####
+##.#...#.#.....######.##
+.#...####..####.##...##.
+#.#########..###..#.####
+#.##..###.#.######.#####
+##..##.##...####.#...##.
+###...###.##.####.#.##..
+####.#.....###..#.####.#
+##.####..##.#.##..##.#.#
+#####..#...####..##..#.#
+.##.##.##...###.##...###
+..###.########.#.###..#.
diff --git a/19/input/11 b/19/input/11
new file mode 100644
index 0000000..6ecf042
--- /dev/null
+++ b/19/input/11
@@ -0,0 +1,2 @@
+3,8,1005,8,329,1106,0,11,0,0,0,104,1,104,0,3,8,102,-1,8,10,1001,10,1,10,4,10,1008,8,0,10,4,10,1002,8,1,29,2,1102,1,10,1,1009,16,10,2,4,4,10,1,9,5,10,3,8,1002,8,-1,10,101,1,10,10,4,10,108,0,8,10,4,10,101,0,8,66,2,106,7,10,1006,0,49,3,8,1002,8,-1,10,101,1,10,10,4,10,108,1,8,10,4,10,1002,8,1,95,1006,0,93,3,8,102,-1,8,10,1001,10,1,10,4,10,108,1,8,10,4,10,102,1,8,120,1006,0,61,2,1108,19,10,2,1003,2,10,1006,0,99,3,8,1002,8,-1,10,1001,10,1,10,4,10,1008,8,0,10,4,10,101,0,8,157,3,8,102,-1,8,10,1001,10,1,10,4,10,1008,8,1,10,4,10,1001,8,0,179,2,1108,11,10,1,1102,19,10,3,8,102,-1,8,10,1001,10,1,10,4,10,1008,8,1,10,4,10,101,0,8,209,2,108,20,10,3,8,1002,8,-1,10,101,1,10,10,4,10,108,1,8,10,4,10,101,0,8,234,3,8,102,-1,8,10,101,1,10,10,4,10,108,0,8,10,4,10,1002,8,1,256,2,1102,1,10,1006,0,69,2,108,6,10,2,4,13,10,3,8,102,-1,8,10,101,1,10,10,4,10,1008,8,0,10,4,10,1002,8,1,294,1,1107,9,10,1006,0,87,2,1006,8,10,2,1001,16,10,101,1,9,9,1007,9,997,10,1005,10,15,99,109,651,104,0,104,1,21101,387395195796,0,1,21101,346,0,0,1105,1,450,21101,0,48210129704,1,21101,0,357,0,1105,1,450,3,10,104,0,104,1,3,10,104,0,104,0,3,10,104,0,104,1,3,10,104,0,104,1,3,10,104,0,104,0,3,10,104,0,104,1,21101,0,46413147328,1,21102,404,1,0,1106,0,450,21102,179355823323,1,1,21101,415,0,0,1105,1,450,3,10,104,0,104,0,3,10,104,0,104,0,21102,1,838345843476,1,21101,0,438,0,1105,1,450,21101,709475709716,0,1,21101,449,0,0,1105,1,450,99,109,2,22102,1,-1,1,21102,40,1,2,21101,0,481,3,21101,0,471,0,1105,1,514,109,-2,2105,1,0,0,1,0,0,1,109,2,3,10,204,-1,1001,476,477,492,4,0,1001,476,1,476,108,4,476,10,1006,10,508,1101,0,0,476,109,-2,2106,0,0,0,109,4,2101,0,-1,513,1207,-3,0,10,1006,10,531,21101,0,0,-3,21201,-3,0,1,21201,-2,0,2,21101,1,0,3,21101,550,0,0,1105,1,555,109,-4,2106,0,0,109,5,1207,-3,1,10,1006,10,578,2207,-4,-2,10,1006,10,578,21201,-4,0,-4,1105,1,646,22101,0,-4,1,21201,-3,-1,2,21202,-2,2,3,21101,597,0,0,1105,1,555,22102,1,1,-4,21101,0,1,-1,2207,-4,-2,10,1006,10,616,21101,0,0,-1,22202,-2,-1,-2,2107,0,-3,10,1006,10,638,22102,1,-1,1,21101,638,0,0,106,0,513,21202,-2,-1,-2,22201,-4,-2,-4,109,-5,2106,0,0
+
diff --git a/19/input/12 b/19/input/12
new file mode 100644
index 0000000..550a98c
--- /dev/null
+++ b/19/input/12
@@ -0,0 +1,4 @@
+<x=-1, y=-4, z=0>
+<x=4, y=7, z=-1>
+<x=-14, y=-10, z=9>
+<x=1, y=2, z=17>
diff --git a/19/input/13 b/19/input/13
new file mode 100644
index 0000000..def383f
--- /dev/null
+++ b/19/input/13
@@ -0,0 +1 @@
+1,380,379,385,1008,2151,549350,381,1005,381,12,99,109,2152,1102,1,0,383,1101,0,0,382,21002,382,1,1,21001,383,0,2,21101,37,0,0,1106,0,578,4,382,4,383,204,1,1001,382,1,382,1007,382,36,381,1005,381,22,1001,383,1,383,1007,383,21,381,1005,381,18,1006,385,69,99,104,-1,104,0,4,386,3,384,1007,384,0,381,1005,381,94,107,0,384,381,1005,381,108,1105,1,161,107,1,392,381,1006,381,161,1101,-1,0,384,1106,0,119,1007,392,34,381,1006,381,161,1102,1,1,384,20101,0,392,1,21102,19,1,2,21102,1,0,3,21101,0,138,0,1106,0,549,1,392,384,392,21002,392,1,1,21101,19,0,2,21102,3,1,3,21102,161,1,0,1106,0,549,1102,0,1,384,20001,388,390,1,21002,389,1,2,21101,0,180,0,1105,1,578,1206,1,213,1208,1,2,381,1006,381,205,20001,388,390,1,20102,1,389,2,21101,205,0,0,1105,1,393,1002,390,-1,390,1102,1,1,384,21002,388,1,1,20001,389,391,2,21102,1,228,0,1106,0,578,1206,1,261,1208,1,2,381,1006,381,253,21001,388,0,1,20001,389,391,2,21102,253,1,0,1106,0,393,1002,391,-1,391,1102,1,1,384,1005,384,161,20001,388,390,1,20001,389,391,2,21102,1,279,0,1105,1,578,1206,1,316,1208,1,2,381,1006,381,304,20001,388,390,1,20001,389,391,2,21101,0,304,0,1106,0,393,1002,390,-1,390,1002,391,-1,391,1101,1,0,384,1005,384,161,21001,388,0,1,21001,389,0,2,21102,1,0,3,21102,1,338,0,1106,0,549,1,388,390,388,1,389,391,389,20102,1,388,1,20101,0,389,2,21102,4,1,3,21101,365,0,0,1106,0,549,1007,389,20,381,1005,381,75,104,-1,104,0,104,0,99,0,1,0,0,0,0,0,0,236,16,16,1,1,18,109,3,22101,0,-2,1,22102,1,-1,2,21101,0,0,3,21102,1,414,0,1106,0,549,21202,-2,1,1,22102,1,-1,2,21102,429,1,0,1105,1,601,1202,1,1,435,1,386,0,386,104,-1,104,0,4,386,1001,387,-1,387,1005,387,451,99,109,-3,2105,1,0,109,8,22202,-7,-6,-3,22201,-3,-5,-3,21202,-4,64,-2,2207,-3,-2,381,1005,381,492,21202,-2,-1,-1,22201,-3,-1,-3,2207,-3,-2,381,1006,381,481,21202,-4,8,-2,2207,-3,-2,381,1005,381,518,21202,-2,-1,-1,22201,-3,-1,-3,2207,-3,-2,381,1006,381,507,2207,-3,-4,381,1005,381,540,21202,-4,-1,-1,22201,-3,-1,-3,2207,-3,-4,381,1006,381,529,22102,1,-3,-7,109,-8,2106,0,0,109,4,1202,-2,36,566,201,-3,566,566,101,639,566,566,1202,-1,1,0,204,-3,204,-2,204,-1,109,-4,2105,1,0,109,3,1202,-1,36,594,201,-2,594,594,101,639,594,594,20101,0,0,-2,109,-3,2105,1,0,109,3,22102,21,-2,1,22201,1,-1,1,21101,0,383,2,21102,1,195,3,21102,1,756,4,21101,0,630,0,1106,0,456,21201,1,1395,-2,109,-3,2105,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,2,2,0,2,0,0,0,0,2,2,0,2,2,2,0,2,2,2,2,0,0,2,0,2,0,0,0,2,2,2,2,2,0,1,1,0,2,0,0,2,2,2,0,0,2,0,0,2,0,2,0,0,2,2,0,0,2,0,0,2,2,2,0,2,0,2,2,2,0,1,1,0,2,2,0,2,2,0,2,0,0,0,2,0,2,0,0,2,0,2,0,0,2,2,2,2,0,2,2,2,0,0,0,2,0,1,1,0,0,0,0,2,0,0,2,2,0,0,2,2,0,2,0,2,2,0,2,2,2,0,0,0,2,2,2,2,0,2,2,2,0,1,1,0,2,0,0,0,0,0,0,0,2,2,2,2,0,2,2,2,2,2,0,2,2,0,2,0,0,0,2,2,2,0,2,0,0,1,1,0,2,0,2,2,2,2,2,0,0,2,0,0,0,2,0,2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,9,18,83,31,88,84,91,60,30,80,76,17,43,67,53,1,87,74,50,67,38,2,13,58,18,4,4,46,61,32,48,76,53,56,73,93,20,24,80,69,13,67,19,15,13,29,16,92,21,20,22,82,83,21,51,54,13,97,7,78,96,6,9,63,21,66,62,6,57,2,83,63,26,49,13,8,72,52,67,51,17,52,34,89,37,76,10,62,28,41,79,62,28,48,29,85,52,35,45,25,66,25,84,34,12,34,64,34,54,13,53,82,51,89,14,15,7,32,58,64,26,21,70,38,5,73,91,9,95,62,69,5,41,66,89,17,65,88,18,15,82,53,86,59,12,70,26,75,31,54,44,86,36,89,97,94,4,4,46,84,49,7,38,40,93,28,20,18,6,37,35,68,51,71,12,26,47,30,98,76,14,82,36,5,7,90,20,71,20,69,83,70,37,53,37,68,74,50,49,85,83,34,35,43,54,43,41,23,29,75,85,70,52,83,74,72,49,75,64,61,28,69,15,74,20,38,96,96,22,64,23,91,50,11,80,55,66,47,88,5,18,18,55,8,92,20,42,98,37,82,5,1,11,32,41,86,93,49,56,37,64,45,79,24,26,82,49,47,43,56,51,17,11,18,36,86,49,38,58,33,97,65,56,86,57,23,74,70,58,50,29,14,20,5,78,54,20,90,39,95,80,3,29,50,47,74,25,98,98,66,1,13,50,38,48,97,89,20,78,74,5,23,45,44,65,31,5,44,71,91,86,81,86,87,28,1,71,38,19,34,16,92,92,2,71,93,12,97,87,33,86,26,15,81,88,85,98,10,27,42,26,20,78,4,42,62,57,38,84,27,21,54,55,34,63,41,7,18,93,18,27,94,83,85,92,97,43,21,12,91,17,96,56,60,15,93,3,13,39,85,49,8,39,54,54,66,44,7,23,98,2,1,3,9,1,85,88,27,82,15,5,67,43,93,23,35,57,57,24,11,65,12,61,44,40,76,60,60,45,8,24,34,91,22,38,34,33,69,8,75,7,3,19,35,39,73,64,79,50,89,75,29,96,59,26,64,30,90,15,68,18,71,31,6,84,15,80,3,43,71,65,54,16,79,38,58,81,73,53,21,13,18,49,72,66,58,74,4,78,19,73,51,97,93,53,53,57,34,89,57,49,13,7,16,44,42,49,26,85,31,72,13,19,30,22,12,39,92,98,26,17,46,25,78,77,94,40,74,90,52,2,51,33,16,6,55,66,82,10,6,7,96,98,43,10,42,34,15,9,92,64,15,18,13,8,72,37,20,76,72,90,48,65,55,5,65,66,50,44,76,97,61,72,24,23,33,91,68,31,29,63,51,98,83,6,53,43,14,71,98,50,5,81,49,72,56,58,77,14,74,51,66,77,31,2,3,45,37,25,53,78,3,74,76,26,72,74,86,96,98,90,71,61,95,85,68,68,89,85,47,82,59,28,60,6,44,33,97,67,51,13,90,77,63,49,27,22,6,49,68,33,15,39,83,51,66,85,57,8,75,13,37,39,78,52,31,83,8,26,35,65,25,11,69,71,3,91,6,66,88,82,10,59,28,30,66,60,26,19,87,62,14,97,9,94,42,27,5,90,73,81,67,13,71,67,77,28,48,36,17,29,91,53,87,9,23,20,77,61,76,549350
diff --git a/19/input/14 b/19/input/14
new file mode 100644
index 0000000..c9b5f41
--- /dev/null
+++ b/19/input/14
@@ -0,0 +1,58 @@
+3 DJDNR => 1 ZCMR
+7 VWJH => 5 ZPGT
+5 BHZP => 2 DJDNR
+6 KCNKC, 19 MZWS => 4 PKVJF
+21 GXSHP, 1 TWGP, 3 BGCW => 1 XHRWR
+12 DZGWQ, 2 XRDL, 3 XNVT => 2 FTMC
+7 VWJH, 33 BGCW, 1 TBVC => 9 DSDP
+1 NMTGB, 4 KCNKC, 5 SBSJ, 4 MCZDZ, 7 DLCP, 2 GRBZF, 1 CLKP, 10 VQHJG => 6 DVCR
+7 ZCMR => 9 VNTF
+2 VNTF, 1 GKMN => 1 TZWBH
+6 QMFV, 7 GRBZF => 7 RHDZ
+8 PKVJF => 9 NJQH
+110 ORE => 9 GZTS
+4 DJDNR, 7 SFHV => 8 KQFH
+1 ZTCZ, 5 LZFBP => 7 VWPMZ
+2 GKMN, 6 TZWBH, 1 GXSHP => 1 MJHJH
+2 DLCP, 4 NGJRN => 3 GRBZF
+2 DJDNR, 1 GSRBL => 4 VWJH
+7 RMQX => 3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mode 100644
index 0000000..8058324
--- /dev/null
+++ b/19/input/15
@@ -0,0 +1 @@
+3,1033,1008,1033,1,1032,1005,1032,31,1008,1033,2,1032,1005,1032,58,1008,1033,3,1032,1005,1032,81,1008,1033,4,1032,1005,1032,104,99,101,0,1034,1039,1001,1036,0,1041,1001,1035,-1,1040,1008,1038,0,1043,102,-1,1043,1032,1,1037,1032,1042,1105,1,124,101,0,1034,1039,101,0,1036,1041,1001,1035,1,1040,1008,1038,0,1043,1,1037,1038,1042,1106,0,124,1001,1034,-1,1039,1008,1036,0,1041,1001,1035,0,1040,1001,1038,0,1043,1002,1037,1,1042,1105,1,124,1001,1034,1,1039,1008,1036,0,1041,102,1,1035,1040,101,0,1038,1043,1002,1037,1,1042,1006,1039,217,1006,1040,217,1008,1039,40,1032,1005,1032,217,1008,1040,40,1032,1005,1032,217,1008,1039,1,1032,1006,1032,165,1008,1040,33,1032,1006,1032,165,1101,0,2,1044,1106,0,224,2,1041,1043,1032,1006,1032,179,1101,1,0,1044,1106,0,224,1,1041,043,1032,1006,1032,217,1,1042,1043,1032,1001,1032,-1,1032,1002,1032,39,1032,1,1032,1039,1032,101,-1,1032,1032,101,252,1032,211,1007,0,43,1044,1105,1,224,1101,0,0,1044,1106,0,224,1006,1044,247,1002,1039,1,1034,1002,1040,1,1035,102,1,1041,1036,1001,1043,0,1038,101,0,1042,1037,4,1044,1105,1,0,13,30,60,64,5,28,36,24,67,12,1,67,32,39,14,78,29,17,38,88,79,9,62,25,15,18,88,25,7,81,38,41,10,69,86,32,11,33,1,10,22,84,14,92,48,79,10,3,62,33,61,13,93,78,20,63,68,17,80,34,12,8,23,61,90,51,17,84,37,46,64,25,3,73,19,45,99,41,62,21,77,8,17,89,9,13,84,75,85,14,53,60,6,29,76,63,14,23,63,61,93,72,17,41,28,94,5,3,19,47,57,55,14,34,38,79,85,40,13,22,99,67,72,15,62,15,6,63,3,90,2,87,20,84,15,50,70,27,18,78,21,70,48,52,2,99,92,55,3,46,41,93,99,88,13,39,4,45,71,3,96,1,91,59,31,53,23,25,82,32,50,16,60,38,78,34,59,30,15,51,92,3,22,26,62,60,37,42,74,28,21,76,7,24,70,18,40,11,81,41,9,73,62,12,66,81,9,3,74,62,11,6,56,16,34,20,78,79,1,97,17,39,87,15,12,77,94,28,22,66,45,59,39,2,6,52,6,72,49,17,92,15,86,18,92,79,67,20,22,72,10,72,3,52,26,77,78,41,97,36,59,88,24,57,12,38,90,53,14,38,67,2,36,44,93,99,10,41,49,3,16,7,63,32,11,15,81,12,91,39,62,19,83,6,91,28,19,80,38,23,63,31,71,14,58,8,21,71,21,21,81,38,26,32,29,82,52,28,72,54,97,41,65,96,75,1,48,28,80,66,25,47,49,29,87,51,12,50,70,36,60,81,29,77,76,55,25,40,45,83,91,26,72,99,12,47,11,20,27,52,9,98,17,99,27,37,62,25,3,15,73,66,22,5,85,5,20,98,20,38,62,78,21,16,59,28,98,38,31,2,40,46,87,14,48,33,80,48,36,27,56,21,1,50,83,3,61,92,20,52,16,50,10,86,9,98,39,56,25,50,42,39,91,81,56,25,70,44,24,15,99,4,20,55,12,98,27,65,20,77,97,76,36,42,87,6,11,79,65,16,65,44,13,90,13,48,79,13,95,60,19,55,24,66,4,53,11,23,68,14,97,53,45,14,16,93,18,29,83,5,6,77,19,70,97,34,20,70,52,11,74,14,72,10,36,44,33,45,19,38,36,77,5,37,51,1,55,17,2,48,23,18,2,34,90,97,24,30,51,66,33,70,51,37,31,51,37,65,55,18,8,66,4,65,62,26,93,29,88,3,75,73,24,23,67,1,13,68,7,36,87,62,48,1,31,45,28,62,86,24,98,1,59,49,37,26,62,36,44,66,18,17,97,92,40,36,65,80,84,5,84,6,79,87,36,31,96,15,71,96,2,72,11,81,95,94,41,54,31,58,25,74,24,51,81,38,32,73,22,96,40,62,22,59,74,39,25,86,2,55,20,61,40,37,88,69,1,60,42,18,31,54,13,27,19,93,34,41,99,33,89,20,16,52,84,32,94,31,6,61,25,1,61,1,38,78,87,39,31,39,26,68,42,36,2,94,66,2,67,30,80,2,95,65,40,54,50,33,11,23,97,89,1,31,56,9,35,49,92,55,23,84,48,91,20,7,72,25,55,3,85,3,16,40,90,22,99,44,38,86,98,11,76,26,76,13,82,80,24,93,4,15,64,95,58,15,85,25,57,29,66,3,66,19,98,57,24,44,59,35,76,48,31,92,33,94,68,56,41,45,15,46,5,68,15,65,34,73,49,68,17,78,28,80,24,59,26,74,21,52,1,94,5,61,41,88,37,56,1,49,0,0,21,21,1,10,1,0,0,0,0,0,0
diff --git a/19/input/15-ed b/19/input/15-ed
new file mode 100644
index 0000000..da43b33
--- /dev/null
+++ b/19/input/15-ed
@@ -0,0 +1 @@
+3,1033,1008,1033,1,1032,1005,1032,31,1008,1033,2,1032,1005,1032,58,1008,1033,3,1032,1005,1032,81,1008,1033,4,1032,1005,1032,104,99,1002,1034,1,1039,102,1,1036,1041,1001,1035,-1,1040,1008,1038,0,1043,102,-1,1043,1032,1,1037,1032,1042,1105,1,124,101,0,1034,1039,102,1,1036,1041,1001,1035,1,1040,1008,1038,0,1043,1,1037,1038,1042,1106,0,124,1001,1034,-1,1039,1008,1036,0,1041,1002,1035,1,1040,1001,1038,0,1043,101,0,1037,1042,1106,0,124,1001,1034,1,1039,1008,1036,0,1041,101,0,1035,1040,102,1,1038,1043,1002,1037,1,1042,1006,1039,217,1006,1040,217,1008,1039,40,1032,1005,1032,217,1008,1040,40,1032,1005,1032,217,1008,1039,35,1032,1006,1032,165,1008,1040,9,1032,1006,1032,165,1101,0,2,1044,1105,1,224,2,1041,1043,1032,1006,1032,179,1102,1,1,1044,1105,1,224,1,1041,1043,1032,1006,1032,217,1,1042,1043,1032,1001,1032,-1,1032,1002,1032,39,1032,1,1032,1039,1032,101,-1,1032,1032,101,252,1032,211,1007,0,26,1044,1105,1,224,1101,0,0,1044,1106,0,224,1006,1044,247,102,1,1039,1034,101,0,1040,1035,102,1,1041,1036,1002,1043,1,1038,1001,1042,0,1037,4,1044,1106,0,0,22,11,19,72,14,9,6,73,82,17,41,18,83,18,49,19,12,14,39,17,20,69,20,12,48,8,8,59,36,7,33,1,15,13,10,46,96,15,2,22,80,99,12,68,99,79,22,84,16,45,25,51,4,20,95,4,51,43,13,89,2,91,48,2,46,55,24,84,8,88,10,98,46,57,15,27,7,1,19,20,63,24,50,13,63,13,59,19,13,53,75,8,20,8,44,44,21,5,11,76,9,21,2,11,27,61,6,12,72,22,40,11,9,50,18,2,38,21,78,18,13,99,9,74,5,22,30,35,5,16,34,91,55,4,19,28,42,21,62,12,74,94,16,40,2,95,54,21,2,23,56,34,9,49,47,14,39,9,65,35,53,23,25,68,15,95,25,70,27,3,33,2,31,17,40,60,24,94,34,6,99,9,92,1,92,7,49,32,8,46,47,13,37,15,11,2,15,24,8,73,8,21,64,19,74,24,5,60,9,21,47,12,12,72,18,39,90,16,6,85,13,71,19,14,24,2,65,11,51,9,19,23,34,12,9,88,77,17,6,72,19,79,39,19,21,95,87,24,91,53,7,29,20,25,11,39,38,24,72,6,1,97,15,87,11,77,64,17,57,95,9,85,19,77,8,18,97,8,39,49,4,16,81,12,36,7,7,81,22,52,56,22,47,42,4,46,75,21,19,85,37,22,90,20,10,56,24,85,55,4,91,7,22,86,1,89,13,68,35,14,27,35,9,44,79,12,42,20,16,28,89,11,57,10,60,15,13,95,3,48,24,90,86,51,18,8,71,11,80,91,5,4,93,9,80,94,9,31,7,6,90,6,57,18,19,41,69,57,8,3,42,21,16,5,79,9,13,56,99,98,19,22,85,14,35,12,21,69,16,23,3,5,78,68,2,24,12,35,36,24,93,72,12,16,7,7,19,56,8,69,45,94,18,49,44,61,21,25,19,96,7,13,27,50,76,14,5,60,4,11,90,60,9,31,85,17,11,18,74,37,20,53,53,1,42,93,66,24,10,10,73,36,19,84,14,87,71,18,64,58,3,9,70,14,10,62,81,25,19,52,5,3,78,10,66,84,84,14,66,9,19,81,8,56,11,7,39,84,31,98,22,25,56,4,12,43,78,20,19,43,88,23,10,62,90,22,38,29,5,29,32,20,14,1,3,44,13,92,79,11,59,22,77,38,3,83,18,22,37,24,32,8,19,47,20,23,32,14,72,80,24,37,33,20,8,12,17,31,20,13,51,68,65,19,31,1,1,47,88,15,31,25,94,4,11,95,87,16,77,86,92,3,2,48,39,52,62,22,63,1,70,18,61,78,14,12,50,75,10,30,2,10,96,13,58,87,9,90,3,83,5,13,28,3,67,66,21,46,10,1,70,64,8,10,50,13,22,93,3,58,13,58,2,69,1,44,2,18,22,61,61,25,36,20,7,31,6,2,7,29,2,27,22,93,16,25,8,79,93,22,2,29,27,12,56,48,34,6,40,14,13,8,14,2,8,64,32,19,18,99,22,83,83,79,16,84,58,22,88,19,31,18,35,18,31,85,20,30,16,75,16,46,16,65,16,3,44,6,2,65,97,24,40,20,25,31,88,14,66,20,13,11,76,18,43,67,13,92,47,9,81,78,20,51,12,7,43,17,24,99,14,4,89,13,84,48,13,60,13,51,23,66,7,61,19,91,17,72,64,48,10,74,13,85,8,76,11,72,3,32,22,37,80,44,18,86,50,71,5,36,21,76,23,64,23,61,40,62,24,61,0,0,21,21,1,10,1,0,0,0,0,0,0
diff --git a/19/input/15-eskil b/19/input/15-eskil
new file mode 100644
index 0000000..834f639
--- /dev/null
+++ b/19/input/15-eskil
@@ -0,0 +1 @@
+3,1033,1008,1033,1,1032,1005,1032,31,1008,1033,2,1032,1005,1032,58,1008,1033,3,1032,1005,1032,81,1008,1033,4,1032,1005,1032,104,99,101,0,1034,1039,101,0,1036,1041,1001,1035,-1,1040,1008,1038,0,1043,102,-1,1043,1032,1,1037,1032,1042,1105,1,124,101,0,1034,1039,102,1,1036,1041,1001,1035,1,1040,1008,1038,0,1043,1,1037,1038,1042,1106,0,124,1001,1034,-1,1039,1008,1036,0,1041,102,1,1035,1040,1001,1038,0,1043,1001,1037,0,1042,1106,0,124,1001,1034,1,1039,1008,1036,0,1041,1001,1035,0,1040,1001,1038,0,1043,1002,1037,1,1042,1006,1039,217,1006,1040,217,1008,1039,40,1032,1005,1032,217,1008,1040,40,1032,1005,1032,217,1008,1039,7,1032,1006,1032,165,1008,1040,5,1032,1006,1032,165,1102,1,2,1044,1105,1,224,2,1041,1043,1032,1006,1032,179,1101,0,1,1044,1105,1,224,1,1041,1043,1032,1006,1032,217,1,1042,1043,1032,1001,1032,-1,1032,1002,1032,39,1032,1,1032,1039,1032,101,-1,1032,1032,101,252,1032,211,1007,0,27,1044,1106,0,224,1102,1,0,1044,1106,0,224,1006,1044,247,101,0,1039,1034,101,0,1040,1035,102,1,1041,1036,1001,1043,0,1038,102,1,1042,1037,4,1044,1106,0,0,13,3,18,86,2,10,5,16,95,16,54,4,23,63,70,10,21,20,26,99,85,9,96,3,83,5,9,91,14,1,4,78,11,15,53,10,35,13,7,17,30,90,23,65,65,67,16,4,65,39,11,57,13,36,22,95,53,63,22,47,12,47,2,12,3,71,92,17,55,16,51,79,6,3,92,15,17,15,18,63,8,12,3,49,6,69,32,1,25,83,17,12,1,76,23,95,17,13,92,13,56,16,69,94,11,20,31,83,30,21,88,22,61,45,6,70,12,3,30,23,86,6,93,4,24,9,73,72,7,72,83,9,30,6,24,86,99,11,11,96,16,68,10,35,19,23,6,79,51,8,3,8,75,2,32,26,73,23,80,30,86,25,64,46,24,81,20,18,85,7,94,28,37,93,18,12,77,99,14,22,19,50,2,18,45,63,8,2,89,79,79,7,33,77,18,20,22,12,58,61,20,4,58,20,51,79,14,32,19,87,21,19,76,8,81,7,13,72,75,22,28,22,14,92,30,18,90,10,6,97,25,34,9,20,26,52,45,6,4,97,4,46,26,86,61,20,25,28,26,22,54,69,16,51,3,58,5,23,75,92,18,98,12,11,55,38,22,87,14,20,17,52,73,9,91,30,14,26,12,56,81,54,9,72,18,12,47,93,22,54,21,59,73,7,78,12,87,26,5,39,45,4,55,16,21,86,62,20,98,61,14,20,70,14,25,92,32,44,2,3,15,32,23,23,97,76,78,15,23,95,21,11,69,34,12,89,3,95,24,15,59,38,39,72,14,15,55,48,18,2,43,26,13,58,68,11,22,89,33,79,22,43,40,14,26,5,50,11,28,9,36,33,2,22,43,21,90,15,92,14,14,49,9,80,14,85,99,70,8,16,14,15,70,1,39,32,45,5,57,12,12,4,99,75,28,14,2,28,71,5,69,61,4,28,98,97,87,10,80,2,65,93,6,21,81,7,95,22,35,18,38,23,11,53,14,5,2,84,3,70,33,19,8,52,10,99,14,58,36,1,3,30,53,4,7,47,10,93,2,32,17,40,68,43,20,41,4,16,21,29,23,82,2,18,37,37,15,19,26,41,28,9,95,17,17,52,25,13,49,28,47,22,5,52,14,21,72,83,7,17,86,20,3,18,58,14,19,25,56,65,65,26,53,8,20,75,31,21,40,17,6,33,20,95,47,24,75,26,17,96,24,48,65,97,4,52,20,78,47,14,23,77,32,8,18,98,43,7,61,25,84,40,6,36,24,87,24,71,77,13,20,49,16,60,35,9,64,48,21,2,74,25,1,2,57,11,58,7,45,35,26,13,74,92,2,9,82,9,20,23,15,33,94,7,10,48,78,16,24,94,33,11,21,5,89,47,15,52,12,51,51,81,9,18,39,14,2,97,79,33,23,12,99,3,16,11,79,83,45,18,23,78,86,69,10,25,98,62,62,18,7,44,47,1,3,92,8,22,81,9,3,29,8,81,21,13,95,6,5,99,5,29,16,3,53,72,26,14,44,97,7,43,12,42,65,17,8,12,88,55,18,20,34,13,39,10,72,58,15,11,69,17,94,20,22,52,28,13,30,65,8,2,63,18,4,36,17,8,71,16,71,15,64,14,31,51,75,1,12,92,14,35,23,40,45,1,5,87,28,18,83,43,9,90,2,3,50,18,61,68,5,89,16,44,7,34,82,74,15,83,15,70,13,80,20,43,8,35,14,58,50,75,20,50,9,68,46,52,2,73,11,60,32,61,25,40,9,31,21,73,0,0,21,21,1,10,1,0,0,0,0,0,0 \ No newline at end of file
diff --git a/19/input/16 b/19/input/16
new file mode 100644
index 0000000..a424590
--- /dev/null
+++ b/19/input/16
@@ -0,0 +1 @@
+59766832516471105169175836985633322599038555617788874561522148661927081324685821180654682056538815716097295567894852186929107230155154324411726945819817338647442140954601202408433492208282774032110720183977662097053534778395687521636381457489415906710702497357756337246719713103659349031567298436163261681422438462663511427616685223080744010014937551976673341714897682634253850270219462445161703240957568807600494579282412972591613629025720312652350445062631757413159623885481128914333982571503540357043736821931054029305931122179293220911720263006705242490442826574028623201238659548887822088996956559517179003476743001815465428992906356931239533104
diff --git a/19/input/17 b/19/input/17
new file mode 100644
index 0000000..84520cf
--- /dev/null
+++ b/19/input/17
@@ -0,0 +1 @@
+1,330,331,332,109,3016,1101,1182,0,16,1101,1441,0,24,102,1,0,570,1006,570,36,1002,571,1,0,1001,570,-1,570,1001,24,1,24,1106,0,18,1008,571,0,571,1001,16,1,16,1008,16,1441,570,1006,570,14,21101,58,0,0,1105,1,786,1006,332,62,99,21101,333,0,1,21101,73,0,0,1105,1,579,1101,0,0,572,1101,0,0,573,3,574,101,1,573,573,1007,574,65,570,1005,570,151,107,67,574,570,1005,570,151,1001,574,-64,574,1002,574,-1,574,1001,572,1,572,1007,572,11,570,1006,570,165,101,1182,572,127,102,1,574,0,3,574,101,1,573,573,1008,574,10,570,1005,570,189,1008,574,44,570,1006,570,158,1106,0,81,21101,340,0,1,1106,0,177,21102,1,477,1,1106,0,177,21101,514,0,1,21102,176,1,0,1105,1,579,99,21102,1,184,0,1105,1,579,4,574,104,10,99,1007,573,22,570,1006,570,165,1002,572,1,1182,21101,0,375,1,21101,211,0,0,1105,1,579,21101,1182,11,1,21101,222,0,0,1105,1,979,21102,1,388,1,21102,1,233,0,1105,1,579,21101,1182,22,1,21102,244,1,0,1106,0,979,21102,401,1,1,21101,0,255,0,1106,0,579,21101,1182,33,1,21101,266,0,0,1106,0,979,21102,414,1,1,21101,0,277,0,1105,1,579,3,575,1008,575,89,570,1008,575,121,575,1,575,570,575,3,574,1008,574,10,570,1006,570,291,104,10,21102,1,1182,1,21101,0,313,0,1106,0,622,1005,575,327,1102,1,1,575,21101,327,0,0,1106,0,786,4,438,99,0,1,1,6,77,97,105,110,58,10,33,10,69,120,112,101,99,116,101,100,32,102,117,110,99,116,105,111,110,32,110,97,109,101,32,98,117,116,32,103,111,116,58,32,0,12,70,117,110,99,116,105,111,110,32,65,58,10,12,70,117,110,99,116,105,111,110,32,66,58,10,12,70,117,110,99,116,105,111,110,32,67,58,10,23,67,111,110,116,105,110,117,111,117,115,32,118,105,100,101,111,32,102,101,101,100,63,10,0,37,10,69,120,112,101,99,116,101,100,32,82,44,32,76,44,32,111,114,32,100,105,115,116,97,110,99,101,32,98,117,116,32,103,111,116,58,32,36,10,69,120,112,101,99,116,101,100,32,99,111,109,109,97,32,111,114,32,110,101,119,108,105,110,101,32,98,117,116,32,103,111,116,58,32,43,10,68,101,102,105,110,105,116,105,111,110,115,32,109,97,121,32,98,101,32,97,116,32,109,111,115,116,32,50,48,32,99,104,97,114,97,99,116,101,114,115,33,10,94,62,118,60,0,1,0,-1,-1,0,1,0,0,0,0,0,0,1,14,0,0,109,4,1202,-3,1,587,20102,1,0,-1,22101,1,-3,-3,21102,0,1,-2,2208,-2,-1,570,1005,570,617,2201,-3,-2,609,4,0,21201,-2,1,-2,1105,1,597,109,-4,2105,1,0,109,5,1202,-4,1,630,20101,0,0,-2,22101,1,-4,-4,21102,0,1,-3,2208,-3,-2,570,1005,570,781,2201,-4,-3,652,21002,0,1,-1,1208,-1,-4,570,1005,570,709,1208,-1,-5,570,1005,570,734,1207,-1,0,570,1005,570,759,1206,-1,774,1001,578,562,684,1,0,576,576,1001,578,566,692,1,0,577,577,21101,0,702,0,1106,0,786,21201,-1,-1,-1,1105,1,676,1001,578,1,578,1008,578,4,570,1006,570,724,1001,578,-4,578,21101,0,731,0,1105,1,786,1105,1,774,1001,578,-1,578,1008,578,-1,570,1006,570,749,1001,578,4,578,21101,756,0,0,1106,0,786,1105,1,774,21202,-1,-11,1,22101,1182,1,1,21101,774,0,0,1106,0,622,21201,-3,1,-3,1105,1,640,109,-5,2106,0,0,109,7,1005,575,802,20101,0,576,-6,20101,0,577,-5,1106,0,814,21101,0,0,-1,21101,0,0,-5,21102,1,0,-6,20208,-6,576,-2,208,-5,577,570,22002,570,-2,-2,21202,-5,45,-3,22201,-6,-3,-3,22101,1441,-3,-3,2101,0,-3,843,1005,0,863,21202,-2,42,-4,22101,46,-4,-4,1206,-2,924,21102,1,1,-1,1105,1,924,1205,-2,873,21101,35,0,-4,1106,0,924,1201,-3,0,878,1008,0,1,570,1006,570,916,1001,374,1,374,1202,-3,1,895,1101,2,0,0,1201,-3,0,902,1001,438,0,438,2202,-6,-5,570,1,570,374,570,1,570,438,438,1001,578,558,922,20101,0,0,-4,1006,575,959,204,-4,22101,1,-6,-6,1208,-6,45,570,1006,570,814,104,10,22101,1,-5,-5,1208,-5,35,570,1006,570,810,104,10,1206,-1,974,99,1206,-1,974,1101,0,1,575,21101,973,0,0,1105,1,786,99,109,-7,2106,0,0,109,6,21102,0,1,-4,21102,1,0,-3,203,-2,22101,1,-3,-3,21208,-2,82,-1,1205,-1,1030,21208,-2,76,-1,1205,-1,1037,21207,-2,48,-1,1205,-1,1124,22107,57,-2,-1,1205,-1,1124,21201,-2,-48,-2,1105,1,1041,21102,-4,1,-2,1105,1,1041,21101,-5,0,-2,21201,-4,1,-4,21207,-4,11,-1,1206,-1,1138,2201,-5,-4,1059,1202,-2,1,0,203,-2,22101,1,-3,-3,21207,-2,48,-1,1205,-1,1107,22107,57,-2,-1,1205,-1,1107,21201,-2,-48,-2,2201,-5,-4,1090,20102,10,0,-1,22201,-2,-1,-2,2201,-5,-4,1103,2101,0,-2,0,1106,0,1060,21208,-2,10,-1,1205,-1,1162,21208,-2,44,-1,1206,-1,1131,1106,0,989,21102,439,1,1,1105,1,1150,21102,477,1,1,1106,0,1150,21101,514,0,1,21102,1149,1,0,1105,1,579,99,21101,1157,0,0,1105,1,579,204,-2,104,10,99,21207,-3,22,-1,1206,-1,1138,2101,0,-5,1176,2101,0,-4,0,109,-6,2106,0,0,10,5,40,1,44,1,44,1,44,7,44,1,44,1,7,13,24,1,7,1,11,1,8,7,9,1,7,1,11,1,8,1,5,1,9,1,7,1,11,1,8,1,5,1,9,1,1,5,1,1,5,9,6,1,5,1,9,1,1,1,3,1,1,1,5,1,5,1,1,1,6,1,5,1,7,11,1,11,1,1,6,1,5,1,7,1,1,1,1,1,3,1,3,1,3,1,7,1,6,1,5,1,7,1,1,7,3,1,3,1,7,1,6,1,5,1,7,1,3,1,7,1,3,1,7,1,6,1,5,1,1,11,1,11,7,1,6,1,5,1,1,1,5,1,5,1,5,1,11,1,6,1,5,9,5,1,5,1,11,1,6,1,7,1,11,1,5,1,11,1,6,7,1,1,11,1,5,7,5,7,6,1,1,1,11,1,11,1,11,1,6,1,1,13,11,1,11,1,6,1,25,1,11,1,6,1,25,1,11,1,6,1,25,1,11,1,6,1,25,1,11,1,6,1,25,1,11,1,6,1,25,1,1,11,6,1,25,1,1,1,16,7,19,7,40,1,3,1,40,1,3,1,40,1,3,1,40,5,6
diff --git a/19/py/d01.py b/19/py/d01.py
new file mode 100644
index 0000000..d1c57c8
--- /dev/null
+++ b/19/py/d01.py
@@ -0,0 +1,28 @@
+import math
+import sys
+
+def get_fuel(mass):
+ fuel = math.floor(mass / 3) - 2
+ return 0 if fuel <= 0 else fuel + get_fuel(fuel)
+
+def pt1(_in):
+ s = 0
+ for line in _in:
+ mass = int(line)
+ if mass == 0:
+ break
+ fuel = math.floor(mass / 3) - 2
+ s += fuel
+ return s
+
+def pt2(input):
+ return sum([get_fuel(int(line)) for line in input])
+
+if __name__ == "__main__":
+ import cProfile
+
+ input = open("../input/01", "r").readlines()
+ cProfile.run("pt1(input)")
+ cProfile.run("pt2(input)")
+ print(pt1(input))
+ print(pt2(input))
diff --git a/19/py/d02.py b/19/py/d02.py
new file mode 100644
index 0000000..6b5aa0a
--- /dev/null
+++ b/19/py/d02.py
@@ -0,0 +1,49 @@
+import sys
+
+def pt1(input):
+ program = [int(x) for x in input[0].split(",")]
+
+ memory = program.copy()
+ memory[1] = 12
+ memory[2] = 2
+
+ pointer = 0
+ while True:
+ if memory[pointer] == 99:
+ break
+ elif memory[pointer] == 1:
+ memory[memory[pointer+3]] = memory[memory[pointer+1]] + memory[memory[pointer+2]]
+ elif memory[pointer] == 2:
+ memory[memory[pointer+3]] = memory[memory[pointer+1]] * memory[memory[pointer+2]]
+ pointer += 4
+ return memory[0]
+
+def pt2(input):
+ program = [int(x) for x in input[0].split(",")]
+
+ for n in range(100):
+ for v in range(100):
+ memory = program.copy()
+ memory[1] = n
+ memory[2] = v
+
+ pointer = 0
+ while True:
+ if memory[pointer] == 99:
+ break
+ elif memory[pointer] == 1:
+ memory[memory[pointer+3]] = memory[memory[pointer+1]] + memory[memory[pointer+2]]
+ elif memory[pointer] == 2:
+ memory[memory[pointer+3]] = memory[memory[pointer+1]] * memory[memory[pointer+2]]
+ pointer += 4
+ if memory[0] == 19690720:
+ return (n, v, n*100 + v)
+
+if __name__ == "__main__":
+ import cProfile
+
+ input = open("../input/02", "r").readlines()
+ cProfile.run("pt1(input)")
+ cProfile.run("pt2(input)")
+ print(pt1(input))
+ print(pt2(input))
diff --git a/19/py/d03.py b/19/py/d03.py
new file mode 100644
index 0000000..70bf9f0
--- /dev/null
+++ b/19/py/d03.py
@@ -0,0 +1,83 @@
+from profilehooks import coverage
+import math
+
+def intersection(l1, l2):
+ l1 = set(l1)
+ l2 = set(l2)
+ return [value for value in l2 if value in l1]
+
+def man_dist(point):
+ return abs(point[0]) + abs(point[1])
+
+#@coverage
+def pt1(input):
+ wire1 = []
+ wire2 = []
+ for wire, moves in zip((wire1, wire2), (input[0], input[1])):
+ x = 0
+ y = 0
+ dx = 0
+ dy = 0
+ for move in moves.split(","):
+ if move[0] == "D":
+ dx = 0
+ dy = -1
+ elif move[0] == "U":
+ dx = 0
+ dy = 1
+ elif move[0] == "R":
+ dx = 1
+ dy = 0
+ elif move[0] == "L":
+ dx = -1
+ dy = 0
+ for i in range(int(move[1:])):
+ x += dx
+ y += dy
+ wire.append((x, y))
+ points = intersection(wire1, wire2)
+ dist = man_dist(points[0])
+ for point in points[1:]:
+ dist = min(dist, man_dist(point))
+ return dist
+
+#@coverage
+def pt2(input):
+ wire1 = {}
+ wire2 = {}
+ # wire {(x,y) : dist}
+ for wire, moves in zip((wire1, wire2), (input[0], input[1])):
+ x = 0
+ y = 0
+ dx = 0
+ dy = 0
+ steps = 0
+ for move in moves.split(","):
+ if move[0] == "D":
+ dx = 0
+ dy = -1
+ elif move[0] == "U":
+ dx = 0
+ dy = 1
+ elif move[0] == "R":
+ dx = 1
+ dy = 0
+ elif move[0] == "L":
+ dx = -1
+ dy = 0
+ for i in range(int(move[1:])):
+ x += dx
+ y += dy
+ steps += 1
+ wire[(x, y)] = steps
+
+ points = intersection(list(wire1.keys()), list(wire2.keys()))
+ length = wire1[points[0]] + wire2[points[0]]
+ for point in points[1:]:
+ length = min(length, wire1[point] + wire2[point])
+ return length
+
+if __name__ == "__main__":
+ input = open("../input/03", "r").readlines()
+ print(pt1(input))
+ print(pt2(input))
diff --git a/19/py/d04.py b/19/py/d04.py
new file mode 100644
index 0000000..c9bcbf3
--- /dev/null
+++ b/19/py/d04.py
@@ -0,0 +1,65 @@
+from collections import Counter
+
+def isIncreasing(num):
+ s = list(str(num))
+ n = int(s[0])
+ n_i = 0
+ for sp in s[1:]:
+ n_i += 1
+ if int(sp) < n:
+ for i in range(n_i, 6):
+ s[i] = str(n)
+ return False, int("".join(s))
+ n = int(sp)
+ return (True,)
+
+def pt1(input):
+ def containsDouble(num):
+ s = str(num)
+ amounts = [0 for _ in range(10)]
+ for c in s:
+ amounts[int(c)] += 1
+ c = Counter(amounts)
+ return c[0] + c[1] < 10
+
+ amount = 0
+ n = 357253
+ while n < 892942 + 1:
+ inc = isIncreasing(n)
+ if inc[0] == True:
+ if containsDouble(n):
+ amount += 1
+ n += 1
+ else:
+ n = inc[1]
+ return amount
+
+def pt2(input):
+ def containsDouble(num):
+ s = str(num)
+ amounts = [0 for _ in range(10)]
+ for c in s:
+ amounts[int(c)] += 1
+ c = Counter(amounts)
+ if c[0] + c[1] < 10:
+ return c[2] >= 1
+
+ amount = 0
+ n = 357253
+ while n < 892942 + 1:
+ inc = isIncreasing(n)
+ if inc[0] == True:
+ if containsDouble(n):
+ amount += 1
+ n += 1
+ else:
+ n = inc[1]
+ return amount
+
+if __name__ == "__main__":
+ import cProfile
+
+ cProfile.run("pt1([])")
+ cProfile.run("pt2([])")
+ print(pt1([]))
+ print(pt2([]))
diff --git a/19/py/d05.py b/19/py/d05.py
new file mode 100644
index 0000000..1415b99
--- /dev/null
+++ b/19/py/d05.py
@@ -0,0 +1,34 @@
+import intcode
+
+def pt1(input):
+ program = [int(x) for x in input[0].split(",")]
+ c = intcode.Computer(program)
+ c.input = 1
+ output = []
+ while c.memory[c.pointer] != 99:
+ c.step()
+ if c.output != None:
+ output.append(c.output)
+ c.output = None
+ return output
+
+def pt2(input):
+ program = [int(x) for x in input[0].split(",")]
+ c = intcode.Computer(program)
+ c.input = 5
+ output = []
+ while c.memory[c.pointer] != 99:
+ c.step()
+ if c.output != None:
+ output.append(c.output)
+ c.output = None
+ return output
+
+if __name__ == "__main__":
+ import cProfile
+
+ input = open("../input/05", "r").readlines()
+ cProfile.run("pt1(input)")
+ cProfile.run("pt2(input)")
+ print(pt1(input))
+ print(pt2(input))
diff --git a/19/py/d06.py b/19/py/d06.py
new file mode 100644
index 0000000..0b54362
--- /dev/null
+++ b/19/py/d06.py
@@ -0,0 +1,87 @@
+from typing import Iterable
+import sys
+
+class Tree(object):
+ # https://stackoverflow.com/a/28015122
+ def __init__(self, name='root', children=None):
+ self.name = name
+ self.children = []
+ self.parent = None
+ if children is not None:
+ for child in children:
+ self.add_child(child)
+ def add_child(self, node):
+ self.children.append(node)
+ node.parent = self
+
+ def __eq__(self, other):
+ if isinstance(other, Tree):
+ return self.name == other.name
+ return False
+ def parents(self):
+ return [self.parent] + self.parent.parents() if self.parent != None\
+ else []
+
+def gen_tree(input):
+ trees = {}
+ seen = set() # seen trees. contains only IDs
+ leafs = {}
+
+ for orbit in input:
+ orbit = orbit.split(")")
+ #print(orbit)
+ if not orbit[0] in seen:
+ trees[orbit[0]] = Tree(orbit[0])
+ seen.add(orbit[0])
+
+ # hook up each child to its parent (since every parent now exists)
+ for orbit in input:
+ orbit = orbit.rstrip().split(")")
+ if orbit[1] in seen:
+ trees[orbit[0]].add_child(trees[orbit[1]])
+ else:
+ leafs[orbit[1]] = Tree(orbit[1])
+ trees[orbit[0]].add_child(leafs[orbit[1]])
+ for k in trees:
+ pass
+ #print(trees[k], trees[k].children)
+
+ trees.update(leafs)
+ return trees
+
+sum_depths = 0
+def pt1(input):
+ tree = gen_tree(input)
+ depth = 0
+ depths = {}
+ def count_children(tree, depth):
+ global sum_depths # fusk-rekursion? ville bara att det skulle fungera
+ sum_depths += depth
+ depths[tree.name] = depth
+ for child in tree.children:
+ count_children(child, depth+1)
+ count_children(tree["COM"], 0)
+ return sum_depths
+
+def pt2(input):
+ # find common parent and distance to it
+ tree = gen_tree(input)
+ src_parents = tree["YOU"].parent.parents()
+ tar_parents = tree["SAN"].parent.parents()
+ src_dist = 0
+ for src_parent in src_parents:
+ src_dist += 1
+ tar_dist = 0
+ for tar_parent in tar_parents:
+ tar_dist += 1
+ if src_parent == tar_parent:
+ return (src_parent.name, src_dist, tar_dist, src_dist + tar_dist)
+
+if __name__ == "__main__":
+ import cProfile
+
+ input = open("../input/06", "r").readlines()
+ cProfile.run("pt1(input)")
+ cProfile.run("pt2(input)")
+ print(pt1(input))
+ print(pt2(input))
diff --git a/19/py/d07.py b/19/py/d07.py
new file mode 100644
index 0000000..7ab2fe6
--- /dev/null
+++ b/19/py/d07.py
@@ -0,0 +1,80 @@
+import intcode
+import itertools
+import queue
+
+def pt1(input):
+ program = [int(x) for x in input[0].split(",")]
+ highest_signal = 0
+ highest_sequence = None
+ for phase_seq in list(itertools.permutations(list(range(0,5)))):
+ q = queue.Queue(5)
+ for phase in phase_seq:
+ q.put(phase)
+ amps = [intcode.Computer(program) for _ in range(5)]
+ for amp in amps:
+ amp.input = q.get()
+ signal = 0
+ for amp in amps:
+ while True:
+ amp.step()
+ if amp.input is None:
+ amp.input = signal
+ if amp.output is not None:
+ signal = amp.output
+ amp.output = None
+ break
+ if signal > highest_signal:
+ highest_signal = signal
+ highest_sequence = phase_seq
+ return (highest_sequence, highest_signal)
+
+def pt2(input):
+ program = [int(x) for x in input[0].split(",")]
+ highest_signal = 0
+ highest_sequence = None
+ for phase_seq in list(itertools.permutations(list(range(5,10)))):
+ q = queue.Queue(5)
+ for phase in phase_seq:
+ q.put(phase)
+ amps = [intcode.Computer(program) for _ in range(5)]
+ for amp in amps:
+ amp.input = q.get()
+
+ signal = 0
+ current_amp = 0
+ while True:
+ amp = amps[current_amp]
+ amp.step()
+ if amp.input is None:
+ if amp.phase_read == False:
+ amp.phase_read = True
+ amp.input = signal
+ else:
+ pass
+ if amp.output is not None:
+ signal = amp.output
+ amp.output = None
+ current_amp = (current_amp + 1) % 5
+ if amps[current_amp].phase_read == True:
+ amps[current_amp].input = signal
+ continue
+ if amp.memory[amp.pointer] == 99:
+ if current_amp == 4:
+ break
+ current_amp = (current_amp + 1) % 5
+ amps[current_amp].input = signal
+ continue
+ if signal > highest_signal:
+ highest_signal = signal
+ highest_sequence = phase_seq
+ return (highest_sequence, highest_signal)
+
+if __name__ == "__main__":
+ import cProfile
+
+ input = open("../input/07", "r").readlines()
+ cProfile.run("pt1(input)")
+ cProfile.run("pt2(input)")
+ print(pt1(input))
+ print(pt2(input))
+
diff --git a/19/py/d08.py b/19/py/d08.py
new file mode 100644
index 0000000..7df2aec
--- /dev/null
+++ b/19/py/d08.py
@@ -0,0 +1,38 @@
+def count(layer, num):
+ return sum([row.count(num) for row in layer])
+
+def pt1(input):
+ img = []
+ least_zeroes = 150 # max
+ n = 0
+ for l in range(100):
+ layer = [[int(input[0][l*25*6 + y*25 + x]) for x in range(25)] for y in range(6)]
+ if count(layer, 0) < least_zeroes:
+ least_zeroes = count(layer, 0)
+ n = count(layer, 1) * count(layer, 2)
+ img.append(layer)
+ return n
+
+def pt2(input):
+ img = [[[int(input[0][l*25*6 + y*25 + x]) for x in range(25)] for y in range(6)] for l in range(100)]
+ result = img[0]
+ for layer in img[1:]:
+ for x in range(25):
+ for y in range(6):
+ if result[y][x] == 2:
+ result[y][x] = layer[y][x]
+ str_res = []
+ for row in result:
+ str_res.append("\n ")
+ for c in row:
+ str_res.append('\u2588' if c == 1 else ' ')
+ return "".join(str_res)
+
+if __name__ == "__main__":
+ import cProfile
+
+ input = open("../input/08", "r").readlines()
+ cProfile.run("pt1(input)")
+ cProfile.run("pt2(input)")
+ print(pt1(input))
+ print(pt2(input))
diff --git a/19/py/d09.py b/19/py/d09.py
new file mode 100644
index 0000000..ada6763
--- /dev/null
+++ b/19/py/d09.py
@@ -0,0 +1,27 @@
+import intcode
+
+def do(input, code):
+ program = [int(x) for x in input.split(",")]
+ c = intcode.Computer(program)
+ c.input = code
+ output = []
+ while True:
+ c.step()
+ #print(c.relative_base, c.pointer, c.memory)
+ if c.SIG_HALT:
+ break
+ if c.output is not None:
+ output.append(c.output)
+ c.output = None
+ return output
+
+def pt1(input):
+ return do(input[0], 1)
+
+def pt2(input):
+ return do(input[0], 2)
+
+if __name__ == "__main__":
+ input = open("../input/09", "r").readlines()
+ print(pt1(input))
+ print(pt2(input))
diff --git a/19/py/d10.py b/19/py/d10.py
new file mode 100644
index 0000000..0d918d9
--- /dev/null
+++ b/19/py/d10.py
@@ -0,0 +1,261 @@
+import math
+import os
+import queue
+import sys
+import time
+
+def red(dcoord):
+ dx = dcoord[0]
+ dy = dcoord[1]
+ if dx == 0:
+ return (0, (1 if dy > 0 else -1))
+ if dy == 0:
+ return ((1 if dx > 0 else -1), 0)
+ gcd = math.gcd(dx, dy)
+ return (dx // gcd, dy // gcd)
+
+def angle(x, y): # from y-axis, clockwise
+ if x >= 0 and y > 0:
+ return math.atan(abs(x/y))
+ if x > 0 and y <= 0:
+ return math.atan(abs(y/x)) + math.pi/2
+ if x <= 0 and y < 0:
+ return math.atan(abs(x/y)) + math.pi
+ else:
+ return math.atan(abs(y/x)) + 3*math.pi / 2
+
+def pt1(input):
+ asteroids = set()
+ res = {}
+
+ max_x = len(input[0].rstrip())
+ max_y = len(input)
+
+ for y in range(max_y):
+ for x in range(max_x):
+ if input[y][x] == "#":
+ asteroids.add((x,y))
+
+ for a in asteroids:
+ candidates = set(asteroids.copy())
+ candidates.remove(a)
+ seen = set()
+ while len(candidates) > 0:
+ c = candidates.pop()
+ seen.add(c)
+ dx = c[0] - a[0]
+ dy = c[1] - a[1]
+ x = a[0]
+ y = a[1]
+ x += dx
+ y += dy
+ dx, dy = red((dx, dy))
+ x += dx
+ y += dy
+ while x < max_x and y < max_y and x >= 0 and y >= 0:
+ if (x, y) in candidates:
+ candidates.remove((x, y))
+ if (x, y) in seen:
+ seen.remove((x, y))
+ x += dx
+ y += dy
+ res[a] = seen
+
+ best = [0, 0, 0]
+ for coord in res:
+ amount = len(res[coord])
+ if amount > best[0]:
+ best = [amount, coord, res[coord]]
+ return (best[1], best[0])
+
+def pt2(input):
+ asteroids = set()
+ res = {}
+
+ max_x = len(input[0].rstrip())
+ max_y = len(input)
+
+ for y in range(max_y):
+ for x in range(max_x):
+ if input[y][x] == "#":
+ asteroids.add((x,y))
+
+ for a in asteroids:
+ candidates = set(asteroids.copy())
+ candidates.remove(a)
+ seen = set()
+ while len(candidates) > 0:
+ c = candidates.pop()
+ seen.add(c)
+ dx = c[0] - a[0]
+ dy = c[1] - a[1]
+ x = a[0]
+ y = a[1]
+ x += dx
+ y += dy
+ dx, dy = red((dx, dy))
+ x += dx
+ y += dy
+ while x < max_x and y < max_y and x >= 0 and y >= 0:
+ if (x, y) in candidates:
+ candidates.remove((x, y))
+ if (x, y) in seen:
+ seen.remove((x, y))
+ x += dx
+ y += dy
+ res[a] = seen
+
+ best = [0, 0, 0]
+ for coord in res:
+ amount = len(res[coord])
+ if amount > best[0]:
+ best = [amount, coord, res[coord]]
+ asteroids.remove(best[1])
+ x0 = best[1][0]
+ y0 = best[1][1]
+
+ angles = {}
+ q = queue.Queue()
+ for a in asteroids:
+ angles[a] = angle(a[0] - x0, y0 - a[1])
+
+ for k, v in sorted(angles.items(), key=lambda item: item[1]):
+ if k in best[2]:
+ q.put(k)
+
+ destroyed = 1
+ while not q.empty():
+ asteroid = q.get()
+ if destroyed == 200:
+ return (asteroid, asteroid[0]*100 + asteroid[1])
+ asteroids.remove(asteroid)
+ destroyed += 1
+
+ # add next asteroid behind to queue
+ dx = asteroid[0] - x0
+ dy = asteroid[1] - y0
+ x = x0
+ y = y0
+ x += dx
+ y += dy
+ dx, dy = red((dx, dy))
+ x += dx
+ y += dy
+ while x < max_x and y < max_y and x >= 0 and y >= 0:
+ if (x, y) in asteroids:
+ q.put((x, y))
+ break
+ x += dx
+ y += dy
+
+def print_map(coords, w, h):
+ time.sleep(0.01)
+ os.system("clear")
+ s = ""
+ for y in range(w):
+ for x in range(h):
+ s += (coords[(x, y)] + " ") if (x,y) in coords else " "
+ s += "\n"
+ print(s)
+
+def visualize(input):
+ asteroids = set()
+ res = {}
+
+ max_x = len(input[0].rstrip())
+ max_y = len(input)
+
+ for y in range(max_y):
+ for x in range(max_x):
+ if input[y][x] == "#":
+ asteroids.add((x,y))
+
+ #print_map(asteroids, max_x, max_y)
+
+ for a in asteroids:
+ print(a)
+ time.sleep(3)
+ candidates = set(asteroids.copy())
+ candidates.remove(a)
+ seen = set()
+ while len(candidates) > 0:
+ #print(len(candidates))
+ time.sleep(0.02)
+ union = {a: "\u2588"}
+ for c in candidates:
+ union[c] = "C"
+ for s in seen:
+ union[s] = "s"
+ print_map(union, max_x, max_y)
+ c = candidates.pop()
+ seen.add(c)
+ dx = c[0] - a[0]
+ dy = c[1] - a[1]
+ x = a[0]
+ y = a[1]
+ x += dx
+ y += dy
+ dx, dy = red((dx, dy))
+ x += dx
+ y += dy
+ while x < max_x and y < max_y and x >= 0 and y >= 0:
+ if (x, y) in candidates:
+ candidates.remove((x, y))
+ if (x, y) in seen:
+ seen.remove((x, y))
+ x += dx
+ y += dy
+ res[a] = seen
+
+ best = [0, 0, 0]
+ for coord in res:
+ amount = len(res[coord])
+ if amount > best[0]:
+ best = [amount, coord, res[coord]]
+ asteroids.remove(best[1])
+ x0 = best[1][0]
+ y0 = best[1][1]
+
+ angles = {}
+ q = queue.Queue()
+ for a in asteroids:
+ angles[a] = angle(a[0] - x0, y0 - a[1])
+
+ for k, v in sorted(angles.items(), key=lambda item: item[1]):
+ if k in best[2]:
+ q.put(k)
+
+ destroyed = 1
+ while not q.empty():
+ #print_map(asteroids, max_x, max_y)
+ asteroid = q.get()
+ if destroyed == 200:
+ return (asteroid, asteroid[0]*100 + asteroid[1])
+ asteroids.remove(asteroid)
+ destroyed += 1
+
+ # add next asteroid behind to queue
+ dx = asteroid[0] - x0
+ dy = asteroid[1] - y0
+ x = x0
+ y = y0
+ x += dx
+ y += dy
+ dx, dy = red((dx, dy))
+ x += dx
+ y += dy
+ while x < max_x and y < max_y and x >= 0 and y >= 0:
+ if (x, y) in asteroids:
+ q.put((x, y))
+ break
+ x += dx
+ y += dy
+if __name__ == "__main__":
+ import cProfile
+
+ input = open("../input/10","r").readlines()
+ visualize(input)
+ #cProfile.run("pt1(input)")
+ #cProfile.run("pt2(input)")
+ print(pt1(input))
+ print(pt2(input))
diff --git a/19/py/d11.py b/19/py/d11.py
new file mode 100644
index 0000000..e9b280c
--- /dev/null
+++ b/19/py/d11.py
@@ -0,0 +1,165 @@
+import intcode
+import time
+
+
+def draw(colors, ship, direction):
+ min_x, max_x, min_y, max_y = 0, 0, 0, 0
+ ship_c = ""
+ if direction == 0:
+ ship_c = "^"
+ elif direction == 1:
+ ship_c = "<"
+ elif direction == 2:
+ ship_c = "v"
+ elif direction == 3:
+ ship_c = ">"
+ for color in colors:
+ min_x = min(min_x, color[0])
+ max_x = max(max_x, color[0])
+ min_y = min(min_y, color[1])
+ max_y = max(max_y, color[1])
+ s = ""
+ for y in range(min_y, max_y+1):
+ s += "\n"
+ for x in range(min_x, max_x+1):
+ if (x,y) == ship:
+ s += ship_c
+ elif (x,y) in colors:
+ c = colors[(x,y)]
+ s += "\u2588" if c == 1 else " "
+ else:
+ s += "."
+ return s
+
+def pt1(input):
+ program = [int(x) for x in input[0].split(",")]
+ x=y = 0
+ direction = 0
+ # 0 is up
+ # 1 is left
+ # 2 is down
+ # 3 is right
+ # 4 is up (again)
+ # turning left is direction += 1
+ # turning right is direction -= 1
+ # direction is direction % 4
+ colors = {} # (x,y): 1/0 (1 = white, 0 = black)
+
+ got_color = False
+ c = intcode.Computer(program)
+ while c.memory[c.pointer] != 99:
+ # input
+ #print(x, y)
+ #draw(colors, (x,y), direction % 4)
+ #input()
+ #time.sleep(0.1)
+ c.input = colors.get((x, y), 0)
+ c.step()
+ if c.output is not None:
+ if not got_color:
+ colors[(x, y)] = c.output
+ c.output = None
+ got_color = True
+ elif got_color:
+ direction += (1 if c.output == 0 else -1)
+ dir = direction % 4
+ if dir == 0:
+ y -= 1
+ elif dir == 1:
+ x -= 1
+ elif dir == 2:
+ y += 1
+ elif dir == 3:
+ x += 1
+ got_color = False
+ c.output = None
+ return len(colors)
+
+def pt2(input):
+ program = [int(x) for x in input[0].split(",")]
+ x=y = 0
+ direction = 0
+ # 0 is up
+ # 1 is left
+ # 2 is down
+ # 3 is right
+ # 4 is up (again)
+ # turning left is direction += 1
+ # turning right is direction -= 1
+ # direction is direction % 4
+ colors = {(0,0): 1} # (x,y): 1/0 (1 = white, 0 = black)
+
+ got_color = False
+ c = intcode.Computer(program)
+ while c.memory[c.pointer] != 99:
+ c.input = colors.get((x, y), 0)
+ c.step()
+ if c.output is not None:
+ if not got_color:
+ colors[(x, y)] = c.output
+ c.output = None
+ got_color = True
+ elif got_color:
+ direction += (1 if c.output == 0 else -1)
+ dir = direction % 4
+ if dir == 0:
+ y -= 1
+ elif dir == 1:
+ x -= 1
+ elif dir == 2:
+ y += 1
+ elif dir == 3:
+ x += 1
+ got_color = False
+ c.output = None
+ return draw(colors, (0,0), 0)
+
+def visualize(input):
+ program = [int(x) for x in input[0].split(",")]
+ x=y = 0
+ direction = 0
+ # 0 is up
+ # 1 is left
+ # 2 is down
+ # 3 is right
+ # 4 is up (again)
+ # turning left is direction += 1
+ # turning right is direction -= 1
+ # direction is direction % 4
+ colors = {(0,0): 1} # (x,y): 1/0 (1 = white, 0 = black)
+
+ got_color = False
+ c = intcode.Computer(program)
+ while c.memory[c.pointer] != 99:
+ time.sleep(0.002)
+ print(draw(colors, (x,y), direction % 4))
+ c.input = colors.get((x, y), 0)
+ c.step()
+ if c.output is not None:
+ if not got_color:
+ colors[(x, y)] = c.output
+ c.output = None
+ got_color = True
+ elif got_color:
+ direction += (1 if c.output == 0 else -1)
+ dir = direction % 4
+ if dir == 0:
+ y -= 1
+ elif dir == 1:
+ x -= 1
+ elif dir == 2:
+ y += 1
+ elif dir == 3:
+ x += 1
+ got_color = False
+ c.output = None
+
+if __name__ == "__main__":
+ import cProfile
+
+ input = open("../input/11", "r").readlines()
+ cProfile.run("pt1(input)")
+ cProfile.run("pt2(input)")
+ print(pt1(input))
+ print(pt2(input))
+ visualize(input)
diff --git a/19/py/d12.py b/19/py/d12.py
new file mode 100644
index 0000000..878acc6
--- /dev/null
+++ b/19/py/d12.py
@@ -0,0 +1,126 @@
+import itertools
+#import primefac
+
+class Moon(object):
+ def __init__(self, x, y, z):
+ self.x = x
+ self.y = y
+ self.z = z
+ self.dx = 0
+ self.dy = 0
+ self.dz = 0
+
+ def step(self):
+ self.x += self.dx
+ self.y += self.dy
+ self.z += self.dz
+
+ def gx(self, other):
+ if self.x < other.x:
+ self.dx += 1
+ other.dx -= 1
+
+ def gy(self, other):
+ if self.y < other.y:
+ self.dy += 1
+ other.dy -= 1
+
+ def gz(self, other):
+ if self.z < other.z:
+ self.dz += 1
+ other.dz -= 1
+
+ def gravity(self, other):
+ self.gx(other)
+ self.gy(other)
+ self.gz(other)
+
+ def get_x(self):
+ return self.x, self.dx
+
+ def get_y(self):
+ return self.y, self.dy
+
+ def get_z(self):
+ return self.z, self.dz
+
+ def get(self):
+ return self.get_x, self.get_y, self.get_z
+
+def pt1(input):
+ return
+ moons = []
+
+ for line in input:
+ dims = line.rstrip().split(",")
+ x = int(dims[0][3:])
+ y = int(dims[1][3:])
+ z = int(dims[2][3:-1])
+ moons.append(Moon(x, y, z))
+
+ for _ in range(1000):
+ for pair in itertools.permutations(moons, 2):
+ pair[0].gravity(pair[1])
+ for moon in moons:
+ moon.step()
+
+ tot = 0
+ for moon in moons:
+ pot = abs(moon.x) + abs(moon.y) + abs(moon.z)
+ kin = abs(moon.dx) + abs(moon.dy) + abs(moon.dz)
+ tot += pot*kin
+ return tot
+
+def get_cycle(init_pos, init_vel):
+ initial = tuple(init_pos)
+ pos = init_pos.copy()
+ vel = init_vel.copy()
+ iters = 0
+ while 1:
+ for i, j in itertools.permutations(range(4), 2):
+ if i == j:
+ continue
+ if pos[i] < pos[j]:
+ vel[i] += 1
+ vel[j] -= 1
+ for i in range(4):
+ pos[i] += vel[i]
+ iters += 1
+ if pos[0] == initial[0] and pos[1] == initial[1] and \
+ pos[2] == initial[2] and pos[3] == initial[3] and \
+ vel[0] == 0 and vel[1] == 0 and \
+ vel[2] == 0 and vel[3] == 0:
+ return iters
+
+def pt2(input):
+ return
+ moons = []
+ xs = 0
+ ys = 0
+ zs = 0
+
+ for line in input:
+ dims = line.rstrip().split(",")
+ x = int(dims[0][3:])
+ y = int(dims[1][3:])
+ z = int(dims[2][3:-1])
+ moons.append(Moon(x, y, z))
+
+ xs = get_cycle([moon.x for moon in moons], [0 for _ in range(4)])
+ ys = get_cycle([moon.y for moon in moons], [0 for _ in range(4)])
+ zs = get_cycle([moon.z for moon in moons], [0 for _ in range(4)])
+
+ factors = [primefac.factorint(n) for n in (xs, ys, zs)]
+ nums = {}
+ for factor in factors:
+ for n in factor:
+ nums[n] = max(nums.get(n, 0), factor[n])
+ ans = 1
+ for n in nums:
+ ans *= n ** nums[n]
+ return ans
+
+if __name__ == "__main__":
+ input = open("../input/12", "r").readlines()
+ print(pt1(input))
+ print(pt2(input))
diff --git a/19/py/d13.py b/19/py/d13.py
new file mode 100644
index 0000000..3dbc5fb
--- /dev/null
+++ b/19/py/d13.py
@@ -0,0 +1,132 @@
+import intcode
+import queue
+import time
+
+def pt1(input):
+ c = intcode.Computer([int(x) for x in input[0].split(",")])
+ buffer_out = []
+ screen = {}
+ while c.memory[c.pointer] != 99:
+ c.step()
+ if c.output is not None:
+ buffer_out.append(c.output)
+ c.output = None
+ if len(buffer_out) == 3:
+ screen[(buffer_out[0], buffer_out[1])] = buffer_out[2]
+ buffer_out = []
+ blocks = 0
+ for p in screen:
+ if screen[p] == 2:
+ blocks += 1
+ return blocks
+
+
+def pt2(input):
+ def draw(screen, points):
+ ball_x = 0
+ paddle_x = 0
+ min_x = max_x = min_y = max_y = 0
+ for p in screen:
+ if p == (-1,0):
+ points = screen[p]
+ elif screen[p] == 3:
+ paddle_x = p[0]
+ elif screen[p] == 4:
+ ball_x = p[0]
+ return points, ball_x, paddle_x
+
+ c = intcode.Computer([int(x) for x in input[0].split(",")])
+ c.memory[0] = 2
+
+ screen = {}
+ buffer_out = []
+ points = 0
+ ball_x = paddle_x = 0
+
+ while c.memory[c.pointer] != 99:
+ if c.SIG_INPUT:
+ points, ball_x, paddle_x = draw(screen, points)
+ if paddle_x < ball_x:
+ c.input = 1
+ elif paddle_x > ball_x:
+ c.input = -1
+ else:
+ c.input = 0
+ c.step()
+ if c.output is not None:
+ buffer_out.append(c.output)
+ c.output = None
+ if len(buffer_out) == 3:
+ screen[(buffer_out[0], buffer_out[1])] = buffer_out[2]
+ buffer_out = []
+ return c.memory[386]
+
+def visualize(input):
+ def draw(screen, points):
+ ball_x = 0
+ paddle_x = 0
+ min_x = max_x = min_y = max_y = 0
+ for p in screen:
+ min_x = min(min_x, p[0])
+ max_x = max(max_x, p[0])
+ min_y = min(min_y, p[1])
+ max_y = max(max_y, p[1])
+ s = ""
+ for y in range(min_y-1, max_y+1):
+ for x in range(min_x-1, max_x+1):
+ if (x,y) in screen:
+ if (x,y) == (-1,0):
+ points = screen[(x,y)]
+ elif screen[(x,y)] == 0:
+ s += " "
+ elif screen[(x,y)] == 1:
+ s += "\u2588"
+ elif screen[(x,y)] == 2:
+ s += "#"
+ elif screen[(x,y)] == 3:
+ s += "-"
+ paddle_x = x
+ elif screen[(x,y)] == 4:
+ s += "O"
+ ball_x = x
+ else: # (x,y) not in screen
+ s += " "
+ s += "\n"
+ return s, points, ball_x, paddle_x
+
+ c = intcode.Computer([int(x) for x in input[0].split(",")])
+ c.memory[0] = 2
+
+ screen = {}
+ buffer_out = []
+ frame_n = 0
+ points = 0
+ ball_x = paddle_x = 0
+
+ while c.memory[c.pointer] != 99:
+ if c.SIG_INPUT:
+ time.sleep(0.01)
+ frame_n += 1
+ frame, points, ball_x, paddle_x = draw(screen, points)
+ print(frame)
+ if paddle_x < ball_x:
+ c.input = 1
+ elif paddle_x > ball_x:
+ c.input = -1
+ else:
+ c.input = 0
+ c.step()
+ if c.output is not None:
+ buffer_out.append(c.output)
+ c.output = None
+ if len(buffer_out) == 3:
+ screen[(buffer_out[0], buffer_out[1])] = buffer_out[2]
+ buffer_out = []
+
+if __name__ == "__main__":
+ import cProfile
+
+ _input = open("../input/13", "r").readlines()
+ print(pt1(_input))
+ print(pt2(_input))
+ #visualize(_input)
diff --git a/19/py/d14.py b/19/py/d14.py
new file mode 100644
index 0000000..1d628a4
--- /dev/null
+++ b/19/py/d14.py
@@ -0,0 +1,77 @@
+import math
+
+class Chem(object):
+ def __init__(self, name, created):
+ self.name = name
+ self.created = created
+
+ self.amount = 0
+ self.left_over = 0
+ self.producers = {}
+
+ def add_producer(self, producer, amount):
+ self.producers[producer] = amount
+
+ def produce(self, to_create):
+ if self.name == "ORE":
+ self.amount += to_create
+ return
+ if self.left_over > 0:
+ if self.left_over < to_create:
+ to_create -= self.left_over
+ self.left_over = 0
+ else:
+ self.left_over -= to_create
+ to_create = 0
+ productions = math.ceil(to_create / self.created)
+ self.amount += productions * self.created
+ self.left_over += productions * self.created - to_create
+ for producer, amount in self.producers.items():
+ producer.produce(productions * amount)
+
+ def __repr__(self):
+ return str((self.name, self.amount))
+
+def read_chems(input):
+ chems = {"ORE": Chem("ORE", 1)}
+ for line in input:
+ output = line.strip().split(" => ")[1]
+ chems[output.split(" ")[1]] = Chem(output.split(" ")[1], int(output.split(" ")[0]))
+
+ for line in input:
+ inputs = line.strip().split(" => ")[0]
+ output = line.strip().split(" => ")[1]
+ for i in inputs.split(", "):
+ chems[output.split(" ")[1]] \
+ .add_producer(chems[i.split(" ")[1]], int(i.split(" ")[0]))
+ return chems
+
+def pt1(input, amount=1):
+ chems = read_chems(input)
+ chems["FUEL"].produce(amount)
+ return chems["ORE"].amount
+
+def pt2(input):
+ low, high = 0, int(1e9)
+ target = 1000000000000
+ prev_guess = 0
+ while low != high:
+ guess = (low+high) // 2
+ if guess == prev_guess:
+ break
+ prev_guess = guess
+ chems = read_chems(input)
+ chems["FUEL"].produce(guess)
+ if chems["ORE"].amount == target:
+ break
+ elif chems["ORE"].amount > target:
+ high = guess
+ else:
+ low = guess
+ #print(low, guess, high)
+ return guess
+
+if __name__ == "__main__":
+ input = open("../input/14", "r").readlines()
+ print(pt1(input))
+ print(pt2(input))
diff --git a/19/py/d15.py b/19/py/d15.py
new file mode 100644
index 0000000..b2a9b10
--- /dev/null
+++ b/19/py/d15.py
@@ -0,0 +1,276 @@
+import intcode
+import heapq as heap
+import collections
+import time
+
+def neighbours(p):
+ return [(p[0]+1, p[1]), (p[0]-1, p[1]), \
+ (p[0], p[1]+1), (p[0], p[1]-1)]
+
+def get_path(start, end, board, draw_search=False):
+ if start == end:
+ return collections.deque()
+ visited = set()
+ h = []
+ heap.heappush(h, (0, start, collections.deque()))
+ while True:
+ cur = heap.heappop(h)
+ for n in neighbours(cur[1]):
+ if n == end:
+ cur[2].append(n)
+ if draw_search:
+ print(draw(board, path=cur[2], visited=visited))
+ return cur[2]
+ if n in visited or n not in board or board[n] == "#":
+ continue
+ new_path = collections.deque(cur[2])
+ new_path.append(n)
+ visited.add(n)
+ heap.heappush(h, (cur[0] + 1, n, new_path))
+ if draw_search:
+ time.sleep(0.005)
+ print(draw(board, path=new_path, visited=visited))
+
+def pt1(input):
+ cur_x = cur_y = 0
+ q = collections.deque()
+ q.append((0,0))
+ path = collections.deque()
+ board = {}
+ board[(0,0)] = "."
+
+ c = intcode.Computer([int(x) for x in input[0].split(",")])
+
+ while not c.SIG_HALT:
+ if len(q) == 0:
+ break
+ c.step()
+ if c.SIG_INPUT:
+ direction = 0
+ prev_x, prev_y = cur_x, cur_y
+ if len(path) == 0:
+ # find new path
+ for n in neighbours((cur_x, cur_y)):
+ if n not in q and n not in board:
+ q.append(n)
+ if (cur_x, cur_y) in q:
+ q.remove((cur_x, cur_y))
+ next = q.pop()
+ path = get_path((cur_x, cur_y), next, board)
+ next_step = path.popleft()
+ if next_step[1] == cur_y-1:
+ direction = 1
+ cur_y -= 1
+ elif next_step[1] == cur_y+1:
+ direction = 2
+ cur_y += 1
+ elif next_step[0] == cur_x-1:
+ direction = 3
+ cur_x -= 1
+ elif next_step[0] == cur_x+1:
+ direction = 4
+ cur_x += 1
+ else:
+ print("invalid path")
+ break
+ c.input = direction
+ c.SIG_INPUT = False
+ if c.SIG_OUTPUT:
+ if c.output == 0:
+ board[(cur_x, cur_y)] = "#"
+ cur_x, cur_y = prev_x, prev_y
+ elif c.output == 1:
+ board[(cur_x, cur_y)] = "."
+ elif c.output == 2:
+ board[(cur_x, cur_y)] = "S"
+ oxygen = (cur_x, cur_y)
+ else:
+ break
+ c.output = None
+ c.SIG_OUTPUT = False
+ return len(get_path((0,0), oxygen, board))
+
+def pt2(input):
+ cur_x = cur_y = 0
+ q = collections.deque()
+ q.append((0,0))
+ path = collections.deque()
+ board = {}
+ board[(0,0)] = "."
+ oxygen = (0,0)
+
+ c = intcode.Computer([int(x) for x in input[0].split(",")])
+
+ while not c.SIG_HALT:
+ if len(q) == 0:
+ break
+ c.step()
+ if c.SIG_INPUT:
+ direction = 0
+ prev_x, prev_y = cur_x, cur_y
+ if len(path) == 0:
+ # find new path
+ for n in neighbours((cur_x, cur_y)):
+ if n not in q and n not in board:
+ q.append(n)
+ if (cur_x, cur_y) in q:
+ q.remove((cur_x, cur_y))
+ next = q.pop()
+ path = get_path((cur_x, cur_y), next, board)
+ next_step = path.popleft()
+ if next_step[1] == cur_y-1:
+ direction = 1
+ cur_y -= 1
+ elif next_step[1] == cur_y+1:
+ direction = 2
+ cur_y += 1
+ elif next_step[0] == cur_x-1:
+ direction = 3
+ cur_x -= 1
+ elif next_step[0] == cur_x+1:
+ direction = 4
+ cur_x += 1
+ else:
+ print("invalid path")
+ break
+ c.input = direction
+ if c.SIG_OUTPUT:
+ if c.output == 0:
+ board[(cur_x, cur_y)] = "#"
+ cur_x, cur_y = prev_x, prev_y
+ elif c.output == 1:
+ board[(cur_x, cur_y)] = "."
+ elif c.output == 2:
+ board[(cur_x, cur_y)] = "S"
+ oxygen = (cur_x, cur_y)
+ else:
+ break
+ c.output = None
+
+ steps = 0
+ visited = set(oxygen)
+ cur_layer = []
+ next_layer = [oxygen]
+ while True:
+ cur_layer = next_layer.copy()
+ next_layer = []
+ for p in cur_layer:
+ for n in neighbours(p):
+ if n in board and board[n] != "#" and n not in visited:
+ visited.add(n)
+ next_layer.append(n)
+ if len(next_layer) == 0:
+ break
+ steps += 1
+ return steps
+
+def draw(board, droid=None, path=None, visited=None):
+ min_x=max_x=min_y=max_y = 0
+ for p in board:
+ min_x = min(p[0], min_x)
+ max_x = max(p[0], max_x)
+ min_y = min(p[1], min_y)
+ max_y = max(p[1], max_y)
+ s = ""
+ for y in range(min_y-1, max_y+2):
+ s += "\n"
+ for x in range(min_x-1, max_x+2):
+ point = (x, y)
+ if droid is not None and point == droid:
+ s += "D" * 2
+ elif path is not None and point in path:
+ s += "\u2591" * 2
+ elif visited is not None and point in visited:
+ s += "." * 2
+ elif point in board:
+ if board[point] == "#":
+ s += "\u2588" * 2
+ elif board[point] == "S":
+ s += "\u2591" * 2
+ else:
+ s += " " * 2
+ else:
+ s += "." * 2
+ return s
+
+def visualize(input):
+ cur_x = cur_y = 0
+ q = collections.deque()
+ q.append((0,0))
+ path = collections.deque()
+ board = {}
+ board[(0,0)] = "."
+
+ c = intcode.Computer([int(x) for x in input[0].split(",")])
+
+ while not c.SIG_HALT:
+ if len(q) == 0:
+ break
+ c.step()
+ if c.SIG_INPUT:
+ direction = 0
+ prev_x, prev_y = cur_x, cur_y
+ if len(path) == 0:
+ # find new path
+ for n in neighbours((cur_x, cur_y)):
+ if n not in q and n not in board:
+ q.append(n)
+ if (cur_x, cur_y) in q:
+ q.remove((cur_x, cur_y))
+ next = q.pop()
+ path = get_path((cur_x, cur_y), next, board)
+ next_step = path.popleft()
+ if next_step[1] == cur_y-1:
+ direction = 1
+ cur_y -= 1
+ elif next_step[1] == cur_y+1:
+ direction = 2
+ cur_y += 1
+ elif next_step[0] == cur_x-1:
+ direction = 3
+ cur_x -= 1
+ elif next_step[0] == cur_x+1:
+ direction = 4
+ cur_x += 1
+ else:
+ print("invalid path")
+ break
+ c.input = direction
+ if c.SIG_OUTPUT:
+ if c.output == 0:
+ board[(cur_x, cur_y)] = "#"
+ cur_x, cur_y = prev_x, prev_y
+ elif c.output == 1:
+ board[(cur_x, cur_y)] = "."
+ elif c.output == 2:
+ board[(cur_x, cur_y)] = "S"
+ oxygen = (cur_x, cur_y)
+ else:
+ break
+ time.sleep(0.005)
+ print(draw(board, droid=(cur_x, cur_y)))
+ c.output = None
+
+ get_path((0,0), oxygen, board, draw_search=True)
+
+ steps = 0
+ visited = set(oxygen)
+ cur_layer = []
+ next_layer = [oxygen]
+ while True:
+ cur_layer = next_layer.copy()
+ next_layer = []
+ for p in cur_layer:
+ for n in neighbours(p):
+ if n in board and board[n] != "#" and n not in visited:
+ visited.add(n)
+ next_layer.append(n)
+ if len(next_layer) == 0:
+ break
+ steps += 1
+
+if __name__ == "__main__":
+ input = open("../input/15", "r").readlines()
+ print(pt1(input))
+ print(pt2(input))
+ visualize(input)
diff --git a/19/py/d16.py b/19/py/d16.py
new file mode 100644
index 0000000..93b52d2
--- /dev/null
+++ b/19/py/d16.py
@@ -0,0 +1,46 @@
+def do(input, phases=100, repeats=1):
+ nums = []
+ for i in range(repeats):
+ nums += [int(x) for x in input[0].strip()]
+
+ for phase in range(phases):
+ #print(phase)
+ new_list = []
+ for i in range(len(nums)): # position of number to calculate
+ new_num = 0
+ for k in range(len(nums)):
+ mod = (k+1) % (4*(i+1))
+ if mod >= i + 1 and mod < 2*i + 2:
+ new_num += nums[k]
+ elif mod >= 3*i + 3:
+ new_num -= nums[k]
+ new_list.append(abs(new_num) % 10)
+ nums = new_list
+ return "".join([str(n) for n in nums[:8]])
+
+def pt1(input):
+ return do(input, phases=100, repeats=1)
+
+def pt2(input, phases=100, repeats=10000):
+ offset = int(input[0][:7])
+ nums = []
+ for i in range(repeats):
+ nums += [int(x) for x in input[0].strip()]
+ nums = nums[offset:]
+ for phase in range(phases):
+ #print(phase)
+ nums = nums[::-1]
+ new_nums = []
+ n = sum(nums)
+ while len(nums) != 0:
+ new_nums.append(abs(n) % 10)
+ n -= nums.pop()
+ nums = new_nums
+ return "".join([str(n) for n in nums[:8]])
+
+if __name__ == "__main__":
+ input = open("../input/16", "r").readlines()
+ ans1 = pt1(input)
+ ans2 = pt2(input)
+ print(ans1)
+ print(ans2)
diff --git a/19/py/d17.py b/19/py/d17.py
new file mode 100644
index 0000000..b12e03a
--- /dev/null
+++ b/19/py/d17.py
@@ -0,0 +1,305 @@
+import intcode
+from collections import deque
+import heapq as heap
+import time
+
+def draw(view, intersections={}, robot=None, direction=None):
+ min_x=max_x=min_y=max_y = 0
+ for p in view:
+ min_x = min(p[0], min_x)
+ max_x = max(p[0], max_x)
+ min_y = min(p[1], min_y)
+ max_y = max(p[1], max_y)
+ s = ""
+ for y in range(min_y, max_y+1):
+ s += "\n"
+ for x in range(min_x, max_x+1):
+ point = (x, y)
+ if robot is not None and point == robot:
+ if direction == 0:
+ s += ">"
+ elif direction == 1:
+ s += "v"
+ elif direction == 2:
+ s += "<"
+ elif direction == 3:
+ s += "^"
+ else:
+ s += "D"
+ elif point in intersections:
+ s += "O"
+ elif point in view:
+ s += view[point] * 1
+ else:
+ s += " " * 1
+ return s
+
+def neighbours(p):
+ return [(p[0]+1, p[1]), (p[0]-1, p[1]), \
+ (p[0], p[1]+1), (p[0], p[1]-1)]
+
+def get_infront(robot, direction):
+ dx=dy = 0
+ if direction == 0:
+ dx = 1
+ elif direction == 1:
+ dy = 1
+ elif direction == 2:
+ dx = -1
+ else:
+ dy = -1
+ return (robot[0]+dx, robot[1]+dy)
+
+def get_behind(robot, direction):
+ dx=dy = 0
+ if direction == 0:
+ dx = -1
+ elif direction == 1:
+ dy = -1
+ elif direction == 2:
+ dx = 1
+ else:
+ dy = 1
+ return (robot[0]+dx, robot[1]+dy)
+
+def get_turn(robot, direction, point):
+ dx = point[0] - robot[0]
+ dy = point[1] - robot[1]
+ if dx == 1:
+ turn_direction = 0
+ elif dy == 1:
+ turn_direction = 1
+ elif dx == -1:
+ turn_direction = 2
+ else:
+ turn_direction = 3
+ if direction == turn_direction:
+ return None
+ if (direction + 1) % 4 == turn_direction:
+ return "R"
+ elif (direction - 1) % 4 == turn_direction:
+ return "L"
+ else:
+ return False
+
+def get_direction(direction, turn):
+ if turn == "L":
+ return (direction - 1) % 4
+ elif turn == "R":
+ return (direction + 1) % 4
+ else:
+ return False
+
+def get_turnable_points(scaffolds, robot, direction):
+ valid = set()
+ for n in neighbours(robot):
+ if n in scaffolds and n != get_behind(robot, direction):
+ valid.add(n)
+ return list(valid)
+
+def pt1(input):
+ c = intcode.Computer([int(x) for x in open("../input/17", "r").readlines()[0].split(",")])
+
+ view = {}
+ scaffolds = []
+ buffer = ""
+ x=y = 0
+ while not c.SIG_HALT:
+ c.step()
+ if c.SIG_INPUT:
+ print("input??")
+ break
+ if c.SIG_OUTPUT:
+ if c.output == 10:
+ y += 1
+ x = 0
+ elif c.output == 35:
+ view[(x,y)] = "#"
+ scaffolds.append((x,y))
+ x += 1
+ elif c.output == 46:
+ view[(x,y)] = "."
+ x += 1
+ else:
+ view[(x,y)] = "#"
+ scaffolds.append((x,y))
+ robot = (x,y)
+ if c.output == 60: # <
+ direction = 2
+ elif c.output == 62: # >
+ direction = 0
+ elif c.output == 94: # ^
+ direction = 3
+ elif c.output == 86 or c.output == 118: # V or v
+ direction = 1
+ else:
+ print("????????????????")
+ break
+ x += 1
+ buffer = ""
+ c.output = None
+ c.SIG_OUTPUT = False
+ #print(draw(view))
+
+ intersections = set()
+ al_sum = 0
+ for s in scaffolds:
+ ns = 0
+ for n in neighbours(s):
+ if n in scaffolds:
+ ns += 1
+ if ns == 4:
+ intersections.add(s)
+ al_sum += s[0] * s[1]
+ #print(intersections)
+ #print(draw(view, intersections=intersections, robot=robot, direction=direction))
+ return al_sum
+
+def pt2(input):
+ c = intcode.Computer([int(x) for x in open("../input/17", "r").readlines()[0].split(",")])
+
+ view = {}
+ scaffolds = []
+ buffer = ""
+ x=y = 0
+ while not c.SIG_HALT:
+ c.step()
+ if c.SIG_INPUT:
+ print("input??")
+ break
+ if c.SIG_OUTPUT:
+ if c.output == 10:
+ y += 1
+ x = 0
+ elif c.output == 35:
+ view[(x,y)] = "#"
+ scaffolds.append((x,y))
+ x += 1
+ elif c.output == 46:
+ view[(x,y)] = "."
+ x += 1
+ else:
+ view[(x,y)] = "#"
+ scaffolds.append((x,y))
+ robot = (x,y)
+ if c.output == 60: # <
+ direction = 2
+ elif c.output == 62: # >
+ direction = 0
+ elif c.output == 94: # ^
+ direction = 3
+ elif c.output == 86 or c.output == 118: # V or v
+ direction = 1
+ else:
+ print("????????????????")
+ break
+ x += 1
+ buffer = ""
+ c.output = None
+ c.SIG_OUTPUT = False
+ #print(draw(view))
+
+ intersections = set()
+ for s in scaffolds:
+ ns = 0
+ for n in neighbours(s):
+ if n in scaffolds:
+ ns += 1
+ if ns == 4:
+ intersections.add(s)
+
+ '''
+ For each path, take steps until a wall is reached. When a wall is reached, tuirn
+ towards the next unvisited point. Repeat until the end is reached.
+
+ Structure of a deque-element:
+ Each search-element consists of a single tuple. The tuple contains
+ - The robot's position
+ - The robot's direction (after turning)
+ - The instruction-set up to that point
+ - The current WIP instruction
+ - All points that have been visited (as a set)
+
+ Structure of the instruction-set:
+ The instruction-set consists of a list of tuples. The tuples contain
+ - A turn-instruction
+ - The number of steps to take (after turning)
+ For example:
+ [(R,8), (R,8), (R,4), (R,4), (R,8)]
+ '''
+
+ current = None
+ direction = 2
+ paths = deque()
+ visited = set()
+ visited.add(robot)
+ paths.append((robot, direction, [], ["L", 0], visited))
+ while True:
+ if current is None:
+ current = paths.popleft()
+ robot = current[0]
+ direction = current[1]
+ instruction_set = current[2]
+ wip_instruction = current[3]
+ visited = current[4].copy()
+ if len(visited) == len(scaffolds):
+ #print("len(visited) == len(scaffolds)")
+ instruction_set.append(wip_instruction)
+ break
+ if get_infront(robot, direction) not in scaffolds:
+ # wall in front. save
+ instruction_set.append(wip_instruction)
+ avail_points = get_turnable_points(scaffolds, robot, direction)
+ if len(avail_points) == 0:
+ if len(visited) == len(scaffolds):
+ break
+ else:
+ current = None
+ continue
+ wip_instruction = [get_turn(robot, direction, avail_points[0]), 0]
+ direction = get_direction(direction, get_turn(robot, direction, avail_points[0]))
+ paths.append((robot, direction, instruction_set, wip_instruction, visited))
+ current = None
+ else: # wall not in front
+ '''
+ if robot in intersections and wip_instruction[1] != 0:
+ # queue intersections
+ new_instruction_set = instruction_set.copy()
+ new_instruction_set.append(wip_instruction.copy())
+ paths.append((robot, get_direction(direction, "L"), \
+ new_instruction_set.copy(), ["L", 0], visited))
+ paths.append((robot, get_direction(direction, "R"), \
+ new_instruction_set.copy(), ["R", 0], visited))
+ '''
+ # take step
+ robot = get_infront(robot, direction)
+ visited.add(robot)
+ wip_instruction[1] += 1
+
+ #print(instruction_set)
+ s = ""
+ for instruction in instruction_set:
+ s += str(instruction[0]) + "," + str(instruction[1]) + "\n"
+ #print(s)
+
+ c.reset()
+ c.memory[0] = 2
+ c.queue_ascii("A,A,B,C,C,A,C,B,C,B")
+ c.queue_ascii("L,4,L,4,L,6,R,10,L,6")
+ c.queue_ascii("L,12,L,6,R,10,L,6")
+ c.queue_ascii("R,8,R,10,L,6")
+ c.queue_ascii("n")
+ c.SIG_ASCII = True
+ output = []
+ while not c.SIG_HALT:
+ c.step()
+ if c.SIG_OUTPUT:
+ output.append(c.output)
+ c.output = None
+ c.SIG_OUTPUT = False
+ return output[-1]
+
+if __name__ == "__main__":
+ input = open("../input/17", "r")
+ print(pt1(input))
+ print(pt2(input))
diff --git a/19/py/intcode.py b/19/py/intcode.py
new file mode 100644
index 0000000..6079250
--- /dev/null
+++ b/19/py/intcode.py
@@ -0,0 +1,153 @@
+from collections import deque
+param_amount = {1:3, 2:3, 3:1, 4:1, 5:2, 6:2, 7:3, 8:3, 9:1, 99:0}
+
+ADD = 1
+MUL = 2
+IN = 3
+OUT = 4
+JNZ = 5
+JEZ = 6
+LET = 7
+EQV = 8
+BAS = 9
+HAL = 99
+
+class Computer(object):
+ def __init__(self, program):
+ self.program = program
+ self.memory_size = len(self.program)
+
+ self.reset()
+
+ def reset(self):
+ self.memory = self.program.copy()
+ self.extra_memory = {}
+ self.instruction_cache = {}
+ self.pointer = 0
+ self.phase_read = False # for day 7
+ self.relative_base = 0
+
+ self.input = None
+ self.input_queue = deque()
+ self.output = None
+
+ self.SIG_INPUT = False
+ self.SIG_ASCII = False
+ self.SIG_OUTPUT = False
+ self.SIG_HALT = False
+
+ def parse_op(self, op):
+ # if op in self.instruction_cache:
+ # return self.instruction_cache[op]
+ code = op % 100
+ ops = str(op).zfill(param_amount[code]+2)
+ self.instruction_cache[op] = [code] + [int(x) for x in ops[:-2][::-1]]
+ return self.instruction_cache[op]
+ #return [code] + [(op // 10**(i+2)) % 10**(i+1) for i in range(param_amount[code])]
+
+ def clear_flags(self):
+ self.input = None
+ self.output = None
+
+ def write(self, addr, val):
+ if addr >= self.memory_size:
+ self.extra_memory[addr] = val
+ else:
+ self.memory[addr] = val
+
+ def get(self, addr):
+ if addr >= self.memory_size:
+ return self.extra_memory.get(addr, 0)
+ return self.memory[addr]
+
+ def get_param(self, inst, num):
+ if inst[num] == 0:
+ return self.get(self.get(self.pointer + num))
+ elif inst[num] == 1:
+ return self.get(self.pointer + num)
+ elif inst[num] == 2:
+ return self.get(self.relative_base + self.get(self.pointer + num))
+
+ def write_param(self, inst, num, val):
+ if inst[num] == 0:
+ self.write(self.get(self.pointer + num), val)
+ elif inst[num] == 1:
+ self.write(self.pointer + num, val)
+ elif inst[num] == 2:
+ self.write(self.relative_base + self.get(self.pointer + num), val)
+
+ def queue_input(self, data: list):
+ for val in data:
+ self.input_queue.append(data)
+
+ def queue_ascii(self, data: str, newline=True):
+ for c in data:
+ if c == "\n":
+ self.input_queue.append(10)
+ else:
+ self.input_queue.append(ord(c))
+ if newline:
+ self.input_queue.append(10)
+
+ def step(self):
+ if self.SIG_OUTPUT and self.output is None:
+ self.SIG_OUTPUT = False
+ if self.SIG_INPUT and self.input is not None:
+ self.SIG_INPUT = False
+
+ inst = self.parse_op(self.memory[self.pointer])
+ if inst[0] == HAL:
+ self.SIG_HALT = True
+ return
+ elif inst[0] == ADD:
+ self.write_param(inst, 3, \
+ self.get_param(inst, 1) + self.get_param(inst, 2))
+ self.pointer += 4
+ elif inst[0] == MUL:
+ self.write_param(inst, 3, \
+ self.get_param(inst, 1) * self.get_param(inst, 2))
+ self.pointer += 4
+ elif inst[0] == IN:
+ if self.SIG_ASCII and len(self.input_queue) != 0:
+ self.input = self.input_queue.popleft()
+ if self.input is None:
+ self.SIG_INPUT = True
+ return
+ self.write_param(inst, 1, self.input)
+ self.input = None
+ self.SIG_INPUT = False
+ self.pointer += 2
+ elif inst[0] == OUT:
+ if self.SIG_OUTPUT:
+ return
+ self.output = self.get_param(inst, 1)
+ self.SIG_OUTPUT = True
+ self.pointer += 2
+ elif inst[0] == JNZ:
+ if self.get_param(inst, 1) != 0:
+ self.pointer = self.get_param(inst, 2)
+ else:
+ self.pointer += 3
+ elif inst[0] == JEZ:
+ if self.get_param(inst, 1) == 0:
+ self.pointer = self.get_param(inst, 2)
+ else:
+ self.pointer += 3
+ elif inst[0] == LET:
+ self.write_param(inst, 3, 1 if \
+ self.get_param(inst, 1) < self.get_param(inst, 2) \
+ else 0)
+ self.pointer += 4
+ elif inst[0] == EQV:
+ self.write_param(inst, 3, 1 if \
+ self.get_param(inst, 1) == self.get_param(inst, 2) \
+ else 0)
+ self.pointer += 4
+ elif inst[0] == BAS:
+ self.relative_base += self.get_param(inst, 1)
+ self.pointer += 2
+ else:
+ print(self.memory)
+ print(self.pointer)
+ print("invalid instruction", self.memory[self.pointer])
+ print(inst)
diff --git a/19/py/main.py b/19/py/main.py
new file mode 100644
index 0000000..c45bac7
--- /dev/null
+++ b/19/py/main.py
@@ -0,0 +1,52 @@
+import time
+
+import d01
+import d02
+import d03
+import d04
+import d05
+import d06
+import d07
+import d08
+import d09
+import d10
+import d11
+import d12
+import d13
+import d14
+import d15
+import d16
+import d17
+
+mods = [d01, d02, d03, d04, d05, d06, d07, d08, d09, d10, \
+ d11, d12, d13, d14, d15, d16, d17]
+
+skip = [12, 16]
+
+timings = [[0 for _ in range(2)] for _ in range(len(mods))]
+#clock_type = time.CLOCK_MONOTONIC
+
+for mod, day in zip(mods, range(len(mods))):
+ if day+1 in skip:
+ continue
+ print("Day", str(day+1).zfill(2))
+ #t0 = time.clock_gettime_ns(clock_type)
+ print("Part", 1, mod.pt1(open("../input/" + str(day+1).zfill(2), "r").readlines()))
+ #timings[day][0] = time.clock_gettime_ns(clock_type) - t0
+ #t0 = time.clock_gettime_ns(clock_type)
+ print("Part", 2, mod.pt2(open("../input/" + str(day+1).zfill(2), "r").readlines()))
+ #timings[day][1] = time.clock_gettime_ns(clock_type) - t0
+
+#print()
+#tot = 0
+#for day in range(len(timings)):
+# for part in range(2):
+# tot += timings[day][part]
+#for day in range(len(timings)):
+# if day+1 in skip:
+# print("day {0} skipped".format(str(day+1)))
+# else:
+# for part in range(2):
+# print("day {0}-{1}: {2:.2f}ms\t({3:.1f}%)".format(str(day+1).zfill(2), part+1, \
+# timings[day][part] / 1000000, 100*timings[day][part] / tot))
+#print("sum", tot / 1000000, "ms")