2020 day19/haskell: add solution
This commit is contained in:
parent
b0abe9abbb
commit
06203aee16
4 changed files with 513 additions and 0 deletions
|
@ -24,5 +24,6 @@ https://adventofcode.com/2020/
|
||||||
|16 | | `**` | |
|
|16 | | `**` | |
|
||||||
|17 | | | |
|
|17 | | | |
|
||||||
|18 | | `**` | |
|
|18 | | `**` | |
|
||||||
|
|19 | | `**` | |
|
||||||
|
|
||||||
`test.sh` can be used to run all solutions and automatically compares them to (my) puzzle inputs and the expected outputs.
|
`test.sh` can be used to run all solutions and automatically compares them to (my) puzzle inputs and the expected outputs.
|
||||||
|
|
2
2020/data/day19.expected
Normal file
2
2020/data/day19.expected
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
147
|
||||||
|
263
|
465
2020/data/day19.input
Normal file
465
2020/data/day19.input
Normal file
|
@ -0,0 +1,465 @@
|
||||||
|
90: 86 86
|
||||||
|
122: 86 1 | 99 20
|
||||||
|
116: 86 58 | 99 75
|
||||||
|
20: 86 123
|
||||||
|
62: 99 95 | 86 113
|
||||||
|
81: 76 99 | 90 86
|
||||||
|
106: 120 86 | 93 99
|
||||||
|
73: 99 72 | 86 45
|
||||||
|
117: 131 99 | 72 86
|
||||||
|
92: 86 96 | 99 98
|
||||||
|
13: 3 99 | 118 86
|
||||||
|
56: 90 86 | 58 99
|
||||||
|
85: 72 99 | 51 86
|
||||||
|
51: 99 99 | 86 86
|
||||||
|
59: 99 25 | 86 62
|
||||||
|
65: 99 15 | 86 97
|
||||||
|
112: 86 13 | 99 38
|
||||||
|
46: 33 86 | 2 99
|
||||||
|
10: 67 86 | 68 99
|
||||||
|
33: 120 99 | 76 86
|
||||||
|
38: 35 86 | 125 99
|
||||||
|
26: 86 10 | 99 55
|
||||||
|
1: 33 99 | 60 86
|
||||||
|
8: 42
|
||||||
|
16: 51 86 | 93 99
|
||||||
|
107: 40 99 | 2 86
|
||||||
|
40: 17 120
|
||||||
|
34: 86 82 | 99 127
|
||||||
|
88: 93 17
|
||||||
|
2: 99 51 | 86 120
|
||||||
|
32: 100 99 | 7 86
|
||||||
|
113: 86 127 | 99 82
|
||||||
|
14: 73 86 | 44 99
|
||||||
|
25: 86 101 | 99 56
|
||||||
|
130: 110 86 | 109 99
|
||||||
|
19: 86 4 | 99 49
|
||||||
|
30: 86 92 | 99 70
|
||||||
|
27: 17 86 | 86 99
|
||||||
|
94: 47 86 | 53 99
|
||||||
|
115: 86 107 | 99 84
|
||||||
|
15: 76 99 | 58 86
|
||||||
|
58: 86 99
|
||||||
|
105: 130 86 | 32 99
|
||||||
|
71: 120 99 | 131 86
|
||||||
|
12: 99 131 | 86 82
|
||||||
|
60: 72 86 | 93 99
|
||||||
|
84: 86 102 | 99 80
|
||||||
|
44: 99 76 | 86 72
|
||||||
|
125: 76 99 | 131 86
|
||||||
|
18: 99 71 | 86 52
|
||||||
|
129: 37 86 | 111 99
|
||||||
|
102: 99 131 | 86 76
|
||||||
|
66: 86 105 | 99 41
|
||||||
|
99: "a"
|
||||||
|
9: 99 18 | 86 65
|
||||||
|
131: 17 99 | 99 86
|
||||||
|
39: 76 99 | 93 86
|
||||||
|
64: 115 99 | 114 86
|
||||||
|
57: 86 48 | 99 94
|
||||||
|
35: 72 86 | 51 99
|
||||||
|
0: 8 11
|
||||||
|
77: 86 83 | 99 106
|
||||||
|
118: 72 86 | 75 99
|
||||||
|
47: 99 103 | 86 85
|
||||||
|
23: 99 27 | 86 76
|
||||||
|
48: 119 99 | 78 86
|
||||||
|
49: 86 51 | 99 45
|
||||||
|
67: 86 120
|
||||||
|
61: 86 72 | 99 127
|
||||||
|
108: 72 99 | 72 86
|
||||||
|
95: 86 58 | 99 90
|
||||||
|
83: 86 27 | 99 131
|
||||||
|
75: 86 99 | 99 99
|
||||||
|
101: 51 99 | 27 86
|
||||||
|
103: 90 99 | 90 86
|
||||||
|
128: 86 69 | 99 33
|
||||||
|
70: 99 14 | 86 19
|
||||||
|
52: 127 86 | 90 99
|
||||||
|
21: 86 24 | 99 59
|
||||||
|
22: 86 63 | 99 12
|
||||||
|
42: 79 86 | 66 99
|
||||||
|
97: 51 17
|
||||||
|
104: 86 33 | 99 28
|
||||||
|
100: 99 16 | 86 39
|
||||||
|
72: 99 86
|
||||||
|
78: 86 43 | 99 50
|
||||||
|
55: 86 6 | 99 34
|
||||||
|
45: 99 99
|
||||||
|
5: 86 46 | 99 77
|
||||||
|
93: 99 99 | 99 86
|
||||||
|
6: 131 99 | 51 86
|
||||||
|
110: 71 86 | 28 99
|
||||||
|
68: 90 86 | 27 99
|
||||||
|
29: 87 86 | 122 99
|
||||||
|
80: 86 93 | 99 131
|
||||||
|
54: 120 86 | 75 99
|
||||||
|
43: 93 86
|
||||||
|
98: 99 103 | 86 117
|
||||||
|
7: 101 86 | 88 99
|
||||||
|
127: 17 86 | 99 99
|
||||||
|
96: 86 12 | 99 61
|
||||||
|
41: 99 5 | 86 112
|
||||||
|
79: 86 57 | 99 21
|
||||||
|
11: 42 31
|
||||||
|
86: "b"
|
||||||
|
111: 45 99 | 72 86
|
||||||
|
63: 76 99 | 127 86
|
||||||
|
124: 86 81 | 99 116
|
||||||
|
28: 86 75 | 99 58
|
||||||
|
82: 99 86 | 86 99
|
||||||
|
121: 64 86 | 74 99
|
||||||
|
87: 86 124 | 99 104
|
||||||
|
74: 99 26 | 86 9
|
||||||
|
31: 126 99 | 121 86
|
||||||
|
50: 99 72
|
||||||
|
119: 34 86 | 36 99
|
||||||
|
36: 86 82 | 99 75
|
||||||
|
91: 86 131
|
||||||
|
3: 58 99 | 27 86
|
||||||
|
114: 99 129 | 86 22
|
||||||
|
24: 86 89 | 99 128
|
||||||
|
53: 91 99 | 95 86
|
||||||
|
126: 29 86 | 30 99
|
||||||
|
109: 99 108 | 86 23
|
||||||
|
17: 86 | 99
|
||||||
|
76: 86 86 | 99 86
|
||||||
|
120: 17 17
|
||||||
|
89: 54 86 | 37 99
|
||||||
|
4: 99 131 | 86 58
|
||||||
|
69: 27 17
|
||||||
|
37: 99 58
|
||||||
|
123: 86 76 | 99 82
|
||||||
|
|
||||||
|
bbababbaabbaaabaaaabbabbbbbababbbababaaaabbaabaaaaaabaaaabbaabba
|
||||||
|
aaabbbabbabbbbbbaabbabababaaaaabaaabaaaaabaaaabbbbabbabb
|
||||||
|
babaabaabbabaaaaabbababb
|
||||||
|
babbabbaababbaaaababbaabbbbbaabaabbbababaabbbabbbabababaabbabbabaabbbaababbbbbbb
|
||||||
|
bababbbabaaabbaabbababab
|
||||||
|
aaaaabaaaabbaabaaaaabbaa
|
||||||
|
aabbbaaaaababbaaabaabbbbabbbaaaaabbaaaab
|
||||||
|
baaaabaaaabbababbaaabbab
|
||||||
|
ababababaaaaabaaaaabbaaa
|
||||||
|
baabaababaaabbaabbbababb
|
||||||
|
abbbabbbbbabaaabaabbabbb
|
||||||
|
aaababbbabababbbaabbaaaabababbaa
|
||||||
|
babbaaabbaaaabaababbbabb
|
||||||
|
bbbabbbabbabaaaabaabaaab
|
||||||
|
bbbbaaabaaaabbbaabbbbabb
|
||||||
|
aaaaaaaaaaaaabaabaaaabbb
|
||||||
|
babaabbababbabaababbaaba
|
||||||
|
bbabaaaabaaabbaaaabbbbbbbabbabbbbaaaabab
|
||||||
|
babaabbbbbbbbbaabbaaabaa
|
||||||
|
baabbbabababbababaabbbaa
|
||||||
|
baaaabaaaabaaaaaaaaaaaab
|
||||||
|
aaabbbbbbbabbbabbbbbabbb
|
||||||
|
bbabaaabaaababaabbbbbbba
|
||||||
|
baaabaaabbabbaaaaaaababb
|
||||||
|
abbabaabbaaaaaaaaabaabba
|
||||||
|
aaaabababbbbbbaabababbab
|
||||||
|
bbbbbbabababbaabaabbbabaaaabbabbaabbabbbbaababbbabaabbbbabbabaabababaabaaaaaabab
|
||||||
|
bbbabbaaaababbabaabaabbbabbbabab
|
||||||
|
bbbabbbababbbbaabbbbbbab
|
||||||
|
baabaaaaabaabbbbaaabaaaabbbbbbab
|
||||||
|
bbbbaaaaaabaaaaaabbbabaababbaabb
|
||||||
|
bbbbbabaabaaaaababbaaabbbaababbbbbaaabaa
|
||||||
|
aaabaabaaaabaaaaababbaaaaaababbbaaababab
|
||||||
|
bbaaaababbbaaabbabbabbabbabbbbabbababaabbbabbabbabaaabbabaaaabba
|
||||||
|
aababbbaaaabbbaabbbbababbabbaaaa
|
||||||
|
abbbaabbabaaaaababaaaaaa
|
||||||
|
babbabbabbaabababbabaaaaaabbbabbbabaabbbbabbbaabbaaaaaba
|
||||||
|
aabbbaabaaabbabbbbaabaaabbbabbababbaababababbbba
|
||||||
|
baabbabbbaabbbbbbbaaaaaababababaaabbbbabaabaabbaaaaabbab
|
||||||
|
bbabaaabbbbbaaaababbabbb
|
||||||
|
baabaabaaababbbabaaababa
|
||||||
|
aaaabbbbabbbaabbababaaaa
|
||||||
|
babbababaaaababababaabab
|
||||||
|
bbbaabbbabbbabaabbbabbbaaabbaabbabbbbbbbaaaabaaabaaabbaabbbbabbb
|
||||||
|
aabbaabbabbabbbabaaaabba
|
||||||
|
abaabbaaaaabbabbaaabbbabbabbaaaa
|
||||||
|
bababaabbaaabaaababbababbbbbbabbbaaabaab
|
||||||
|
aaababbbaabbaabbbbaaabbaaababaaabaabbbaa
|
||||||
|
abbaaababbaaababbaaaabba
|
||||||
|
bbaababaaabbabaaababbaabbaabbbbaaabbaabbabaaabbabbabbbbbabbbaaabbbababbb
|
||||||
|
bbaaabbbbbaaabbabaaaabba
|
||||||
|
abbbabaabbaabaaaaaabbaaa
|
||||||
|
bbbabaabbbbbbbaababbbbaaabbbabba
|
||||||
|
abbabbaaaaaabbbbbbabaaabbaaaaaab
|
||||||
|
bbaababaaaababaabaabbababbbbbaab
|
||||||
|
aabbababaaabbbaaaaabbabbaabbbbbbbabbbabb
|
||||||
|
aaabbbaaaababbabbababbbb
|
||||||
|
aababbababaaabaabababbbb
|
||||||
|
bbabbbabbbabbbabababbbba
|
||||||
|
aaabaaaaabbbbbbbbaaaaaab
|
||||||
|
babaabbbaaabbbabbaaaaaab
|
||||||
|
bbaabbbaaabbababbbaaabaa
|
||||||
|
aabbbaaaaaaaaaaaaaaaabaaaabbbbbabbabaaaaabbbbbab
|
||||||
|
abaaaaabaabbbaaaabbbaaab
|
||||||
|
abaabbabbabbbbbabbababaa
|
||||||
|
baaabbaaaabbbabbaaaabaaa
|
||||||
|
abbbbbaabbaaababbbbabaab
|
||||||
|
aababbaaaabbbbbabaababaabababaabbabbbaba
|
||||||
|
abaabaaabbabababababababbaabaaabbbaabaabaabbbababbbabbbabbabbbbbabababaabbabbaba
|
||||||
|
aaaaaabaaaaabababbbabbabbbaabbabaababbbb
|
||||||
|
babaaaababaaababaabbabba
|
||||||
|
ababbaaaabaaabbbbababaaa
|
||||||
|
baababbbabbbbaaabaababbbabbbbaababaaabaaaabbaabababababaaaaababa
|
||||||
|
bbaabbababbabaabbbabbabb
|
||||||
|
bbabbbbaababbaabbbbabbbbbabbabaaaaabbbababbbbaabaaaaaabbbababbbbbabbbabb
|
||||||
|
baaaaaaababaaaabbbbbaaaaabaabbbbbaababbb
|
||||||
|
aabbabaaabbbbbaabbbaabab
|
||||||
|
ababbabbbbaabaaabababaabaaaabbab
|
||||||
|
aaabbabaaaaabbbbabbbbaaa
|
||||||
|
bbaaaaabbaaaabaaabbbaaaa
|
||||||
|
abbbaaaaabbbabbbabbabaaa
|
||||||
|
bbaaaabbaaaababababaababaaaabbbaaabaabaaaababbabbbaaaabaabaaabbaababbbaaabaabbaababbbaabaabaabbb
|
||||||
|
bbaabbaaaababbababbaaabbbabbbababbbbbbaabbaabababbababaababbaababbbaaabbaabbbbab
|
||||||
|
aababbabaaabaaaabbaabbaa
|
||||||
|
babaaabbaaabaababbabbbbabbbaabaabbaabbbababbabaabababaabbbababbabbbbaababbaabaaa
|
||||||
|
baabbabbbbaabbbaaabbaaab
|
||||||
|
abaaaaabbbaababaabbaabab
|
||||||
|
aaabbbbbaaababaaabababaabbaababb
|
||||||
|
bbaaababbaabbbbababbbbbabbaabbabbbbbaaabbbabbabb
|
||||||
|
bbabbbbaabbbbbbbbaaaabba
|
||||||
|
aababbabaaabaababaabbabbabaaaabaaabbbabaaabbbabbbabaaaaa
|
||||||
|
babbbbbbaabbbaabbabbbabb
|
||||||
|
baabbbbaababbaabaaabbabb
|
||||||
|
aaabaabaabbbaabababbbbaaaaaabaabbabaabbbabaaabbbaaaabababaababbbababbabaaaaaabab
|
||||||
|
aabbabaabaaaaaaababbababaabaabba
|
||||||
|
ababbababbaabbbaabaabaababbaabbbaaaabbaa
|
||||||
|
aabbababaabbbbbbbaababaababbabba
|
||||||
|
baabbabbbaaaaaaaaaaabaaa
|
||||||
|
baabbbabaaabbabbbbbbbabb
|
||||||
|
babaabaaaabaaaaabbbaaaab
|
||||||
|
baaaaaaababbbbbaabbbbbab
|
||||||
|
bbabbbabababbaabbaaababa
|
||||||
|
bbbbabababaaaaababbabbbababbabaaabbaabababbababaaaaabbab
|
||||||
|
aabbbbbababbabaaabababaaaaabaababbbabbab
|
||||||
|
babbbbaabaabbbbabbbbbabb
|
||||||
|
aaabbbabbabaabbbabaaababbaaabaab
|
||||||
|
abbaaabbbbaaabbbbabbbbbbbbbbabaa
|
||||||
|
bbabbabaaaabbabbbbbababababbaaabbabaaaaababaaaba
|
||||||
|
bbaabaaaaabaaababaababbb
|
||||||
|
baabbaaaaaababbababbaabaabababbbabaaabbbbbbaaabbbbababaababaabbbbbabaaababbaaaabbbaaaaaa
|
||||||
|
aaabaaabbbbbaaaabbbbabba
|
||||||
|
abbbaabbbabbbaaaaabaabab
|
||||||
|
aaabbbaabbaabbabbaabbbbbbbabbaaaaaaabbbaaaaaabab
|
||||||
|
aaaaaaaaaabbaabaaabbbbaabbaaaaabaaabbaababbbbbab
|
||||||
|
bbbbababbabababbbbababba
|
||||||
|
abaaaabaabbbbaaaabbbbbbbbaababbabbbbaabbaabbbbbabaaabbbaaaaaabab
|
||||||
|
bbbbbbaabaabaaaaaaaaabbaaaaaaababbabbabaabbabbab
|
||||||
|
abbbbbbbbaaaabaaaababbabbbbbaabb
|
||||||
|
bababaabaababbbaabbaabab
|
||||||
|
abaaaabaabaabbabaaabbbbbbbaaaaaa
|
||||||
|
aaaaaabaababababbbaabbbabbaaaaba
|
||||||
|
abaabaabbbababbababbaabb
|
||||||
|
baaabbaabbbaabbbbabbabbb
|
||||||
|
baababaabaaabaaaabbabbbabababbaabbbbbbba
|
||||||
|
bbbaabbabbbabaabbaaabbaaaabababaaabbbbaaababbaab
|
||||||
|
abaabbbbabbabbbbaaaaabab
|
||||||
|
bbbabaababaabbbbbbbaaaab
|
||||||
|
abbaaabaaaaaaabaabaaaabaabbaaabbabbabbbbaabaabab
|
||||||
|
aabaaaaababbbaaaaaaababb
|
||||||
|
aaabbbaaabaabbbabbbbabaa
|
||||||
|
aaaaabaababaabbabaaaabaaabbaaaaa
|
||||||
|
aaaabaabababbbbbaaaaaaaaaabbbbbbbbbbbbababbbbabbbaaabaab
|
||||||
|
bbabbbabbaabbbbaaaabaabaabaaabbbaaaaaaababbbaaab
|
||||||
|
aabaaabaaabbababbabababa
|
||||||
|
babbbaaaaabbbaabbbabbababbbbbbbaabbababa
|
||||||
|
abbaabaabaabbaaaabaaaaaaababbaab
|
||||||
|
abaaaababbaabababaabbbababbabaabaaababbbbbbbabba
|
||||||
|
bbaaaabababbabababbabaabbbaaabbbbbbabbaa
|
||||||
|
aabbaabbaaabbbaabaaaaaab
|
||||||
|
bbaabbabaaaabbbabbabbabb
|
||||||
|
abbaaabbabbbaaaabbbbbaaabbabbabababbbbbbabaabbbbbabbaaaaabaababb
|
||||||
|
ababbaabbabbbbbbbbabaaaabbbbababbaaabbbabaabaabb
|
||||||
|
aaabbabaaabbbabaaaaabaabaaababbaabbbabbababbbbabaabbabbb
|
||||||
|
abbabbaaabababababbbabaaaaaabaabbabaabab
|
||||||
|
babaabaaababbaaaaabbaaab
|
||||||
|
aaaaaababababaababbaaaab
|
||||||
|
ababbabaaababbaaabbbaababaaaaabb
|
||||||
|
bbaaabbabaaaabaabbabaaaaaaaababbbbbabaaa
|
||||||
|
bababbbabbaabbabbbbbabba
|
||||||
|
bbaaabbaaabbbbaabababaabbabbaaaa
|
||||||
|
aaaabaabaaaaabbaababbaabababbaaa
|
||||||
|
ababbabaabbabbbbbbaababb
|
||||||
|
aabbbbbbbaaabbbababababa
|
||||||
|
bababbbaabbabbaabaaaabab
|
||||||
|
bbaaabbbaabbbbbaaabaabba
|
||||||
|
aabbbbaaababbbabbbaabbbb
|
||||||
|
baaaabaaabaaabbbababbbabaabbbabbaabbbaabbbbbbbabaaaabbaababbaabaaababbbb
|
||||||
|
babbbbabbbbababbabaaabba
|
||||||
|
babbbbaaababbbbbbabbbaaabaabbaab
|
||||||
|
bbbbbbaaaabbbabbaaabaaaabbbabaaaaabaabab
|
||||||
|
babbbbbabbabaaaaaaaaabbb
|
||||||
|
ababbbabbabaabbaaaabbabbaaaabbaa
|
||||||
|
bbbabbbabababbbabbaaabbbbbbbaaba
|
||||||
|
abbabbaaabaaababbaaaaabb
|
||||||
|
bbababbabababaaaaababbbbbabbbaabababbaabaabbbaababbaaaba
|
||||||
|
babbababaabbbaaaabbaaaab
|
||||||
|
abbaaabbbaaaaaaabbababab
|
||||||
|
bbbabbbabbabbabababbbbab
|
||||||
|
babbbaaabababaabaababbbababbbbbaabbbbaba
|
||||||
|
bbbababaabaabaabababbbbbabaaaababbabbbabbbaaabaababbaaaaabaaaabbaaaabbab
|
||||||
|
babababbabbabbbaaaaabbab
|
||||||
|
baabbabbabaabbaaababbbbb
|
||||||
|
aabbabaaaaaaabbaabbabbbaababbaabababbbbbbabbbababbbaaaba
|
||||||
|
aababababbbabbbaabbaaaaa
|
||||||
|
aabababaaabaaabaaabbaababbbabbaabbaaababbbbbbbababababbaabbbbbab
|
||||||
|
abbbaabbbbabbbbaabbabbab
|
||||||
|
aaaabbbbaabbaabbbabaaaaa
|
||||||
|
aababbababaabbbaaabaabba
|
||||||
|
baaaaabaaaaaabbababaabbbabaaaabbabaabbbaabaaabbaabaababaaaabbaaa
|
||||||
|
ababbaaabaababaabbbbbababaaabbbb
|
||||||
|
babbabababbbaaaabbbaabaa
|
||||||
|
baabbabbbaabbabaaabbbbaabbbaabbaabbabaababaaabaabbaababbbaaaabbb
|
||||||
|
abaabbbbaaaabaabbbbbbbba
|
||||||
|
baabbabaaaababaaabbaabbbbbbbbbbb
|
||||||
|
abbaaaabababbbbabababaabbbaaabbaababaabbbaaaaaaaaabaaaab
|
||||||
|
bbbabbabaaaabbababbaabababaaaabaaabbaaaabbbababa
|
||||||
|
bbbababababbbbbbababbbba
|
||||||
|
bbbbbbaaaaabbbaabaababab
|
||||||
|
aaaabbbaabbaaababaaababa
|
||||||
|
bbaaabbabbabaabaaaabaaaaabaaabbabaaababb
|
||||||
|
ababbabaabaabbaababaaaaa
|
||||||
|
bbbaabbaaaababbaabbbbabaaabaaaab
|
||||||
|
abbbabbbbbbabbaaabbaabbbababbbbaaabababb
|
||||||
|
bbbbbaaabaaabaabaabbaaab
|
||||||
|
bbaabbababaaababaaabbbabaaaababaabbaaababaabaaab
|
||||||
|
abbbabbbaabbbbbabbababbb
|
||||||
|
bbbaabbabbabbbabbaaaabba
|
||||||
|
bbabaabaababbbaababababaaabaabababaaaaaabaaababb
|
||||||
|
babaabaaaaaaabaaaabaabba
|
||||||
|
babbbbbaaabbbaaaaabbababbaababba
|
||||||
|
aababbaaababbbbbbabbabba
|
||||||
|
bbabbbabaabbaabbbbbbabaa
|
||||||
|
ababbababbbababaababbbaa
|
||||||
|
aaabbbaabbabaabaababbbba
|
||||||
|
bbaabbabbbabbaaabaabbbababaaabaabbbbbabbbbaaabaaababaaba
|
||||||
|
baababaabbaaabbabaaababb
|
||||||
|
abbaabbbababababaaababbbbaabaabb
|
||||||
|
baabbbbbaaabaababaababba
|
||||||
|
babaabaababaabbbbaabaabaaaababaababbabba
|
||||||
|
bbaaaaabaababbaaaabbaabaaabbabbbbababbaa
|
||||||
|
abbaaabbaaabbbbaaabbbbaaabbaaaabaabbaaabbaababbbabbabbabaaaababb
|
||||||
|
aaabbaabababaaaabaabaaab
|
||||||
|
bbaabbaabbbabaaabbabbbbbbbbabaabbabaaabababbbbabbaabbabbbbbabbaa
|
||||||
|
bbbabbbbbbabbbaabaababab
|
||||||
|
bbabbbbabbaabbbababbabba
|
||||||
|
aaabbbaabaabaababaabbabababbaaaabbbbbbba
|
||||||
|
babbaabababbabababbbbbbaababaabbbaabbbbababaaaabbbaaaaababbabaaabbbbaaaaabaaababbbbaabba
|
||||||
|
babbbabbbaaaaaaabbaabbbbabbbbabbaaabababaabbbbab
|
||||||
|
bbaaaaababaaabbaabbbaaaaaababbabbbaabaabaaabaaabbabaabab
|
||||||
|
baabbbbbabbaaababbbbaaabbbbbbaabbbbbbaabbaaaaababbaaaaaaaabbabba
|
||||||
|
bbabbbaaabaaabbbabbbabaaaababbaaaabbbaabababbbbabbababaaaaaababb
|
||||||
|
baaabaaaaabbababbbabbbbaabaabbbaaabbbaabbaaabbabbaaabaab
|
||||||
|
aaaaaabaaaaabbbabbbaabaa
|
||||||
|
bbaaabbbbabaaaabbabaaaabaabaaaaababaababaaaabaaaaababbbb
|
||||||
|
babbaaababbbaabaabbbbaab
|
||||||
|
aaabbaababbbbbabaaabbaaaaabbbbbaabaabaababababababbabbbb
|
||||||
|
babababbbaabaaaabaaabbbb
|
||||||
|
babbabaaaaabbbabbbbbbbaabbbaaaaa
|
||||||
|
aabbabaabaaabbbaaaaaabab
|
||||||
|
bbbabbaaabbbbabbbababbabaaabababaababaab
|
||||||
|
bbabaaaabaabbabbbbbabaabaaababbb
|
||||||
|
baababbbbaaaabbabbaabbbbbbbbbaaabbbbaaba
|
||||||
|
aabbaababaaaabaabaabbaba
|
||||||
|
bbbabbaababaabaaabbbaaaaabaaaabaaabaaababababaaabbababbbbbbbabba
|
||||||
|
bbabaabaabaaabaabbabbaab
|
||||||
|
aabaaaaaaaababbbaaababbbbbbaabab
|
||||||
|
baaaabaaabbbabbbabaaababbaabbaaa
|
||||||
|
baabbbbabababbbaaababbbabbabbbbabbaabbbaabbabababaaabababaabaabbbabbabba
|
||||||
|
baabaabaabababaabaaaabbb
|
||||||
|
abbaabbbbabaabaaababbababaabbabbbabbbbabbbbbaabababbaabb
|
||||||
|
abbbabbbbbbababaabbbabbabbbbbaab
|
||||||
|
abaaabbbbbbaabbbaabbaaab
|
||||||
|
ababbbabbbabbbaaabaaabaababababa
|
||||||
|
bbbbbbaaabbbaaaaaaabbabaabbbbaabbbbaaaab
|
||||||
|
bababbbbbabbbbbbbaabbbbbbbababbbbabbabbbabbbbaabbaaaabba
|
||||||
|
baaabbaaaaaaaababaaabbbaabaabaaabaabababaaabbaaaabbaabaa
|
||||||
|
aabbaabbbbbabaababaabaaaababbaaabbabbababbbbaabb
|
||||||
|
abbbbbaabbbabbbbbbbbaaba
|
||||||
|
aaabbabbbbbabbbababaaabb
|
||||||
|
abaabaaaaabbaaaababbbaab
|
||||||
|
aaaabaabbbbbaabababaaaaaaaaaaabb
|
||||||
|
bbbababaabbbabaabaababba
|
||||||
|
abbbaabbabaaababbbbbbabb
|
||||||
|
babbabbbaaaaabbbaababbabbaabbbbbbaaabbaaaabbbbbaabaababbbbaaaaba
|
||||||
|
aaaaaababbbababababaabab
|
||||||
|
bbaabaabbbaaaabbabbababaaaaaababaabaaabb
|
||||||
|
aabbabaababaaaababbbabab
|
||||||
|
ababbbababaabbbbbaaaabbbbbbbbaababbbbaaabbabbbaaabbbabbbbaaaabbbaaaaaaaaababaaab
|
||||||
|
bbbabaabaaaaabbaaaabaabb
|
||||||
|
babbaaabbaabaababbbbaaba
|
||||||
|
bbabaabababbbbbaabaabaaabbaaabbabbbabaaa
|
||||||
|
abbabaabbaaaabaabbbaaaba
|
||||||
|
aabbabaabaaabbbaaaabbbabbabababbbbbaabbb
|
||||||
|
aabbbbbbabababababbbbbab
|
||||||
|
abbabbbabbabaababaaabbbb
|
||||||
|
baaabbaaababbaaabaabaabb
|
||||||
|
bbbabbbaaaabaaaaabaaababaaaabbbbaabbaaaaabbbabab
|
||||||
|
aabbbabaaaababaabaaaaaba
|
||||||
|
abbbabbbababbabbbbaabbaa
|
||||||
|
abbbbbabaabababbbabababa
|
||||||
|
bbaabaabaababbaabababaaa
|
||||||
|
bbabaaabaababbbaaababbbaaaababba
|
||||||
|
abbaabaababbababaaaabbbaabbabaababbbaabaaaabaaabaabbbbab
|
||||||
|
babbbaaabbabbbaababbbbaaaabaababaaaabaaa
|
||||||
|
babababbabaaaabaaabbbabaaabbbabababaaaabbbabbaab
|
||||||
|
aabbbaababbaaabaababbaababaaabbbaaaaaabaababbaaaaabaaabbbbababaa
|
||||||
|
abbbabbbaaabbbbaaabaabab
|
||||||
|
abaabbaaaabbaabbbbbaaaaa
|
||||||
|
bbabaaabaaaabbbbaabbbaaaaabbbbbbabbbbbbabbbabaaa
|
||||||
|
bbbabbaababbbbbabbaaaaabbabaabaaababaababaaaaabb
|
||||||
|
abbbabbbababbaaabbabaaaaabbabbbabbabaabbbaaaaabbabbabaaabbbbbbbb
|
||||||
|
bababbbaaaabaabaabbababb
|
||||||
|
abbbbbbbabababaaabbaababbabaaababbaaaaaa
|
||||||
|
abbaabbbabaaaaabaaaaabbaabaaaaabababbbababbbabab
|
||||||
|
abbabbbbbbabaaaabbbabbbabbbbaaba
|
||||||
|
abbaabbbbaabaababaababba
|
||||||
|
bbabaaababaabbbaaaaaabbb
|
||||||
|
baabbabaaaaabbabaabbbbabbabbabbabbaaaaaa
|
||||||
|
babbbbbbababbababbabbbabaabbaaab
|
||||||
|
aaabaaabbbbabbbbaabbabbbbaaaaaabaabbbaabbaababaa
|
||||||
|
baabbbbbaaabaababababbab
|
||||||
|
babbaaabaaaabaababbabbaaaabaabaa
|
||||||
|
abaabbbbbbabaaaaaabaabab
|
||||||
|
aaaaabbaabababaabbbbbababbbababbbbaababb
|
||||||
|
abababababaabaaabbaaababbabbabbb
|
||||||
|
abaaaaabbbbbbabaaaaabbaa
|
||||||
|
aaaabbbbbbbbababbbabaabb
|
||||||
|
bbabbabaabaaabaaaaababab
|
||||||
|
aaabbbbbabbabbbbbabaababbbaabaababbababb
|
||||||
|
bbabaabaabbabbaaaabaabba
|
||||||
|
abbabaaababbaabaaaaabbbabbaaaaabbbaabbabbababaaabaabbaabbbbaaabaaaabbbaabbbbabba
|
||||||
|
ababbbabaaabbabbaaabbabaaabaabba
|
||||||
|
bbbabbbbbabbbbbbabaaabaaaaababbbbababaaa
|
||||||
|
babbabaaabbaaabbabbabaaa
|
||||||
|
babbbbaaabbbbbaaabaaabaabbbbababbaaababb
|
||||||
|
abbabbbbabababbbbbabbaaabaaababb
|
||||||
|
babbababbbaababaabbabbab
|
||||||
|
bbaaababbbbbaaababbbbabb
|
||||||
|
baaaabaababaabbbabaabbbaaabbbaabaaaabbab
|
||||||
|
abbaabbbbbaaaaabbbaabbabbaabbaab
|
||||||
|
aaaaaababbaababaaabaaabababbbabb
|
||||||
|
baaabbaabbbababaaababbbaaaaaabba
|
||||||
|
bbbbabaaaaabaaaaaaababbaaaababbbbbaabaaaaabaaaabaaaabbaabbbbbbbb
|
||||||
|
abaaabbbbaaabaaababbabba
|
||||||
|
aaaaabaaaaabbbaabbabaaaaabababaaabbbbbaabbaaaaba
|
||||||
|
ababbabababbbaaaaaaaabbb
|
||||||
|
aaababaaabaabbaababbabbb
|
||||||
|
ababababaabbbabbbaaabaab
|
||||||
|
baabbbabbaaabaaabaaabbbabbabbabb
|
||||||
|
bbbabbaabbabbababaabbbbaabaabbabaabaaabbbaaabbbb
|
||||||
|
aaabbbabaaabbbbbabbabbbbbbbaaaaa
|
||||||
|
aaabbababbaaababaaaabbaa
|
||||||
|
bbbabbaaababbbabaaabaabb
|
||||||
|
baababbabbbabaaababaaababababbaaaababaabbbbaaaabbabaaababbbabaababbabbbbbaaabbab
|
||||||
|
bbbabbaababaabbabbbbbaaa
|
||||||
|
abababaabaaaabaaabababbbbaababbbbbabbaaaaaabbaabbbbabababbabaabb
|
||||||
|
babbbababaaabbbabaababbbaaabababaaaababbbabbaabbabaabbba
|
||||||
|
bbbabbaabaabbbbaaaaaabaabaaabbab
|
||||||
|
bbbabbbbaabbaabaaaaabbbbbaabbabbabbaabaababbaabbaaabbaaa
|
||||||
|
aaababbbbaaaabaaabbabbbbabbbbaba
|
||||||
|
aaaaabbababaabbabaaaaaaaaaaaaababbbbbbaaababbaaaaabaabab
|
||||||
|
babbababbaaabbabbabbaaaabbaabaabbaaabbab
|
45
2020/day19/day19.hs
Normal file
45
2020/day19/day19.hs
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
module Day19 where
|
||||||
|
|
||||||
|
import AoC
|
||||||
|
|
||||||
|
import Control.Applicative
|
||||||
|
import Data.Char
|
||||||
|
import Data.Foldable
|
||||||
|
import Data.Map (Map, (!))
|
||||||
|
import qualified Data.Map as M
|
||||||
|
import Data.Maybe
|
||||||
|
import Data.Tuple
|
||||||
|
import Text.ParserCombinators.ReadP
|
||||||
|
import Text.Read.Lex
|
||||||
|
|
||||||
|
data RuleElement = Literal String | Reference Int
|
||||||
|
|
||||||
|
parseElement :: ReadP RuleElement
|
||||||
|
parseElement = parseRef <|> parseLit
|
||||||
|
where parseRef = Reference <$> readDecP
|
||||||
|
parseLit = Literal <$> between (char '"') (char '"') (many1 $ satisfy isAlphaNum)
|
||||||
|
|
||||||
|
parseRule :: ReadP (Int, [[RuleElement]])
|
||||||
|
parseRule = do ruleNum <- readDecP
|
||||||
|
string ": "
|
||||||
|
alternatives <- parseAlternatives
|
||||||
|
return (ruleNum, alternatives)
|
||||||
|
where parseAlternatives = parseSequence `sepBy` string " | "
|
||||||
|
parseSequence = parseElement `sepBy` char ' '
|
||||||
|
|
||||||
|
buildParser :: Map Int [[RuleElement]] -> Int -> ReadP String
|
||||||
|
buildParser m i = buildAlternatives $ m ! i
|
||||||
|
where buildAlternatives = asum . map buildSequence
|
||||||
|
buildSequence = foldl1 (liftA2 (++)) . map buildElement
|
||||||
|
buildElement (Literal s) = string s
|
||||||
|
buildElement (Reference j) = buildParser m j
|
||||||
|
|
||||||
|
countRootMatches :: [String] -> Map Int [[RuleElement]] -> Int
|
||||||
|
countRootMatches input rules = length . filter (isJust . oneCompleteResult rootParser) $ input
|
||||||
|
where rootParser = buildParser rules 0
|
||||||
|
|
||||||
|
main = runAoC splitInput run (run . withExtraRules)
|
||||||
|
where splitInput = swap . fmap tail . break (=="") . lines
|
||||||
|
withExtraRules = fmap (++ ["8: 42 | 42 8", "11: 42 31 | 42 11 31"])
|
||||||
|
run = uncurry countRootMatches . fmap parseRules
|
||||||
|
parseRules = M.fromList . map (fromJust . oneCompleteResult parseRule)
|
Loading…
Reference in a new issue