This commit is contained in:
Keenan Tims 2024-12-13 02:16:43 -08:00
parent 35637cece1
commit 1a6d37f4f3
Signed by: ktims
GPG Key ID: 11230674D69038D4
5 changed files with 8 additions and 6 deletions

View File

@ -11,5 +11,6 @@ repos:
# Simply remove the comments (#) below for args and the flags you want. # Simply remove the comments (#) below for args and the flags you want.
args: args:
- --auto-add-tiles-to-git=amend - --auto-add-tiles-to-git=amend
- --create-all-days
# - --language-sorting=jl,kt,py,rs # - --language-sorting=jl,kt,py,rs
# - --exclude-patterns=2021/*/*.apl,2021/*/*.py,2021/*/*.cpp # - --exclude-patterns=2021/*/*.apl,2021/*/*.py,2021/*/*.cpp

View File

@ -10,7 +10,7 @@ pub fn get_input(input: &[u8]) -> Vec<String> {
// PROBLEM 1 solution // PROBLEM 1 solution
#[aoc(day3, part1)] #[aoc(day3, part1)]
pub fn part1(input: &Vec<String>) -> u64 { pub fn part1(input: &[String]) -> u64 {
let re = Regex::new(r"(?-u)mul\((\d+),(\d+)\)").unwrap(); let re = Regex::new(r"(?-u)mul\((\d+),(\d+)\)").unwrap();
input input
.iter() .iter()
@ -24,7 +24,7 @@ pub fn part1(input: &Vec<String>) -> u64 {
// PROBLEM 2 solution // PROBLEM 2 solution
#[aoc(day3, part2)] #[aoc(day3, part2)]
pub fn part2(input: &Vec<String>) -> u64 { pub fn part2(input: &[String]) -> u64 {
let mut sum = 0u64; let mut sum = 0u64;
let mut do_mul: u64 = 1; let mut do_mul: u64 = 1;
let re = Regex::new(r"(?-u)(do\(\)|don't\(\)|mul\((\d+),(\d+)\))").unwrap(); let re = Regex::new(r"(?-u)(do\(\)|don't\(\)|mul\((\d+),(\d+)\))").unwrap();

View File

@ -65,10 +65,7 @@ impl OrderingRules {
} }
} }
fn is_sorted(&self, a: u64, b: u64) -> bool { fn is_sorted(&self, a: u64, b: u64) -> bool {
match self.pairs.get(&(a, b)) { matches!(self.pairs.get(&(a, b)), Some(Ordering::Less) | Some(Ordering::Equal))
Some(Ordering::Less) | Some(Ordering::Equal) => true,
_ => false,
}
} }
} }

View File

@ -12,5 +12,6 @@ pub mod day9;
pub mod day10; pub mod day10;
pub mod day11; pub mod day11;
pub mod day12; pub mod day12;
pub mod day13;
aoc_lib! { year = 2024 } aoc_lib! { year = 2024 }

3
src/main.rs Normal file
View File

@ -0,0 +1,3 @@
use aoc_runner_derive::aoc_main;
aoc_main!{ lib = aoc2024 }