Added early abort if there are too many damaged springs in a row
This commit is contained in:
parent
250417760b
commit
86202a10e6
|
@ -154,8 +154,13 @@ fn count_valid(
|
|||
a + b
|
||||
}
|
||||
Spring::Damaged => {
|
||||
if damaged_chain + 1 > list[0] {
|
||||
// The chain is to long
|
||||
0
|
||||
} else {
|
||||
// Add to the damaged chain
|
||||
count_valid(&mut springs[1..], list, damaged_chain+1, cache)
|
||||
count_valid(&mut springs[1..], list, damaged_chain + 1, cache)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user