I'm building a game where users select from a list of symbols and later identify what those selections were.
Example:
Symbols: [A, B, C, D, E, F, G]
User selects [B, F, G] and this representative array [0, 1, 0, 0, 0, 1, 1] gets saved in the database
When a user correctly replicates a selection, I'd like to be able to award bonus points if the selection is unique.
By unique I mean if the selection is sufficiently different from all previous selections. What I've considered so far is to compare a user's selection array to all previous ones and check if the "variance" is at least some X value
Example previous selections:
- [1, 1, 0, 0, 0, 0, 0]
- [0, 1, 0, 0, 0, 0, 0]
User's selection: [0, 1, 0, 0, 0, 1, 1]
compare user's selection array to each previous and find how many indices differ
1)
[0, 1, 0, 0, 0, 1, 1]
[1, 1, 0, 0, 0, 0, 0] ---- variance = 3
2)
[0, 1, 0, 0, 0, 1, 1]
[0, 1, 0, 0, 0, 0, 0] ---- variance = 2
For a min variance (X) of 3, this user doesn't get any bonus points But for 2, he does
Is there a better way to think around and implement this?
EDITS
To clarify. I'm going to set the Minimum variance to 3. So after computing the variance between a user's rule and all other existing rules, if the minimum variance found is greater than 3, the user gets awarded the bonus points, otherwise not.