# Math Help

tglessy
Member Posts:

**41**
What are all of the combinations I make with three single digit numbers. Each digit is between 1-8 (1 and 8 are included). Within the combination, each number is different (1,2,6) and does not repeat within the combination.

Also, if a combination is rearranged, it won't be included. Ex: if combination 1 = (1,2,6), combinations (1,6,2),(6,1,2),(2,6,1), etc wouldn't be included. Thanks for any help!

Also, if a combination is rearranged, it won't be included. Ex: if combination 1 = (1,2,6), combinations (1,6,2),(6,1,2),(2,6,1), etc wouldn't be included. Thanks for any help!

## Comments

12,82238Sounds like you're doing some random order stuff with a sequential number set. This may be of some help to you:

http://www.ezinterweb.com/2013/03/fisher-yates-in-place-shuffle-for_18.html

414112,8221,2,3

1,2,4

1,2,5

1,2,6

1,2,7

1,2,8

1,3,4

1,3,5

1,3,6

1,3,7

1,3,8

1,4,5

1,4,6

1,4,7

1,4,8

1,5,6

1,5,7

1,5,8

1,6,7

1,6,8

1,7,8

2,3,4

2,3,5

2,3,6

2,3,7

2,3,8

2,4,5

2,4,6

2,4,7

2,4,8

2,5,6

2,5,7

2,5,8

2,6,7

2,6,8

2,7,8

3,4,5

3,4,6

3,4,7

3,4,8

3,5,6

3,5,7

3,5,8

3,6,7

3,6,8

3,7,8

4,5,6

4,5,7

4,5,8

4,6,7

4,6,8

4,7,8

5,6,7

5,6,8

5,7,8

6,7,8

1,143`local TotalNumbers = 0 for a=1,8,1 do for b=a+1,8,1 do for c=b+1,8,1 do local Number = a*100 + b*10 + c print(Number) TotalNumbers = TotalNumbers + 1 end end end print("\n"..TotalNumbers.." combinations")`

The program output is:

`123 124 125 126 127 128 134 135 136 137 138 145 146 147 148 156 157 158 167 168 178 234 235 236 237 238 245 246 247 248 256 257 258 267 268 278 345 346 347 348 356 357 358 367 368 378 456 457 458 467 468 478 567 568 578 678 56 combinations`

You can paste that code into the form here to test it out: http://www.lua.org/cgi-bin/demo

Exactly like Socks! We got the same answer! :P

75412,822I used my Lua-Free engine and my digital input device (10bit).

1,143Nice!

41411,1434112,82212,822Would 4 digits look like this (guess work, be kind ) )

for a=1,8,1 do

for b=a+1,8,1 do

for c=b+1,8,1 do

for d=c+1,8,1 do

local Number = a*1000 + b*100 + c*10 + d

print(Number)

TotalNumbers = TotalNumbers + 1

end

end

end

end

4112,822730`local TotalNumbers = 0 for OneLittleCat=1,8,1 do for LikedToDance=OneLittleCat+1,8,1 do for ItBecameVeryFitCauseIt=LikedToDance+1,8,1 do for CauseItEnjoyedDancingSoMuch=ItBecameVeryFitCauseIt+1,8,1 do for AndItLivedHappyEveryAfter=CauseItEnjoyedDancingSoMuch+1,8,1 do local Number = OneLittleCat*10000 + LikedToDance*1000 + ItBecameVeryFitCauseIt*100 + CauseItEnjoyedDancingSoMuch*10 + AndItLivedHappyEveryAfter print(Number) TotalNumbers = TotalNumbers + 1 end end end end end`

...and this is why i dont code

1,143`-- SNICHOLS: tweak these three variables to control the generator local MinNumber = 1 local MaxNumber = 8 local NumDigits = 3 -- SNICHOLS: generate some code to make the numbers local GeneratedCode = "" GeneratedCode = GeneratedCode.."local MinNumber="..MinNumber.." " GeneratedCode = GeneratedCode.."local MaxNumber="..MaxNumber.." " GeneratedCode = GeneratedCode.."local NumDigits="..NumDigits.." " GeneratedCode = GeneratedCode.."local Combinations=0 " GeneratedCode = GeneratedCode.."for d1=MinNumber,MaxNumber,1 do " for Index=2,NumDigits,1 do GeneratedCode = GeneratedCode.."for d"..Index.."=d"..(Index-1).."+1,MaxNumber,1 do " end GeneratedCode = GeneratedCode.."local Number = " for Index=NumDigits,1,-1 do GeneratedCode = GeneratedCode.."d"..Index.."*"..math.pow(10,Index-1).."+" end GeneratedCode = GeneratedCode.."0 print(Number) Combinations = Combinations + 1 " for Index=1,NumDigits,1 do GeneratedCode = GeneratedCode.."end " end GeneratedCode = GeneratedCode..[[print("\n"..Combinations.." combinations") ]] print("Generated Code:\n") print(GeneratedCode) print("\nOutput:\n") loadstring(GeneratedCode)()`

Output for the original data:

`Generated Code: local MinNumber=1 local MaxNumber=8 local NumDigits=3 local Combinations=0 for d1=MinNumber,MaxNumber,1 do for d2=d1+1,MaxNumber,1 do for d3=d2+1,MaxNumber,1 do local Number = d3*100+d2*10+d1*1+0 print(Number) Combinations = Combinations + 1 end end end print("\n"..Combinations.." combinations") Output: 321 421 521 621 721 821 431 531 631 731 831 541 641 741 841 651 751 851 761 861 871 432 532 632 732 832 542 642 742 842 652 752 852 762 862 872 543 643 743 843 653 753 853 763 863 873 654 754 854 764 864 874 765 865 875 876 56 combinations`

Interestingly enough, you can't go higher than 9 digits without it breaking. Makes sense based on your rules. Fun times!

411,8038!/(3!*(8-3)!) = 8*7*6*5*4*3*2*1/(3*2*1*5*4*3*2*1) = 8*7*6/3*2 = 8*7 = 56.

246