Browse Source

2020 day 19

master
Terrana Ninetailed 2 years ago
parent
commit
58e444aa0f
  1. 560
      2020/day19/input
  2. 56
      2020/day19/part1.hs
  3. 65
      2020/day19/part2.hs

560
2020/day19/input

@ -0,0 +1,560 @@
7: 128 83 | 90 111
67: 128 128
73: 83 128
38: 90 55 | 128 126
69: 90 49 | 128 7
82: 122 128 | 111 90
55: 90 128 | 128 128
44: 51 90 | 123 128
25: 128 10 | 90 135
109: 128 16 | 90 68
129: 97 132
21: 97 128 | 111 90
71: 128 95 | 90 110
43: 128 104 | 90 134
120: 90 97 | 128 67
59: 77 90 | 95 128
50: 95 90
127: 90 106 | 128 61
35: 90 104 | 128 45
83: 128 90
10: 62 90 | 63 128
1: 90 112 | 128 103
57: 99 90 | 40 128
40: 128 2 | 90 93
2: 83 128 | 83 90
91: 128 96 | 90 64
45: 128 90 | 90 90
110: 90 90
123: 128 87 | 90 79
104: 128 132 | 90 90
121: 95 128 | 111 90
111: 90 128 | 90 90
124: 128 108 | 90 54
88: 55 128 | 26 90
125: 128 126 | 90 83
58: 90 78 | 128 14
118: 55 90 | 134 128
48: 116 90 | 86 128
130: 23 90 | 97 128
61: 90 43 | 128 56
78: 90 47 | 128 37
128: "b"
99: 128 114 | 90 7
87: 128 111 | 90 23
84: 128 62 | 90 101
135: 34 90 | 30 128
41: 90 121 | 128 100
63: 45 90 | 122 128
115: 118 90 | 94 128
37: 97 90 | 55 128
23: 132 132
65: 128 45
98: 128 1 | 90 70
36: 90 69 | 128 19
122: 90 128
32: 128 50 | 90 85
114: 23 128 | 67 90
17: 128 83 | 90 55
103: 128 102 | 90 22
79: 128 67 | 90 134
94: 90 111 | 128 97
30: 128 122 | 90 77
89: 132 55
100: 122 128 | 126 90
11: 42 31
18: 21 90 | 7 128
86: 117 128 | 17 90
33: 95 90 | 111 128
6: 65 90 | 100 128
102: 35 90 | 49 128
14: 39 90 | 53 128
66: 83 90 | 67 128
105: 104 128 | 126 90
47: 90 26 | 128 122
16: 90 44 | 128 25
72: 97 128 | 55 90
53: 55 128 | 122 90
112: 128 6 | 90 124
75: 128 82 | 90 94
70: 90 24 | 128 52
31: 98 128 | 109 90
126: 90 90 | 128 128
49: 23 90 | 111 128
28: 90 130 | 128 129
54: 90 110 | 128 45
97: 128 90 | 90 128
80: 127 128 | 119 90
107: 128 133 | 90 92
27: 90 117 | 128 88
60: 90 23 | 128 134
0: 8 11
39: 23 90 | 55 128
13: 134 90 | 67 128
52: 115 90 | 41 128
77: 128 90 | 132 128
117: 128 67 | 90 83
90: "a"
76: 134 132
26: 128 90 | 128 128
4: 58 128 | 9 90
20: 128 111 | 90 77
42: 46 128 | 15 90
116: 89 128 | 131 90
9: 18 90 | 84 128
5: 90 134 | 128 77
113: 128 76 | 90 20
95: 90 128 | 132 90
92: 113 128 | 32 90
12: 128 72 | 90 66
8: 42
74: 128 111 | 90 122
15: 3 90 | 107 128
24: 28 128 | 81 90
34: 90 67 | 128 95
3: 48 90 | 91 128
131: 132 26
51: 73 128 | 60 90
93: 126 90 | 67 128
108: 134 90 | 95 128
68: 57 128 | 36 90
133: 29 90 | 27 128
64: 38 90 | 59 128
56: 126 132
62: 128 122 | 90 97
85: 128 134 | 90 26
96: 33 90 | 5 128
132: 90 | 128
29: 5 128 | 74 90
81: 128 105 | 90 17
119: 90 12 | 128 75
101: 134 90
22: 128 131 | 90 71
134: 90 90 | 132 128
46: 4 90 | 80 128
106: 13 90 | 89 128
19: 125 128 | 120 90
bbbbababababbbaabbabbabbaabaabaaaabaabaabbabbbbbaabbbaaaaabbaabbaaaaaabb
baabbbbbbbabbbaaaaababbaaabbabbbaababbbb
abbbabaabaaabbaabababbaa
babbabaaababbbababbbabaabbbbbaaaabbbaaba
baabaababbbabababbbbaaaaabababbb
aabaaabbabaaaaaabaaabbaaabbaaababaaaabbaabaababaaaaabbab
abbbaabbbaababbaabbabbab
abbaababbbbbabbabaabaaaa
aaabaaabaabaabbbbbbbaaba
baaababbbabbbababaaabbbbaaabaaabaabbbbba
bbaabaaabaabaabaabbbbaaabbbbbaaaabbbaabbbabbaabbaabaabaabaaaabbb
babbabbbbabbbabaabbbbaaa
bbbaababaabaabbbaabaaabbaaabaabb
aabbbabbbabaaaababbbbbabaaaaabba
bbbbbbabaaaabbbababaaabb
aaababababababbaabbabbaaaaaabaabbabbbbbbabaaaaaabbbbbaabaabbaabb
aabbabaaaaababbaaabaabaa
aababaaaaabbaabaabbbbababaabaaabaabbbababbbbbaaabaaababbaaababba
aabbaaaaabbaabbbabbabaaababbabaaabaabbab
baaababababaabbbabbbbbbbabbabbbbbabababa
aababbababbbabaaaababababababaaa
aaaabbbabbaaaabababaaaabbaabaaab
ababbabbabaaaaaaabbababa
babbbbabababbabbbbabaabbbbbabbabbbbabbbb
bbbbabbbaaabbbaaababbbbabbabaabababaaaababbbabbabababbbbbaababbb
ababbbaababababbababbaba
baaababbababbbabaabaaabbaaabaabaaaaaaaaa
baaabbbaabbbbbbbaabbbbabaaaabbaaabbbbbbaaaaaabbbaababaaa
aaaaaaabbaaaabaabbbabbab
bbaaabbbbbaababaababaaba
abbbbbbabbabaabbaaaaabaabbbaabbbaaaabbbabababbaabaabbaabaaababba
bbbbaaaabbbbababaabababb
bbbbabbbbbbbabbabbaabbba
abbbaaaabbbbbbaaaabababbababbbbabbbabaaaabbaaaaaabbbabaa
babababbabbbaaaabbbaabbabbbbabaa
bbaabbabbbbbaababbbbaabbaaabbaababaabaaaaaaabbab
aabaaababbaaabbbbabbaaab
abbaaaabbaaababbbbbbabaa
abbaaabababbaabbbbaaabbabbbabbbb
aabbaaaaaaabbbbaababbbbbaaaabaababaabaaaaabaababbbbabbbb
abbaaabaabbabaaabbabbaba
ababbbaababbaaaaababaaab
bbbbbbaaaabbbbaabbaaaabaaababbbb
bbbaabbabbaaababbababbbb
baaababbbabbabbbbabababa
bbaaabaabaaabbbbabbaabba
aaabbbbaababbbabbaaaaabaaabbaabbaaababbbaabaaaaa
abbaaaababbbabbbaabababb
babaabaabbabaabbaaabaaaabaabbbabbbabbabbbbbbbbab
babaaaababbbabbbbbbaabaabaababababaabbaaabbabaabaaaabbbaabbabbababababbbabaabaab
bbbbababbaababaaaaabbbbaabaaabaabaaaababaabbabbaaabaabab
aaababaababbaabbbabaabaaaaabababbbabbbbaaaabbbabbabababaababbaab
baaaabaaaabbaaaabaabbabababbbbbabaaabbaaabbabbab
aaabbbbbabaaaaaaababbbbaabbaabba
ababaaababbbaaabbaaaaabbbabaaaababaabbbbbabaabaaaabbbaaa
babbbaababbbbaabbbbaaababaabaaaa
abbaaabbaaaaabbbbbbababbbbbbbabababbabaababbbaaaaabaaaabbaabbaab
abaabbbabaaabbbabbbabaabbbaabbaaabbbababbbbaabaa
bbbabbaaaababbaaaaababbb
ababaabbbbbbababaaaabbbabaaabbabbbababba
babaabbbbaabbbaababbabaaaaabaaab
abaaaabaaabbbbbaaaaabbabaabbbbabaababbabbbbbbbabababaabbbbabbbba
babaaaabbbbbabbaaabaaabaabbaababaabbabbaabababaa
abbbabbbbbabbaabaabaabaaabbaaaaababaaabbaaabaaababbaabbaaabbbaaaaabbbbbaabaabaaa
abbabbaaaaaabaaaaaaaaaaabbbababb
aababbbaabaaaababaaabbbbaabbbbbbaaabbbbb
abaaabaaaaababbaababbbbbbbaaaababbbbbbbbabbbbbaa
bbbbbbbbbaaaababaaababababaabbab
aaabaabababaabababaaaaabaabbbababbaabaaaaaaaaaaabbbaabaa
bbabbabbbbaaabaababaabaaabbbaaaabaabaaab
aaabababbabababbaaababbabbaaabbbaabbaaba
abababbaaabbbabaaaaabbbaabbabaaabbaabbaa
babababbbbaaaaaaaabbaaaaaababbbb
baababaabababaabaabbaaaabbabbaabbbaababbabaabbbb
aaaaabbbaababbabaaabbbabbbbbbbabbbbbaaaabaaabaababbbaaba
babaabababaabbbabbbabaaaabbbbbabaaabaaaabbabbaababaaaaabbbbaabbabbaabbba
bbbbabbababababbbbbaababbbaabaaaabaaabaaaaabaaaabbabbbabbaaaaaba
aababbbaaaabbbbbaaabbbabbaabbbbbbbabaaababaaabab
abbaaaaabbaaabbbaaaabbbaaaabbaabbbbaabaa
ababaababaaaababbbbababaaabaabab
aaabaabaabbbabaaabbababa
babababbbbbbabaaabaaabaabbaababb
baaabbbbbabbaaabbbabbbaa
abbbbbbaaaabaababaaaaaaa
baabbaabbbbbaaaaabaaabbb
babababbaaabbabababbababaaaabbbaaabbabbbbbaabaab
baaaabbbaababbbabbaaaaaabbaababb
bababbabbbaaabbbabaaaabaaaababbabababbaa
abbaaaababbaabaaabbabbaaabbbababababaaaaaaabaaababaaabbababbbabbaaaabaaaababbaba
bbbabababbaaabbbaaabbbbbaaabaabb
bbabaaabaabbaaabaabaabbaaabbbaab
bbaaaabbbabaabbbaaaaaaba
bbabbbbabbbbbbbbbbaaaaaabbbaaababaaaaaab
abbaabaabaabaaabababbabbbbaababaabbababa
aaabbbbbbababaabbbabaabbbababbabbaaaabababbaaabaababaaaa
babaabbbbbabbbaabbbbbbbaabbabaaabaabbaaaaabaaaaa
aababbabbabaabaaabbababa
aaaabbbaabbaaabababababa
bbbabababbabbbabaaabbaababbaaabaabbabbabbbbbbbbb
babaabaabaaababbbaabbaabbbbbbbbaabbbaaaaabaabbab
bbaabbbababbbbbaaabaabbabbbabbaaaaaaabbbbbbabbabaaabbbabbbaabaaaabbbbbba
ababbbbbaabaabbabaababbaabbbbbabaaaabaaa
abbbabbbabaaabbaabbaabbbaabbbbbababababa
bbabbabbbbabaabaabbbbbabaaaaabbbbabaaabb
bbbbbaaaababbbabbbbaaaaabbaaabbbbbaaabaaabaaababaaaaaaba
baaaaabbaababaaaababaababababbababbbaabaabbaabaa
bbaaaabbbabbbbbbbabbbaab
aabbbbaabbbbbababaabbbab
bbbaabbbabaabbabbabababbbabbbbaabaabbaab
aaabbabaaabaabbababaabbbabbabaaaabbaabba
abbbbbbaababbbbbbbabbbaabbbaaaaabbabbabaaabbbabaabababbbbaaaaaabbabbbabb
abbaaaabbbbaaaaaabaabaaabbabbabbbbaaabababbabaabaababaab
abbbaabbbbbbabbbaaaaabbaaaaababbabbaaaba
bbabaabbbbbbababaabaaababbbaabbb
aaaaabbbbaaababababbababbbbaaaabbaabbbab
bbbbbabbabaabbabaaaabbbb
bbbaaaaabbbbbbbbaaabbbabaababbabaaaaabbbbaabaabaaaabbaaabbababaaaaaaabba
aabaabbabbbbbbaababbaaba
bababbbaaabbbabaababbbbabbabbaaababbbaaababbaabababaabbbbabbbbba
ababbabbaabaaabaaabbaaabbbbbabbbbbbabaaa
baababaabaaaabbbabbbbabb
bbbbbbabaababaaaababaabbabbbaaba
babbabbaabaaaabbbaabaabbbbaabbba
aabaaabbbaaababaabaaaaaabaaabbabaabaaaaa
aababaaabbbaaaaaaaabbbbbaababababaaababbbabbaaab
bbabababbaaaabbababaabbaaabbaabbbabaaabb
babaabbbbaaabbaaabaabbab
baaaaabaaababbbbaaababbbbbabbaaa
baaababbbbbababaababababbbabaaabbababaaaabbbbabbbbbaaaba
abbbbbbbbbbbabbbabaabbbabaaababababbbaabaabbabbabbbabbba
bbbbbbaabaaaabbbabaaaabbbbbaaabbabbbbbaaaaaabbaa
baaaababaaaaaaabbabbabbaaabbabba
abbaaaabaabaabbbabbaaababaaababbbabbabbbbaabaaaa
aababaaabaaaaabbbbaababb
aaabababbabbbabaabaabbbababaabbb
babbababaaabbbbbabbaabaa
babbbbbbbbaaaaaabaabaababaabbbabaaaababb
aabaaabababaababbaaabbba
ababbbbbabbaababbaaaaaba
aaaabaabaabaabbbabbbabaaabbbabbbbaaaabbaaaabbaaababbaaabaabaaaab
babbbbbabbbbbbabaaababbabbaaaabaaaaaaaba
baaababbbbabbaabababababaabaabbaaaaababb
baaaabaabbabaabbaaaaaaba
bbbbbaaaabbabababbbabbabaabaaabbaaaaaabbbbbbbbaaaabbaaab
abababbababbaabbbbaabbbbbbabbaabaabbabbbababbbaababaaaaaaabbaaab
baaaabaaabbaaabaaaabaabb
baaaabaabaaaabaabbabaabbbaabbbba
aaababaaaaabbbabbabbabba
abbaaabaababbbabababaabababbababbabbabba
ababababbbaaabbbbbabaabbbaabaaab
bbbbbbbaaababbaabbbbbbbbabbabbba
aabbaabbbaaaaabaaabbaaababbaababbaabaabaababababaabbbbab
bbabbbaaabaaabaaaababaababaaabbb
bbaababaaaaaababaaaaaaaabaaabaaabbbbaaababbaabbbbbbaababbabbabaabbabaaabbababbababbaabbb
aababbbababbbbbaaabbaaabbbbbabaa
aaaaababbabbaababbabaababbbbaabbaaabaabbababaaba
abbbaabbbbaabbabbbabbbbbbabbaaaa
baaaababbabbbbabbbabaabbbbabaaba
baaaabbbbbbaaaaaaababbbababbbbbaaaabbbbbabaababa
bbaaaaaaabaaabbaababbabbabaababa
aababbbabbbaaaaabbbaababaaababbabbbbabbabaaaabba
aababaaabbbbbaaaabbaaaaaaaaaabab
abbaaabaabbbabbaababaabbbaababbabababaaa
baababbabbabbabaaaababbaaabaaabbaabbabba
aababbabbababbabbbaabaaabaaabbabaabaaaab
aaabaaaaababbbaabbbaaaaabbaaaaaaabbaabbaaaabaaaaaababbbababaaaababaaaaabbbbaaaba
abaaaabababaaaabbbbbbbbbbbbabbbb
bbbabbaaababbabbaababbbabbbaababbbbbbbabbbbbbabbbaaaaaab
abaabbaaaaabaababaaababaaabbbbba
babbbbaaabbaaaaabbbaaababbaababa
ababbabbbbbbabbaaaaabbbabbabaabbbbbbaabbbaaaaaaaaaaaabaa
aababbbababbabaaaabbbabbbabbbbabbbbbabbbaaaababaaabbabbbababaaabababaaab
bbabaaaabbbabbbbbbbbbabbabbbbbaabbabbbab
ababbbabbaababbabaabbbaabaaaabba
abbabaababbbabbbabababbabababbbb
bbabbbbaaaaaabbbabbbaabbaaaabaababaababb
babbbaabaaaabaaaaaababaaaabaabbabababbaabbbbbbbabbababbabbaabbbabaabbbaa
aaabbbaaabbababbaabbabab
bbabaabbbaaabbbbbaaaaaba
babababbaabbbbaabbbbbbaaaaaaaaaabbaabaabbbbbaaba
bbabaababaaaabbbabbabbab
aababbaabbbbabbaabbabbaabbbaaaaabbaabaaaaabbabbb
ababbbabbabaababababbaab
aabbbbaabbbbbababaaabababbabbaabbbababbaababbaba
abbbaabbaabbbbaaabbbbbbabbabaaabbbaababb
baaaabababbbaaaaaaabbbbaabbaaabbbbaabbaa
bbaaaabaaabbaaababbabbba
bbbaaabbbaabaabbabaaaaabbaabbababaababbbbbaaaabababaabaabbaababa
baabbababaabbbbbbabbabba
baaaaabbabbbabbbababbaab
aaabbbababbaaaabababbbaaabaababa
abbaabaabbbaaabbabaababa
abbbbbbbbabababbbababbaa
abbaaabaabbaababbbbabaab
baababbabaabababbbbbbbabbbbaaaabaaabbbbb
aabbbababbaabbbbaaaabaabbbbaaaaabaaabababaaabbbbaabbabbbbbbabaabaaaaababaaaabbbb
aaaabbbaabbaaabaaabaabbbaaabababbbbaaaba
baaaaabbbbbbbbbbaababbbabbbababaaaabbaab
abaaaaaababbbabaabbbbaaa
aabbaaaabbbbabbbaaaaabab
aaabbaabbaabbbbaaabbbaaaabbbabbabbbbaaba
babbbbbbbbaaaaaabaabbbab
aaabaabbbbbbbbbbaaabababbaaaababbbbabaaaaabbabbbbbabbabbaaaabbaabaabababaabbbabbabaabbbb
aaabbbbabbabbabbababbaba
aaabbbbbaaababababaaabbababababa
aababbaabbbbbabaaaabbbaaaababbbaabbaaabb
babaabbbbaaabababbabbbababaabbab
baabbbaabbaabbbbaaaaaabb
aaaaabbbbabbbbbaaaabababaaaabbbbabbababa
bbbaaaaaababbbaabbababaa
aabbbbabbbabbbaabababbbbbbaabbbbababaababababbaaabbbbbbaababaaababaabbaaaabaaaba
abbaabbbabbabababaabbabb
bbaaababababbabbbababbbb
baabbbaababbabababaabbbaabaaabab
babbbbaababbbbaaabbabbbababaaaaabbaababa
bbbababaabbbbbababbbaaab
ababbbbabbabbbaaababbaab
bbbbaaaaabbbbaaaabbabbbbababbaba
aabbbbaabbaaaabbababaabbbaabbaabbaaaabbbabbbaaba
bbbabbaabbbbbbaababbababaaaabbbababaabaabaaabbba
baabbaababaabbaaaabbabab
babbbbaaabbababbbbaabbbbbbababbbbabaaabb
baabbbaaabbababbbabbbaab
abaaaababbabbaababaaaabb
bbbaabababaabbaaaaabbbaabaaabbbbbabbbbabbababaaa
bbbbbbbaaababbaabaaabbab
ababaabbaabbbabaababbaaabbbabababaaaabba
aaababbabaabbbbbbaaababaaaababbaabbbbbbbaaababbb
babaababbabaabaaabbbabbbbbbaaaaabaababab
ababbaaaaaaabaabaaaabbabbbbbaaaaaaaababaaaaabbab
bbbbabbbbaabbabababbbbabaabbbbbbaabababaaabbabaaaabbbbabbabaabbaaaaababbbbaababa
aaaabbbaaababaabaaaaabaa
bbbaababaabaabbaaababbabaaaabbbaaabaaaabaaaabbbb
abbabbaaabbaaababbbabbaabbaaabbabaaaaaab
ababaabaabbbbbbabaaaaaba
babbaabbbbbbaaaaabbaaabababbabaabbbbbabb
aababaaaaabaabbaaabbaaaababaaaabbbaabaab
bababaabaabaaabaabbbaabbaabaaaaa
babbabbbabbabaaaaaaabbbabaaababbbaaaaaaa
bbabbabbaaababaabbbbbabb
abaabbaaaababaabbbbaaaaabbabaabababbabaabbbbaabaaabbbaabababbaab
baaabbaaabbbaabbbbbbaababbbaaabbaabbaaabbaaaaabaaaabaaaabbbabbabaaabbbbabbbbaabaababbbabbbbbabaa
baaaabbbaabbbbbbbbaaabbbbaaaabbbbbaaaaab
babbabababbaaabaabbabaabaabaaabababbaabbbbbabaab
bbaaaaaaaabbbabaabbabaaabaaababaabaabbbb
bbbbabbbbbabbababbbbbbbbaababbbaabababababbababa
aaaaabbbbaaaabaababbbabababaaaabbbbbaaabaaabaabb
bbaabaaaaabbbbbbbbbbbaaaabaabbab
bbababaaaabaaabbaabbbabbbbbabbaaababbabbababaabbabbbababbabbabbabbbbaaab
bbbbbababbbbbaaaaaabababbaaabbaaaabbaabb
abbbaaaaababbbbbbbabbabbaaabbbaaaaabbabababaaaabbbababbb
abaaabaaaabbbabaabbbabab
bbaaaabbaaabbbabaaabababaaabbabbaabbabbaabaabbbbbbbbbabbbaabaabb
aabbaabababaaabbabaabaaaabbabaaaaaaabbbbaaaaaaab
bbaaababababbaaaababbbaababbbabb
babaabaabbbbbaaabbbaabaa
baaaabbbababbbbabaabbaabaababaaabaababbaabbbbbaa
aabbbabababbbbaaaaababaa
bbaabaaabbbbbaaabbabbaabbabbbbbbbabaaaba
baaaababababbbbaababbaaabaaaabbbbbaaabba
bbaabbbbbabbaabbabbbabbbbbabaabbbbbbbbbabaababbb
ababbabbbbaabbbaabbbbbbaabbbabababbbbbaabbbaabaabbababbb
bbaabaaabaabbababbbbaaba
baaaaabbaabbbabbbabbabab
aaabbbaabbabbbbaabbbabaaaaabbaab
abababbababbaabbaabbabaaabababaa
bbabbabaaababaaaabbabaabbbbbbbbbaaabaabaabbbbbbabbbbbabbabbbbaaa
baaaaabbaaaabbbabbbbbbabaabaabbabababaaabababbbb
bababbabababbbbaabbbabab
aabbaaaaaaabaaabbbaaaaab
bbbbbbaaabbbabbbaabaabbaabaabababbabbbbbabbabbababaabaaaaabbabbb
babaaaabbaababbababbbbbaaaaaaaababaabaab
abbbbbabbbabbbbaaabaaaaa
ababababaaabaababbaaabba
baababaabaaabababbaaababbbbbbabbbabaaabb
bbbbbbbbaabaaababbbbababaaaabaabbbbbabaa
abaabbaaabababababbabaaabbaaabaaabaaaaaa
abbaaababbaabaaabbbaabbabbbbaaab
bbabaabbaabaaabbbaaaabababbaaaabaabbbbaaaabbbbbabbaabbab
abaaaaabbbaaaabaaaaababa
ababbabbabaaaababaaabbaabaaabbab
bbabbbbabbabaabbbbabbabbaabababaabababbb
aaabbbaaabaaaaabbaaababaabbababbabbabbbababbaaabbabaaaaa
bbaaabbbaaabaabbbaabbbba
abbaabababaaaabababbbbababaaaaabbbbbabbabbbabbbabaabaaaa
bbbababaaababaaaaabaaaaa
ababbbabbbbaababbbaaaaaaabbbbbbabbbaaabaaababbbb
aababbabbbbababaabaabbbbbbaabbaabababbababaababaaabbaaaaababbbab
baabaabaaabbaababbbbaaba
bbabbbbbbabaaabbabaabaabbbabaaabbaaabaaa
abaaaabbabbabaabbbaaaabaaaaabbaabbbbababababbabb
ababbbababaaaaabaabbabaaaaabaababaabaababbababbaaabbaabaabbaabbaaaaabbab
abbabaabbababbabaaaabbab
aabbbabaabbbaaaabbabaabbbabbaaaaabababbb
babbbbbbaabbaaaaaabbbabbbbbabaabbbbabbab
aabababaaabbaaabaaaababa
aabababababbbabaaababbababaabbbaaaabaaaababbaaab
abbababbbbaabbbbabbaabba
baaabbaaaabbaaababbaaaabbbaabbba
bbbaababaabababbbbababba
baaababbabbaaaaababaaabb
abaabbaabaabbababaaaababbabaababababbaab
bababaabbbaabbbbbababbba
abbaababbababaabbbbabababbbaababbbbaaabbbbababaaabbababa
abbbabbbbbaaaaababbbbaababbababa
abbbbabaaabbbbabbaabbbab
ababbbaabbbabbbbababbaabbbbaaaab
aaabaaabbbabbbabbbbbbbabaabbbbbbbbbaaabababaabba
abbbbbabbabaabbbababaababaabaabaaabbbbaaaaaaaaabaaabbaab
baaaabbbabbabaaaaaaaabbbabbaaaababababaa
aababababaabaabaabaaaaaaaabababb
baaaabaaaabbaaaabbbbaaaaabbaabba
bbbbbbbabbbbabbbabbbbaab
aabbbabbaabbabaaaaaaabbbababbbbabbabbaabbaabababbbaabbbabbbaaaba
aababbaabbbbbbaaaababbbb
bababaabaabaaabbbbaabaaabbabbabbaabbbaab
bbabbabbabbaaaaabbaaaabbbabaaaaa
bbbbbabaabbabbaabbabbabbbbaaabbbbbaaaabbbbbaabbbaabaababbbbaabbb
aaabababababbbbabbbaabbabbabbbab
aaaaababaaababbbaabaaaabaaaabbaabbbaaaab
baabbbaabbaabaaabbabaaabaaababaabaaababbabbbabaabbaabbaaaaaabbaa
abbabbaaaaabbbbaabbbbbabbabbaaab
baaaababaababbabbbbbabbabaababaaabbaaaabbbabaaaaaabbabba
aababbabaaaabbbaaabaaababbabaaabbabbaaaababaaababbababaabaabbbba
bbaaabababbbabbabbabbabbbaabbababbaabaab
babaabababbbbbbaabbababbabbbaaab
aabababaababbbbbabbaaabaabbbbaba
baaabbbbbbaaabababbbaaaaababbbaabbbbaabbaaaaabaa
bbbbabbbbabbaabbabaabbab
abaabbbabaabbaabbaaaabbaaabbaaaababaaabbabbabbabbbabbbbbabbaaabaaaaabaab
abbbbbbbabbabbaaaabaaababbbbbaaabbaaaaababbbbbaaaabbabbb
aaaabbbaabbbabbaabbabbaabaabbaaa
bbaaaaaaabaabbaaaaaaaaababaaaabbaaabaaaa
baababbaabbaabbbababbaaabababbaa
aabbababaabbababbabbabbbabbbabbaababbabbaaabbabbabaaaabaaabbbbaababbbbbb
bbbbbaaaaababaababaabbbaaabaababaaabaaaa
aaabaabaaabaaabaabaabbbabbbaaaab
babaabbabbbbbbabbbbbbbbbbaaaaaaa
aabaaabbbabbbbaabaaababbbbabbbbb
baababaabaaaaabbabbbabbbbbababaaababbaba
bbaaaabbbbaaabaababaabaaaaabaabb
babbaabbababbaaaabbbbbbbaaaabbbabbbaabbabaaaabbababaaaaa
aaaaaaabbabaababababbbabbbabbaabbbabbbabbaaabaaa
abbaaaaabbbbbaaaabaabbaabababaaabbababbb
aababbaababbbbabbaaaaaba
babbbbabababbaaabbaabbbb
bbbbabbbbbabaabbbababbababaaabbb
bababbabaaaaabbbaabbbaba
abaaabaababbabbbaaaaabbbbbbbbaab
aababbbaaaababbaabbaabbbbbbbbbbbaaaaaabbbbbaaabb
babaababaabbaaabbabababbaaabbbabbbababbbabbaaabb
babaabababbabaaaababbaaababbbbaabbababbbbbbaaaba
babbabbbabaaabaabbbbabaa
aaabbbbaaababababbbbbabaaabbaabbbbbababbabbaaabb
aabaaabaaabbaaaabababaab
bbababbbaaabaaaaabbaaaaaabbbabaaabbbbabbaababaabbbabaabaabbabbaaabbaabab
babbabaaaababbabbabaaaabaaaaabbbaaabbbababbabbaababbbaaabbbababb
aabbbabbaabaabbbabbaaabb
bbbbaaabbabaaabaabbaaabbbbbabaabaabbabbb
aabbaaabbaaabbaabababaaa
abbbaabbbbbbaaaabababbabbbabaabbabbaaaaaaabaaaab
aaaabbbaaaabbbbabaaabbbbaaabbbbbabbaaabababababbbabaaaaabaabaabbbbbaaaabaaaaaabbbbbabaaa
bbbbabbbbbaabaaabbbaaaaaaababaabaaabbaaa
bbbbabbaaaabbbabaabbaaaaaababaaabaabbbaaabaaababbababbbabbababba
bbabbabaabaaaaaabbaababa
bbbaabababbabaabbaaaaaab
bbaaabbbbbbaaabbaaabaaabbbbaaabababbaabbaabbbabbabbabbba
abaabbaaabbbbbbaaaababbaaabaaabaaabbabbbabababbbabababaa
aaabababaabbbbaaabababbb
babaabbbaababbbabbaabbab
aaaaaabaabbabbabaaabbabbaaabaabb
aaaaaaababbbaabbbbabaabaaaabbaaaabaabbab
babbbbbbababaabbaaaaabba
ababbaaaaaaaabbbaabbbababbbaaabaaabbbbba
bbbbbbaaabbbaabbbaabbbaaaababaaabaabaabbbbababaaaabbbaaa
aaaaabaaaaabaabaaababbaaabaaababbbaababaaaabbbababbbaaabaaaaabbbbabbababbbbbbabb
bababaabababbbaaaabaaabaabaaaabbbabaaaaa
bababaabbbabaabbbabbbbaaaaaabbab
aabbbbaaabbbbbbaabaabbbb
aaabaababbbaaaaabbaabbab
abbbbbbabbbaababaaaabbbb
ababaabbbbabbbaababababa
bbabbabbaaabbbbabaaaabaababaabaabbbbabaa
abaaaabbaaabbaaaabbbaabaaabbaaaaababaaabaababaabbaabaaaabababbba
bbaaaabbbaababaaababbbbaaabbaaba
baaaababbaaabbaaabbaaaabaaabbbaabbaaabbbaaaabbab
babbbbbababbaaaaaabaaababaaaaabbabababbaabbbbbabbbaaaaababbaaabb
babbbbbabbbbbbababbaaaaaaabbabbb
babbbabaaaabaaabbbbabbba
abaaabbbbbbaaababaaabbabbaaabbba
baababbaaaaaabbbbbaabbbbababaaabaabbabab
bbaababbbaabaabbaaaababbaaabbaaabbbbbabbbabbbbabaabaabaabbbbaaaaaaaabbbababbaaaaabbaaaab
baaaaabbbbabbabababbbababababbbbaaaabbbb
bbaaababaabbabaababbaaaaaaababaaaaabbabaabbaabbb
bababaababaaaaabaaabbbbbabaabaab
aaabaaabbaaababaabbbabbbabbbaabbababbaab
bbabaababaaaabaaaaaaabab
bbabbabaaabbbabaabbbaaab
babaaaabbabbbabaaaaabaabbbbbbbbaabaaaababaaaaaab
bbaaaabbaaabbabaababaaab
bbbbbababbabaaababaababa
abbbabaabbaaaaaaabaaaaabbabbaaaaabbabbaabbaabaabaaabaabbaabababb
bbabbbbabbbbabbbbbabbabbbaaaababbbaaaaaaaabbaaabaaabbaaa
babbabbbaabaaaaabaaaabbaabbbbbbabbbbaababbbbabaaaabbbbaa
abaaaababaabbabaabaaaabbaaaaaaabbbaaabababababbbabbabbabababbaba
abaabbabbbaaaaaaabbbaaaababbbbbbbbaaaaaa
babbabababbbabbbabaaaaaaabaabaaa
bbabaaababbbbabbbbbabbabaababbbaaaaabbaaaabbabaabbabbbbbbbaaabbababaaaaa
ababaabbbaabbaabbbbbbbbbbbbabbababbbaaab
bbaaaababaaabababaaaaaaa
baabbbbbbbaabbbbbaabbabaaaabbbbabaabbabb
ababbbbbaaaaaaabaaaabbbb
baababaababbabaabaabbbba
aabbbbbbaabaaabbbbbbbbbabababaabbbbaabbbaababbbbbbaababb
bbbbabbaabaaaaaaababbbbabaabbababbaabbabbabaaaaabbaabbab
bbabbabababbaabaabbbbabbaaaabbbbabbbbabb
bbbaababababaababbaaabba
aabbbabaabaabbbaaaabaababbbabbab
abbababbbbabbbbaababababbbbaabbbbaaabbba
aababbaabbaaaabaaaabaaabbbbbabaa
bbaaaababbbbbbbbbbbbbbabaaabaabb
baaaabaababababbbabaabaaabbaaaaabbabbaaa
babaabbbbabaaaabaabaaabbbaabaababbbababb

