I thought since my memory is so bad, that I would make a brain-exercise game for myself. The game is supposed to work in a way that you get some boxes with different numbers, and you have to remember which box has which number, so you can find matching pairs.
Some things to keep in mind: The number placement is random each match, so you always have to use your memory to find matching pairs. The numbers will never be higher than half the number of boxes, so that if there's 10 boxes, you will need to find the pairs with the numbers 1,2,3,4 and 5.
The problem: How do I do this? Assigning numbers to the boxes is no problem. It's basically just spreading values. The problem is to give half the boxes the same number as the other half, without there being more than 2 of one number. Example: I don't want 3 boxes to have the number 1, as the number 1 should only be found on 2 boxes (hence a pair).
I have tried different solutions, like using a value that starts on 1, picks one random box and gives it that number, then adds 1 more to the value, assigns that number to a random box, etc. For some reason, this doesn't work.
Any help please? Hope people can understand what I just tried to explain.