Is a while loop embedded in if/else if legal?

Each digit could have a different color and would need to be tested after each random generation until a suitable new color for all 2 or 3 digits is found.

Test the colour of each digit individually.

while (lastColor_2 == newColor_2)
{
   newColor_2 = random(11);
}

I will say it before anyone else does. There is a much neater way of doing this using arrays to avoid repeating code for each digit but I suggest that you get the tedious 'do each number separately' method working first.