|
| 1 | +--- Day 5: Doesn't He Have Intern-Elves For This? --- |
| 2 | + |
| 3 | +Santa needs help figuring out which strings in his text file are naughty or nice. |
| 4 | + |
| 5 | +A nice string is one with all of the following properties: |
| 6 | + |
| 7 | +It contains at least three vowels (aeiou only), like aei, xazegov, or aeiouaeiouaeiou. |
| 8 | +It contains at least one letter that appears twice in a row, like xx, abcdde (dd), or aabbccdd (aa, bb, cc, or dd). |
| 9 | +It does not contain the strings ab, cd, pq, or xy, even if they are part of one of the other requirements. |
| 10 | +For example: |
| 11 | + |
| 12 | +ugknbfddgicrmopn is nice because it has at least three vowels (u...i...o...), a double letter (...dd...), and none of the disallowed substrings. |
| 13 | +aaa is nice because it has at least three vowels and a double letter, even though the letters used by different rules overlap. |
| 14 | +jchzalrnumimnmhp is naughty because it has no double letter. |
| 15 | +haegwjzuvuyypxyu is naughty because it contains the string xy. |
| 16 | +dvszwmarrgswjxmb is naughty because it contains only one vowel. |
| 17 | +How many strings are nice? |
| 18 | + |
| 19 | +Your puzzle answer was 255. |
| 20 | + |
| 21 | +--- Part Two --- |
| 22 | + |
| 23 | +Realizing the error of his ways, Santa has switched to a better model of determining whether a string is naughty or nice. None of the old rules apply, as they are all clearly ridiculous. |
| 24 | + |
| 25 | +Now, a nice string is one with all of the following properties: |
| 26 | + |
| 27 | +It contains a pair of any two letters that appears at least twice in the string without overlapping, like xyxy (xy) or aabcdefgaa (aa), but not like aaa (aa, but it overlaps). |
| 28 | +It contains at least one letter which repeats with exactly one letter between them, like xyx, abcdefeghi (efe), or even aaa. |
| 29 | +For example: |
| 30 | + |
| 31 | +qjhvhtzxzqqjkmpb is nice because is has a pair that appears twice (qj) and a letter that repeats with exactly one letter between them (zxz). |
| 32 | +xxyxx is nice because it has a pair that appears twice and a letter that repeats with one between, even though the letters used by each rule overlap. |
| 33 | +uurcxstgmygtbstg is naughty because it has a pair (tg) but no repeat with a single letter between them. |
| 34 | +ieodomkazucvgmuy is naughty because it has a repeating letter with one between (odo), but no pair that appears twice. |
| 35 | +How many strings are nice under these new rules? |
| 36 | + |
| 37 | +Your puzzle answer was 55. |
| 38 | + |
| 39 | +Both parts of this puzzle are complete! They provide two gold stars: ** |
0 commit comments