From: Brett Parker Date: Tue, 7 Dec 2021 22:07:35 +0000 (+0000) Subject: Day 19 (slightly evil!) X-Git-Url: https://git.sommitrealweird.co.uk/advent-of-code-2020.git/commitdiff_plain/74eb6cebd0b3532d96275e3e2aa8d41657f00cbf?hp=b1754ed665fed108a29cd4f9f5d6bee7c38f0258 Day 19 (slightly evil!) --- diff --git a/day19/input.txt b/day19/input.txt new file mode 100644 index 0000000..4e04851 --- /dev/null +++ b/day19/input.txt @@ -0,0 +1,536 @@ +101: 64 33 | 14 121 +130: 14 96 +117: 64 14 | 14 14 +48: 78 14 | 102 64 +107: 14 14 | 64 64 +56: 14 43 | 64 104 +5: 107 14 | 106 64 +67: 14 44 | 64 94 +100: 14 39 | 64 103 +32: 14 96 | 64 16 +25: 64 107 | 14 96 +37: 64 108 | 14 30 +42: 95 14 | 27 64 +113: 14 79 +13: 14 136 | 64 116 +83: 64 62 | 14 2 +105: 14 108 | 64 117 +28: 14 133 | 64 35 +66: 64 106 | 14 96 +41: 64 85 | 14 60 +88: 16 64 | 108 14 +49: 58 64 | 14 14 +111: 52 64 | 114 14 +3: 14 124 | 64 119 +82: 14 17 | 64 47 +116: 49 14 | 98 64 +91: 58 6 +127: 106 64 | 30 14 +125: 56 14 | 100 64 +23: 64 61 | 14 5 +31: 64 9 | 14 109 +86: 125 14 | 99 64 +35: 64 49 | 14 106 +10: 64 25 | 14 84 +85: 92 64 | 132 14 +46: 14 18 | 64 82 +128: 78 14 | 79 64 +79: 64 64 | 14 64 +29: 135 14 | 68 64 +87: 106 14 | 79 64 +96: 64 14 | 64 64 +27: 134 14 | 51 64 +109: 76 64 | 86 14 +9: 64 120 | 14 74 +81: 64 131 | 14 93 +12: 118 64 | 37 14 +11: 42 31 +108: 64 14 | 14 64 +16: 64 14 | 14 58 +63: 117 64 | 16 14 +126: 64 129 | 14 15 +53: 64 79 | 14 16 +75: 105 14 | 88 64 +93: 127 14 | 73 64 +26: 36 14 | 97 64 +124: 30 58 +36: 106 14 | 117 64 +21: 25 14 | 119 64 +92: 64 96 | 14 102 +131: 64 59 | 14 66 +4: 64 108 | 14 106 +44: 32 64 | 71 14 +45: 41 14 | 67 64 +94: 119 14 | 110 64 +58: 14 | 64 +38: 14 14 +112: 75 14 | 21 64 +104: 58 79 +59: 14 16 | 64 98 +114: 14 30 | 64 102 +65: 96 14 | 6 64 +68: 30 14 | 79 64 +129: 29 14 | 12 64 +39: 14 6 | 64 117 +78: 14 14 | 64 58 +115: 14 72 | 64 24 +57: 64 122 | 14 22 +71: 107 14 | 96 64 +30: 14 14 | 14 64 +64: "a" +106: 14 64 +89: 28 64 | 80 14 +20: 64 70 | 14 19 +133: 107 14 | 34 64 +34: 64 64 +22: 96 58 +90: 16 14 | 96 64 +51: 14 46 | 64 112 +69: 23 14 | 13 64 +15: 14 55 | 64 3 +123: 30 14 | 108 64 +17: 117 64 | 78 14 +40: 49 64 | 117 14 +135: 64 34 | 14 108 +47: 64 102 | 14 78 +97: 14 34 | 64 117 +2: 64 63 | 14 88 +54: 14 26 | 64 77 +118: 98 14 | 96 64 +76: 69 14 | 54 64 +102: 64 14 +121: 114 14 | 130 64 +99: 64 57 | 14 10 +60: 130 64 | 65 14 +98: 58 58 +132: 64 117 | 14 30 +74: 89 14 | 50 64 +19: 78 64 | 6 14 +1: 115 64 | 20 14 +18: 53 64 | 128 14 +72: 14 78 | 64 30 +103: 34 64 | 38 14 +52: 30 14 | 49 64 +120: 83 14 | 81 64 +70: 79 14 | 108 64 +7: 64 113 | 14 40 +24: 49 14 | 16 64 +84: 30 64 | 34 14 +110: 64 30 | 14 96 +55: 14 90 | 64 37 +62: 14 4 | 64 47 +80: 64 48 | 14 91 +95: 126 64 | 45 14 +77: 14 87 | 64 35 +14: "b" +134: 101 64 | 1 14 +119: 14 102 | 64 102 +0: 8 11 +33: 14 92 | 64 123 +6: 58 64 | 64 14 +50: 111 64 | 7 14 +43: 14 98 | 64 38 +73: 102 14 | 6 64 +61: 96 64 +8: 42 +136: 30 64 | 96 14 +122: 58 49 + +ababbbaaabbbbbbbbaaaabaaabbabaabbaaababbabbbbbbaabbbbbbababbaaaa +aabaabaaabbabaaaabbbabbbbbbbaababbababaa +baaabbbabbababbbbaaabbab +babbbaabbabbbbbbbbabbbababbbaaaa +baabbaabbabbabbaabbbabababbabaaa +ababbbabaaaaaaababbabaabaabbaaaa +abbabbaaaabbbaaababbababbbbbbabbbbaaabbaaababbbb +bbbaabaababaaabbbabaaabbbbaaaabaabaaaaabaaababaa +ababaabbbaababaabbababbabbaabaabaabbababbbbababb +bbaaaaaabbbbabbabaaababbabaababbaaaabaab +bbaaaabaaaababbbbabbbbaababaabbaababbabbbabbababbbababaa +bbabbbbabbbabaabaabbbbba +aaabaaabaaabbbbabaaaababbbbaaaaa +bbaabbaabbbbbbaaabababbbaabaaabaabaabbbbbabbaababbbbbbaaabbbabaaababbaabbbbbaabbbbaababababaabaa +bbbbbabaabababbaaaaabbbb +ababababbbaaaaaaaababababbbaaabaabbbbbaa +aaabbabbaaaaababbaabaaaabaaababbbabaabbb +bbaaabbaababaaaaabababababbbababbabbbbabaaabbaaaabbbabaa +ababababbabaabaabaaababbbbabbbaabaabababaaaaaabb +aaabbbbaabbbaaabbbabbbababbababaaabababaabbbaaaababbaaaababaaaaabaaabaab +abababababbabaababababababbaaaababbaaaaa +aaabbaabbbbbbaaabaaaaaaa +abbaabbaabbababaabbaaaab +baaababbababbaaaababaabababbaaaaaabaabab +baabbabbababbbbbaaabbbbbbaaabaaabaaaabbbbbbababaaabbbabbbbababababbbaabb +baaabbbbababaaaaabbaaaab +bbababbaaaabbbbaabbaaaba +baababaabaabbbbbabaabbbabbbbababbaaabaaabbbbaabaaabbabab +bbabaabababbaaabaaaaaaabbabaaaaaaabaaaaa +baabbabaaabbbbaabbbbaaab +aabaabbabbabbaabbaabbbaaabaabbbbbbabbaba +baaabbbbababbaaaaabaabbabaabbabaabaaaaabaaabbaaaaabbabbbaabbabbbbaaaaabb +baaababbbbabbbaabbababbbaaabbabbaabbbbaabbbabbaabbbbabbb +ababbaaababababbaabbbababaabbbbbababbabbaababbbbaaaaaabbaaaaabba +aaabbaabaaabbbbabbbbaaaaababbbbb +baabbaababbaaaabbaaabbaa +bbbababababbbaaabbbaabab +bbaaabaabbaaababbbbbabbb +abababbabbabbaabaabbbabb +bbaaaaaaaababababaaaaaaa +aabaaabbbabbbbaaabbaabbaaabbbababbababab +babaaababbabbaaaabbaabbb +babababbbabaaabbbaaaaaab +ababbabbabaaabbabbbbbbbb +babbbbabaabaaabbbaaaabababbbabbbabbaaaba +bbaaaabbbbaabbbbbbbbaaab +bbbaaabbbaaaaaaabababaababaabbab +aabaabbababaaaabbbbbbbbbbbbbaabbbbbaabababbbababbabbaaabaabaabbaaabbbababbbbbbbbbaabbbaaabbbabba +abaabbbaaaababbaabbaabaabababbbabaabbabaaabbabaabbababaa +aaabbbbbbabaabbaabbaaaaa +bbabbbbababbababbaabbababaabbabbabbbbbbbabbaaabaababbaab +bababbbaaababbbabbaaabababbbaaba +abbababaaaababbbaaabbabbbbababbbbbababab +bababaaabbbbbabaabaaabbabbbabbbabbbbabbabaabbbbaaabbbbab +baaababbaaabbbaababbbbbaaaaabbbbbabbbabb +bbbbbbabbaaabbaababaaaaaababaaba +aabbaaababbbbaabbbaababb +aaabbabbaabaaabbaaaaaaba +ababbaaaabbaabbabaabbbab +aaaabbababaabbabbabaababbbaaaaabbbabbabbbbaababb +bbaaabaabbaaabbabbabbbaaabbbabbabaaaabaa +aaabaaabbaaaabaaaabaabbb +ababbbbaabababaaabbaabbaabaabbbaabbbaababbbbbbbaaabbabab +bbabbbaaabababaabbbbbbabbabbbbbbabbbbaba +abbabaabbbbaaaabababbaab +aaabbbaabbaaabbabbbbababaabaabbaabaabbaa +baaaababbbbbbbabaababbbaaaaabbbb +baababababbabbbbaaaabbbb +bbbbbaaaaaaabbabaaaabbba +bbbbabbababababbbabbbbaabababbbaabaaabbb +bbaaabbbabbbaaabbbbbbaab +bbababbabababbbbbbababbbaabbaaabbabaabaaaabaaaabaabbaaaa +abbabaabbabbaabbbabbaaabbbbbbaaaabaababbaaabaaaababbaabb +babbbbbbbbbbaaabaabbbbabaabbabbababbbabaabababba +bbbabbbabbaaabaaabbaabbabbbaaaba +abbabbaaaabaabbaababbbbaaababbabbbaabbba +abbabbababababbaabbbbaba +babbbaabaaabbbaaabaabbab +aaaaababaaababbaaabbbbaabaabbbaabaaababbbbaabbbabbbabbaaabaaabbb +abaaabaabbaaabbaabbaabaabbbbaaab +abaabaaabbabbbaaaababaabbababbbbabaabbab +abaaaabbaaaabbabaaaababb +aaabbaabbbaabbbbaabaabab +bbabaabaabaaaabababbaaaa +ababbbaaababbbaaaabaabbaaabaaabbaaabbaabbaabbbbabbbbaabbabbaaaaa +bababbbbababababbbaaaabaabbbbabb +abaaaaaabaaaabaaababbaaaaaabbbbaabbbaaab +abababbbbabaaabbbaaaaabb +bbbbbbaababbbaaabbbaabaababbbbabbbababbabbabbabbbbbaaaaa +bbababbbbaaababbaaabbbaabbbbaaaababbbbaaaaaabaabaabaabbbaababbaa +abaaabbabbaabaabaabbaaaa +abaababbbbaaaaabbbbaabbababababa +baabbbaaabaabbbabbaabbab +babbbbbaabbabbbbbabbaabbaabbbbbaaabbaaaa +babababbbbbabbbabbbbbbbb +ababbbabaabaaabaabaabbab +babbababbaaabbbbaaaabbaa +abbabbbbbbabbbabaaabbaba +aaabbbaababbbaaabaabbbaabbbaaaabaababbaa +aabaaaababaaabaaaababbbabbbabababbbaabbb +baaaabbbaabbabaaababbababbaaabbbaaaabababaaaabbbbabbaabbaabbaabbabbababb +aaabbbaaaaabbabbababbbbabababbbababababa +bbaabaabbbababbaaabbbabb +ababababbbabaabbababbbbaabbbbbaa +abbaaaabaaaababbabbababb +abbbababababbbaaabaaababaaaaaaabaaabbabbabbbaaaabaabbaaabbbaabab +aababababaaaababbabbabbb +babbbbabbabbbbabbbaaabbbaaabaababbaabaabbbbaaabaabbaababaaaaaabb +aaabbbaabaaabbbabbbbabbb +ababaabbaaabaaabbbbabbabaabbabab +ababbabbabaababaababbbbaabbbabaa +abbbbaababbabbababbaaabb +ababbbababbababaabbaabaabbabbbaabbababaa +abbbaaabbbaabaaabbbbbaabbaaaaabb +abbbabbababaaabaaabbbabb +bbbaabaabaabbbbabbbabaabbbababbaaaaaabbbabbabbbbbaaabbabaaabbbab +baabbbaabbbbbbababaaababaaaaabaaaabbbaabbaaaaababbbabbaabaaaaabb +aaaaaaabbaababaabbabbbabbababbbababbabaaabbbbabaabaabbbb +bababbaaaabaaabbbabaabbaabababbaaaaababa +abbabbbbaabababababbaaaa +aababbbabbaaaabababaabbb +bbbbbabbbaababababaaaaaa +babbababaabaabbbaabaabbabbababbbbaabaaabaaabbabbabaabbab +bababaaaabbbabbaaaaababb +aabaabaabbabbbbababababbabbabababaababba +ababbbabbabbababbbbbaaba +abaabababbaaabaaaaabaabb +abbabbabbbbbbaaabaabbbaaaababbbabbbaaaaa +abaaaabbbabbababbaaaaaba +bbabbaaababbbbabaaababaaabaaabbbabaababbaaabaabbaaabbbbb +aaabaabaababbbabaaabbbaaaaabbaaa +babbbbbaaaabbbaaaaabbbaabaabbabaababbbaa +babbbbabbbbbababaabaabaababbbababbbaaabb +baabbabaabaabbbaababbabbaaababbbbbbabbaabaaabbaa +abbabbaaaaabbbbabbabababaababbabbbbabbaa +aaaababababbbaaaaaababbbaaabaabaaabaabbabbaaabaa +baabaabbabbaabaabbbabbbabbaaabababaabbab +aabbaabbaabbbabaabbbbbaa +abbabbbbaaaabbabaabaaababbbabbbb +bbabbbbabbbaabaabbaaaabaaabbaaaa +abaaaababaaaabbabbbaaabababababaabaababb +babbbbbabbabababbbbbaabbbbababaaabbbabaaabbbaababbaaaaba +abbbabbabbbaabaaabaabbbb +babbbaabbababbaabbaaabba +bbaaabbaaabbaaabbbbabbbabaaaabbbaabbbbaaababaaabbbaaabbb +aaaaabbbabaabaaaabababbbabbbaabb +bbabbbabbababbbaabababaabbababbabbbababababaaaaaaaaabaababbaaabb +ababbabbbaaabbbbbabaabaabaabbbaababbabbb +bbbbbbaabbaaaabaabbabaabbbbaaaababbaababaaaabbbbbbaabbba +babaabbabaabbbbbababbbabababbbaabbbaaaaa +ababaaaaabbbbaabbaababbb +bbaaabbbbbbaabaaaabbbbba +bbbbbabbaaaaabbbababbbbaabaabababbabaaaaababbaaabbbaaababaaaabbaabbbbbab +babbaabbbababbbbbabaabbaaabaaabbbaabaaab +aabbbaaabaaababbaaaaaaababbbabaa +ababaaabaaabbbaabaabbaaa +bbbbbbaaaaabaaaaaababababbbababababababa +aaabaabaabaaabbaaaaaaaaa +babaabaaaabbaaabaaabbbaabbbbbbababbaabbb +abbabaabaabbaaabbbbbaaba +aabaaaababbabbbbabaaabababaabaab +bbabbbabbababbaabababbbaaaaaabba +aaababbabbaaabbaaaaaabbbbabbabbaabaabbbabbaabbabbbbbbaab +aaaabaaabbaaabbaaaaabaaaababbbaabbbbbabbbaabababbbabbaaaaaabaabbaabababb +bbbabaabbaabababaaaabbabbaaababbbbabbabb +babbbbaabaabaabbbbabbbaaabbaaaababbbbabb +ababaaaabbbbbabaabaababb +bbaabaabbbbabaaaababbaab +aabaaaabaababaabbaaabbaa +aaabaaaabbbbbabbaababababbbbaabb +babbbaaaabababaaababbaaabbaaabaaaabaabababaabaab +bababbbbaaabaaaaabbbaaabaabaabbb +abbbabbabaabaabbaaaaabba +baaababbbbaaabaabbabaabbabababbabababababbbbababaaabaaaa +bbabbbbababbbbbbbabbbaba +bbbbbabbbbababbbbbbbaaba +babbaabbbbabbbabbbbababb +bbaabaaabbbbbababababababbaabbaaabaaaabbbabbbaababaabbbbaaababab +ababbbabbbabbbbabaabbaab +bbaabbbbbababbaaabbaabab +aaabbaaaaaabbabbbabbbbbbabaabbbaaaaaaaaabbaabababbababaabbaababbabaaaabbaaaabaabbbbbbaab +abaaabbbbaaabbaababbbabbabbabbba +abaabbbababbbbabaababbab +abaaaabaabbabbaaaabaabab +aaabaabaaaabbbbbaabaabaaaaabbbaababbababbbbbbaab +ababaabbabaaabbaababbaba +baabbabbaaabbaabbbbaaaababbbbabaaababbbb +baaaababaaabbbbaaabbaaba +bbabbaababaaabbabbbaaaabbbaabbbababaabbb +aabaabaababababbaaabbbab +aababaabbbabaaaaaabbbbab +babbbbbaababbbaaaaaaabba +bbababbababbbaabbbabbabb +bbbaaaabbbababbabbaaababbabaaaba +bbababbbbbbbababaababaaa +babaaabbababaaaabababbaabbbaabab +ababaaaaabaaaabbababbabbbaaaaababaaaaabb +bbbbabbabbbbbabbbaaaaaaa +ababbbabbbaabaabbaaabaaa +baabbbaaaabbbbaaabbbbabb +bbaaabaabaaabbbbabababbbaabababababbaabbbbbababbabaaabbb +abbbaaababbbbbbbbabaabbb +ababaabbbbbbbbababbbbabbaabaaaabaaabbaabaaabbababbababab +abbaabaaaabbbbaaaabbabbb +bbaaabbbbbbbbbaaabbabbbbbabbbbaabaaaabbabbbaaabb +bbbabababbbbbbabbaabaabbbabbaabbbaabaabbabaabaab +bbbaaaabbaaababbabbabbbbabaabbaaabbbabbb +abbaabbabaabbaaababababaabbbaaba +babbbbbababbbaaababababa +abbbbaabaaaaababbabaaabbbaaabaab +aaabbabbbbbabaababbaaaaa +aaabbbbaabbaabbaaaaaaabb +babbaabbbbaaabababaaaabaaababbbaabbbaababbbabbaabaaaabbabaabaaabbbbaaaba +aababaabbabbbbaabbbababababbaaaa +abababaabbaaaabaababbbbb +bbbbababbbabbbbabaaababa +bbababbbaababababbbaabaaabababaabaaabbbbbaaaaaab +baabbbabbbaabbbaabbababbbbbaaabbbabbaaabbabbaabaabbbbbabababbbab +bbbbbabbbabbbbbbaabaabbb +abbabaabababaabbababbaba +abaaabaaabbabbbbababbaaaaaaaaabbaabbbabb +bbabbaabbbbbabbababbaaba +bbababbaaabababaaaaababa +baabbbaababaaabbabbbabbaaabbbabbabaaabbb +aaabbabbababbaaabbbabaababbaaabb +abbbbaabaabaabbababbbaabaaaaaaabaabbaabbabbabbba +babbabababaaaabbbabbaabbbbaaabbaabaababb +abbabbaabbbabaaaaabbbaab +babbaabbbbbbababaaababab +aaabaaaaaabbbbbbbaabababaaaaaaba +abbabbaababbababaabbbabb +abababaabbbabababbaaaabb +aaaaabbbbbbbbabaabbaaaab +bbabaababababaaabbaaabaababababa +aababaabbbaabbaababbbbbaaabbbbbaaabbabab +ababaabbbababbabbaaabaaaabaabaabaabbbbabbbbbbbbbabaabbaa +abbababaabaaababbaabbbaababbaabbbabbbabbbaababbb +bbababbabababbaaababbabbaabbaaababbaabab +aabbbaaababbaaabbbbaaaaa +babbbbaabbbabaababbbbaabbbaaaaaabbababbbaaababbabaaaaaba +bababaaaaabaabbaaabbaaaa +babbababbabbaabbbaabbbbbbbaaababbbabaababbabaaaabbbbaaabaaaabaab +aaaabaaaaaaabaaababbbaababbbbaba +baaaaabaaabbaabaaaaabaabaababbbb +bbbbbabaababbbababaabbbaabaabbbbbabbaaba +babbbbbbaaaaababbbbbababaabaaabbbaaababbaabbabbb +abaaaabaabbbbbbbbabaaaab +bababbbabbaaaaaaaaababab +abbabbabbbababbabbabbaabbaabaaaabbaababbbabaaaba +bbbbababbabababbabbabbabbbaaabaabbabbabb +aabaaabaabbabbabbaaaabaabbbbaaaabbaaabbbaaaaaabb +bbabbbabaabbbaaaababbbbabbbbbbbb +bbaaabbbbabbbbbaabbbaaaa +bbbbbabaaabaabbaaabbbbba +aaabbbbbbbbaabaaabbbbabb +baabbabbbaabbbbaaabaaabbababababbaaababa +aaaabaaaaabbbbbbababababbbbbaaba +baabbbbabaaaababababbbbababbbbba +babbaabbaaabbbbbbbbaabab +abaaaabbbaabbabaabbbaaababbabaabbaaaabbbaaabbaaaababbaab +bbaabaabbaabbbaabaabbabbbbbaabaabbbbaaabbbbaaaba +abbbababbbbabaaaaaaabbba +aabbbbbbbabbbbaaabaaabbb +bbaaaaaabbbbabbabaabbaaa +baaaabababaaabaaabaabaaabababaab +abaaabaaabbbababbbbababb +bbbabaaabaabaaaabbabbbbabbababbbbbbbaabaaabbbabb +bbaaaaabbbbaabbbbbabbabbbbababbaaaaaaabbbbbbababbaaabbbabbaabaabbaaaaaabbbbbaaba +abbaabbabaabbababaaaabababbaaabbabaaaaab +abbaabaaabaabbbabbabaaab +baabbbaabbbbbaabababaaaababbaabbabaaaaaaabbbbabbbaabaaaaabababbb +aabbaaabbbaaaabbaaaabbabaabbbaaaaabaababbbababab +baabbbbaabaaabaaabbaabbbbbaababababbaaba +abaabaaaababaaaaabaabaab +bbbbabbabbabaaaabaabbabababbbaababbbaabaabbbaaaa +abaaababaabaaabbbbbbbaaababaaaaa +ababbaaabbbbbabbaabaaaababaaabbb +aababbbbbababbaaaabbbabbabbbabababbbbbababaabaabaabbbaabaaabbbbb +babbbbbbaabaaabaabbababaabbbabbaababbbabababaabbbbbaaaba +bbbabaabbbaaaabbbbbababb +abbbabbaabaababaabbbbbbbbbababaa +aaaaabbbabbbbaabaaaabbaa +bababbbaabbabbbbaaabbbbbaabbabababbabbababaabbbbababbbbb +bbababbbabbabbbbbbabbbababaaaababbbbaaaabbbbbabbbbbbaabb +abbbababaabbaabbbbbaabab +aaababbabbbaabaaaaabbbbbabbbabbaabbababaabbbbbba +aaabbabbaababaabbababbbabbaabbbbabbbbbbbbaaabaaa +bbbbabbabbaabaabbaaabbbbbaabbabbbaababbbabaaaaaa +baabaabbbababbbbabaaabbbabaabaababbabbaaaabbbabaaaababbbbaaaabaa +bbabbaabbabbbbabababbbaabbabbaaabbbaabbb +ababaabbababbbbabbbabbbb +abababbabababbbbbbbababb +bababbbbbbbbbbaaaabaabbb +babbbbaabaabbabbbbbabbbb +baabbbbbbabbbbbbbbababab +bbbbabbababbbbbaaabbbbaaabbbbbaa +abababbabbbaaaaaaaabbbababababaaabbbababaaababbababbabbaaaabbaabaabbaababbbbaaba +abbaabaababbbbbbbaaaabba +abaabababbababbbabbbaaaa +bbbbbababbaaaabbaabbaaba +aaabbaabbaabbbaabbababaa +bbaaaabbabbabbbbaaababaa +bbbabaababaabbbbaababaaa +bbaaabbbaabaaababbbabbabbbbbbbbb +abbaabababbbbbbbbababbaabbbbabbbbabbbabaaabaabaa +bbbbbaaaaaaaababaaaaababbaababaabbbbaaabbababbab +bbaabbbbaabbbbaaabaaabaaaaabbabbaaaaabba +baabbbbabaabbabababbabaa +aabaabaabaaaabaabaabbbaaaaabaaababbbbbbbbbaabaab +ababbbaaaaabbbbbaabbbbbbbbbabbaaababbaab +babaabbaaaaabaaababbbbbababbbaabbababaab +baabababababbbaababababbbbbaabab +abaabababaabbabaaaaaaabaababbbbaaaaaaabaabbbbabaaaaaabbababbabbababaabbababbbaaa +babababbaaabaabababababa +aaababbbaababababbbbaaaaaaababbaabbbbbabaabaabbb +aababababbaabbbbbabbaabbbbbaaaaa +abaaabbaabbababababbaaababaabbab +aaabbaabbabbbbaaaabaabaabaaabbbbabbabbaabaabaaababbaaaab +bababbbbaaabbabbabaaaabbaaaabbbaabbabbbaaaabaabb +bbbabaaaaaabaaabaabbaabbbaaabaaa +babaabbabbbbababbbabaaaaabbaaabbaaaaaaaa +abbbbbbbbbaabbbbbbbaabab +ababbabbbbaaabbaaaaababb +abbbababbbaaaabbabababaaababaaabbaabaaabaaababaabaababbb +babbbbbbbababbaababababa +babaaabbbaaaabaaaaaaaaba +bbbabbbaaaababbbaaaababb +aaabaaabbbabaaaababbbaba +baabbbaaaaaabaaaaabababaaaabaabababaabbb +abbabbbbbaababaabaabbbab +bbbababbbbbabbabaababbbaabaabbbababbbbbbbbababbabbaabbabaaabaabaabaabaababaaaababbbaabaaaaaabbbb +baaabbbabababbbbbabbaaaaaaababaa +bbbaabaaaaababbbabbbabbaaaaaaabababaaaab +ababbbaabbbaabaaaaaaaaaa +baabaaaaababaabbabbbbbaa +aabbbaaaaaabbaabaabbbaaaabaabbaa +baababaaaaaabbabbbbabaababaabaab +abbbbabbaaabbabaabbbbabbbababbab +bbaaabbbabbabbaabbbaaabb +bbaaababaabaaaabaaabbbab +aaababbbaaaabbabbaaaabba +bbbbbbbbbbabaaaababbbbabaaabbabbaaaaabaabbabbbaabaabaabb +abbbababbbbbbabbabbbbaaa +aaaabaaaaabbaabbbaabbabbaaabaababbaabaabbabaaaaa +babababbaabbaabbbbbabaababbbbaabbbababab +abaaabaaabbbbbbbaababababbaabbbabaaababa +bbaabbbbabbabbabbbaaabbabbaaaaaaaabaaabbbbababaaabaaaabbbabbababbbbbaabbbbaababb +baabbbbbabbbabababbbababbbaaababbbabaabbbbaaabaaaaabbabaaaaaaabb +ababbbaabaabbabbaaabbbbbbababaaababaaaba +aaaaababbbaabbababbaabbbbbabaaabbaaabbab +aabbaabbaaaabaaaaabbbbaaabaabaaababaabbabaabbaabababbbbb +aaabbbbaaaaabaaabbbbabbabbbaababbbaabaaa +bbbbbbabbaabaaaabbbaaaaa +babbbaaabaaaabaabbbbbaabbbbbaabb +bbaabbbbbaabaaaaabbbaaaa +bbababbaaababbbaababbaaaaaaaabba +abababaabaabbbaababababbbaaaaaba +ababaaabbbaabbbbbabbaaba +abaaabbaaabbbbbbbabaabbb +aabbbbaabbaaaabbbabbbbbbaabaaababaabaababaaabbab +ababaaabababbbbaaabbbbab +abbbababbbbabaabbbbaabbb +aabbabaabaabbabbbbbbababababababaabbbabb +bababbaaaaabaabaaabbbbaaaabbabab +bbabaaaaaababbbaabbaaaaa +bababaaabbbbaaaaababaaaababbbabaabbaaaab +bbbbbaaababbbbbbabbbbbba +baabaabbbaaaabbabbbaabbaababbaab +aabbbbbbaaababbaabaaababababaaabbbbaabbaaaaaaabaaaababaa +bbbbbabbabbabaabbaaabbbbabaababaaababbabbabbabaa +aaabbabbabababaabaabaaba +abaaabbabbabbbbabaababbb +baaabbbbbbabaaaaaaaabbbb +baabaaaabaabbabaababbbabbabbabaa +babbababbbaabaabbbbbbabbaababbbb +aaabbbaabaabbbbbabbbbbab +baababbaabbbbbaaaabaabab +bbabbbababbaabaaaaaabaaaabaababababbbaabbbabbaba +ababbbbabaabbabaababbaab +ababbbaabbbbbabaaabbbaaaaabbbbbabbaabbba +babbaaababaabababbbbabaa +baabaabbbbbbabbabbaabbaaabaabbab +aabbaaabbbaaabababbaabaaabbbabababbaaabbbabbbabb +bababbbababbbaaabbbbbababbaabbaabbbbaabb +baabbbbbbaaaabaaabbbaaabbabbbbaaababbabbaaabaaaaaaaaabaaabbabaaaaabbbaabbbabbbbb +babababbabbabbbbbabbbbab +baaaababbbbabbabbbabaabaaabbbbba +babbbbabaabbaaababaaababaaabbabbbabaaababaaaaaaa +aabaaabaabbabbaaabbbbbaa +bababaaabaababaababaaaaa +ababbbbabbabaabaababaaaabaaaaabb +bbababbaabaabbbabbabbabb +baaaababbbbaabbbbbbbabaaababbaba +aaabaaabbabaabbaababbbabbaaabbaa +babaabbabbbbabbaabbabababbbbbaababbbabbb +bababbaababbbbaabbbabaaaababbababbbbabbb +bbbbbababababbaaabbabbaabbabbaabbaaabbbabaaabababaaabababbbababb +aabbbbbbbababaaaabaaaabbbbbaabba diff --git a/day19/monstermessages.py b/day19/monstermessages.py new file mode 100755 index 0000000..0dc8d16 --- /dev/null +++ b/day19/monstermessages.py @@ -0,0 +1,59 @@ +#!/usr/bin/python3 + +import sys +import re + +filename="p1_2.txt" +if len(sys.argv) > 1: + filename=sys.argv[1] + +in_rules=True +rules={} +data=[] + +for line in open(filename, "r"): + line = line.rstrip() + if line == "": + in_rules=False + continue + + if in_rules: + (rule_number,rule) = line.split(":") + rule_number=int(rule_number) + rule=rule.strip() + rules[rule_number] = [s.strip() for s in rule.split("|")] + else: + data.append(line) + +def get_rule_regex(rulenumber): + regex="" + first=False + for rule in rules[rulenumber]: + if rule[0] != '"': + # not a character, so we're going to go down the wishing well + for number in rule.split(" "): + number=int(number) + regex+=get_rule_regex(number) + regex+="|" + else: + regex+=rule[1:-1] + if regex[-1] == "|": + regex=regex[0:-1] + regex="("+regex+")" + + return regex + +# ok - so all the rules are in, lets build a huge regex that gets all the rules +for rule_number in rules: + print(str(rule_number) + ": " + "| ".join(rules[rule_number])) + +pattern="^"+get_rule_regex(0)+"$" + +match_count=0 + +for line in data: + if re.search(pattern, line): + print("Line: {} matches".format(line)) + match_count+=1 + +print("There were {} matches in total".format(match_count)) diff --git a/day19/monstermessages2.py b/day19/monstermessages2.py new file mode 100755 index 0000000..be35125 --- /dev/null +++ b/day19/monstermessages2.py @@ -0,0 +1,90 @@ +#!/usr/bin/python3 + +import sys +import re + +filename="p2_12.txt" +if len(sys.argv) > 1: + filename=sys.argv[1] + +in_rules=True +rules={} +data=[] + +for line in open(filename, "r"): + line = line.rstrip() + if line == "": + in_rules=False + continue + + if in_rules: + (rule_number,rule) = line.split(":") + rule_number=int(rule_number) + rule=rule.strip() + rules[rule_number] = [s.strip() for s in rule.split("|")] + else: + data.append(line) + +def get_rule_regex(rulenumber): + regex="" + first=False + for rule in rules[rulenumber]: + if rule[0] != '"': + # not a character, so we're going to go down the wishing well + for number in rule.split(" "): + number=int(number) + regex+=get_rule_regex(number) + regex+="|" + else: + regex+=rule[1:-1] + if regex[-1] == "|": + regex=regex[0:-1] + if len(rules[rulenumber]) > 1 or len(rules[rulenumber][0]) > 3: + regex="("+regex+")" + + return regex + +# because we're doing insane things, lets build the regex for rules[8] first, which is literally 42 multiple times +#rules[8]=["42", "42 8"] +#rules[11]=["42 31", "42 11 31"] + +rules[8]=['"((' + get_rule_regex(42) + ')(?P(' + get_rule_regex(42) + ')*))"'] +rules[11]=['"((' + get_rule_regex(42) + '))(?P.*)((' + get_rule_regex(31) + '))"'] + +# ok - so all the rules are in, lets build a huge regex that gets all the rules +pattern="^"+get_rule_regex(0)+"$" + +match_count=0 + +for line in data: + matches = re.match(pattern, line) + if matches: + if matches.group('rule11'): + part=matches.group('rule8') + matches.group('rule11') + rule_31_matches=0 + rule_42_matches=0 + while len(part) > 0: + # remove the end, and keep count, we need at least that many rule 42s to + # be removed from the front + remove_pattern=get_rule_regex(31)+"$" + new_part=re.sub(remove_pattern, '', part) + if len(new_part) == len(part): + # try removing a rule 42 from the start + remove_pattern="^" + get_rule_regex(42) + new_part=re.sub(remove_pattern, '', part) + if len(new_part) == len(part): + # if nothing got removed, and we're not 0 length, we're not a match + break + else: + part=new_part + rule_42_matches+=1 + else: + rule_31_matches+=1 + part=new_part + else: + if rule_42_matches >= rule_31_matches: + match_count+=1 + else: + match_count+=1 + +print("There were {} matches in total".format(match_count)) diff --git a/day19/p1_2.txt b/day19/p1_2.txt new file mode 100644 index 0000000..1500b6f --- /dev/null +++ b/day19/p1_2.txt @@ -0,0 +1,12 @@ +0: 4 1 5 +1: 2 3 | 3 2 +2: 4 4 | 5 5 +3: 4 5 | 5 4 +4: "a" +5: "b" + +ababbb +bababa +abbbab +aaabbb +aaaabbb diff --git a/day19/p2_12.txt b/day19/p2_12.txt new file mode 100644 index 0000000..8c931b1 --- /dev/null +++ b/day19/p2_12.txt @@ -0,0 +1,47 @@ +42: 9 14 | 10 1 +9: 14 27 | 1 26 +10: 23 14 | 28 1 +1: "a" +11: 42 31 +5: 1 14 | 15 1 +19: 14 1 | 14 14 +12: 24 14 | 19 1 +16: 15 1 | 14 14 +31: 14 17 | 1 13 +6: 14 14 | 1 14 +2: 1 24 | 14 4 +0: 8 11 +13: 14 3 | 1 12 +15: 1 | 14 +17: 14 2 | 1 7 +23: 25 1 | 22 14 +28: 16 1 +4: 1 1 +20: 14 14 | 1 15 +3: 5 14 | 16 1 +27: 1 6 | 14 18 +14: "b" +21: 14 1 | 1 14 +25: 1 1 | 1 14 +22: 14 14 +8: 42 +26: 14 22 | 1 20 +18: 15 15 +7: 14 5 | 1 21 +24: 14 1 + +abbbbbabbbaaaababbaabbbbabababbbabbbbbbabaaaa +bbabbbbaabaabba +babbbbaabbbbbabbbbbbaabaaabaaa +aaabbbbbbaaaabaababaabababbabaaabbababababaaa +bbbbbbbaaaabbbbaaabbabaaa +bbbababbbbaaaaaaaabbababaaababaabab +ababaaaaaabaaab +ababaaaaabbbaba +baabbaaaabbaaaababbaababb +abbbbabbbbaaaababbbbbbaaaababb +aaaaabbaabaaaaababaa +aaaabbaaaabbaaa +aaaabbaabbaaaaaaabbbabbbaaabbaabaaa +babaaabbbaaabaababbaabababaaab +aabbbbbaabbbaaaaaabbbbbababaaaaabbaaabba