How To:
Select the Answer and Alternates from a list

Mobius Logo

(Tested in Mobius 09/18/2018)

Suppose you have a list of values from which you wish to randomly select the correct answer and then use the rest of the list as alternates. For example suppose I have the following code to randomly select an answer from my list:

$Which=rint(4);
$Answers=[24,29,25,23];
$Ans=switch($Which,$Answers);

Once my answer is chosen, how do I pick the other three values as my alternates?

It is quite simple. Double your list length by repeating the elements in the same order, then simply pick the next 3 items after your answer!

$Which=rint(4);
$Answers=[24,29,25,23,24,29,25,23];
$Ans=switch($Which,$Answers);
$Alt1=switch($Which+1,$Answers);
$Alt2=switch($Which+2,$Answers);
$Alt3=switch($Which+3,$Answers);
;


How-To Index

Main Index

Updated: 2021/07/16 SMS/DAG