2024-12-01 22:25:51 +01:00
|
|
|
use advent_of_code::strings::{get_numbers, get_string_numbers};
|
|
|
|
#[allow(unused_imports)]
|
2024-12-03 23:16:23 +01:00
|
|
|
use advent_of_code_macros::{include_data, include_example};
|
2024-12-01 22:25:51 +01:00
|
|
|
|
2024-12-02 21:50:56 +01:00
|
|
|
include_data!(DATAa 2023 01a);
|
|
|
|
include_data!(DATAb 2023 01b);
|
2024-12-01 22:25:51 +01:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut sum: u32 = 0;
|
2024-12-02 21:50:56 +01:00
|
|
|
for coordinates in DATAa.split('\n').map(get_numbers) {
|
2024-12-01 22:25:51 +01:00
|
|
|
if coordinates.len() == 0 {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
let first = coordinates.first().unwrap() * 10;
|
|
|
|
let last = *coordinates.last().unwrap();
|
|
|
|
let number = first + last;
|
|
|
|
println!("Number: {}", number);
|
|
|
|
sum += number;
|
|
|
|
}
|
|
|
|
println!("Sum of Numbers {}", sum);
|
|
|
|
sum = 0;
|
2024-12-02 21:50:56 +01:00
|
|
|
for coordinates in DATAb.split('\n').map(get_string_numbers) {
|
2024-12-01 22:25:51 +01:00
|
|
|
if coordinates.len() == 0 {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
let first = coordinates.first().unwrap() * 10;
|
|
|
|
let last = *coordinates.last().unwrap();
|
|
|
|
let number = first + last;
|
|
|
|
println!("Number: {}", number);
|
|
|
|
sum += number;
|
|
|
|
}
|
|
|
|
println!("Sum of Numbers with strings {}", sum);
|
|
|
|
}
|