lostend
|
  |
| Joined: 21 Aug 2011 |
| Total Posts: 8265 |
|
|
| 12 Aug 2015 11:32 AM |
function getCombinations(tab,length) local combos={} for i=1,#tab^length do end end
thats all i have ): |
|
|
| Report Abuse |
|
|
lostend
|
  |
| Joined: 21 Aug 2011 |
| Total Posts: 8265 |
|
| |
|
lostend
|
  |
| Joined: 21 Aug 2011 |
| Total Posts: 8265 |
|
| |
|
| |
|
CrowClaws
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 4466 |
|
|
| 12 Aug 2015 12:06 PM |
Do you wan the COMBINATIONS or the PERMUTATIONS of said table
Those are usually mixed up |
|
|
| Report Abuse |
|
|
lostend
|
  |
| Joined: 21 Aug 2011 |
| Total Posts: 8265 |
|
|
| 12 Aug 2015 12:07 PM |
i thought it would be obvious just by looking at the function, but here: tab is a table of characters length is the length the possibilities can be
getAllPossibilities({'a','b','c','d},3)
Should return all possible combos that are 3 characters long |
|
|
| Report Abuse |
|
|
|
| 12 Aug 2015 12:08 PM |
4 nPr 3 or 4 nCr 3
Probably the second one based on your post. |
|
|
| Report Abuse |
|
|
lostend
|
  |
| Joined: 21 Aug 2011 |
| Total Posts: 8265 |
|
| |
|
lostend
|
  |
| Joined: 21 Aug 2011 |
| Total Posts: 8265 |
|
| |
|
CrowClaws
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 4466 |
|
|
| 12 Aug 2015 01:19 PM |
nPr and nCr are functions on scientific calculators
just remake it into a function search it uppp |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 12 Aug 2015 01:24 PM |
| I thought he wanted a table of strings that are possible combinations. The function on the calculator returns a number that shows how much combinations there are |
|
|
| Report Abuse |
|
|
lostend
|
  |
| Joined: 21 Aug 2011 |
| Total Posts: 8265 |
|
|
| 12 Aug 2015 01:29 PM |
ok, I have a table with possible characters, and the length is the length each combo has to be if len is 3, each combo is 3 characters long. it gets those characters from the table |
|
|
| Report Abuse |
|
|
lostend
|
  |
| Joined: 21 Aug 2011 |
| Total Posts: 8265 |
|
|
| 12 Aug 2015 01:40 PM |
function getCombos(tab,len) local chars={} local combos={} for i=1,len do for d,v in next,tab do chars[#chars+1]=tab[d] end end local e=#chars for i=1,e do local ran={} for o=1,len do local r=math.random(1,#chars) ran[#ran+1]=r chars[r]=nil end end return chars end print(table.concat(getCombos({'a','b'},3),' '))
This is what I have now, but it errors. However, if I remove line 15, it works?
|
|
|
| Report Abuse |
|
|