diff --git a/.aoc_tiles/tiles/2025/03.png b/.aoc_tiles/tiles/2025/03.png new file mode 100644 index 0000000..7376104 Binary files /dev/null and b/.aoc_tiles/tiles/2025/03.png differ diff --git a/README.md b/README.md index 807be67..ba3e2c6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

- 2025 - 4 ⭐ - Rust + 2025 - 6 ⭐ - Rust

@@ -8,4 +8,7 @@ + + + diff --git a/src/day2.rs b/src/day2.rs index d5629c6..974fd2f 100644 --- a/src/day2.rs +++ b/src/day2.rs @@ -31,7 +31,7 @@ fn part1(input: &[RangeInclusive]) -> u64 { for r in input { for product in r.clone() { let prod_s = product.to_string(); - if prod_s.len() % 2 != 0 { + if !prod_s.len().is_multiple_of(2) { continue; } let (left, right) = prod_s.split_at(prod_s.len() / 2); @@ -50,7 +50,7 @@ fn part2(input: &[RangeInclusive]) -> u64 { for product in r.clone() { let prod_s = product.to_string(); for n in 1..=prod_s.len() / 2 { - if prod_s.len() % n != 0 { + if !prod_s.len().is_multiple_of(n) { continue; } if prod_s @@ -76,7 +76,7 @@ fn part1_arithmetic_brute(input: &[RangeInclusive]) -> u64 { // println!("Range: {:?}", r); for product in r.clone() { let n_digits = (product.ilog10() + 1) as usize; - if n_digits % 2 != 0 { + if !n_digits.is_multiple_of(2) { continue; } @@ -101,7 +101,7 @@ fn part2_arithmetic_brute(input: &[RangeInclusive]) -> u64 { for n in 1..=n_digits / 2 { let repetitions = n_digits / n; - if n_digits % n != 0 { + if !n_digits.is_multiple_of(n) { continue; } let decade = POW10[n_digits - n]; @@ -127,7 +127,7 @@ fn part1_clever(input: &[RangeInclusive]) -> u64 { for r in input { let n_digits = (r.start().ilog10() + 1) as usize; - let mut lhs = if n_digits % 2 != 0 { + let mut lhs = if !n_digits.is_multiple_of(2) { // If the number of digits is odd, we start our guess at the first possibility in the next decade POW10[n_digits / 2] } else { diff --git a/src/day3.rs b/src/day3.rs index 5cf2ada..2be5275 100644 --- a/src/day3.rs +++ b/src/day3.rs @@ -1,11 +1,6 @@ -use std::collections::HashMap; - use aoc_runner_derive::{aoc, aoc_generator}; -use lazy_static::lazy_static; use memoize::memoize; -type Bank = [u8]; - #[aoc_generator(day3)] fn parse(input: &str) -> Vec> { input @@ -40,12 +35,12 @@ fn max_joltage(bank: Vec, n: usize) -> u64 { } #[aoc(day3, part1)] -fn part1(input: &Vec>) -> u64 { +fn part1(input: &[Vec]) -> u64 { input.iter().map(|bank| max_joltage(bank.clone(), 2)).sum() } #[aoc(day3, part2)] -fn part2(input: &Vec>) -> u64 { +fn part2(input: &[Vec]) -> u64 { input.iter().map(|bank| max_joltage(bank.clone(), 12)).sum() } diff --git a/src/lib.rs b/src/lib.rs index 3a057fc..31454ef 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ -mod day3; mod day1; mod day2; +mod day3; use aoc_runner_derive::aoc_lib;