Advent 2023 Day 1

This commit is contained in:
Jos van Goor 2023-12-02 12:16:45 +01:00
parent e8126364c4
commit e55fda8da2
4 changed files with 1141 additions and 1 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,25 @@
use std::fs::read_to_string;
fn main() {
let mut calibration = 0;
for line in read_to_string("input.txt").unwrap().lines() {
let mut first = 0;
let mut last = 0;
let mut set_first = false;
for char in line.chars() {
if char.is_ascii_digit() {
if !set_first {
first = char as i32 - '0' as i32;
set_first = true;
}
last = char as i32 - '0' as i32;
}
}
calibration += 10 * first + last;
}
println!("{}", calibration);
}