Random quiz questions

708 views
Skip to first unread message

Peter Collins

unread,
Dec 23, 2013, 12:26:06 PM12/23/13
to mitappinv...@googlegroups.com

I am making a quiz that selects random questions from a list. How would I stop it selecting the same question in the list more than once in the random process please?




Hal Abelson

unread,
Dec 23, 2013, 1:23:54 PM12/23/13
to mitappinv...@googlegroups.com
I assume you are using pick random element to pick from the list.

If you don't want to generate the same sequence of random numbers each time, you need to set the seed for the random number generator (set random seed). 
Of course, you need to arrange to not set that seed to the same value each time.

Taifun

unread,
Dec 23, 2013, 1:39:24 PM12/23/13
to mitappinv...@googlegroups.com
instead of using the pick a random item block use the following logic:
1. use the random integer block to get a random list index between 1 and the length of your working list
2. use the select list item block to select that item
3. remove the item from the working list with the remove list item block


Taifun

Trying to push the limits of App Inventor! Snippets and Tutorials from Pura Vida Apps by Taifun.




Hal Abelson

unread,
Dec 23, 2013, 2:44:49 PM12/23/13
to mitappinv...@googlegroups.com
Taifun and I are answering two different questions.

He is answering the question:  How do I make sure the program will not pick a given element more that once.

I'm answering the question:  How do I arrange that the program won't pick the same sequence of things each time you call it?

Hal Abelson

unread,
Dec 23, 2013, 2:48:59 PM12/23/13
to mitappinv...@googlegroups.com
Whoops.  I was wrong.  You don't need to set the random seed if all you want is for something different each time.
Taifun's answer is what you want.
Reply all
Reply to author
Forward
0 new messages