fixed explanatory comments

This commit is contained in:
Acvaxoort 2023-12-13 22:36:13 +01:00
parent 672e465976
commit e3d4b31f88

View File

@ -5,12 +5,10 @@ use std::iter;
const PRINT_VALUES: bool = false; const PRINT_VALUES: bool = false;
const PRINT_VISUALISATION: bool = false; const PRINT_VISUALISATION: bool = false;
// Counts all options by advancing through the spring layout from left to right, splitting at // Creates a cache for count_options_with_cache and calls it
// possible uncertainities. Groups sequences of uncertain values and uses combinatorics.
fn count_options_dp(layout: &[u8], broken_sequences: &[u32], sum_broken: u32) -> u64 { fn count_options_dp(layout: &[u8], broken_sequences: &[u32], sum_broken: u32) -> u64 {
// Indexed with [a][b], storing results for computation, last a elements of layout // Indexed with [a][b], storing results for computation, last a elements of layout
// and last b elements of broken_sequences // and last b elements of broken_sequences, u64::MAX are values that aren't computed yet
// u64::MAX marks values that will never be used and don't need to be computed
let mut cache: Vec<Vec<u64>> = vec![vec![u64::MAX; broken_sequences.len() + 1]; layout.len() + 1]; let mut cache: Vec<Vec<u64>> = vec![vec![u64::MAX; broken_sequences.len() + 1]; layout.len() + 1];
// For empty layout and empty broken sequences there's one option // For empty layout and empty broken sequences there's one option
cache[0][0] = 1; cache[0][0] = 1;