2018-03-15 16:24:23 +00:00
|
|
|
|
Advent of Code
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
--- Day 5: Doesn't He Have Intern-Elves For This? ---
|
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
Santa needs help figuring out which strings in his text file are naughty or
|
|
|
|
|
nice.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
A nice string is one with all of the following properties:
|
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
• It contains at least three vowels (aeiou only), like aei, xazegov, or
|
|
|
|
|
aeiouaeiouaeiou.
|
|
|
|
|
|
|
|
|
|
• It contains at least one letter that appears twice in a row, like xx,
|
|
|
|
|
abcdde (dd), or aabbccdd (aa, bb, cc, or dd).
|
|
|
|
|
|
|
|
|
|
• It does not contain the strings ab, cd, pq, or xy, even if they are part
|
|
|
|
|
of one of the other requirements.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
• ugknbfddgicrmopn is nice because it has at least three vowels
|
|
|
|
|
(u...i...o...), a double letter (...dd...), and none of the disallowed
|
|
|
|
|
substrings.
|
|
|
|
|
|
|
|
|
|
• aaa is nice because it has at least three vowels and a double letter,
|
|
|
|
|
even though the letters used by different rules overlap.
|
|
|
|
|
|
2016-12-16 22:21:15 +00:00
|
|
|
|
• jchzalrnumimnmhp is naughty because it has no double letter.
|
2018-03-15 16:24:23 +00:00
|
|
|
|
|
2016-12-16 22:21:15 +00:00
|
|
|
|
• haegwjzuvuyypxyu is naughty because it contains the string xy.
|
2018-03-15 16:24:23 +00:00
|
|
|
|
|
2016-12-16 22:21:15 +00:00
|
|
|
|
• dvszwmarrgswjxmb is naughty because it contains only one vowel.
|
|
|
|
|
|
|
|
|
|
How many strings are nice?
|
|
|
|
|
|
|
|
|
|
Your puzzle answer was 255.
|
|
|
|
|
|
|
|
|
|
--- Part Two ---
|
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
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.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
Now, a nice string is one with all of the following properties:
|
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
• 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).
|
|
|
|
|
|
|
|
|
|
• It contains at least one letter which repeats with exactly one letter
|
|
|
|
|
between them, like xyx, abcdefeghi (efe), or even aaa.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
• qjhvhtzxzqqjkmpb is nice because is has a pair that appears twice (qj)
|
|
|
|
|
and a letter that repeats with exactly one letter between them (zxz).
|
|
|
|
|
|
|
|
|
|
• 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.
|
|
|
|
|
|
|
|
|
|
• uurcxstgmygtbstg is naughty because it has a pair (tg) but no repeat
|
|
|
|
|
with a single letter between them.
|
|
|
|
|
|
|
|
|
|
• ieodomkazucvgmuy is naughty because it has a repeating letter with one
|
|
|
|
|
between (odo), but no pair that appears twice.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
How many strings are nice under these new rules?
|
|
|
|
|
|
|
|
|
|
Your puzzle answer was 55.
|
|
|
|
|
|
|
|
|
|
Both parts of this puzzle are complete! They provide two gold stars: **
|
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
At this point, you should return to your advent calendar and try another
|
|
|
|
|
puzzle.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
If you still want to see it, you can get your puzzle input.
|
|
|
|
|
|
|
|
|
|
References
|
|
|
|
|
|
|
|
|
|
Visible links
|
|
|
|
|
. http://adventofcode.com/
|
|
|
|
|
. http://adventofcode.com/about
|
|
|
|
|
. http://adventofcode.com/stats
|
|
|
|
|
. http://adventofcode.com/leaderboard
|
|
|
|
|
. http://adventofcode.com/settings
|
|
|
|
|
. http://adventofcode.com/auth/logout
|
|
|
|
|
. http://adventofcode.com/
|
|
|
|
|
. http://adventofcode.com/day/5/input
|