New random number loop

Weller:
However i need to make sure all the numbers are unique. Obviously if I request a new random number each time then theres a good chance there will be duplicates. How do I code this?

One method is for each element in the array, keep generating numbers until you find one that is not already present in the array.

I'm not going to code it for you, but you would need:

  • A for loop to process each element in the array.
  • A while loop inside it to process the current element repeatedly until a unique random number had been found
  • A for loop inside that to compare the currently proposed random number against all the preceding elements in the array