My submissions for Advent of Code 2025 adventofcode.com/2025
rust aoc

add solution for day 10 part 1

cherry.computer afab2194 6efd0a62

verified
+58
+7
10/part1/Cargo.toml
···
··· 1 + [package] 2 + name = "aoc25-10-1" 3 + version = "1.0.0" 4 + edition = "2024" 5 + 6 + [dependencies] 7 + itertools = "0.14.0"
+44
10/part1/src/main.rs
···
··· 1 + use std::fs::read_to_string; 2 + 3 + use itertools::Itertools; 4 + 5 + fn main() { 6 + let minimum_presses: usize = read_to_string("../input.txt") 7 + .expect("failed to open input file") 8 + .lines() 9 + .map(|line| { 10 + let (diagram, wiring) = line 11 + .split_once("] ") 12 + .expect("failed to find indicator light diagram delimiter"); 13 + let lights: Vec<_> = diagram[1..].bytes().map(|light| light == b'#').collect(); 14 + let wires: Vec<Vec<_>> = wiring 15 + [..wiring.find(" {").expect("failed to find joltage delimiter")] 16 + .split(' ') 17 + .map(|wires| { 18 + wires[1..wires.len() - 1] 19 + .split(',') 20 + .map(|wire_idx| { 21 + wire_idx 22 + .parse::<usize>() 23 + .expect("failed to parse wire index") 24 + }) 25 + .collect() 26 + }) 27 + .collect(); 28 + (1..wires.len()) 29 + .find(|&buttons_pressed| { 30 + wires.iter().combinations(buttons_pressed).any(|wires| { 31 + let mut current_lights = vec![false; lights.len()]; 32 + for &wire in wires.into_iter().flatten() { 33 + current_lights[wire] ^= true; 34 + } 35 + current_lights == lights 36 + }) 37 + }) 38 + .expect("failed to find any combination of buttons to press") 39 + }) 40 + .sum(); 41 + 42 + println!("The fewest number of button presses is {minimum_presses}!"); 43 + } 44 +
+7
Cargo.lock
··· 81 ] 82 83 [[package]] 84 name = "either" 85 version = "1.15.0" 86 source = "registry+https://github.com/rust-lang/crates.io-index"
··· 81 ] 82 83 [[package]] 84 + name = "aoc25-10-1" 85 + version = "1.0.0" 86 + dependencies = [ 87 + "itertools", 88 + ] 89 + 90 + [[package]] 91 name = "either" 92 version = "1.15.0" 93 source = "registry+https://github.com/rust-lang/crates.io-index"