Added early abort if there are too many damaged springs in a row

This commit is contained in:
Dreaded_X 2023-12-12 14:55:31 +01:00
parent 250417760b
commit 86202a10e6
Signed by: Dreaded_X
GPG Key ID: 5A0CBFE3C3377FAA

View File

@ -154,8 +154,13 @@ fn count_valid(
a + b a + b
} }
Spring::Damaged => { Spring::Damaged => {
// Add to the damaged chain if damaged_chain + 1 > list[0] {
count_valid(&mut springs[1..], list, damaged_chain+1, cache) // The chain is to long
0
} else {
// Add to the damaged chain
count_valid(&mut springs[1..], list, damaged_chain + 1, cache)
}
} }
} }
}; };