Skip to content

Commit af20804

Browse files
committed
Fix docs
1 parent dd76d26 commit af20804

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

docs/2025/puzzles/day10.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ https://adventofcode.com/2025/day/10
1010

1111
The input includes multiple lines, each of them can be handled independently, the result is the sum from the output of each scenario.
1212

13-
For part 1, I applied the [Breadth-first Search](https://en.wikipedia.org/wiki/Breadth-first_search) algorithm (BFS), BFS allows finding the shorest-path from a state to another when every transition has the same cost, this was quicky to implement and produced the correct output.
13+
For part 1, I applied the [Breadth-first Search](https://en.wikipedia.org/wiki/Breadth-first_search) algorithm (BFS), BFS allows finding the shortest-path from a state to another when every transition has the same cost, this was quick to implement and produced the correct output.
1414

15-
For part 2, BFS wasn't adequate due to the number of potential states, there is an alternative [Divide-and-conquer](https://en.wikipedia.org/wiki/Divide-and-conquer_algorithm) approach which is fast enough.
15+
For part 2, BFS wasn't adequate due to the number of potential states, there is an alternative Reduce-and-conquer approach (a variation of [Divide-and-conquer](https://en.wikipedia.org/wiki/Divide-and-conquer_algorithm)) which is fast enough.
1616

1717

1818
## Parsing the input
@@ -98,7 +98,7 @@ def loop(queue: Queue[State], touched: Set[String], inputCase: InputCase): Optio
9898
}
9999
```
100100

101-
The final piece is just wiring the existing functionaly to cover each scenario and sum the results:
101+
The final piece is just wiring the existing functionality to cover each scenario and sum the results:
102102

103103
```scala
104104
def part1(input: String): Unit = {
@@ -132,7 +132,7 @@ There are potential alternatives to deal with this but given the input size, the
132132

133133
## Part 2
134134

135-
My initial reaction was that resolving this might be trivial to do by reusing the BFS implementation while by changing a few operations:
135+
My initial reaction was that resolving this might be trivial to do by reusing the BFS implementation by changing a few operations:
136136

137137
- State is now the joltage.
138138
- Instead of going from the empty state to the goal, let's go from the given joltage to `0` values.
@@ -189,9 +189,9 @@ index 21ccc48..b98c9e4 100644
189189
}
190190
```
191191

192-
This resolved the example input but was too slow with the actual test scenarios, I tried a few heuristics to trim unnecessary paths, tried `DFS` with prunning, `A*`, and, I was close to implement a [bidirectional BFS](https://en.wikipedia.org/wiki/Bidirectional_search).
192+
This resolved the example input but it was too slow with the actual test scenarios, I tried a few heuristics to trim unnecessary paths, I also tried `DFS` with prunning, `A*`, and, I was close to implement a [bidirectional BFS](https://en.wikipedia.org/wiki/Bidirectional_search).
193193

194-
Eventually, I got an idea from [reddit](https://old.reddit.com/r/adventofcode/comments/1pk87hl/2025_day_10_part_2_bifurcate_your_way_to_victory/) about using a [Divide-and-conquer](https://en.wikipedia.org/wiki/Divide-and-conquer_algorithm) approach instead which goes like this, if the path from `0` to `T` takes `N` steps, the path from `0` to `2T` takes `2N` steps, with this:
194+
Eventually, I got an idea from [reddit](https://old.reddit.com/r/adventofcode/comments/1pk87hl/2025_day_10_part_2_bifurcate_your_way_to_victory/) about using the Reduce-and-conquer approach instead, it goes like this; if the path from `0` to `T` takes `N` steps, the path from `0` to `2T` takes `2N` steps, with this:
195195

196196
- We can try to get convert the `joltage` into even numbers.
197197
- Resolve `joltage / 2`.
@@ -200,13 +200,13 @@ Eventually, I got an idea from [reddit](https://old.reddit.com/r/adventofcode/co
200200

201201
**DISCLAIMER** I have no proof that this handles every possible scenario but with the test cases I prepared, the BFS result leads to the same from this, and, the result has been accepted by Advent of Code.
202202

203-
Let's start by defining how to press the buttons to get `` from the alternatives to resolve part 1, I mentioned that applying a button more than once is not necessary because it invalidates the previous action, in this case with integer values, we can claim the same but it is not about the value itself but the parity.
203+
There is an important detail to resolve part 1, applying a button more than once does not make sense because it invalidates the previous action, in the case of part 2 which uses integer values, we can focus on the value parity instead, for this, the same statement holds, applying the same button twice invalidates the previous action.
204204

205-
For example, applying a buton `0, 3` to joltages `3, 4, 5, 6` leads to joltates `2, 4, 4, 6` (all even) but applying the same button again will revert the parity back.
205+
For example, applying the button `0, 3` to joltages `3, 4, 5, 6` lead to `2, 4, 4, 6` (all even) but applying the same button again will revert the parity back.
206206

207-
When all joltages are even (like `2, 4, 4, 6`), we can divide them by 2, leaving us with joltages `1, 2, 2, 3`, then, we apply the same process recursively.
207+
When all joltages are even (like `2, 4, 4, 6`), we can divide each value by 2, leaving us with `1, 2, 2, 3`, then, we can apply the same process recursively.
208208

209-
Having said this, let's generate all possible transitions given the available buttons, this is, all subsets from the given buttons, leveraging the powerful Scala stdlib, we can call the `Set#subsets` function:
209+
Having said this, let's generate all possible transitions from the available buttons, this is, all [subsets](https://en.wikipedia.org/wiki/Subset) from the given buttons, leveraging the powerful Scala stdlib, we can call the `Set#subsets` function:
210210

211211
```scala
212212
scala> List(1, 2, 3).toSet.subsets.foreach(println)

0 commit comments

Comments
 (0)