Help with random numbers

I actually may have this sorted, probably not the most efficient but it appears to work.