random() : test if a number does not appear twice
Posted: Tue Jan 05, 2016 1:16 am
Hello, (Happy new year)
I have a program that randomly selected numbers , then checks whether the number is not already out before, if it is already out , it chose a new number if not we put it in a list. The program ends when all the numbers are out.
My program work correctly with 10 numbers but when i test with 32 numbers, liveCode crash.
I have a program that randomly selected numbers , then checks whether the number is not already out before, if it is already out , it chose a new number if not we put it in a list. The program ends when all the numbers are out.
My program work correctly with 10 numbers but when i test with 32 numbers, liveCode crash.
Code: Select all
global liste, number
put 10 into number
--put 32 into number
command test2
if num of items of liste = number then
answer "End"
else
put random(number) into motRdm
--put motRdm & "||||||||||||||" & liste
if liste contains motRdm then
test2
else
if liste is empty then
put motRdm into liste
else
put liste & "," & motRdm into liste
end if
end if
end if
end test2