View Single Post
Old Jun 7th, 2006, 5:56 PM   #6
chepfaust
Programmer
 
chepfaust's Avatar
 
Join Date: Feb 2005
Posts: 62
Rep Power: 4 chepfaust is on a distinguished road
solution?

well, here's what i ended up doing.

i ended up having to limit the total number of generated numbers to 899, but i came up with (what i think is) a rather efficient way of generating 899 pseudo-random non-recurring numbers.

first i generate a list of three-digit sequential numbers. (i started with 100 because i didn't feel like messing with the number formatting to create values like 001. the fact that i started with 100 is also the reason i can only generate 899 numbers, instead of 999.)

100.txt
101.txt
...
349.txt
...
666.txt

then i add a certain number of random digits to the front of the sequential numbers. since everything in the sequential number list is already a unique value, it doesn't matter if i make duplicate numbers with my random number routine.

my output ends up looking like

456100.txt
642101.txt
...
265349.txt
...
478666.txt

and i can have values like

884201.txt
884202.txt

without breaking anything.

if coded correctly, both of these operations can be performed within the same loop, thus eliminating the need to waste time comparing every single value to every single other value in the array.

i'm sure this can be implemented on a larger scale like i envisioned, but it is beyond my capabilities to pull that off.
chepfaust is offline   Reply With Quote