Skip to content

Commit

Permalink
Solve 2015.12.01
Browse files Browse the repository at this point in the history
  • Loading branch information
jontmy00 committed Dec 1, 2021
1 parent 91213a3 commit 9e268d4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions output/2015/12.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
191164
0
33 changes: 33 additions & 0 deletions src/aoc2015/day12.rs
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))
}
}

0 comments on commit 9e268d4

Please sign in to comment.