randomseed in LUA

lua, random

Solution

Call `math.randomseed` once at the start of the program. No point calling it in a loop.

Problem

I am working on a code that randomizes numbers. I put `math.randomseed(os.time())` inside a loop. The code goes like this: ``` for i = 1, 1000 do math.randomseed( os.time() ) j = math.random(i, row-one) u[i], u[j] = u[j], u[i] for k = 1, 11 do file:write(input2[u[i]][k], " ") end file:write"\n" end ``` And when I run it several times, the whole output is always the same. Isn't the randomseed supposed to prevent repeats when re-run?

Original source

Related problems