-
Notifications
You must be signed in to change notification settings - Fork 0
/
day.template.rs
54 lines (47 loc) · 1.08 KB
/
day.template.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use std::{
collections::HashMap,
fs,
io::{self, BufRead, BufReader},
usize,
};
fn day01a(input: &str) -> usize {
input
.lines()
.map(|line| {
// todo #rev
// let (first, last) = find_first_last(line);
})
.sum()
}
fn day01b(input: &str) -> usize {
input
.lines()
.map(|line| {
let (first, last) = find_first_last(line);
format!("{}{}", first, last).parse::<usize>().unwrap();
})
.sum()
}
fn main() {
let filecontent = fs::read_to_string("input/day01.txt").unwrap();
println!("---");
println!("PART A:");
println!("result of day01a: {}", day01a(&filecontent));
println!("---");
println!("PART B:");
println!("result of day01b: {}", day01b(&filecontent));
println!("---");
}
#[cfg(test)]
mod tests {
use super::*;
const TEST_STRINGS: &str = "";
#[test]
fn test_day01a() {
assert_eq!(281, day01a(TEST_STRINGS))
}
#[test]
fn test_day01b() {
assert_eq!(281, day01b(TEST_STRINGS))
}
}