you only need two nested loops, the outher for assigning new random values, inner for searching trough already assigned values for a match with a test random value. If no match is found, assign the value and increment index.