Shuffled options (Quiz App)
Players remember positions, so shuffle the options. SEED <n turns shuffling on: with x = n, for each question in order and for k from the last option index down to 1: x = (1103515245 × x + 12345) mod 2147483648, j = x mod (k + 1), swap options k and j. Then print every question as Q<n <text with its options A) …. Answers use the shuffled letters; the correct option is still the one marked by ANSWER in the original order. Then print the leaderboard as in stage 4.
Input: As before, with an optional SEED.
Output: The shuffled quiz, then as before.
Difficulty: Hard. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.
Hint
- Use a 64-bit integer for x: the multiplication overflows 32 bits.