Day 1 part 1 complete.
This commit is contained in:
parent
de452d97c0
commit
6b55dd0f52
|
@ -0,0 +1,7 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aoc23"
|
||||
version = "0.1.0"
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1 @@
|
|||
tab_spaces = 2
|
11
src/main.rs
11
src/main.rs
|
@ -1,3 +1,12 @@
|
|||
use std::io;
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
let mut buffer = String::new();
|
||||
let mut sum = 0;
|
||||
while io::stdin().read_line(&mut buffer).unwrap() > 0 {
|
||||
let nums: Vec<u32> = buffer.chars().filter_map(|c| c.to_digit(10)).collect();
|
||||
sum += nums.first().unwrap() * 10 + nums.last().unwrap();
|
||||
buffer = String::new();
|
||||
}
|
||||
println!("Sum: {}", sum);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue