Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
qselle committed Dec 3, 2024
1 parent 30e908c commit f500bef
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/day3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,20 @@ pub fn part1(input: &[String]) -> usize {
let re = Regex::new(r"(?<a>\d+),(?<b>\d+)").unwrap();
input.iter().fold(0, |acc, m| {
let caps = re.captures(m).unwrap();
acc + (&caps["a"].parse::<usize>().unwrap() * &caps["b"].parse::<usize>().unwrap())
acc + (caps["a"].parse::<usize>().unwrap() * caps["b"].parse::<usize>().unwrap())
})
}

#[aoc(day3, part2)]
pub fn part2(input: &[String]) -> usize {
let re = Regex::new(r"(?<a>\d+),(?<b>\d+)").unwrap();
input.iter().fold(0, |acc, m| {
let caps = re.captures(m).unwrap();
acc + (caps["a"].parse::<usize>().unwrap() * caps["b"].parse::<usize>().unwrap())
})
}


#[cfg(test)]
mod tests {
use super::*;
Expand All @@ -29,8 +39,8 @@ mod tests {
assert_eq!(161, part1(&input_generator(INPUT)))
}

// #[test]
// fn test_part2() {
// assert_eq!(4, part2(&input_generator(INPUT)))
// }
#[test]
fn test_part2() {
assert_eq!(4, part2(&input_generator(INPUT)))
}
}

0 comments on commit f500bef

Please sign in to comment.