56
2020/day19/part1.hs

@ -0,0 +1,56 @@
{-# LANGUAGE OverloadedStrings #-}
import Data.Bifunctor
import Data.Char
import Data.List
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IntMap
import Data.Maybe
import Data.Text (Text)
import qualified Data.Text as T
import Text.Read
main :: IO ()
main = do
input <- readFile "input"
print . countMatches . first (\rmap -> ruleNormalForm rmap . fromJust $ IntMap.lookup 0 rmap) . readInput $ input
data Rule = Ref Int | Character Char deriving (Eq, Show)
countMatches :: ([String], [String]) -> Int
countMatches (patterns, dat) = length $ intersect patterns dat
readInput :: String -> (IntMap [[Rule]], [String])
readInput = bimap readRules readData . T.breakOn "\n\n" . T.pack
readData :: Text -> [String]
readData = lines . drop 2 . T.unpack
readRules :: Text -> IntMap [[Rule]]
readRules = IntMap.fromList . map (bimap tRead readRuleBody . T.breakOn ": ") . T.lines . T.replace "\"" ""
readRuleBody :: Text -> [[Rule]]
readRuleBody = map (map readSingleRule . T.words) . T.splitOn " | " . T.drop 2
tRead :: Read a => Text -> a
tRead = read . T.unpack
readSingleRule :: Text -> Rule
readSingleRule s
| isDigit (T.head s) = Ref (tRead s)
| otherwise = Character (T.head s)
ruleNormalForm :: IntMap [[Rule]] -> [[Rule]] -> [String]
ruleNormalForm ruleMap = concat . map (ruleBranchNormalForm ruleMap)
ruleBranchNormalForm :: IntMap [[Rule]] -> [Rule] -> [String]
ruleBranchNormalForm ruleMap ((Ref r):next) = listJoinCombinations (lookupNormalizedRule ruleMap r) (ruleBranchNormalForm ruleMap next)
ruleBranchNormalForm _ ((Character r):next) = [[r]]
ruleBranchNormalForm _ [] = []
lookupNormalizedRule :: IntMap [[Rule]] -> Int -> [String]
lookupNormalizedRule ruleMap r = ruleNormalForm ruleMap . fromJust $ IntMap.lookup r ruleMap
listJoinCombinations :: [[a]] -> [[a]] -> [[a]]
listJoinCombinations [] _ = []
listJoinCombinations a [] = a
listJoinCombinations (a:as) bs = map (a ++) bs ++ listJoinCombinations as bs

65
2020/day19/part2.hs

@ -0,0 +1,65 @@
{-# LANGUAGE OverloadedStrings #-}
import Data.Bifunctor
import Data.Char
import Data.List
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IntMap
import Data.Maybe
import Data.Text (Text)
import qualified Data.Text as T
main :: IO ()
main = do
input <- readFile "input"
print . countMatches . first applyPart2Patch . readInput $ input
data Rule = Ref Int | Character Char | EndOfString
type RuleMap = IntMap [[Rule]]
countMatches :: (RuleMap, [String]) -> Int
countMatches (ruleMap, dat) = length $ filter (matchRule0 ruleMap) dat
matchRule0 :: RuleMap -> String -> Bool
matchRule0 ruleMap = matchString ruleMap (fromJust $ IntMap.lookup 0 ruleMap)
matchString :: RuleMap -> [[Rule]] -> String -> Bool
matchString ruleMap rules str = any (== Left True) . concat $ map (matchStringToBranch ruleMap str) (map (++ [EndOfString]) rules)
matchStringToBranch :: RuleMap -> String -> [Rule] -> [Either Bool Int]
matchStringToBranch _ str (EndOfString:_) = [Left (null str)]
matchStringToBranch _ _ [] = [Right 0]
matchStringToBranch _ [] _ = [Left False]
matchStringToBranch ruleMap (cb:str) (Character ca:next)
| ca == cb = map (second (+ 1)) $ matchStringToBranch ruleMap str next
| otherwise = [Left False]
matchStringToBranch ruleMap str (Ref r:next) = flatMap (matchStringToBranchRec ruleMap str next) . flatMap (matchStringToBranch ruleMap str) . fromMaybe [] $ IntMap.lookup r ruleMap
flatMap :: Eq b => (a -> [b]) -> [a] -> [b]
flatMap f = nub . concat . map f
matchStringToBranchRec :: RuleMap -> String -> [Rule] -> Either Bool Int -> [Either Bool Int]
matchStringToBranchRec ruleMap str next (Right depth) = map (second (+ depth)) $ matchStringToBranch ruleMap (drop depth str) next
matchStringToBranchRec _ _ _ result@(Left _) = [result]
applyPart2Patch :: RuleMap -> RuleMap
applyPart2Patch = IntMap.insert 11 [[Ref 42, Ref 31], [Ref 42, Ref 11, Ref 31]] . IntMap.insert 8 [[Ref 42], [Ref 42, Ref 8]]
readInput :: String -> (RuleMap, [String])
readInput = bimap readRules readData . T.breakOn "\n\n" . T.pack
readData :: Text -> [String]
readData = lines . drop 2 . T.unpack
readRules :: Text -> RuleMap
readRules = IntMap.fromList . map (bimap tRead readRuleBody . T.breakOn ": ") . T.lines . T.replace "\"" ""
readRuleBody :: Text -> [[Rule]]
readRuleBody = map (map readSingleRule . T.words) . T.splitOn " | " . T.drop 2
readSingleRule :: Text -> Rule
readSingleRule s
| isDigit (T.head s) = Ref (tRead s)
| otherwise = Character (T.head s)
tRead :: Read a => Text -> a
tRead = read . T.unpack
Loading…
Cancel
Save