I have a function which takes six octal (0-7) digits as an argument and returns true or false.
I would like to run a loop that tries every single permutation of the values 0-7, and counts the number of "true" returns.
something like:
function count_possibles()
local count=0
local a,b,c,d,e,f=0,0,0,0,0,0
while possiblepermutations > 0 do
if compare(a,b,c,d,e,f) == true then count = count +1 end
permute(a,b,c,d,e,f)
possiblepermutations = possiblepermutations -1
return count
end
I've tried playing around with the examples provided in http://www.lua.org/pil/9.3.html but those are all about iterating over tables, not quite what I'm doing.
I don't necessarily care about performance, this function is to test the compare function I wrote.
Is there an easy way to loop something until all possible permutations are tried?