2024-12-19 17:12:39 +01:00
|
|
|
use advent_of_code::include_aoc;
|
2024-12-08 01:44:21 +01:00
|
|
|
use advent_of_code::strings::{convert_to_array, get_numbers, get_string_numbers};
|
2024-12-01 22:25:51 +01:00
|
|
|
|
2024-12-19 17:12:39 +01:00
|
|
|
include_aoc!(DATAa, 2023, 01a);
|
|
|
|
include_aoc!(DATAb, 2023, 01b);
|
2024-12-01 22:25:51 +01:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut sum: u32 = 0;
|
2024-12-08 01:44:21 +01:00
|
|
|
|
|
|
|
for coordinates in convert_to_array::<_, _, '\n'>(DATAa, get_numbers::<u32>) {
|
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);
|
|
|
|
}
|