33 Zeilen
1 KiB
Rust
33 Zeilen
1 KiB
Rust
use advent_of_code::include_aoc;
|
|
use advent_of_code::strings::{convert_to_array, get_numbers, get_string_numbers};
|
|
|
|
include_aoc!(DATAa, 2023, 01a);
|
|
include_aoc!(DATAb, 2023, 01b);
|
|
|
|
fn main() {
|
|
let mut sum: u32 = 0;
|
|
|
|
for coordinates in convert_to_array::<_, _, '\n'>(DATAa, get_numbers::<u32>) {
|
|
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;
|
|
for coordinates in DATAb.split('\n').map(get_string_numbers) {
|
|
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);
|
|
}
|