#pseudo... draw 99 random numbers for the first value knock out dups # which is do-able at part of step one by # stuffing the drawn numbers as keys to a hash rinse, repeat as necessary draw 99 more; combine as values for your hash test that they satisfy your spec # except for the "make it impossible for # the rand function ...." # which ain't possible by any direct method! remove unacceptable pairs # perhaps the test for (1,23) & (23,1) #should occur in prior step rinse, repeat succeed.