tangled
alpha
login
or
join now
cherry.computer
/
aoc25
My submissions for Advent of Code 2025
adventofcode.com/2025
rust
aoc
0
fork
atom
overview
issues
pulls
pipelines
add solution for day 10 part 1
cherry.computer
1 month ago
afab2194
6efd0a62
verified
This commit was signed with the committer's
known signature
.
cherry.computer
SSH Key Fingerprint:
SHA256:SIA77Ll0IpMb8Xd3RtaGT+PBIGIePhJJg5W2r6Td7cc=
+58
3 changed files
expand all
collapse all
unified
split
10
part1
Cargo.toml
src
main.rs
Cargo.lock
+7
10/part1/Cargo.toml
···
1
1
+
[package]
2
2
+
name = "aoc25-10-1"
3
3
+
version = "1.0.0"
4
4
+
edition = "2024"
5
5
+
6
6
+
[dependencies]
7
7
+
itertools = "0.14.0"
+44
10/part1/src/main.rs
···
1
1
+
use std::fs::read_to_string;
2
2
+
3
3
+
use itertools::Itertools;
4
4
+
5
5
+
fn main() {
6
6
+
let minimum_presses: usize = read_to_string("../input.txt")
7
7
+
.expect("failed to open input file")
8
8
+
.lines()
9
9
+
.map(|line| {
10
10
+
let (diagram, wiring) = line
11
11
+
.split_once("] ")
12
12
+
.expect("failed to find indicator light diagram delimiter");
13
13
+
let lights: Vec<_> = diagram[1..].bytes().map(|light| light == b'#').collect();
14
14
+
let wires: Vec<Vec<_>> = wiring
15
15
+
[..wiring.find(" {").expect("failed to find joltage delimiter")]
16
16
+
.split(' ')
17
17
+
.map(|wires| {
18
18
+
wires[1..wires.len() - 1]
19
19
+
.split(',')
20
20
+
.map(|wire_idx| {
21
21
+
wire_idx
22
22
+
.parse::<usize>()
23
23
+
.expect("failed to parse wire index")
24
24
+
})
25
25
+
.collect()
26
26
+
})
27
27
+
.collect();
28
28
+
(1..wires.len())
29
29
+
.find(|&buttons_pressed| {
30
30
+
wires.iter().combinations(buttons_pressed).any(|wires| {
31
31
+
let mut current_lights = vec![false; lights.len()];
32
32
+
for &wire in wires.into_iter().flatten() {
33
33
+
current_lights[wire] ^= true;
34
34
+
}
35
35
+
current_lights == lights
36
36
+
})
37
37
+
})
38
38
+
.expect("failed to find any combination of buttons to press")
39
39
+
})
40
40
+
.sum();
41
41
+
42
42
+
println!("The fewest number of button presses is {minimum_presses}!");
43
43
+
}
44
44
+
+7
Cargo.lock
···
81
81
]
82
82
83
83
[[package]]
84
84
+
name = "aoc25-10-1"
85
85
+
version = "1.0.0"
86
86
+
dependencies = [
87
87
+
"itertools",
88
88
+
]
89
89
+
90
90
+
[[package]]
84
91
name = "either"
85
92
version = "1.15.0"
86
93
source = "registry+https://github.com/rust-lang/crates.io-index"