lostend
|
  |
| Joined: 21 Aug 2011 |
| Total Posts: 8265 |
|
|
| 13 Aug 2015 01:24 PM |
local a={ 'a';'b';'c';'d';'e';'f';'g';'h';'i';'j';'k';'l';'m';'n';'o';'p';'q';'r';'s';'t';'u';'v';'w';'x';'y';'z' }
local find=function(tab,val) local isFound=false for _,v in next,tab do if rawequal(v,val) then isFound=true break end end return isFound end local getCombinations=function(tab,len) local _chars={} local _combos={} for i=1,len do for _,v in next,tab do _chars[#_chars+1]=v end end local ran={} local random for i=1,#_chars do repeat random=math.random(1,#_chars) until not find(ran,random) ran[#ran+1]=random end for _,v in next,ran do _combos[#_combos+1]=_chars[v] end print(table.concat(_combos,' ')) end getCombinations(a,3)
So it works, but I'm not sure on how to make it where it returns a combination of the characters. halp |
|
|
| Report Abuse |
|