Skip to content

Commit

Permalink
Merge pull request #46 from JayXon/validate
Browse files Browse the repository at this point in the history
check for duplicated input
  • Loading branch information
JayXon authored Feb 6, 2024
2 parents 133e958 + df391e0 commit 5b4f38c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,28 @@ fn find_expressions(cache: &mut Cache, hashset_cache: &mut HashSetCache, n: usiz
add_to_cache(cn, cache, hashset_cache);
}

fn main() {
fn validate_input() {
for i in INPUTS {
assert_eq!(
i.vec.len(),
GOAL.len(),
"INPUTS and GOAL must have equal length"
);
}

let mut input_set = HashSet::new();
for i in 0..INPUTS[0].vec.len() {
let mut input = [0; INPUTS.len()];
for j in 0..INPUTS.len() {
input[j] = INPUTS[j].vec[i];
}
assert!(input_set.insert(input), "duplicated input {:?}", input);
}
}

fn main() {
validate_input();

let mut cache: Cache = vec![CacheLevel::new()];
let mut hashset_cache: HashSetCache = HashSetCache::new();
let mut total_count = 0;
Expand Down

0 comments on commit 5b4f38c

Please sign in to comment.