Skip to content

Commit

Permalink
Tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
samestep committed Dec 3, 2024
1 parent 07b3c40 commit 6606c87
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/day03/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ fn parse_mul(caps: Captures) -> usize {
}

pub fn puzzle1(input: &str) -> usize {
let re = Regex::new(r"mul\((\d+),(\d+)\)");
re.unwrap().captures_iter(input).map(parse_mul).sum()
let re = Regex::new(r"mul\((\d+),(\d+)\)").unwrap();
re.captures_iter(input).map(parse_mul).sum()
}

pub fn puzzle2(input: &str) -> usize {
let mut sum = 0;
let mut enabled = true;
let re = Regex::new(r"mul\((\d+),(\d+)\)|do\(\)|don't\(\)");
for caps in re.unwrap().captures_iter(input) {
let re = Regex::new(r"mul\((\d+),(\d+)\)|do\(\)|don't\(\)").unwrap();
for caps in re.captures_iter(input) {
match &caps[0] {
"do()" => enabled = true,
"don't()" => enabled = false,
Expand Down

0 comments on commit 6606c87

Please sign in to comment.