-
-
Save popey456963/a654e98d0180566b897b70ee54c400e2 to your computer and use it in GitHub Desktop.
Wordle best clue calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn best_clue(words_list: &Vec<Vec<char>>) -> Clue { | |
words_list | |
.par_iter() | |
.enumerate() | |
.map(|(i, word)| { | |
let mut bucket_counts = [0; 3_usize.pow(5)]; | |
for j in 0..words_list.len() { | |
//let overlap = fast_calculate_word_overlap(&word_overlaps, word_count, i, j); | |
let overlap = calculate_word_overlap(&word, &words_list[j]); | |
bucket_counts[overlap_to_index(&overlap)] += 1; | |
} | |
let value = match &SCORE_METHOD { | |
ScoreType::MinimiseLargestBucketSize => *bucket_counts.iter().max().unwrap(), | |
ScoreType::MinimiseVariance => { | |
let average = bucket_counts.iter().sum::<usize>() / bucket_counts.len(); | |
bucket_counts | |
.iter() | |
.map(|v| (v - average).pow(2)) | |
.sum::<usize>() | |
} | |
}; | |
Clue { | |
value: value, | |
word: word.to_vec(), | |
} | |
}) | |
.min_by(|a, b| a.value.cmp(&b.value)) | |
.unwrap() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment