From cb80c2bafcf1823dbeaa454742b94621191b331f Mon Sep 17 00:00:00 2001 From: Nick Gammon Date: Fri, 26 Aug 2011 10:09:30 +1000 Subject: [PATCH] Fixed bug in shuffle algorithm --- lua/commas.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/commas.lua b/lua/commas.lua index b9dbeddd..a37b8978 100644 --- a/lua/commas.lua +++ b/lua/commas.lua @@ -152,7 +152,7 @@ shuffle (cards) function shuffle(t) local n = #t - while n > 2 do + while n >= 2 do -- n is now the last pertinent index local k = math.random(n) -- 1 <= k <= n -- Quick swap