-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jontmy00
committed
Dec 1, 2021
1 parent
91213a3
commit 9e268d4
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
191164 | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use regex::Regex; | ||
|
||
pub fn solve_part_one(input: &String) -> i32 { | ||
let re: Regex = Regex::new(r"(-?\d+)").unwrap(); | ||
re.captures_iter(input) | ||
.map(|capture| capture.get(1).unwrap().as_str().parse::<i32>().unwrap()) | ||
.sum() | ||
} | ||
|
||
pub fn solve_part_two(input: &String) -> i32 { | ||
0 | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use rstest::rstest; | ||
|
||
use super::{solve_part_one, solve_part_two}; | ||
|
||
#[rstest] | ||
#[case(indoc::indoc ! {" | ||
123 -> a | ||
"}.to_string(), 123)] | ||
fn test_part_one(#[case] input: String, #[case] expected: i32) { | ||
assert_eq!(expected, solve_part_one(&input)) | ||
} | ||
|
||
#[rstest] | ||
#[case("str", 0)] | ||
fn test_part_two(#[case] input: String, #[case] expected: i32) { | ||
assert_eq!(expected, solve_part_two(&input)) | ||
} | ||
} |