randomize 2 of 3 sections

please help
I need to randomize 3 sections in which I could choose one, two or all three sections depending on a precondition so that one option of them can be disabled

As I understand that gives us the following 7 possibilities:

  • A
  • B
  • C
  • AB
  • AC
  • BC
  • ABC

Then the following could be the condition to enable, e.g. the B section:

(new[]{"A","B","C","AB","AC","BC","ABC"})[(int)r*7].Contains("B")

where r is a random number obtained from the random generator Quest.IRnd().

Or, alternatively, use a lookup table with 0’s and 1’s to determine which sections should be enabled in each combination.

Hope this helps,
Sergiy

PS: This is possibly related to: Generate a pair of random numbers
If so, please comment

1 Like