add day 12 part 1
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
use regex::Regex;
|
||||
use serde_json::Value;
|
||||
|
||||
fn main() {
|
||||
let content = std::fs::read_to_string("input.json").unwrap();
|
||||
|
||||
part1(&content);
|
||||
part2(&content);
|
||||
}
|
||||
|
||||
fn part2(content: &str) {
|
||||
let json: Value = serde_json::from_str(content).unwrap();
|
||||
|
||||
// dbg!(json.as_object().unwrap().iter().next().unwrap());
|
||||
}
|
||||
|
||||
fn part1(content: &str) {
|
||||
let re = Regex::new("-?[0-9]+").unwrap();
|
||||
let count: isize = re
|
||||
.find_iter(content)
|
||||
.map(|s| s.as_str().parse::<isize>().unwrap())
|
||||
.sum();
|
||||
println!("{count}");
|
||||
}
|
||||
Reference in New Issue
Block a user