Skip to content

Commit e94a919

Browse files
committed
Added day 5 part 2
1 parent 40b78f9 commit e94a919

File tree

9 files changed

+49
-4
lines changed

9 files changed

+49
-4
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ To run all solutions, simply run `./gradlew run`. If you want to run the solutio
2323
| 2 |||
2424
| 3 |||
2525
| 4 |||
26-
| 5 | ||
26+
| 5 | ||
2727
| 6 |||
2828
| 7 |||
2929
| 8 |||
@@ -44,6 +44,6 @@ To run all solutions, simply run `./gradlew run`. If you want to run the solutio
4444
| 23 |||
4545
| 24 |||
4646
| 25 |||
47-
| **SUM** | **4** | **4 ⭐** |
47+
| **SUM** | **5** | **4 ⭐** |
4848

49-
Total: 8
49+
Total: 9

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44

55
// project meta data
66
group 'de.havox_design.aoc2015'
7-
version '0.4.3'
7+
version '0.4.4'
88

99
// Switch to gradle "all" distribution.
1010
wrapper {

day05/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,24 @@ rules overlap.
1717
* `dvszwmarrgswjxmb` is naughty because it contains only one vowel.
1818

1919
How many strings are nice?
20+
21+
# Part Two
22+
Realizing the error of his ways, Santa has switched to a better model of determining whether a string is naughty or
23+
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+
* It contains a pair of any two letters that appears at least twice in the string without overlapping, like
27+
`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`),
29+
or even `aaa`.
30+
31+
For example:
32+
* `qjhvhtzxzqqjkmpb` is nice because is has a pair that appears twice (`qj`) and a letter that repeats with exactly one
33+
letter between them (`zxz`).
34+
* `xxyxx` is nice because it has a pair that appears twice and a letter that repeats with one between, even though the
35+
letters used by each rule overlap.
36+
* `uurcxstgmygtbstg` is naughty because it has a pair (`tg`) but no repeat with a single letter between them.
37+
* `ieodomkazucvgmuy` is naughty because it has a repeating letter with one between (`odo`), but no pair that appears
38+
twice.
39+
40+
How many strings are nice under these new rules?

day05/src/test/java/de/havox_design/aoc2015/day05/Day05Test.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,20 @@ private static Stream<Arguments> getDataForPart1() {
3232
Arguments.of("part1sample6.txt", 2)
3333
);
3434
}
35+
36+
@ParameterizedTest
37+
@MethodSource("getDataForPart2")
38+
void testPart2(String fileName, int expectedNumberOfNiceStrings) {
39+
Assertions.assertEquals(expectedNumberOfNiceStrings, NiceStrings.solvePart2(fileName));
40+
}
41+
42+
private static Stream<Arguments> getDataForPart2() {
43+
return Stream.of(
44+
Arguments.of("part2sample1.txt", 1),
45+
Arguments.of("part2sample2.txt", 1),
46+
Arguments.of("part2sample3.txt", 0),
47+
Arguments.of("part2sample4.txt", 0),
48+
Arguments.of("part2sample5.txt", 2)
49+
);
50+
}
3551
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
qjhvhtzxzqqjkmpb
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
xxyxx
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uurcxstgmygtbstg
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ieodomkazucvgmuy
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
qjhvhtzxzqqjkmpb
2+
xxyxx
3+
uurcxstgmygtbstg
4+
ieodomkazucvgmuy

0 commit comments

Comments
 (0)