I'm building a language teaching app that provides the user with a quiz for every topic.

I've found a neat solution for the quiz-structure.
But the problem is, that every quiz has a different size and I don't know how to adjust the Random number generator, so that it'll produce only random numbers for the current quiz-size.

I need a self-adjusting RNG, but I have no imagination of how to do this.

Here's my random number generator.

```
genrandomarray() {
    var distinctIds = [];
    var rand = new Random();
    for (int i = 0;;) {
      distinctIds.add(rand.nextInt(10) + 1);
      random_array = distinctIds.toSet().toList();
      if (random_array.length < 10) {
        continue;
      } else {
        break;
      }
    }
    print(random_array);

  }

```

For example one topic has 12 questions, one 30, and so on.