Here is the algorithm:
- For each question you should detect the total number of answers. Lets put it to variable
numAnswers
. - Being on a particular question (let variable
currQuestion
hold the current Question number) you should take the valueindex
which will be evaluated as:index = currQuestion % numAnswers
(all indices start from0
)
Below is the example of how algorithm work:
#Qestion totalAnswers index
0 5 0
1 5 1
2 3 2
3 3 30
4 3 1
5 2 1 <-- **
** - the index will remain the same here. This is what you will probably have to rework in the algorithm. This happens because of variable number of answers for each question and will not be an issue if the number of answers will be constant. However I just give you a direction and it is up to you how to improve the approach.