Output: 66%
local boxes = { {1,1}, {1,0}, {0,0} }
local wins = 0
local tests = 0
while tests < 1000000 do
for _, box in pairs(boxes) do
box = {unpack(box)}
local ball = table.remove(box, math.random(2))
if ball == 1 then --ball is gold
tests = tests + 1
wins = wins + box[1]
end
end
end
print(("%d%%"):format(wins/tests * 100))