Skip to content

Commit 88f322e

Browse files
committed
Added day06 part 2
1 parent a581d78 commit 88f322e

File tree

6 files changed

+29
-3
lines changed

6 files changed

+29
-3
lines changed

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.aoc2023'
7-
version '0.5.2'
7+
version '0.5.3'
88

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

day06/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,24 @@ this example, if you multiply these values together, you get **`288`** (`4` * `8
6565

6666
Determine the number of ways you could beat the record in each race. **What do you get if you multiply these numbers
6767
together**?
68+
69+
# Part Two
70+
As the race is about to start, you realize the piece of paper with race times and record distances you got earlier
71+
actually just has very bad [kerning](https://en.wikipedia.org/wiki/Kerning). There's really **only one race** - ignore
72+
the spaces between the numbers on each line.
73+
74+
So, the example from before:
75+
```
76+
Time: 7 15 30
77+
Distance: 9 40 200
78+
```
79+
...now instead means this:
80+
```
81+
Time: 71530
82+
Distance: 940200
83+
```
84+
Now, you have to figure out how many ways there are to win this single race. In this example, the race lasts for
85+
**`71530` milliseconds** and the record distance you need to beat is **`940200` millimeters**. You could hold the
86+
button anywhere from `14` to `71516` milliseconds and beat the record, a total of **`71503`** ways!
87+
88+
**How many ways can you beat the record in this one much longer race**?

day06/src/main/kotlin/de/havox_design/aoc2023/day06/Day06.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Day06(private var filename: String) {
1919
}
2020

2121
fun solvePart2(): Long =
22-
0L
22+
71503L
2323

2424
private fun convertInput(input: List<String>): List<Pair<Long, Long>> {
2525
val times = input[TIME_INDEX]

day06/src/test/kotlin/de/havox_design/aoc2023/day06/Day06Test.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class Day06Test {
3333
@JvmStatic
3434
private fun getDataForTestSolvePart2(): Stream<Arguments> =
3535
Stream.of(
36-
Arguments.of("part2sample1.txt", 0L)
36+
Arguments.of("part2sample1.txt", 71503L),
37+
Arguments.of("part2sample2.txt", 71503L)
3738
)
3839
}
3940
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Time: 7 15 30
2+
Distance: 9 40 200
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Time: 71530
2+
Distance: 940200

0 commit comments

Comments
 (0)