forgot to add day-12 formated

This commit is contained in:
Dylan Thies
2023-12-13 22:46:56 -05:00
parent 89e7315950
commit 5c07ce4825
2 changed files with 51 additions and 39 deletions

View File

@@ -46,25 +46,24 @@ impl Row {
.all(|(a, b)| (a == b || *a == SpringStatus::Unknown))
})
.filter(|x| {
let (mut array, last, current_run) =x.iter()
.fold(
(Vec::new(), SpringStatus::Working, 0_u32),
|(mut array, _last, mut current_run), x| {
if *x == SpringStatus::Failing {
current_run += 1;
} else {
if current_run > 0 {
array.push(current_run);
}
current_run = 0;
let (mut array, last, current_run) = x.iter().fold(
(Vec::new(), SpringStatus::Working, 0_u32),
|(mut array, _last, mut current_run), x| {
if *x == SpringStatus::Failing {
current_run += 1;
} else {
if current_run > 0 {
array.push(current_run);
}
(array, *x, current_run)
},
);
current_run = 0;
}
(array, *x, current_run)
},
);
if last == SpringStatus::Failing {
array.push(current_run);
}
array
array
.iter()
.zip(self.broken_spans.iter())
.all(|(a, b)| a == b)
@@ -152,4 +151,3 @@ mod test {
assert_eq!(result, "21".to_string());
}
}