Skip to content

Instantly share code, notes, and snippets.

@kunigami
Last active June 4, 2018 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kunigami/bcdb2508a183a3f5743b1294cfd380ca to your computer and use it in GitHub Desktop.
Save kunigami/bcdb2508a183a3f5743b1294cfd380ca to your computer and use it in GitHub Desktop.
fn get_class(visited_bits: u32, guess: &[i32; N]) -> i32 {
let mut class_id = 0;
let mut multiplier: i32 = 1;
let d = (D + 1) as i32;
for pos in 0..guess.len() {
let digit = guess[pos];
if visited_bits & (1 << digit) != 0 {
class_id += multiplier * (digit + 1);
}
multiplier *= d;
}
return class_id;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment