formatted some code

Dieser Commit ist enthalten in:
Sebastian Tobie 2024-12-16 20:42:16 +01:00
Ursprung 4f10c7fb5e
Commit dbc7c9e7ef
2 geänderte Dateien mit 10 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -1,6 +1,9 @@
use advent_of_code::{strings::{convert_to_array, parsenumber}, KD};
#[allow(unused_imports)] #[allow(unused_imports)]
use advent_of_code::{include_data, include_example}; use advent_of_code::{include_data, include_example};
use advent_of_code::{
strings::{convert_to_array, parsenumber},
KD,
};
include_data!(DATA 2024 02); include_data!(DATA 2024 02);
@ -73,7 +76,7 @@ fn safe(record: Vec<u32>) -> bool {
match (direction, last > level) { match (direction, last > level) {
(KD::Top, false) | (KD::Bottom, true) => last = level, (KD::Top, false) | (KD::Bottom, true) => last = level,
(KD::Top, true) | (KD::Bottom, false) => errors += 1, (KD::Top, true) | (KD::Bottom, false) => errors += 1,
_=>unreachable!() _ => unreachable!(),
} }
} }
if errors > 0 { if errors > 0 {

Datei anzeigen

@ -5,21 +5,21 @@ use regex::{Captures, Regex};
include_data!(DATA 2024 03); include_data!(DATA 2024 03);
fn parse_part1(input : Vec<Captures<'_>>) -> u32 { fn parse_part1(input: Vec<Captures<'_>>) -> u32 {
let mut sum = 0; let mut sum = 0;
let (mut i,mut j): (u32, u32); let (mut i, mut j): (u32, u32);
for capture in input { for capture in input {
i = parsenumber(capture.name("i").unwrap().as_str()); i = parsenumber(capture.name("i").unwrap().as_str());
j=parsenumber(capture.name("j").unwrap().as_str()); j = parsenumber(capture.name("j").unwrap().as_str());
sum += i * j sum += i * j
} }
sum sum
} }
fn parse_part2(input : Vec<Captures<'_>>)->u32 { fn parse_part2(input: Vec<Captures<'_>>) -> u32 {
let mut sum = 0; let mut sum = 0;
let mut parse = true; let mut parse = true;
let (mut i,mut j): (u32, u32); let (mut i, mut j): (u32, u32);
for capture in input { for capture in input {
match (capture.get(1).unwrap().as_str(), parse) { match (capture.get(1).unwrap().as_str(), parse) {
("do()", _) => parse = true, ("do()", _) => parse = true,