I am doing a project in Lua that includes random numbers without repetition. Here is my code
for i = 1, 86000 do
while rndom[num] ~= nil do
num = math.random(1,95000)
end
rndom[num] = num
for k=1, 11 do
file2:write(input[num][k], " ")
end
file2:write("\n")
end
This basically sets the value to rndom [num], so when the randomized number is repeated and rndom [num] ~ = nil, it will randomize the number again. My problem is that it takes too long to load, as my "i" gets higher, and there will come a time when it stops. I assume that the randomizer cannot get rndom [num], which is "nil". I mean, what are the odds? I would like to improve the working time. Who can offer a better solution to my problem?
Thank!
source
share