formatted some code
Dieser Commit ist enthalten in:
Ursprung
4f10c7fb5e
Commit
dbc7c9e7ef
2 geänderte Dateien mit 10 neuen und 7 gelöschten Zeilen
|
@ -1,6 +1,9 @@
|
|||
use advent_of_code::{strings::{convert_to_array, parsenumber}, KD};
|
||||
#[allow(unused_imports)]
|
||||
use advent_of_code::{include_data, include_example};
|
||||
use advent_of_code::{
|
||||
strings::{convert_to_array, parsenumber},
|
||||
KD,
|
||||
};
|
||||
|
||||
include_data!(DATA 2024 02);
|
||||
|
||||
|
@ -73,7 +76,7 @@ fn safe(record: Vec<u32>) -> bool {
|
|||
match (direction, last > level) {
|
||||
(KD::Top, false) | (KD::Bottom, true) => last = level,
|
||||
(KD::Top, true) | (KD::Bottom, false) => errors += 1,
|
||||
_=>unreachable!()
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
if errors > 0 {
|
||||
|
|
|
@ -5,21 +5,21 @@ use regex::{Captures, Regex};
|
|||
|
||||
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 i,mut j): (u32, u32);
|
||||
let (mut i, mut j): (u32, u32);
|
||||
for capture in input {
|
||||
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
|
||||
}
|
||||
|
||||
fn parse_part2(input : Vec<Captures<'_>>)->u32 {
|
||||
fn parse_part2(input: Vec<Captures<'_>>) -> u32 {
|
||||
let mut sum = 0;
|
||||
let mut parse = true;
|
||||
let (mut i,mut j): (u32, u32);
|
||||
let (mut i, mut j): (u32, u32);
|
||||
for capture in input {
|
||||
match (capture.get(1).unwrap().as_str(), parse) {
|
||||
("do()", _) => parse = true,
|
||||
|
|
Laden …
Tabelle hinzufügen
In neuem Issue referenzieren