From 38eae3237ae9215ae0b1ac673441e6878e0ba7c5 Mon Sep 17 00:00:00 2001 From: Johannes Date: Tue, 3 Dec 2024 06:38:48 +0100 Subject: [PATCH] shortened bit more --- src/day03.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/day03.rs b/src/day03.rs index aa02e50..f9ba598 100644 --- a/src/day03.rs +++ b/src/day03.rs @@ -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() @@ -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 }) } }