From 6919b7abf8d4893fe6b0182d9bbb315bee894fc6 Mon Sep 17 00:00:00 2001 From: Jan Doumont Date: Sun, 14 Dec 2025 23:23:13 +0100 Subject: [PATCH] cleanup and ignore input --- .gitignore | 1 + src/day10.rs | 14 +------------- src/day2.rs | 16 ---------------- src/day4.rs | 2 -- src/day5.rs | 24 ------------------------ src/day7.rs | 3 --- src/day8.rs | 2 -- src/day9.rs | 18 +----------------- 8 files changed, 3 insertions(+), 77 deletions(-) diff --git a/.gitignore b/.gitignore index ea8c4bf..393948d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +/input/ diff --git a/src/day10.rs b/src/day10.rs index 8193b19..07c38e7 100644 --- a/src/day10.rs +++ b/src/day10.rs @@ -6,14 +6,6 @@ use microlp::{ComparisonOp, OptimizationDirection, Problem, Variable}; #[aoc(day10, part1)] pub fn part1(input: &str) -> u32 { let machines = parse(input); - // for machine in &machines { - // println!( - // "num buttons: {} num lights: {} diff: {}", - // machine.buttons.len(), - // machine.lights.len(), - // machine.buttons.len() as i32 - machine.lights.len() as i32 - // ); - // } machines.into_iter().map(|m| m.button_presses()).sum() } @@ -32,9 +24,7 @@ struct Machine { impl Machine { fn joltage_presses(self: Machine) -> u32 { - // Method: Set up a linear set of equations A^Tx=b, where A contains - // the coordinates of the buttons (one row per button) plus coordinates - // associated with optimisation parameters; or use a milp library :) + // using microlp's milp implementation... TODO: manual gauss elimination? let mut problem = Problem::new(OptimizationDirection::Minimize); let vars: Vec = (0..self.buttons.len()) .map(|_| problem.add_integer_var(1.0, (0, *self.joltage.iter().max().unwrap() as i32))) @@ -51,8 +41,6 @@ impl Machine { ); } - println!("{:?}", problem); - problem .solve() .unwrap() diff --git a/src/day2.rs b/src/day2.rs index c4d85f2..3117ea1 100644 --- a/src/day2.rs +++ b/src/day2.rs @@ -46,21 +46,6 @@ fn invalid_ids_2(ranges: Vec<(&str, &str)>) -> u64 { } } } - // if from.len() == to.len() { - // println!("{} to {}", from, to,); - // for n in (2..=(from.len() / 2).max(2)).filter(|n| from.len() % n == 0) { - // //println!("{}", n); - // let l = from.len() / n; - // for num in from[..l].parse::().unwrap()..=to[..l].parse::().unwrap() { - // let candidate = num.to_string().repeat(n).parse::().unwrap(); - // println!("{}", candidate); - // if candidate <= i_to && candidate >= i_from { - // println!("selected!"); - // result.insert(candidate); - // } - // } - // } - // } } result.iter().sum() } @@ -73,7 +58,6 @@ fn invalid_ids(ranges: Vec<(&str, &str)>) -> Vec { let i_str = i.to_string(); let i_len = i_str.len(); if i_len % 2 == 0 { - //println!("{}: {}-{}", i, &i_str[..i_len / 2], &i_str[i_len / 2..]); if i_str[..i_len / 2] == i_str[i_len / 2..] { result.push(i); } diff --git a/src/day4.rs b/src/day4.rs index 63a51fa..296c3e8 100644 --- a/src/day4.rs +++ b/src/day4.rs @@ -27,7 +27,6 @@ fn make_array(input: &str) -> Vec> { } } } - // println!("{:?}", array); array } @@ -51,7 +50,6 @@ fn get_accessible(array: &Vec>) -> Vec> { < 4) as u8; } } - // println!("{:?}", accessible); accessible } diff --git a/src/day5.rs b/src/day5.rs index 6e9d9a8..2451c37 100644 --- a/src/day5.rs +++ b/src/day5.rs @@ -18,30 +18,6 @@ impl UintInclusiveRange { value >= self.start && value <= self.end } - // fn overlaps(&self, other: &UintInclusiveRange) -> bool { - // (self.start >= other.start && self.start <= other.end) - // || (self.end >= other.start && self.end <= other.end) - // || (self.start <= other.start && self.end >= other.end) - // || (self.start >= other.start && self.end <= other.end) - // } - - // fn join(&self, other: &UintInclusiveRange) -> UintInclusiveRange { - // println!( - // "Joining {:?} and {:?} into {:?}", - // self, - // other, - // UintInclusiveRange::new( - // cmp::min(self.start, other.start), - // cmp::max(self.end, other.end), - // ) - // ); - // assert!(self.overlaps(&other)); - // UintInclusiveRange::new( - // cmp::min(self.start, other.start), - // cmp::max(self.end, other.end), - // ) - // } - fn size(self) -> u64 { self.end - self.start + 1 } diff --git a/src/day7.rs b/src/day7.rs index 85944e8..d3b750d 100644 --- a/src/day7.rs +++ b/src/day7.rs @@ -20,8 +20,6 @@ fn run(input: &str) -> (u32, u64) { let local_split; (beams, local_split) = propagate(&field_slice, beams); split_count = split_count + local_split; - //println!("{}", split_count); - println!("{:?}", beams); } let timeline_count = beams.values().sum(); (split_count, timeline_count) @@ -38,7 +36,6 @@ fn parse(input: &str) -> Vec> { let mut fieldmap: Vec> = vec![Vec::new(); lines.clone().count()]; for (i, line) in lines.enumerate() { - // println!("{}", line); for (j, c) in line.chars().enumerate() { match c { 'S' => fieldmap[i].push((j, TachyonPoint::Source)), diff --git a/src/day8.rs b/src/day8.rs index 07c6d7e..e8368cd 100644 --- a/src/day8.rs +++ b/src/day8.rs @@ -14,7 +14,6 @@ pub fn part2(input: &str) -> i64 { let nodes = parse(input); let distance_matrix = distances(nodes.clone()); let last_nodes = fully_connect(distance_matrix).unwrap(); - println!("{:?}", last_nodes); nodes[last_nodes.0][0] * nodes[last_nodes.1][0] } @@ -64,7 +63,6 @@ fn make_circuits(distance_matrix: Vec>, n_connections: u32) -> Vec>, Vec>) = circuits .into_iter() .partition(|c| c.contains(i) || c.contains(&(*j + 1 + *i))); - // println!("{:?} {} {}", i, j + 1 + i, d); assert!(to_merge.len() < 3); let new_circuit: HashSet = to_merge .iter() diff --git a/src/day9.rs b/src/day9.rs index e429d01..aac2ea6 100644 --- a/src/day9.rs +++ b/src/day9.rs @@ -7,9 +7,7 @@ pub fn part1(input: &str) -> i64 { let mut area = 0; for (x1, y1) in coords.iter().rev().take(10) { for (x2, y2) in coords.iter().take(10) { - if ((x1 - x2 + 1) * (y1 - y2 + 1)) > area { - println!("{:?}", ((x1, y1), (x2, y2))) - }; + if ((x1 - x2 + 1) * (y1 - y2 + 1)) > area {}; area = area.max((x1 - x2 + 1) * (y1 - y2 + 1)); } } @@ -50,13 +48,6 @@ fn check(corner_1: usize, corner_3: usize, coords: &Vec<(i64, i64)>) -> bool { || (x1 <= &upper_left.0 && x2 <= &upper_left.0) || (x1 >= &lower_right.0 && x2 >= &lower_right.0)) { - // println!( - // "rejected horizontal of {:?},{:?} due to line {:?} {:?}", - // upper_left, - // lower_right, - // (x1, y1), - // (x2, y2) - // ); return false; } } else { @@ -66,13 +57,6 @@ fn check(corner_1: usize, corner_3: usize, coords: &Vec<(i64, i64)>) -> bool { || (y1 <= &upper_left.1 && y2 <= &upper_left.1) || (y1 >= &lower_right.1 && y2 >= &lower_right.1)) { - // println!( - // "rejected vertical of {:?},{:?} due to line {:?} {:?}", - // upper_left, - // lower_right, - // (x1, y1), - // (x2, y2) - // ); return false; } }