Skip to content

Instantly share code, notes, and snippets.

@AngelOnFira
Created December 4, 2023 14:57
Show Gist options
  • Select an option

  • Save AngelOnFira/86523b9f4d271aa80dd29b25cd5c536f to your computer and use it in GitHub Desktop.

Select an option

Save AngelOnFira/86523b9f4d271aa80dd29b25cd5c536f to your computer and use it in GitHub Desktop.
// Find the number of matching numbers between the two vecs. This is
// then worth 1/2/4/8/16 points.
let mut points = 0;
for num in &winning {
if got.contains(num) {
points += 1;
}
}
// Add the score to the instances_count for the next cards
let curr_cards = instances_count.entry(i).or_insert(1).to_owned();
for count in i + 1..i + 1 + points {
*instances_count.entry(count).or_insert(1) += curr_cards;
}
}
// Get the sum of all the values in the hashmap
instances_count.values().sum()
@JackMc
Copy link

JackMc commented Dec 4, 2023

Ahh that makes sense - I thought about doing that but then was too lazy and didn't think it would make too much of a diff if I used Python tuples... guess it does 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment