File tree Expand file tree Collapse file tree 5 files changed +286
-1
lines changed
kotlin/adventofcode/year2025
resources/inputs/year2025
kotlin/adventofcode/year2025
resources/inputs/year2025 Expand file tree Collapse file tree 5 files changed +286
-1
lines changed Original file line number Diff line number Diff line change 2929| 2022 | ★ | ★ | ★ | ★ | ★ | ★ | ★ | ★ | ★ | ★ | ★ | ★ | ★ | | | | | | | | ☆ | | | | ☆ | 28 |
3030| 2023 | ★ | ★ | ★ | ★ | ☆ | ★ | ☆ | | | | | | | | | | | | | | | | | | | 12 |
3131| 2024 | ★ | ★ | ★ | ★ | ★ | ★ | ★ | ★ | ★ | ★ | ★ | ★ | ★ | ★ | | ☆ | ★ | ★ | ★ | ★ | | ★ | | | ☆ | 40 |
32- | 2025 | ★ | ★ | ★ | ★ | ★ | ★ | ★ | ★ | ★ | | ★ | | – | – | – | – | – | – | – | – | – | – | – | – | – | 20 |
32+ | 2025 | ★ | ★ | ★ | ★ | ★ | ★ | ★ | ★ | ★ | ☆ | ★ | | – | – | – | – | – | – | – | – | – | – | – | – | – | 21 |
3333
3434## 🛷 How to run
3535
@@ -215,6 +215,7 @@ e.g. `HandyHaversacks`)*
215215| | 7 | [ Laboratories] ( https://adventofcode.com/2025/day/7 ) | [[ Code] ( src/main/kotlin/adventofcode/year2025/Day07Laboratories.kt )]   ; [[ Test] ( src/test/kotlin/adventofcode/year2025/Day07LaboratoriesSpec.kt )] | ` 1711 ` | ` 36706966158365 ` |
216216| | 8 | [ Playground] ( https://adventofcode.com/2025/day/8 ) | [[ Code] ( src/main/kotlin/adventofcode/year2025/Day08Playground.kt )]   ; [[ Test] ( src/test/kotlin/adventofcode/year2025/Day08PlaygroundSpec.kt )] | ` 135169 ` | ` 302133440 ` |
217217| | 9 | [ Movie Theater] ( https://adventofcode.com/2025/day/9 ) | [[ Code] ( src/main/kotlin/adventofcode/year2025/Day09MovieTheater.kt )]   ; [[ Test] ( src/test/kotlin/adventofcode/year2025/Day09MovieTheaterSpec.kt )] | ` 4777409595 ` | ` 1473551379 ` |
218+ | | 10 | [ Factory] ( https://adventofcode.com/2025/day/10 ) | [[ Code] ( src/main/kotlin/adventofcode/year2025/Day10Factory.kt )]   ; [[ Test] ( src/test/kotlin/adventofcode/year2025/Day10FactorySpec.kt )] | ` 517 ` | |
218219| | 11 | [ Reactor] ( https://adventofcode.com/2025/day/11 ) | [[ Code] ( src/main/kotlin/adventofcode/year2025/Day11Reactor.kt )]   ; [[ Test] ( src/test/kotlin/adventofcode/year2025/Day11ReactorSpec.kt )] | ` 699 ` | ` 388893655378800 ` |
219220
220221## 🕯️ Useful commands
Original file line number Diff line number Diff line change 1+ package adventofcode.year2025
2+
3+ import adventofcode.Puzzle
4+ import adventofcode.PuzzleInput
5+ import adventofcode.common.Permutations.powersets
6+
7+ class Day10Factory (
8+ customInput : PuzzleInput ? = null ,
9+ ) : Puzzle(customInput) {
10+ private fun parseInput () = input.lines().map(Machine ::invoke)
11+
12+ override fun partOne () =
13+ parseInput()
14+ .sumOf { machine ->
15+ machine
16+ .buttons
17+ .powersets()
18+ .sortedBy { combination -> combination.size }
19+ .first { combination ->
20+ combination.fold(List (machine.lights.size) { false }) { lights, buttons ->
21+ lights.mapIndexed { index, light ->
22+ when (index in buttons) {
23+ true -> ! light
24+ else -> light
25+ }
26+ }
27+ } == machine.lights
28+ }.size
29+ }
30+
31+ companion object {
32+ private data class Machine (
33+ val lights : List <Boolean >,
34+ val buttons : List <List <Int >>,
35+ val joltages : List <Int >,
36+ ) {
37+ companion object {
38+ operator fun invoke (input : String ): Machine {
39+ val lights =
40+ input
41+ .substringAfter(" [" )
42+ .substringBefore(" ]" )
43+ .split(" " )
44+ .filter(String ::isNotEmpty)
45+ .map { light ->
46+ when (light.single()) {
47+ ' #' -> true
48+ else -> false
49+ }
50+ }
51+
52+ val buttons =
53+ input
54+ .substringAfter(" " )
55+ .substringBefore(" {" )
56+ .split(" " )
57+ .map { buttons ->
58+ buttons
59+ .replace(" (" , " " )
60+ .replace(" )" , " " )
61+ .split(" ," )
62+ .map(String ::toInt)
63+ }
64+
65+ val joltages =
66+ input
67+ .substringAfter(" {" )
68+ .substringBefore(" }" )
69+ .split(" ," )
70+ .map(String ::toInt)
71+
72+ return Machine (lights, buttons, joltages)
73+ }
74+ }
75+ }
76+ }
77+ }
You can’t perform that action at this time.
0 commit comments