Day 1 part 1 complete.

This commit is contained in:
Drew Galbraith 2023-12-01 06:24:49 -08:00
parent de452d97c0
commit 6b55dd0f52
4 changed files with 1018 additions and 1 deletions

7
Cargo.lock generated Normal file
View File

@ -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"

1000
input/day01.txt Normal file

File diff suppressed because it is too large Load Diff

1
rustfmt.toml Normal file
View File

@ -0,0 +1 @@
tab_spaces = 2

View File

@ -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);
}