diff --git a/2020/day19/input b/2020/day19/input new file mode 100644 index 0000000..43b7dee --- /dev/null +++ b/2020/day19/input @@ -0,0 +1,600 @@ +126: 116 104 | 107 95 +28: 104 | 95 +25: 116 95 | 33 104 +17: 98 104 | 14 95 +69: 120 104 | 86 95 +78: 49 95 | 57 104 +124: 95 36 | 104 74 +61: 104 39 | 95 30 +27: 99 95 | 41 104 +114: 50 104 | 102 95 +76: 83 95 | 116 104 +22: 95 133 | 104 53 +9: 104 71 | 95 63 +72: 65 104 | 90 95 +125: 77 95 | 60 104 +130: 104 44 | 95 69 +106: 33 95 +77: 104 20 | 95 101 +118: 95 104 +99: 95 32 | 104 54 +15: 95 116 | 104 116 +92: 104 132 | 95 23 +120: 66 95 | 37 104 +94: 53 104 | 16 95 +3: 104 107 | 95 10 +40: 95 36 | 104 38 +54: 95 104 | 104 95 +21: 97 104 | 16 95 +12: 104 54 | 95 49 +109: 104 16 | 95 33 +26: 76 95 | 106 104 +105: 49 104 | 133 95 +84: 104 131 | 95 72 +34: 104 91 | 95 112 +23: 126 104 | 15 95 +86: 104 81 | 95 113 +67: 104 107 | 95 49 +20: 95 53 | 104 16 +46: 97 95 | 107 104 +47: 95 33 | 104 53 +134: 104 10 | 95 32 +58: 95 32 | 104 116 +70: 2 95 | 40 104 +60: 95 96 | 104 19 +75: 129 104 | 122 95 +102: 124 104 | 26 95 +123: 104 53 | 95 118 +49: 104 95 | 28 104 +41: 104 43 | 95 16 +43: 95 104 | 104 104 +50: 95 119 | 104 64 +31: 95 7 | 104 130 +29: 62 95 | 79 104 +103: 55 95 | 56 104 +2: 22 95 | 123 104 +91: 85 104 | 13 95 +93: 95 30 | 104 134 +6: 104 33 | 95 57 +96: 53 104 | 97 95 +4: 95 27 | 104 75 +101: 49 104 | 118 95 +90: 56 104 | 100 95 +85: 10 28 +18: 95 32 +81: 104 35 | 95 110 +11: 42 31 +80: 95 108 | 104 110 +10: 104 28 | 95 95 +95: "b" +16: 95 95 | 104 104 +115: 95 114 | 104 17 +0: 8 11 +33: 104 104 +14: 104 9 | 95 93 +30: 104 43 +133: 28 28 +53: 104 95 | 104 104 +63: 116 95 | 116 104 +68: 74 95 | 25 104 +1: 95 32 | 104 118 +110: 95 33 | 104 107 +111: 87 95 | 80 104 +5: 32 95 | 97 104 +79: 45 104 | 4 95 +88: 95 54 | 104 118 +122: 53 104 | 33 95 +32: 104 104 | 95 28 +42: 29 104 | 115 95 +129: 95 16 | 104 32 +7: 84 104 | 24 95 +112: 128 104 | 78 95 +119: 127 104 | 88 95 +82: 33 104 | 32 95 +45: 59 104 | 89 95 +37: 104 3 | 95 117 +100: 16 95 | 54 104 +59: 95 82 | 104 18 +98: 68 95 | 61 104 +132: 104 129 | 95 6 +83: 95 28 | 104 95 +44: 104 125 | 95 70 +62: 104 73 | 95 111 +107: 95 95 | 95 104 +38: 10 95 | 43 104 +8: 42 +36: 32 104 | 54 95 +39: 95 54 +117: 116 104 | 10 95 +52: 21 95 | 58 104 +56: 97 104 | 49 95 +24: 95 34 | 104 92 +57: 95 95 +87: 104 12 | 95 121 +127: 83 104 | 107 95 +108: 104 33 | 95 16 +97: 104 95 | 95 95 +113: 104 129 | 95 105 +19: 33 95 | 33 104 +73: 95 48 | 104 103 +13: 54 104 | 49 95 +116: 104 95 +64: 46 104 | 13 95 +55: 16 95 | 33 104 +71: 83 95 | 43 104 +65: 47 104 | 110 95 +35: 104 118 | 95 53 +51: 104 94 | 95 1 +128: 95 57 | 104 116 +121: 95 54 | 104 16 +66: 5 95 | 55 104 +131: 51 95 | 52 104 +74: 133 28 +89: 95 5 | 104 82 +104: "a" +48: 67 104 | 109 95 + +babbaabbbabaaabbababaaaa +babbbbbbaabbbbababaaaaba +aababbabbbaaabaabaaaabba +aaabbabaaaaabbbbabbaaaab +abaaabbbaaaabaaabaababababbabbababbababaaaaaaaba +aaabbaaaaaabbbaaaaababbbbabbbabbbaaaababbbaaababbbbbabbb +baababbbbbbabbabbbabbbaa +aaabaabbbbbbababbabbbbaa +bbbbabbaabaaaaaaabaabaaa +bbbabbbaaaabaabbbbabaaba +baabbabbaabaabaaaaabbaaababaaaabbbbbbbbbabbaaaab +aababbabbbabbbbabbbabbabbbaabbab +baabbababbbaaabbbbbbbaba +abbabbababbaabbaaaabbbabaabbbbaaabbbbabb +aababbababaaaaabbbbbbabb +bbbabaaaaaaabbababaaaaba +aaabbabaabbbaaaaababbbaa +bbbbbaaabababbabbbbaaaaa +aaabbbaaabbaabbaabbbbaaabaaabababbababbb +aabbabaabaabbbababbaabba +aabbabaabbbbbbaaabbbabbb +abbababbbaabbaaaabbaaabbbabbbabbbbbaabbbabbabbba +bbbbabaaabaabbbbbabbbbaa +baababbabbbbaaababaababb +bbbabbaaaababbabbbaababb +babbaaabbbbababbaaabbabb +bbbbaaaabbbbbbbbbbbaabba +aababbaabbbabaaabbbbabbabbbaaabababbaaaaaabaaaab +bbabaaabbabbabbbababbaaabaaaaabaabaaaaabbbbaaababbbaaaabbabaaaab +abaaaaaaabaaaaabbbaaabaaababaabaabababba +abbbbbabaaaaaabbabbbbbaa +aaaabbbbbbbbabaabbababbb +baabaaaababaaabaabbaabbb +baaaaabbbbababababababbb +aababbababbbaababbbabaaabbbabaabaaababaa +baabbabbbbbaaabbabbabbba +baaabbababbaaabbbbaaaababaaaabaababbbabababababaaabbbaab +baaababbbaababbabbabbaaaaabbaababbabbbaaabbbbbbb +abbabbabaaaaaabbaabaabaababaaabbbbbaaaabaaaababb +baabbbaabbaaaababababbbbaabbaaab +bbbaaaabbababbabaabbbabaaabbabbabaabaaab +baabababbabaabaabbbaaabbababbaaaaabbaaab +aabbababaaabbbabaabbabaabbabbaab +abbabababbabbbbbaabaabba +abbbaababaabbabbabbbabaaabaaabab +bbbbbbaaabaaabbbaabbbaaa +bbbabaabbbaaaabaababaabababbbaba +bbabaaabbaababbabbbbaabbbaaabbbb +bbbaaaabbaabababbbabbbab +bbabaaabbbbbbbbbbababbaaabaabaaabbababbb +abaaaabbbbaabbaabbabaaaaabaabbbabbaababa +baabbaaaaaaabbbabbababba +babbabbaaaabaabaababbbabbbbaaabaababbaaaabbabaab +baabbbaabbbbabbaaabaabaaabaaabaaabbaabbaabaababaabaabbbababbabab +babbbabbaaaaabaaabaaaaaabbbabaabaaabbbbbbbaaaababbbbbbbaaababbbaabbbabbbbaaaabba +ababbbbbbbbbbbbbbabbabbaabbbaaab +bbaaabaabaabaabbaaaabababbbbabbb +bbabbabbbbbbbbaabbbaabbb +bbbbabbaaabbaaabaaabaaaa +ababaabbbaabbababaabbbaabbbbbbba +baabaaaabaabbaabbababaab +aabbabaaabaaaaaabbabbbaa +abaaaabbbabaaabbbbaaaababaabbaaabaabbbbaabbbbaba +baaaabaaaabbbbabaababaab +babaabbaaabbaaabbbbabbaaabbaaabbbbaaaabbbbbbabbb +bbaaaabbbbbbabaabbbbabbababbaaaabbabbaab +aaabaabbabbaaabbbabababbbaababababababbabbbbabbb +bbbbbaabbabbbabbbaaaaaab +bababbaababbaaababaaaaabbbabbabbbbbbbbbbaaabbbbabbaabaabaabbbbbb +abbabbabababbababbaaaaab +bbbbbbaaaaaaabbabbabaaabbbaabbababbaabab +bbaaaababbaaabbabbbababbaabbababbbbbabababaaaabaabbaabaaabaababb +aaabaabaaabbbbbababbbabbbabbbbba +bbbbaaabaabbbbbaabababbb +babaaababaaaabaaaaaaabbabababaababababab +bbaaabbabbbbbaaaaabaaaaa +bbbabbaabbaaaaaaabaabaaaaaaaabbbbbbabbbbaaaaabbbbababaab +aababbbbbbaaaabaaaabbaaaaaababbbababaabaabbabaaabaaabababbabbbaa +baaababbbaabbaaaababbbabbbbabbaabbabaaab +aabbbbbabbbbaabbbaaaabbaabababbbbbabbaabaababbbabbaabbbabaaabbbb +baaabaaaabbabbbaabbbaabaabbaabbabbaabbbaaabaabababbbbbab +aababbbbabaabbabbababaab +abbaabbaaaaabbbbbaaabaaa +abaabbbbbbaaaabbbbaaababbbabbabbbabbbaaaabaaaabaaabbabbbabbabaaa +aaaabbabbaaababbabaabbabbbbabaaabaaaaaba +bababaaabbbbbbbbaaabbabb +babaababbbaaabababbbaabbaaabbaab +bbabaaabaaabaabbbbaaabab +abbbabaabbbabbabbabaababbaaabbabbabaabaabbbbabbaabaabaabbabbbaba +bbabbbbabbabbabbabbabbba +aabaabaabbabaaaaabbabaab +ababaaabbabaaaabbbaabbbb +ababbbabbaaababbaaaabbbbabababaa +bbbababbababbabaababbaab +bababbbaaabbababbabbabab +babbabbbaaaabababbbaaaabaaabaabbbbaaaaaaaababababbabababbabaaabbababbbbaaabbbbbbabbababb +bababbaaaabababbabaabbababbaabbb +aaaabbbbabbaaabbbabbabaa +babaababaaabaabaaaabaaab +bbbbaaaabaabbabaaabbbaaa +babbbabbbbbaaabbabbbbbaa +bbabaaaababaababbabaaabbbbbbaaaaabbaabbb +aabbbbbababaaabbaaaabbaabaaaabab +babbbaabbbabbbbaabbaaabbbbabaaba +aabababbababaaabbababaaabbbbaaaabaababbbaabbaaaabbabbbabbbbbbbabbbbabbbb +aabbbbbaababbbbbaaaabbbaabababaaabbbbbba +ababaaabaaabbbbbaaababbbabaababbbbaaabab +aababababbaaabbabbaabaaa +ababbbbaabbababbabbabbbb +bbbaaabbbbbbaaababbaabbababbaaabbaaabbbb +aaaaaabbbaabababbababaab +abbbbaaababababbaabbaaabaabbbaabaaabaaaa +bbbbbbaabaabbbabaaabbabb +baabbbaaaaabbbababaaaaba +abbbaaaababaababbbababba +babbaababbabbabaabbbbaabaaaaaaab +abbbbbabbabaaaabaaabbbbbbaaaaaaaaabbaaaa +aabababaabbbaaaaabbabaab +babbabbabbbaaabaabbaaabaabbabaaa +baabaabaaababbbbaabaabbb +aabbbbabbbbbabbabaabbbbb +abbabbabaaabbbababbbabba +bbaaabbaaabbbbbaaababbabaabbbbbabbabaabbbababaabbbabbbab +babaaabbbbaaaabbaaaabababbbbbbbaaaaabbaaaaabaaabbabbabba +bbababababaaabbbbabaabbb +bbbbaabbbbbbbaaaabbbbaab +baaabbbababaaabaaaabaabbabbabababaabbaababbaabab +bbaabbbaaabbabbabaabbbaaabbaaaababbabbbaabababba +abaabbbbbaabaabbbbbaabab +bbbabbaabbbbabbaabaabbabbaababaa +abaaaaabaaaaabaaabbabbbb +abbbaaaaabaaabbbbbabbabbbaaaaaba +baaabbabbbbabaaabbbaabbb +baabbabbaabbabaaabbbbbba +abaaabbbbbbbbbaabaabbbaabbbbaabbbabaababbbaabbbabbaabaabaaababaa +bbbbabaabbbbabaaabbaaaab +ababbbbbabaaaababbbaabbbbabababaaabaaabaabbabaab +abbaaabbababaaabbbbabbabbabbbaaabbbabbbb +bbbabbbabbbbbaababaabaaa +baaabbbabbbbababababaaababababaabaaaabab +bbbaaaabbaabbabaaaaaabbabbaabbba +babaabaababbbaabbaaabbaa +bbbaabbbaabaabababababba +bbbabaaaabbbbbababbbbaba +bbabbbbbbbbbaaaaabababaa +aaaaababaaabbbaabbbbaaabaabbbbabbabbbbbaaabbaabb +abbababbaababbbbbbaabbba +bbaaaabaaababbabbaababbabbbbabbb +abbbaabababbbabbbaaabbbabbaabbbabbaaabab +bababbbaabaaabbaabbabbababbbbabb +babaabbabbabababbbaabbba +aaaabbbabaaabbabbabbabbabbbbaabbabaabbaa +abaaababbbaaaabbbbababaabbbabbaababbbbbbabbbaaababaabbbbbbbabbaaaaabbaab +bbbabbabbaababbaabaababa +ababbabbabaaabaabaaaabba +abbabbababbaaaaabaaaaaab +baaabbbababaabaaabbaaabbbabbbbbbabbababbabbbbabbbababababaaabababaaabbbb +abbaaaaaaaabbaaaaaaaababbbabbbbababbbbabbabbbbaabbaabaaa +bababbbabbbbaaaaababbabbabaababbabbbbbba +aaaabbbaaababbbbabaaaaba +bbbabbbabbaaaabbabbabbabbbbabaaaaaaaaabb +bbbbabbabbaaaabbaaabaaaa +abbbaaaaababaabababbbaba +ababbbabaaaaabaaaaaaaabbbababbbbbabbaabbbbaaaaab +bbbaabbabababaabaabbaabaaaabaaabbaaabbabbabaaaababbbbbbaababbaaa +aabaabaaababbababbaaaaab +baabbbaabaaabbbabbbbabbaaabbaaababbbabab +bbbaaaabaabbabaaabbbabba +bbbaaabaababbabababbbaaa +baabbaababbababbabbaabbb +bbaaabaabaabaabaabbaabab +aaabbbabbbbaaababbbbbbbbbbaabaaa +abaaabbaaabababababaaabaabbaaabbabbbbaab +abaabbabaabababbbbbbabaabababbaabaabbabababaabaabaaaabbb +aabbababbababaaaabbbaaaabaaaaaab +abaabbababaaaaaabbbaabab +bbbbaabbbbabaaaababaababaaabbbbbaabaabaabaaabbbbbbabaabb +aaabbbbbbbbabbbabbbbabaabbbbbaaaabbbbbabbbbbbbab +aababbaababbabbbbbbbbbab +abbaaaaaaabaaabbbbbbaabababbbababbbaabababbaabbb +aaabbbbbababaabaababbaaabbaaababaaabaaab +abbbababaabbbbbaababaabbbbababbbaaaababaababaaaaabbbababababbabbababaabb +bababaaaabbaaaaaabbbaabb +bbbabbabaaabaabbbaababbababaaababbabaababaaabbbb +bbbbababaabbabaabbbabbababaaaabaaaaaaaba +abaaabaabaabaaaabbaaabaababbaaba +bbbbbaabaababbaaabbbbbbb +bbbabaaaabbaaabbbabaababababbabbbbaabaab +bbbababbbaaaaaaaaabbbaaa +aababbaabbbbbabaabbaabbb +bbbbababbaabaaaababbaabbbaababaa +babbbaabbabaababaaaabbbbbbaaabab +aababaabaaaabaaaabbbabab +baababbbbbabaaaaabbbabab +bbabbbbbbaabbbababbabaaa +aaaaababbaabbabaabbbabaaabaaaabbabbbaaab +aaabbbaabbbbaabbabbbbaba +baabababababaaabbabbbbbbaabaaaababbbabba +bbabaaababbbbbabbbbabaabbabbbabaaabaabab +aabbaabababababbbbbbbabb +bbabbbbabbaaabaaabbabbba +aabbbbabbaabbaaaabaababa +abaabbabbbbbaabbbbbabaabaaaaaaaa +baababbbbaababaabbbababbbabbbaaabababaaabbbbbabbabaabbbababaabbbbabababaabaaabbbabbaaababbababab +abaaaaabbababbababbbbbbb +baabbaabbabbbbbbaabaabbbaabbabba +babaababbbbaaabbabbaaaaaabaaabbbbbabbaaabbaabbbb +aaaabbbaaabbbbbaabaaaaaaaaabaabbbaaaabbaabbaabbbbaaaabbb +bbbaaabbabbabbabbbbbabaaabababbabbbaabab +bbabababbababbaabaaabbbb +ababbbabbbaabbaabaababbbbbbbbbbbabaaaababbaabbbabbbaabba +bbbbabbaababaabababaabaabbbabaabababbbabbbaabbbabbbaabaaaabaaaab +abbaabaababbbaabbabaabbabbbaabaabbabababbbaaaaaabaaaaabaabaababbbbbbaabbbbbaaaab +bababbaaaaaabbbbbaaabbbb +bbbaaabababaaaabbabababababaabaaabaaabababababba +bbbabbbabbbbbaabbaababbbaabbaabb +baaababbaabbaaabbaaaabbb +baabbaabbbbbaabbababbbbaaaaababbabbbaabb +bbbbaaababbbaaaaaaabaaaa +baaabbabaaaaabaaaaababba +bbbaaabbaabaabaaabbbabbb +aababaabbbaaabaaababbaab +ababbbabbbabbbbabaaabbbaaabaabbbaabaaaab +baabbaaabaabbababbaaaaab +aaabbbaaaababaababbaabbb +bbbababbaaaabbbbbbbbabbb +aaabbababaabababbbbabbbaaaaabbbaaaabaaaa +abbbbbabbabaabbaabaabbabaabaabaaaabaabba +bbbaaabbaaaabbabbbaabbab +bbaabbaaaababbbbaababbababbabbabaaaaababbaaabaab +bbbaaababbabbaaababbbbba +babaaabaabaaabbbbbbbbbbaaaababbbbabbabbb +bbbabbbabaabbababababaaabaaaababaabbbbaa +aaaabaaaaaaabbbbaababababaabaabbbbbaabbaabbabbaabbaaabab +abbbaaaaaababbabbaababaa +baababbbbabaaabaaabaabab +bbbbabbabaabbbababbaaababbaabaaaabbbbaab +babbabbababbbabbbabbbbaa +aabbaaababaaaaaabaaaabbb +baaabbabbbbababbabaaaaba +abaaaaababaaabbbabbabbababbaaaaaabbbabaaaabbbaabbbaabbabbbaaababbabbbaaa +bbbabbabbabababbbbbabbabbaaaaabbababaabbbbaabbab +abaaaaaaaaabaabaaaaabbabaaaaaaba +aaaababaaabbaaabababaaababaabaaa +abbbbbabaabababaabbbaaab +bbbbabbaaaaabbabbbaababa +baababbaaaaabaaaaaaaaabbababbbaaabbaabaa +abbbabaaaabaabaabaaabaab +aaaabbabbababbabaabbbbabaababbabaabaaaaa +aaaababababbbaabaaabaaaa +abbabbababaaabaabbabbaaaabbabbbaabaababb +babbabbabbbbbaabbbabaabb +aababbabaaaaaabbbabbbbbbabbaabaabbbaabbb +bbaaabbabababbbbaaaababaaabbbbbb +abababbbbbbbbbbaababbbbbaabaaabaababbbbbbaabbaababaababaaaabaaaaababbabb +aaaabaaabaaaaaaabbbbaabbaabaaaba +abbbabaababaabaaaaaaaaab +bbbababbbabbaabbaaabbaaaaaabbabaababbaabbbaababa +baaaaabbababbabaabaababbaaaaaaabbababababbaabbaaabbbaaaa +bbbababbbbbbabababbbabab +abaaaaabbabababbaabbabbb +bbbbbaababbbbaaaabaabbba +bbbbbaabababbbbaabaaaabbaabbaaababbabbabababaaaa +baabbaabbababaaaababaabbaaababaa +abbbbbababaaaabaabbabbabbabbbbabaaabaabaaaabaaababaaabaababaababbbbbabba +aaaabbabababaababaaabbbb +baabaaaabbabbaaabbbaaaabaaabbbba +baaaaaaaaaaabbaabababaab +baabaababaababbaaabbabba +aabababaabbbbbabbababbaabababaaaabbbbbaa +ababbabbababaabbbbbabaab +aababbabaabbababbaaabbbb +bbbabaabaaaaabaaaabbaababbbbaaabbaaababaaabaaaba +aaaabbbabbbbaaababaaabab +bbbbbaaababbaabbababbbaa +aaabbbabbababbbbabaaaaba +bbabbbbbaabaabaabbbaabab +baaaaaaabbbbbaabaabbaaaa +baabaaaabaabbabbabbabaab +aaaabababaabaaaabbbbbbba +bbaaaabbbaaaaabaaabbaaabbaaabbabbbbbabbbababaabababaaabbbbbaaaaa +baabbaabbababbabaabbbbaa +aabbbbababbaaaaaaabbabbabbabbaabbabaabababaaabbbbabababaababaaabbaabbbaa +bbabababbaaabbabbabaabbabbbbaaaaaabbabbbaaabbabb +babaababbaabababaaababaa +babbaabbbbbbabaabbabbaba +babbbabbbaaaabaaabbaaaaabbaaabbb +ababbbabaababbabbbbaaaaa +abbaaabbbabababbbbbbbbba +bbbaaaabbabaabababbaaabaabbabbbbabbabbaa +bababbbabbbbaabbabbbabbb +bbabbbbbaaaabbbbabbabaab +aaabaabbababbababaabbaaababababbaababbababaaababbabaabbbabbaababbbbaabbababbabab +baaaabaababaabaabbbbabaabaaabbbbbbbaabaa +bababbbbababbbabbaabbabaaaaaaaba +aababbbbbabaaababbaababa +aaabbbaaababbabbaabbabaababbabbaaabbbaaa +bbbababbaaabbbbbbbabbabbaababbabbababbbaaabaaaab +abbabbababaaaaabaaaaaabbabbabaaa +aaabbbaaaabababbababaaabbbbaaabbbbbbbaabbbbaaabbababbbaabbabbbaababababaabaabaabaaabbaab +babaaaababaaabaabbbbbaba +bbbabbabababaabaabaababa +bbbbaaabbbbaaababbaababa +bbbabbbabaababbaaaabbbbbaaaaaaab +aabbaabababaabababaaaaba +aaabbbbbaaabbbbbbabbabaa +baabaabababaabababbababaabbbaabbbbbababa +bbbbabaabbaabbaaaabbaabb +babbbaabbabbbabbbaabbbba +abbabababbbbaaabaaabbbabaabababaabbabbba +baabababbaaababbbbbbbbba +aabbbbabbaabaabaababbaab +abbaabbabaabaabaabaababa +baaabaaabbbaaababbbababbabbaaabbbbabbaaa +abbbbbabbbbabbbabbbbabababbbbaba +aababbbbbbabaaaaaaaababb +ababbabbabbabaaaaabbaaabaabaabababaaabbbaaaabbbaaabbbababbababbb +ababbabbbbabbaaaaababbba +abbbabbababaaaabababaaabaaabaaaabbbbbabbabbbabbbbaaaaababbbbaababbbabbabaaabbbaa +aabababababaabbaaabbabba +aabbaaabbbabbbbbbbbababbbaaabbabaabaaaab +babbbabbbbaaabbaaaabbaaaabaababa +bbaaaababbabbabaabaababb +aabababbaaaabbaaaababbba +babbaabbaaaabbabaaababaa +babaabaabababbbbabbaababaaababaaabbaabbb +aababbaaabaaabaababbbbab +bbabbbbabababbabbbabbabbabbaaaaabaaaaaab +abbbabaaabbaaababaaabaaa +bbababbbbbabaaaabbaabbbababbabbbbbbababbaaabaaaa +baaaabaabbaabbaababbbbbbabaabbbbbbbaaaaaaabbbbbb +baaabbabbabaababbbbbbaaaababbabaaabaabaaaaabbbaabaababaaaabbabbabaaabbbbaabbbbbb +aabbaaabaaabbabaabbababbaaaaaaab +ababaabababaababbbbabbabbbbabbaa +baabbbaaabbaaabbaaababaa +bbbbabbaaaaaaabbbaaabaab +aabbbababbbbbabbabababaababbaabbbabaababbabbbabbbaaaaaabababbbab +abaaaaaababbbbbbbaaababa +baabbbaaabbabbaabbbbabbabaababbbbbabbbaaabbabbababbbbababbabbababbabbbaaabaababa +bababaaaabbbaabababaaabbabbaaaab +abbaaaaaaaaabbbbbabbaaabbbbbababbbabaaabaaaabbbbbbbabbbb +aaaabbaabaababbbaaababbbaaaaababaababbbaaabaabbaabaabbbbaaaababbbaaabaab +babbababbaaaaaabaabbabbb +aabbaaababaaaaaaabbbbbba +bbbabaaaabbaaabaaabaaabb +bbabbaaababbbaabbbabababbbabaaabbaaabbaaaabaabbb +aaabbaaaabbababbaabababbabbbbbabaaaaabaaaabaababaabbbbaa +abaaaaaaaababbabbabababbbbabbbbaaabbababaabbaabbaababaaa +abbabaaaaabaaabaabbbbaabbabaaababaabababbbaababaaaaabbaabbbbbbba +bbaaaabbbbabbaaaabbbbaaa +babababbbaababbaaaaaabbb +aabababaaaabbbaababaaabbbaaaaaaaaaabaaaa +baababbaaaabbbabaaaaabaabaaaaaaabbbaabababababba +ababbbbbabbaaababbbbbabb +baabaaaabaababaaababbbab +bababaaaabaaaabbabbbbbba +aaaabbaaaababbabaababbabbabbbbaa +bbbbaaabbabaaaabbabbbabbaabbababaabbbaaa +bbabaaabbaaaabaaababbabbababbaaaaaaaaaaabbbbbabb +babababbaabbaaababbabaab +babbabbbbabbbbbbbabbababbababbbbaabbbaabaababbab +babaabaaabaaaabbbbbbbbab +aaaabbaabaabbaaaaabababaabbabbabaabbbabaababbaab +abaaaabbbaabbababaaaaaaaaaabbbaaabababaaabbbabba +abaaabaababbbbbbaabbabbbbaaabbbb +aaaabbbaaabaabaaabbaabab +bbbbabaaaaaaabaaaabbbbaa +abaaabaaaaababbbabaaabab +ababbbbbbbabbabbaababaabaaaabaaabbaaabab +aaabbabaababbbbaaaaaabbb +aaaaabbabbbbbbaabbababbb +bbbbaaaaabbbaaaaaabbaababaaaabaaaaabaabaababbbababbabbbbbbaababaaaababba +bbaaabbaaabbbbabaaabbaab +abbbaababaaabbbabaabbbaabbababbbabaabaaa +baabaabbbbbaaababbabababbbaabbababbbbbbb +bbbaaaabbbaabbaabbaaaaab +ababbbbaaabbabaaaababaaa +bbaaabaabbbbaaaaababbabbaabaabbbbaaabbbb +aaabbbabaababababbaabbbb +baabbbaabaaabbbabbbbbbaaababbbabbabbbbbabaaaabba +bbabaaabababaabbaaaaabbaabaaaaaaabbababbbbbbbbbaabbbbbbbaabbbaaa +aaabbbabaaaabbbbbabaabbb +abbbaabababaabbaaababababbaababa +aabbbbabaabaaaababbaabbbaabaaababaaabbababababaabbbaaaabaaaabaaaabbabbbaabaabbabaababaabbbabaabb +aaabbbabbabbabbaaaabbabaabbbabbaabbaabab +bbabbbbbaabbbbabbaaaaaba +bbabaaabbbbbbaabaabbaaaa +abbbaabababbbaababbbbbba +babaabbaabbaaaaaabbbbbbb +abaaabaaaaabaabbaabbbaab +baabaaaaababaabaabaabbbbbbaabaaa +aabbbbbaaabbaabaaababbba +babaaabaaaaaabbabbbaaababbaabbba +aaaabbbababababbabaaabbbbbbbbabaababababaababaaa +ababbbbbbbbabaaaaaababaa +bbaaabbaabbaaabbabbbaaab +bbbbbaaababbbaabbabbaaba +aabbbbabababbabbbaaaaabbabaaaabbbbababbb +baaaaabbaabbbbbabbaabaaa +baababbabbabbbbaaaaaaaaa +bababaaabbaaaabaabbbaabaabbaaaab +aaaababaaabbbbabaaabaabaabbabbbbbbbbbbab +babaaabbaaaaaabbbbababaaabbbbbbbaabbabaabbababbabbbbaaabbaabbaaa +baabaaaabbbababbaaababab +bbaaabbabbbababbaabbabbb +aabababbbabaabaabbaabaaa +bbabaaabbababaaaababbaaabaabababbaaabaabbabbbbab +abbbbbabaaabbabaaaababba +baaabbabbabaaababaaababa +baaaabaaaabbabaababbbbab +babaabbabbbbabbaabaababb +abbbabaaabbbaababaababbabbbabbbb +bbaaabaababbaaabaabaabaaaaaaabbabbaaabbaaaababbbbababaabbbbbbbba +abaaabbbbabaababaaaaababbbbaabaa +abaabbabbaaababbaabbbaab +bbbabbbaaababbabbaabaabbbbbabbababaaaabbbaabaaabbbbaabbbbbbaababbabbbbba +ababbabaabaaaaaabbabbbab +ababbaaaabbaaabbbaabbbaabbbabbbabbbbababbaabaaab +abbbbabbbbaabbbaabaaaaaabaaaabaaabaabbaaabababbabaaaabbbaaabaaab +babbabbaaaaaabbabbaaaaababaababbbbabbbabaabbbbbbaaaaaaba +baabaaababbbbbaabbbaababaaaaaaab +bbbbbbaabaabbabaabaababb +bbbabaabbbbbbabaabbaabbaaabbaabababbbbaababbabaaabaabbba +baabbbabbabaaaababaaaabbabbbaabaabbaaaaaabbaabaaabaabaababababab +abbaaabaaababbbababbaaaabbbbaaabbbbbabbbabbbbbaaaaaaaabbbbaababbaaabbabbababbbabababbabb +aaaaaabbabbaaabbaaaababb +aaabbbababaabbbbbababbaabbaaaababaaabbbabbbbbbbbabaababa +bbbababbaababbaabaaaabbb +bbaaaabbbbabbbbbaabbaabb +aaaabbbaaaabbaaabaaabaab +aaabaabbababbabbabababba +aabbabaaabbababbbaaaaaaabbbbabababbbaabbbbbaaaaa +abaabbabbabbbabbbbababba +abbaaaaaaababbabaaaabbaabaaaabbaabababab +aaabbbbbabbabbabbbabaaababaababb +babbbaabbabbbaabaaaaabaabababbbbbababbbbabbbbabb +bbabbabbaaaaabababaabbababbababbaaaabbbbabbbabbbababbbba +baabaababaabbabaaaaabbbababbbbbbbbabbabbbbbbaabaaaaabaab +aababababaaababbbbababba +baabbaaaaabbbbababaababb +ababaaabbaabbaaaabbabbbb +aaaababaaaabbaaaaabbaaaa +baabbbaaabaaabbaabbbaaaaaaaaaaaa +babababbaaaaaabbbaaababbaaaabbbaabbbbbababbbbbaaaabaabab +babbbababbbbaaabaabbbabbbaaababbabbabaabbabaaabbabbaaabababbbabaababbbba +bbbabbababaaaaaababaaaabbabbabbaaaabbbba +bbabbaaaabaaaaaabbabababbbbbbabaabbabbbbaabaaaaabbaaaaab +babbbbbbabaaaabbabababab +baaababbbbbababbbabbabbb +aaaabbbbabaabbbbabbaabaa +bbbabbbabbbbaaabaaaabbaabbbbaaba +bbbabbaaaaaabbbaababaababbbabbbb +bababbaabbabbabbababaaababaabaaaabbaababbaaaaaaaaabbabbb +bbabaaabbaabaababbaaabab +aababbbbababaaabaabbbaaa +abbbabaabaaababbbbabaaabbbbbababababaaaaaaaababb +aaabbbbbbaabababbbbaabbb +aaabbbaabaababbbbbbaabba +baaabbbaabaaaaaabbbabbabaabaabbabaababaa +abbabbabaaabbbbbabbbbbba +bbbabbbabbbabaabbabbaaba +bbabbbbaabbaabbabbbabaabababbabbbabbabbb +bbbababbaabbbbabbaabbbabbbaaaaabaabaabab +aaaaababaabaaabbbbbabbbbbbabaaab diff --git a/2020/day19/main.go b/2020/day19/main.go index 85926e6..4b4ec3e 100644 --- a/2020/day19/main.go +++ b/2020/day19/main.go @@ -2,7 +2,7 @@ package main import ( "fmt" - "os" + "regexp" "strings" h "git.bullercodeworks.com/brian/adventofcode/helpers" @@ -16,10 +16,6 @@ func main() { solve(inp, h.Atoi(part)) } -var loopingTokens []int -var allTokens map[int]*Token -var totalRules int - /* 8: 42 | 42 8 11: 42 31 | 42 11 31 @@ -32,7 +28,6 @@ affect things as they repeat */ func solve(inp []string, part int) { - allTokens = make(map[int]*Token) var section int var rules []string var messages []string @@ -48,241 +43,130 @@ func solve(inp []string, part int) { messages = append(messages, v) } } - totalRules = len(rules) - last := -1 - for RulesSolved() < totalRules && last != RulesSolved() { - last = RulesSolved() - for _, v := range rules { - fmt.Println("Restarting Rules Parsing") - pts := strings.Split(v, ": ") - num := h.Atoi(pts[0]) - if part == 2 { - if num == 8 { - pts[1] = "42 | 42 8" - } else if num == 11 { - pts[1] = "42 31 | 42 11 31" - } - } - if _, ok := allTokens[num]; !ok { - GenerateToken(num, pts[1]) - } - } - } - if RulesSolved() < totalRules { - fmt.Println("Unable to solve all rules") - os.Exit(1) - } - fmt.Println("Calculating Answer") - var matches int - for _, v := range messages { - if allTokens[0].Matches(v) { - matches++ - } - } - fmt.Printf("## Part 1\nAnswer: %d\n", matches) -} - -// RulesSolved TODO -func RulesSolved() int { - var ret int - for k := range allTokens { - if k >= 0 { - ret++ - } - } - return ret -} - -// Token Kinds -const ( - LEAF = iota - STICK - BRANCH -) - -// Token TODO -type Token struct { - kind int - num int - value string - raw string - - PartNums []int - Parts []*Token - - CachedValues []string - Loops bool -} - -// GenerateToken TODO -func GenerateToken(num int, raw string) *Token { - if v, ok := allTokens[num]; ok { - return v - } - t := Token{num: num, raw: raw} - if raw[0] == '"' { - t.value = strings.ReplaceAll(raw, "\"", "") - t.kind = LEAF + if part == 1 { + solveOne(rules, messages) } else { - if !strings.Contains(raw, "|") { - t.kind = STICK - var partTokens []*Token - pts := strings.Split(raw, " ") - for k := range pts { - if pts[k] == "|" { - continue - } - t.PartNums = append(t.PartNums, h.Atoi(pts[k])) + solveTwo(rules, messages) + } +} + +func solveOne(rules, messages []string) { + reg := regexp.MustCompile(rulesToRegex(rules)) + var answer int + for _, msg := range messages { + if reg.MatchString(msg) { + answer++ + } + } + fmt.Printf("## Part 1\nAnswer: %d\n", answer) +} + +func solveTwo(rules, messages []string) { + // Figure out how many levels deep we have to go to stabilize + var answer int + var last []int + for i := 0; i < 1000; i++ { + answer = 0 + rules = unwrapLoops(rules, i) + reg := regexp.MustCompile(rulesToRegex(rules)) + for _, msg := range messages { + if reg.MatchString(msg) { + answer++ } - solved := true - for k := range t.PartNums { - if v, ok := allTokens[t.PartNums[k]]; ok || h.IntSliceContains(loopingTokens, t.PartNums[k]) { - partTokens = append(partTokens, v) - } else { - solved = false - break + } + if isStable(last, 10) { + break + } + last = append(last, answer) + } + fmt.Printf("## Part 2\nAnswer: %d\n", answer) +} + +func isStable(history []int, confidence int) bool { + if len(history) < confidence { + return false + } + last := h.MAX_INT + for k := len(history) - 1; k > len(history)-confidence; k-- { + if last == h.MAX_INT { + last = history[k] + continue + } + if history[k] != last { + return false + } + } + return true +} + +func unwrapLoops(rules []string, depth int) []string { + for i := range rules { + wrk := rules[i] + if strings.HasPrefix(wrk, "8:") { + wrk = "8: 42 +" + } else if strings.HasPrefix(wrk, "11:") { + rule := "42 31" + for k := 2; k < depth; k++ { + rule += " | " + for j := 0; j < k; j++ { + rule += " 42 " + } + for j := 0; j < k; j++ { + rule += " 31 " } } - if solved { - t.Parts = partTokens + wrk = "11: " + rule + } + rules[i] = wrk + } + return rules +} + +func rulesToRegex(rules []string) string { + cache := make(map[int]string) + for { + if _, ok := cache[0]; ok { + // We've cached 0, so we're all done + break + } + loop: + for _, rule := range rules { + tokens := strings.Fields(rule) + var num int + fmt.Sscanf(tokens[0], "%d:", &num) + if _, ok := cache[num]; ok { + continue } - } else { - t.kind = BRANCH - pts := strings.Split(raw, " ") - for k := range pts { - if pts[k] == "|" { - continue - } - n := h.Atoi(pts[k]) - if n == num { - if !h.IntSliceContains(loopingTokens, t.num) { - fmt.Println(num, "IS A LOOPING TOKEN") - loopingTokens = append(loopingTokens, t.num) - t.Loops = true + tokens = tokens[1:] + // A 'leaf' + if len(tokens) == 1 && tokens[0][0] == '"' { + cache[num] = string(tokens[0][1]) + continue + } + // All other rules + ruleReg := "(?:" + for _, tkn := range tokens { + c := tkn[0] + switch { + case '0' <= c && c <= '9': + tknN := h.Atoi(tkn) + subRuleReg, ok := cache[tknN] + if !ok { + continue loop } + ruleReg += subRuleReg + case c == '|': + ruleReg += "|" + case c == '+': + ruleReg += "+" + default: + panic("Error building RegEx:" + tkn) } } - branches := strings.Split(raw, " | ") - var partTokens []*Token - for k, branch := range branches { - branchID := -(num*1000 + k) - t.PartNums = append(t.PartNums, branchID) - p := GenerateToken(branchID, branch) - if p.Solved() { - allTokens[branchID] = p - partTokens = append(partTokens, p) - } else { - continue - } - } - solved := true - for _, bid := range t.PartNums { - if _, ok := allTokens[bid]; !ok { - solved = false - break - } - } - if solved { - t.Parts = partTokens - } + ruleReg += ")" + cache[num] = ruleReg } } - if t.Solved() { - allTokens[num] = &t - } else { - fmt.Println("> Couldn't Solve", num) - } - return &t -} - -// Solved TODO -func (t *Token) Solved() bool { - return len(t.Values()) > 0 -} - -// Values TODO -func (t *Token) Values() []string { - switch t.kind { - case LEAF: - return t.LeafValue() - case STICK: - return t.StickValue() - case BRANCH: - return t.BranchValue() - default: - return []string{} - } -} - -// LeafValue TODO -func (t *Token) LeafValue() []string { - return []string{t.value} -} - -// StickValue TODO -func (t *Token) StickValue() []string { - if len(t.Parts) < len(t.PartNums) { - return []string{} - } - if len(t.CachedValues) > 0 { - return t.CachedValues - } - var ret []string - for k := range t.Parts { - if len(ret) == 0 { - ret = t.Parts[k].Values() - } else { - var newRet []string - for rk := range ret { - newRet = append(newRet, h.AppendStrings(ret[rk], t.Parts[k].Values())...) - } - ret = newRet - } - } - t.CachedValues = ret - return ret -} - -// BranchValue TODO -func (t *Token) BranchValue() []string { - if len(t.Parts) < len(t.PartNums) { - return []string{} - } - if len(t.CachedValues) > 0 { - return t.CachedValues - } - var ret []string - for k := range t.Parts { - ret = append(ret, t.Parts[k].Values()...) - } - t.CachedValues = ret - return ret -} - -// Matches actually tests a message against this token -func (t *Token) Matches(msg string) bool { - for _, v := range t.Values() { - if msg == v { - return true - } - } - return false -} - -func (t Token) String() string { - return fmt.Sprintf("{num:%d, kind:%s, partNums:%v, value:%v}", t.num, KindToString(t.kind), t.PartNums, t.Values()) -} - -// KindToString TODO -func KindToString(kind int) string { - switch kind { - case LEAF: - return "LEAF" - case STICK: - return "STICK" - case BRANCH: - return "BRANCH" - default: - return "UNKNOWN" - } + // We should be done now, we just want an exact match on rule 0 + return "^" + cache[0] + "$" } diff --git a/2020/day19/testinput b/2020/day19/testinput new file mode 100644 index 0000000..8c931b1 --- /dev/null +++ b/2020/day19/testinput @@ -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 diff --git a/2020/day20/input b/2020/day20/input new file mode 100644 index 0000000..2cb7a6f --- /dev/null +++ b/2020/day20/input @@ -0,0 +1,1728 @@ +Tile 3391: +#.......## +#..#.....# +..#....#.# +##...##.## +#.##.#.... +.#.......# +.#.......# +#..#..#..# +.......#.# +.##.#.#### + +Tile 2549: +.#...##... +##.#...... +....####.. +######..## +...##..#.# +......##.. +.##..#...# +...#....## +..#....#.. +.#.#..##.. + +Tile 1109: +.#.###..#. +##..#.#... +#...###..# +#...#..#.# +.......### +#.#....#.# +.#.#.#.### +.#.#.#.... +.#....#... +..###.#... + +Tile 3023: +##.#.#.##. +...#..#### +.##.#...## +#.##.....# +###.##...# +.......#.. +...##..##. +##.....#.. +###....#.# +.#...#.##. + +Tile 2833: +.#...##### +....#...## +....##...# +#...###... +#...###... +..#.#..#.# +##.....#.# +..#....... +##..##...# +###....##. + +Tile 2347: +#...###.## +#..##.##.# +.#..#.###. +....##..#. +.......#.# +#........# +##..#...## +..#......# +#...#..... +#....####. + +Tile 2311: +####..##.. +#......##. +##..#..... +#..#..#..# +###.#..### +.#...#...# +....#..... +##...##..# +#....##... +.#...####. + +Tile 3137: +...#....#. +#..#.##... +#..#.....# +...#....#. +#..###.##. +..#..#.#.# +#........# +#......... +#.##....#. +#.#.#.#.#. + +Tile 2333: +#.###..#.# +.#....#..# +#....##..# +##....#.## +#..##.##.. +.##..##### +#.....#..# +#.......#. +.#..#.###. +...#....## + +Tile 1439: +..###....# +##.#...#.. +..##.#...# +.##....#.. +#...#..... +#.#.#..... +.#.#....## +.......##. +....#..... +##.##.#..# + +Tile 1999: +....#.#.#. +.....#.... +#...###... +...#..#... +....##.#.. +#.....#... +.....#.... +#..#.##... +##.......# +#.#....### + +Tile 2351: +#..#.###.# +##..##..## +#...#..... +.......### +#....#...# +##....#.#. +#...#..... +.#...#...# +#..#...#.# +##.#..#..# + +Tile 3547: +...#.#...# +###...#..# +.........# +#.#...#... +#.#..##..# +.#.####.#. +#..#.#.#.# +.##......# +#......#.. +.###...### + +Tile 3877: +..##...##. +..#.....## +.#..#....# +##...#...# +##.#..#..# +.#..#....# +..##.#.#.# +......#.#. +#.....##.. +####..#.## + +Tile 2309: +.##.#..#.. +....#..#.# +..#.....## +.........# +#..#...... +#........# +..##.#.... +......#... +........## +#.##.###.. + +Tile 1303: +#.##.####. +.......#.. +...####... +.....#.... +#......#.# +......#... +.#.#.....# +#........# +#.#..#.#.# +##.##.#### + +Tile 3797: +.#.###..#. +#...##.... +#.##.##... +#.##.....# +........## +#.#....... +#...##.... +.......... +.....#..## +#..##..... + +Tile 2161: +.#....##.. +...#.....# +#.....#..# +#..#.#.#.# +.......... +....#..#.# +##...#...# +.#..#....# +......#... +#.#..#.#.. + +Tile 3463: +##.##..### +##.#..##.. +.##..#.##. +.......... +#.#...#..# +....#...## +#..#.....# +#......... +.......#.. +#.#.#.#### + +Tile 1657: +#.##.##.## +.....#.... +.#.....#.# +.#......#. +#...##...# +##.####... +#.#...#... +#..##..... +#..###.... +###.##...# + +Tile 2647: +##.##..##. +#..#...... +##....#### +#......#.. +.#.#...#.. +.#..##.#.. +##...##... +#.##...#.. +..#....#.. +###...###. + +Tile 2557: +.###.#.#.. +#.#...#.#. +#####....# +#..#.....# +..#.....#. +...#...... +#....#.... +.#..#....# +........#. +.#.#.#.##. + +Tile 2113: +###.#..... +.####..... +.....#...# +.#......#. +........#. +...#...... +......#.#. +.......... +.......... +..#.#.#### + +Tile 2729: +###...##.. +...#....#. +#.#....... +....###.## +#..#..##.. +..##..#### +##....#### +#...#.#..# +##...##..# +###.#.#..# + +Tile 2741: +.####..### +.#.#.#.#.. +.##..##.## +#.##...#.. +#..#.#.#.. +#...#....# +#......... +##...#.... +.......... +#####.#... + +Tile 1901: +#.#..##..# +...#.#.... +.##...#... +##........ +..#.#..#.. +...#.##..# +..#..###.. +..##...... +.#.#.....# +#.###.#..# + +Tile 2843: +#...##..## +.........# +##.###.#.. +.........# +#..###.... +..##...... +##......## +..#..##### +##....##.# +##.##...## + +Tile 3229: +#...###.#. +.......#.. +###...#.#. +#.......## +...#.#...# +#.##...#.. +##.###...# +..#....... +....#..... +#....####. + +Tile 1289: +..#.###.## +......#.## +..##...#.. +#......... +#..##..... +###....#.. +.........# +...##..##. +.#...#.... +.#.###...# + +Tile 2953: +..#..##... +...#.#..#. +........#. +#.#......# +###..#.##. +...##.#..# +#...#..##. +.......#.# +.........# +#.#.#.##.# + +Tile 1579: +..##...... +.....#.... +#..#.##..# +.#........ +.....#.... +#.......## +#..#...... +#......... +...#..#.## +##....##.# + +Tile 3359: +.##..####. +.......#.# +....##...# +.........# +.......... +....#....# +....#....# +.#.#.#..#. +...#.#.... +#######... + +Tile 1823: +####..##.# +.........# +...##..... +..#....... +.#...##... +#..#...... +.......... +#....#...# +#...#.#..# +#.#.##.... + +Tile 2659: +##.#.###.# +#......##. +..#.#....# +##...##... +#.#..#..## +#...#..... +...#.#.... +.......#.# +.#..#..#.. +....###..# + +Tile 1097: +.#.#.#.... +##..#...## +###.....#. +.#.....### +##...##..# +...#.##... +.....#..## +#..#.#.... +.#...#..## +.#.##..##. + +Tile 2341: +####.#...# +....#...## +#.##.....# +..#..###.# +...#.#.### +#...#....# +.##......# +#....#.... +##....#.#. +#..#....#. + +Tile 2089: +#.###..##. +#..#####.. +....##.... +#.....#.## +.....###.# +.#..#.#..# +....#.#.## +#.......#. +###......# +###..####. + +Tile 1583: +#.#...#... +#....#.#.# +.........# +#.....#... +...#...... +#........# +#......#.. +.......#.. +.........# +####...#.# + +Tile 3011: +##.####... +.##......# +...#.....# +#.......## +#..#...... +##........ +##..#...#. +##..#..... +#...##..#. +.###.#.#.# + +Tile 1481: +###.#.##.. +..###...## +....##.#.# +..#......# +..#.#..... +..##...... +#........# +......#... +#..#..#..# +#.#.###### + +Tile 2927: +##..##.### +#.##.#...# +....#..#.# +.#....#.## +#...#.#.## +#.#....... +#......... +......#..# +.#.#.#...# +###...#.#. + +Tile 2633: +.##..##.#. +.#..#.#### +..#..##..# +..#.#....# +.........# +..#.....## +........#. +##....#.## +.......##. +....#####. + +Tile 2371: +#..#.####. +....#.#... +..#...#..# +......#... +..#.##.#.. +.#..##.#.. +....#....# +.#.......# +#.#....... +#.##.#.#.. + +Tile 1733: +#.######## +.#.##..#.# +#.#..#.... +..###.##.. +#..##..##. +.##.#..... +#...#.#... +#..##..### +#........# +..#....#.# + +Tile 3583: +#.#.#..... +....#....# +...#.#.... +....#..... +#........# +#.#..##..# +.........# +#....#.... +#.....#... +...#..###. + +Tile 1291: +.##.###.## +#...#.#.#. +#.##.#.##. +....#..#.# +#.##.###.. +#.##...#.# +....#.#.#. +.###.#...# +.#.#.....# +##..#..### + +Tile 3067: +#.#...##.# +#........# +...##.#.#. +#.##.....# +..#....... +#..#...#.# +#....#.... +#.#...#... +.......... +########.# + +Tile 1621: +.#..#.#..# +#...#..#.. +..#.#.#..# +##..##...# +#.#....... +...#..#..# +##.#.....# +..#.#..#.. +...##.##.# +#....#.... + +Tile 3719: +#..###.... +...##..##. +..###..... +.....#.### +##...#..## +#........# +.....#...# +#...#...#. +#.###.#... +#..#.#..## + +Tile 1217: +#.##..#.## +#.....#... +...#.#.... +.#..#.##.. +...##.#.## +#.#.#..#.. +.......... +#.......## +.........# +######..#. + +Tile 2503: +..##.#.#.. +#....#.... +#......... +.#...#.##. +...#.#.... +.........# +..##...... +.##.....#. +.#.....#.. +###.##..#. + +Tile 2971: +#...###..# +#...#.#.## +#........# +#.#....#.. +##........ +#.....#..# +.#........ +.#........ +.#.###..## +.##...#..# + +Tile 2593: +#..#.####. +....#...#. +#.##.#.... +......#.#. +........## +#......... +##.#...... +#...#.#..# +..##...#.. +...####.#. + +Tile 2711: +##..##...# +#....#...# +.........# +##....#.## +##......## +######.... +#...#...## +.....#.... +....#.#.#. +....##.#.# + +Tile 3929: +#.#.#..### +..#.###.#. +.....#...# +.....##.## +..#.#..##. +#........# +#.###..### +..#..#.#.. +.##.....#. +#.#.#.#.## + +Tile 2473: +###....#.. +..##...##. +.#...#...# +.#..#...#. +##......## +#......... +#....#..#. +##........ +..##...... +..#..#..## + +Tile 1103: +.#######.. +#....#.... +.......#.. +.......#.. +##.#.....# +.......#.# +#.....#... +#......#.# +#..#..#... +######..#. + +Tile 1907: +#..##.#..# +#..##.#..# +.##.#.#.#. +########## +....####.. +##...#.... +..##.#.... +#...#....# +..#.####.. +.#.##..### + +Tile 1553: +###.#...#. +#....#.#.# +..#......# +....##...# +......#..# +###...#.## +##...#.... +.......... +..#....... +###.#####. + +Tile 1637: +#####.##.# +.......#.. +...#.#.... +#......##. +#.###...## +.......... +..#.###.#. +#....##..# +#..#.....# +#..##.#... + +Tile 2789: +##..####.# +..#....... +#......... +.......#.. +.#........ +.......... +#....##... +####.....# +...##..#.# +.#.###.#.. + +Tile 3301: +#.#....#.. +.#.....### +##......## +.#.#...... +#..#...#.. +...#...... +.#.....#.# +#........# +#.....#.#. +.###.#.... + +Tile 2957: +#.#.##..#. +#..#...... +.##...#.#. +..#....... +####...... +.....#.#.. +#.#......# +#...###... +#..#..##.. +###..#.#.. + +Tile 2389: +##.#..#... +.#.......# +..#....... +###....#.# +.#....#... +....#..... +....#..#.# +#......#.# +..#.##.##. +...###.##. + +Tile 1087: +##..##.### +#...#....# +.#.##.#.#. +.#.......# +#.#..#...# +.#..##...# +##.#..#.## +.#...#.#.. +#........# +#..#...#.. + +Tile 2251: +#..####... +#..##..#.. +#..#.##... +.#.#.....# +.##.#.#... +#.##.....# +....##.... +.........# +...#.....# +##.#.#..#. + +Tile 2969: +####.##..# +##........ +...#...#.# +.......#.. +###.###### +..#..#.... +...###...# +#......### +.#........ +#.###...## + +Tile 1669: +.#...#.##. +#.##...#.# +#...#..... +#...##.#.# +#.....#... +...#.#.#.. +...#.#.... +..#.#.#..# +#.#.#.##.# +#..#.##..# + +Tile 2713: +#...#.#.## +...##..#.# +.#..#..### +..#.#..... +..#....#.# +..#...#... +#..#....## +##.....#.# +#....#.... +.##.....## + +Tile 3659: +...#....#. +#......... +#..#.#.#.# +#..#..#.## +.#.#.#..## +#....#..## +..#......# +..#.....#. +.##.##.#.. +####..#..# + +Tile 1609: +...#...... +.......#.. +##.....#.# +#...#..#.. +....#..... +#.......## +#...##.... +#..#..##.# +#####.###. +..##...... + +Tile 1979: +#..#.##### +.....#.#.. +.#....#.#. +###.###..# +..#....#.# +..#....#.. +#....#.##. +....#..#.. +....#..... +.#.#..#.## + +Tile 3457: +##.#.#..#. +.#......## +#.##..#..# +#.#..#.... +..#..#.... +##..#..#.. +.........# +.......#.# +.........# +###.##.#.. + +Tile 2531: +#..##...## +##....#..# +#......... +.....####. +.#.####..# +##..##.#.# +#.....#..# +#.....#..# +.....#.##. +#..#..##.# + +Tile 2267: +###..##..# +..#......# +.#..#....# +#..#...#.. +......#..# +...#...... +##.....#.# +##.#....## +.#.....#.. +###.##..#. + +Tile 3853: +##.##.##.# +.....#..## +....#..#.. +.#...#.... +.........# +....#..... +#...#....# +#......... +#........# +#.#..####. + +Tile 3433: +#...#.#... +....#.##.. +###..##.## +##.#...#.. +.#.#.##.#. +......#..# +...##..##. +##....#..# +..#..##..# +###...#### + +Tile 3109: +###.####.# +.#.#....## +.#...#.... +..#...#..# +.#.#...#.. +#......... +...#.##.#. +.......#.. +..#..#.... +#.##.##### + +Tile 2399: +####.##.## +...#.....# +..#.#..... +.#.##..... +...#.#...# +..#..#..#. +...#..#..# +#....#..#. +.......... +#....##### + +Tile 2141: +#.#...#... +#........# +.#.#.##.#. +..#...##.# +..#......# +.........# +#...#...#. +.#.####..# +..#.....## +###..#.#.# + +Tile 3187: +.##.##.#.# +...#.##.## +##...#...# +......#..# +.##.#...## +..##...#.. +#......#.# +...#..###. +#.#....#.# +.#..##.#.# + +Tile 3329: +.#.##..#.. +.#........ +#..#.....# +#.###..#.# +..#.#..... +.#..###..# +..#.....## +#.#..#.### +##.##..#.# +##..##.##. + +Tile 2693: +#..#####.# +.........# +##.#....## +#..#.....# +####.#.... +..####.#.# +....##...# +##.#.....# +#.......#. +.....##### + +Tile 2357: +.#..##...# +......#.## +....#.##.. +#.##.....# +..#.#...## +#........# +#..#...... +#......... +....#..... +...##...## + +Tile 1381: +.#.....#.# +#.....#### +#......... +.#.###.#.. +##....#... +.......... +#.#.#.#..# +.#####.#.# +#.......## +#.####.... + +Tile 3761: +#....##... +#......#.. +#...#...## +.........# +.......... +.#.##.#.#. +...#....## +#...#...#. +#....#.... +.###..#### + +Tile 1889: +..#.#....# +..#..#.... +.#..#....# +.......... +..##..#.#. +.......... +.....#.##. +#..#...... +#......#.. +.#...#..#. + +Tile 3511: +..##.....# +.#....#... +####.....# +.#...#...# +#..##.##.. +#.#.....#. +.#.#...... +#...#..... +#.#....... +###.###..# + +Tile 1619: +...###.##. +#...#.##.# +###....... +..#..##.## +..#.##.... +..###....# +#......### +....###.## +..#....### +..##.##.## + +Tile 1721: +###....#.. +......#.## +.#.....#.# +##.##..### +.#....#... +#...#..#.# +#.#.#....# +...#..#... +#.......## +.######.## + +Tile 3539: +.#.....#.# +...##...## +#.#...#... +..#.#....# +#..#....## +#.#..##..# +##..#..#.# +.....#.#.# +.#..#.#.## +..#...###. + +Tile 3847: +##..###..# +#..##..#.# +.......##. +.#.#.....# +###...#... +.##.##...# +....#.#... +..#..##..# +#......#.. +####..###. + +Tile 3257: +.##.#.#... +###...#.#. +.......... +.......... +..#...#..# +.........# +#.....#..# +...#....#. +#..##.#.## +####...### + +Tile 3851: +#.#.####.. +#.#....#.# +#......... +####.#...# +.###.....# +##..#..#.# +.#.###.... +.........# +####.....# +.#.#..#.## + +Tile 3881: +....#..#.# +#......#.. +.......... +#....#.... +#.#.#.#..# +....#..#.. +.....#..## +#.#...#.#. +....#..... +..#.#..### + +Tile 2539: +#.####.#.# +...#.###.# +####...#.. +#..#...### +......#.#. +#..#.....# +#....#..## +...#...#.. +#.#....#.# +.##.##.#.# + +Tile 1301: +##.##..#.# +.......#.. +#..#.#.#.# +#...#..... +#####.#... +...#.#.... +..#....#.# +...#..#..# +#...#...## +.###.###.. + +Tile 2027: +##..###.#. +##..#..... +#.#..#.... +.##...#... +..##.....# +#......#.# +#.#.....#. +##..#....# +.......... +#..##.#... + +Tile 3001: +.#...#...# +..#.#...#. +...#.##... +#......... +.#...#.... +#.......## +##....##.# +##.#....## +...#.....# +#...###### + +Tile 3767: +#..#.#...# +##..#....# +...###...# +.....#.#.. +........#. +.#...#.... +#..##....# +.......... +##..#..#.# +.#......## + +Tile 1433: +.##.#.##.# +#...#..... +......##.# +##.#....#. +.#.##...## +#..#.##..# +.#.##...## +#...##.#.# +...#...#.# +..#.....#. + +Tile 1931: +##.####.#. +#.##..#..# +#....#...# +#....#.... +...####... +...#...... +#........# +####..#... +...###.... +.#..#.#... + +Tile 3491: +.##..#.#.# +##...#...# +#..#...... +#.#.#....# +........#. +#.#......# +##........ +.#.......# +.##......# +####.....# + +Tile 2683: +...#....## +...#.##.#. +..##.#.... +....##...# +..#.##..#. +...##.#.## +#..#.#...# +..#..#.... +#...#..#.. +#..#####.. + +Tile 3323: +.....#.#.# +###....... +....#.#... +..#......# +.##..#.... +#.....###. +.#....##.. +.....#...# +....#..#.# +.....###.. + +Tile 1061: +#....###.. +#.#.#.#... +#......#.. +#...##...# +#........# +.....#.### +##....#..# +....###..# +###....#.. +..##.##... + +Tile 1163: +####.###.# +#..#.....# +#........# +#...##...# +.##..#.#.. +..#.#.#... +.....#.#.# +##........ +.#....#.#. +###..##### + +Tile 3779: +.#####.#.. +####.##.#. +##...##..# +#.###...#. +..#....... +#........# +...#...#.# +.#.#...... +#...#.#... +.#.#..##.# + +Tile 1993: +#..##.#.## +.#...#...# +#..###.... +#.##.....# +#.....##.# +#...#.#..# +#.#.#..... +.#.#.#...# +....#.#.#. +##......#. + +Tile 1213: +#..##..#.. +..##..#..# +#......... +.##.....#. +#......... +........## +........#. +..#.###..# +##.......# +..##...#.# + +Tile 3373: +#.##..#.## +#......... +.....#.... +#...#..... +#...##...# +..#..#.... +#......... +.......... +#...##..#. +..##.###.# + +Tile 2017: +#...#.##.# +#...##.... +........## +...#...#.# +.......... +##...##..# +.....#...# +#....#.#.# +#........# +#.##...#.. + +Tile 1367: +..###.#### +#..#.#..#. +#...##..#. +.#.....#.# +##......## +.#.#.....# +.....#.... +........## +#...##...# +###.#...## + +Tile 2417: +.#.#.#.#.. +#.##..#.## +#.#......# +###....... +#..#.....# +...#.....# +..#....... +#.#.#....# +.#...#.... +#..##..... + +Tile 1871: +##..#.##.# +.#.#..#### +..#...###. +.##....... +....##..## +..#....#.# +###....... +.#....#.## +.#.#...#.# +#.###..#.. + +Tile 1601: +#####..... +.....#.... +......#..# +.#..###### +#..#.##..# +....#.#... +#.#....... +#.#..##..# +#..##.#.#. +..#..##.## + +Tile 1471: +.#######.. +..#..#...# +.##..#...# +##..#.#..# +......#..# +.#...#.... +#........# +..#......# +.....##..# +###.#....# + +Tile 2521: +###.....## +###.##.##. +......##.# +#...#.#... +........## +##.####... +...###.... +#..#.#...# +#..####... +#.#.#....# + +Tile 1279: +##..#..#.# +.#...#.#.# +#.......#. +#.#.#..#.. +#.#......# +#......### +#..#..#..# +#.#.#...#. +#...#....# +..#......# + +Tile 1069: +#.#.#...## +......#.## +#....#.##. +......#..# +##.#.#...# +#.#.#.#.## +#.......#. +##..#....# +......#... +.##..#..## + +Tile 2143: +#.#...#.#. +#......... +..#...#... +.#..##.... +#......#.# +.....##..# +#.#.....## +#......... +#....#.... +##....#.#. + +Tile 3517: +####.#...# +#.#..#...# +#......#.# +#..#...... +##....#..# +#......#.. +..#...#... +#.....#... +....#.###. +##...#.#.. + +Tile 2543: +.#######.# +.....#.... +#.#.#....# +........#. +##...#.... +..#.....## +..#.#.##.# +........## +#.......#. +#.####.### + +Tile 1567: +...#.##... +...#...### +.....#.... +....#....# +#.....#.#. +.###....#. +#.##..###. +........## +........#. +#####.#.## + +Tile 1459: +..#...###. +##..##...# +.##....... +..###.#... +##.......# +....#..##. +##....#.## +......#... +....#..... +.#.#.#.### + +Tile 1153: +.##...###. +#.#..#.#.. +.......... +.......... +...#.#..#. +..#......# +#.#..##... +..##....#. +#......... +#.#....### + +Tile 1811: +###.#..#.# +#..##....# +#.##..#... +...#...### +......#... +..#....##. +##.......# +..#......# +.....#...# +.....#.... + +Tile 1667: +.#.#.##.## +.....#.#.# +....##.... +....#....# +.###..#..# +.#.####.## +#..##..... +......##.# +#.#...##.. +#####..### + +Tile 2677: +.###...#.# +#..###...# +#....###.. +.......... +##.......# +##.#....#. +###..##.#. +#.#....... +.#......#. +##.#..#... + +Tile 2707: +#..#.#.##. +#.....#### +....#...#. +##..#..... +##........ +..#...#... +....#..... +#....#.#.# +..#..#.#.. +####...#.. + +Tile 1699: +.###....## +..#..#...# +.###...... +.....#...# +#.#.....## +#.##..#... +.#.......# +#......#.# +###.....## +.##....... + +Tile 3919: +..#.#..#.# +#.#...#..# +##.#..#.#. +.#..#..#.. +#.#.#.#.#. +#...##...# +#...##.... +#...#.#... +...#...### +##.#.#..## + +Tile 1019: +#..#..#.## +#....#..## +#......##. +#.#....#.. +##....#... +#....##..# +....#..... +.#..#.#... +......##.. +...#...#.. + +Tile 3319: +..#...#.#. +.##....... +...#.#...# +........#. +#.....##.. +...##....# +..##...##. +.....#..## +..###..... +#...####.. + +Tile 3041: +##..#####. +......#..# +..#..##..# +.......... +#.....#.## +#......#.. +.....#..#. +..##.....# +.#.......# +........## + +Tile 3313: +.##.#..### +#.#..###.. +#....#.#.. +##........ +...#.....# +#......... +.#.....#.. +#.....#... +#.#.#...#. +#.....##.. + +Tile 3541: +#.#....... +.##......# +#......... +##.......# +.#......## +..#..#.... +....#.#.## +.#.......# +##.......# +#.#..##..# + +Tile 1319: +#.#...#..# +#......##. +..#.#.#### +#......... +#..#.....# +..#...##.# +#...#.##.# +#..#....## +....##.... +.#.#.#.### + +Tile 1499: +####...#.. +#...#....# +.....#...# +.......#.. +#.###....# +.......### +.......##. +.......#.# +..#.#...#. +......#.#. + +Tile 2239: +..#....##. +.####....# +...#.....# +......#... +.....#..#. +#..#.....# +#.#.####.. +###.##.... +.........# +...#...#.. + +Tile 3769: +####.####. +#....#.#.# +.##....... +###.....## +##.#...#.# +....#.#..# +.......... +#.#.#..... +##.......# +.#####.### + +Tile 1187: +#..#.#.... +#.......#. +...#....## +#..##....# +#.....#.## +...##.#### +#....#.... +.....#.#.. +#.##.#...# +#..#.##.## + +Tile 1913: +#.##.#.##. +##.#...#.# +#.#...#... +##.#.....# +#.##...... +#.###....# +..#..#.##. +#......... +#.#......# +...#.###.# + +Tile 1753: +..#..#.... +.......#.# +...#.#.#.# +#.#....#.. +#......#.# +##...#.... +#.#.....## +#..#...##. +.##.#.#..# +##.###.##. + diff --git a/2020/day20/main.go b/2020/day20/main.go index 8c7eb84..0b6275c 100644 --- a/2020/day20/main.go +++ b/2020/day20/main.go @@ -26,7 +26,9 @@ func init() { } for y := range monster { for x := range monster[y] { - SeaMonster[h.Coordinate{X: x, Y: y}] = monster[y][x] == '#' + if monster[y][x] == '#' { + SeaMonster[h.Coordinate{X: x, Y: y}] = true + } } } } @@ -58,12 +60,8 @@ func solve(inp []string, part int) { for x := range image[y] { if image[y][x] { waves++ - fmt.Print("#") - } else { - fmt.Print(" ") } } - fmt.Println() } fmt.Println("## Part2\nAnswer:", waves) } @@ -200,11 +198,6 @@ func buildMapFromTiles(tiles map[int]*Tile) [][]bool { func monsterSlayer(inp [][]bool) [][]bool { var found bool for r := 0; r < 8; r++ { - if r == 6 { - // This is the correct orientation - fmt.Println("Rotation:", r) - PrintMap(inp) - } for y := range inp { for x := range inp[y] { match := true @@ -232,7 +225,6 @@ func monsterSlayer(inp [][]bool) [][]bool { } } if found { - fmt.Println("Found, breaking") break } if r&1 == 0 { @@ -284,3 +276,39 @@ func PrintMap(inp [][]bool) { fmt.Println() } } + +func PrintCoordMap(m map[h.Coordinate]bool) { + minX := h.MAX_INT + maxX := h.MIN_INT + minY := h.MAX_INT + maxY := h.MIN_INT + + for k := range m { + if k.X < minX { + minX = k.X + } + if k.X > maxX { + maxX = k.X + } + if k.Y < minY { + minY = k.Y + } + if k.Y > maxY { + maxY = k.Y + } + } + for y := minY; y <= maxY; y++ { + for x := minX; x <= maxX; x++ { + if v, ok := m[h.Coordinate{X: x, Y: y}]; ok { + if v { + fmt.Print("#") + } else { + fmt.Print(".") + } + } else { + fmt.Print(".") + } + } + fmt.Println() + } +} diff --git a/2020/day20/testinput b/2020/day20/testinput new file mode 100644 index 0000000..b07aa4b --- /dev/null +++ b/2020/day20/testinput @@ -0,0 +1,107 @@ +Tile 2311: +..##.#..#. +##..#..... +#...##..#. +####.#...# +##.##.###. +##...#.### +.#.#.#..## +..#....#.. +###...#.#. +..###..### + +Tile 1951: +#.##...##. +#.####...# +.....#..## +#...###### +.##.#....# +.###.##### +###.##.##. +.###....#. +..#.#..#.# +#...##.#.. + +Tile 1171: +####...##. +#..##.#..# +##.#..#.#. +.###.####. +..###.#### +.##....##. +.#...####. +#.##.####. +####..#... +.....##... + +Tile 1427: +###.##.#.. +.#..#.##.. +.#.##.#..# +#.#.#.##.# +....#...## +...##..##. +...#.##### +.#.####.#. +..#..###.# +..##.#..#. + +Tile 1489: +##.#.#.... +..##...#.. +.##..##... +..#...#... +#####...#. +#..#.#.#.# +...#.#.#.. +##.#...##. +..##.##.## +###.##.#.. + +Tile 2473: +#....####. +#..#.##... +#.##..#... +######.#.# +.#...#.#.# +.######### +.###.#..#. +########.# +##...##.#. +..###.#.#. + +Tile 2971: +..#.#....# +#...###... +#.#.###... +##.##..#.. +.#####..## +.#..####.# +#..#.#..#. +..####.### +..#.#.###. +...#.#.#.# + +Tile 2729: +...#.#.#.# +####.#.... +..#.#..... +....#..#.# +.##..##.#. +.#.####... +####.#.#.. +##.####... +##..#.##.. +#.##...##. + +Tile 3079: +#.#.#####. +.#..###### +..#....... +######.... +####.#..#. +.#...#.##. +#.#####.## +..#.###... +..#....... +..#.###... diff --git a/helpers/coordinate.go b/helpers/coordinate.go index 463440f..84a8915 100644 --- a/helpers/coordinate.go +++ b/helpers/coordinate.go @@ -14,6 +14,10 @@ func NewCoordinate(x, y int) *Coordinate { return &Coordinate{x, y} } +func (c Coordinate) Relative(t Coordinate) Coordinate { + return Coordinate{X: c.X + t.X, Y: c.Y + t.Y} +} + func (c *Coordinate) North() Coordinate { return Coordinate{X: c.X, Y: c.Y - 1} } diff --git a/helpers/helpers.go b/helpers/helpers.go index aa73db1..0360caa 100644 --- a/helpers/helpers.go +++ b/helpers/helpers.go @@ -263,6 +263,25 @@ func StringSliceContains(h []string, n string) bool { return false } +// IntSliceContains takes an int slice and an int and return true +// if the int is in the slice +func IntSliceContains(h []int, n int) bool { + for _, v := range h { + if v == n { + return true + } + } + return false +} + +// AppendString returns a slice of strings that are base+group[...] +func AppendStrings(base string, group []string) []string { + for k, v := range group { + group[k] = base + v + } + return group +} + // IsPrime takes a number and return true if that number is prime func IsPrime(value int) bool { for i := 2; i <= int(math.Floor(float64(value)/2)); i++ {