Dynamically exclude some numbers from randomly generated sequence

Delta_G:
Keep the ones you want to exclude in an array and when you generate each random number roll through the array to check if it is there. If it is then get a different random number.

good idea!

example:

void setup() 
{
  Serial.begin(115200);
  randomSeed(analogRead(A0));
}
void loop()
{
  // create an arbitray sized array to be filled with unique values to exclude from desired array
  const int arraySize = 5;
  int exclusions[arraySize];  
  for (int i = 0; i < arraySize; i++)  // fill the array with unique values...
  {
    int val;
    do
    {
      val = random(100,200);
    } while([&exclusions, &val](){
        for (auto j : exclusions)
        {
          if (val == j)
          {
            return true;
          }
        }
        return false;
      }());
    exclusions[i] = val;
  }
  Serial.print(F("Exclusion Array: "));
  for (int i = 0; i < arraySize; i++)
  {
    Serial.print(exclusions[i]);
    if (i < arraySize - 1)
    Serial.print(F(", "));
  }
  Serial.println();

  // create a new array of arbitrary length of unique random numbers in >>>the same<<< range as above (but not necessary)

  const int listSize = 30;
  int list[listSize];
  for (int i = 0; i < listSize; i++)  // fill the array with unique values that will exclude exclusions[]
  {
    int val;
    do
    {
      val = random(100,200);
    } while([&exclusions, &list, &val](){
        for (auto j : list)
        {
          if (val == j)
          {
            return true;
          }
          for (auto k : exclusions)
          {
            if (val == k)
            {
              return true;
            }
          }
        }
        return false;
      }());
    list[i] = val;
  }

  // OPTIONAL -> lets sort the final arry to make spotting the duplicates easier:
  for (int i = 0; i < listSize; i++)
  {
    for (int j = i + 1; j < listSize; j++)
    {
      if (list[j] < list[i])
      {
        int temp = list[i];
        list[i] = list[j];
        list[j] = temp;
      }
    }
  }

  // output the final array
  Serial.print(F("Final Array: "));
  for (int i = 0; i < listSize; i++)
  {
    Serial.print(list[i]);
    if (i < listSize - 1)
    Serial.print(F(", "));
  }
  Serial.println();
  
  
  delay(5000);
}