Skip to content

Commit

Permalink
shortened bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
freelon committed Dec 3, 2024
1 parent af3bb05 commit 38eae32
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/day03.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ fn part1(input: &str) -> RiddleResult {
let r = regex::Regex::new(r"mul\((\d{1,3}),(\d{1,3})\)").unwrap();
r.captures_iter(input)
.map(|c| {
let a: i64 = c.get(1).unwrap().as_str().parse().unwrap();
let b: i64 = c.get(2).unwrap().as_str().parse().unwrap();
let a: i64 = c[1].parse().unwrap();
let b: i64 = c[2].parse().unwrap();
a * b
})
.sum()
Expand All @@ -31,8 +31,8 @@ fn part2(input: &str) -> RiddleResult {
"do()" => (true, result),
"don't()" => (false, result),
_ => {
let a: i64 = c.get(1).unwrap().as_str().parse().unwrap();
let b: i64 = c.get(2).unwrap().as_str().parse().unwrap();
let a: i64 = c[1].parse().unwrap();
let b: i64 = c[2].parse().unwrap();
(enabled, result + if enabled { a * b } else { 0 })
}
}
Expand Down

0 comments on commit 38eae32

Please sign in to comment.