I'm coding up a fairly simple trivia game. Right now, I have about 350 different pairs of questions and answers.

Each question is chosen at random from the 350 before it is displayed.

While it's not that likely that the exact same question will be randomly chosen twice in a row, it seems to me that there's a fairly good chance that it might come up again soon after it was asked. Should I bother implementing some mechanism to try to prevent recently-asked questions from being asked again, or should I just let it happen?

  • 2
    Why do they have to be repeated at all? As soon as you see a question a second time then it's no longer a 'trivia' question it's a memory one.
    – JonW
    Apr 15 '15 at 14:46
  • @JonW They wouldn't intentionally be repeated, but they're chosen at random and there are only so many of them. Apr 15 '15 at 14:47
  • 3
    If it's truly random then the possibility exists that the same question can be shown to the user 3 times in a row. So the 'too quickly' question can be reworded as 'is it OK to show the same question multiple times in a row'. And in that case I'd say no, that's not really ideal. It makes your app look like it only has a few questions, even if it has thousands.
    – JonW
    Apr 15 '15 at 14:49
  • I think the answer to this is simply "yes".
    – DA01
    Apr 15 '15 at 21:03

350 is not very many questions.

Why don't you just shuffle the list when the user starts the game and avoid duplicates altogether?

This takes very little processing power (even a crappy mobile phone can do the operation in milliseconds) and minimal memory (store pointers or indexes to questions and not the question itself....the order can be stored in memory client side if you want to avoid the incremental server side storage).

If you are picking questions sequentially at random, there is a VERY high probability that the user will see a question she has answered recently.

  • Over the course of a 350 card game, there is >99% chance that the user will have seen a duplicate question within the last 5 questions and a >63% chance of the same question appearing immediately after it was just asked.

Shuffling is a conventional approach to this pattern. It's used by music players to randomize play lists while avoiding duplicates.


Take one step deeper.

How should you display the questions?

One step deeper.

Why are users playing your game in the first part?

If they want to learn something, they should repeat. If they want to be entertained they should repeat only if getting a repeated question allows them to feel confident or gain an extra advantage as this will enable a variable reward loop. If they want to see something new, they should never repeat.

Once you decide the WHY, the how gets much easier.


If your users are going to be able to answer the questions quickly, example: Which of the following is an Impressionist painter? (da Vinci, Rembrandt, Monet, Picasso) and they are going to quickly go to another problem then they will get duplicate questions very quickly. If they are using this trivia game in order to help learn a school subject they would have a more positive response than if they are doing it simply as a game.

The obvious answer is to test your user base. If the answer is that they would mind having questions repeated too quickly then you have two solutions to the problem. One,implement some "mechanism" to prevent this from happening or two, quickly ramp up the number of questions.


I believe it would be worthwhile to create your own random algorithm instead of relying on computer generated randomness. Purposely omitting previous results could increase the perceived randomness of the system.

Here's a great article which details this issues with iPod shuffle. It basically says our brain looks for patterns in things -

Some argue that our brains are built to recognize order and patterns instead of chaos and randomness. It happens all the time. People like to find faces or animal shapes in the clouds or religious figures burnt on toast or marvel at the significance of a number

There is also a vsauce video which covers this subject.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.