My code here isn’t functioning as I need.
What im trying to do is scan through my list of 10 letters. If any one letter exists in the list more than 2 times, I want to reset the list until all letters in list have 2 or less duplicates. Here is my wrong code:
int duplicates = 1;
do
{
//Check for duplicate letters
for (int x = 0; x < TotalPlayerLetters; x++)
{
for (int y = 1; y < TotalPlayerLetters; y++)
{
if (currentRack[x] == currentRack[y])
{
duplicates = 1;
//Generate common letters
for (int q = 0; q < TotalPlayerLetters; q++)
{
currentRack.Clear();
Block temp = (Block)Blocks[q].GetComponent(typeof(Block));
temp.transform.localScale = new Vector3(1.6f,1.6f,.15f);
int rand = Random.Range(0,COMMONLETTERS.Length);
currentRack.Insert(q,(COMMONLETTERS[rand]));
}
//Place 2 random letters in the last two blocks
int rand3 = Random.Range(0,FULLALPHABET.Length);
int rand4 = Random.Range(0,FULLALPHABET.Length);
currentRack[8] = FULLALPHABET[rand3];
currentRack[9] = FULLALPHABET[rand4];
}
else duplicates = 0;
}
}
} while (duplicates == 1);