Factorial base numbers indexing permutations of a collection: Difference between revisions

m
Line 358:
 
function factbasenums()
fcount, factnums = makefactorialbased(3, true)
perms = map(facmap, factnums)
for (i, fn) = enumerate(factnums)
Line 367:
println("\nPermutations generated = $fcount, and 11! = $(factorial(11))\n")
 
taskrandom = ["39.49.7.47.29.30.2.12.10.3.29.37.33.17.12.31.29.34.17.25.2.4.25.4.1.14.20.6.21.18.1.1.1.4.0.5.15.12.4.3.10.10.9.1.6.5.5.3.0.0.0",
fac51digits = map(s -> [parse(Int, s) for s in split(s, ".")], [
"3951.4948.716.4722.293.300.219.1234.1029.31.2936.3730.3312.1732.12.31.29.3430.1726.2514.221.48.2512.1.3.10.4.17.14.2017.6.21.188.112.115.115.4.0.513.15.12.47.3.1012.1011.9.1.6.5.5.6.6.3.04.0.03.2.1",]
fac51digitsperms = map(s -> facmap([parse(Int, s) for s in split(s, ".")]), [taskrandom)
"51.48.16.22.3.0.19.34.29.1.36.30.12.32.12.29.30.26.14.21.8.12.1.3.10.4.7.17.6.21.8.12.15.15.13.15.7.3.12.11.9.5.5.6.6.3.4.0.3.2.1"])
perms = map(facmap, fac51digits)
 
cardshoe = split("A♠K♠Q♠J♠T♠9♠8♠7♠6♠5♠4♠3♠2♠A♥K♥Q♥J♥T♥9♥8♥7♥6♥5♥4♥3♥2♥A♦K♦Q♦J♦T♦9♦8♦7♦6♦5♦4♦3♦2♦A♣K♣Q♣J♣T♣9♣8♣7♣6♣5♣4♣3♣2♣", "")
carrcards = split([cardshoe,[2*i+1] "")* cardshoe[2*i+2] for i in 0:51]
printcardshuffle(t, c, o) = (println(ot); for i in 1:length(o) print(c[o[i] + 1]) end; println())
cards = map(x->join(x, ""),[[carr[2*i+2]] for i in 0:51])
printcardshuffle(c, o) = (println(o); for i in 1:length(o) print(c[o[i] + 1]) end; println())
println("\nTask shuffles:")
map(i -> printcardshuffle(taskrandom[i], cards, orderingperms[i]), 1:2)
for ordering in perms
printcardshuffle(cards, ordering)
end
 
myrandordermyran = [rand(collect(0:i)) for i in 51:-1:1]
perm = facmap(myrandordermyran)
println("\nMy random shuffle:")
printcardshuffle(join(string.(myran), "."), cards, perm)
end
 
Line 419 ⟶ 414:
Task shuffles:
39.49.7.47.29.30.2.12.10.3.29.37.33.17.12.31.29.34.17.25.2.4.25.4.1.14.20.6.21.18.1.1.1.4.0.5.15.12.4.3.10.10.9.1.6.5.5.3.0.0.0
[39, 50, 7, 49, 30, 32, 2, 14, 12, 4, 36, 46, 42, 22, 17, 43, 40, 51, 24, 35, 3, 8, 41, 9, 1, 26, 37, 15, 45, 34, 5, 6, 10, 18, 0, 21,
48, 38, 20, 19, 44, 47, 33, 13, 29, 28, 31, 25, 11, 16, 23, 27]
A♣3♣7♠4♣T♦8♦Q♠K♥2♠T♠4♦7♣J♣5♥T♥T♣K♣2♣3♥5♦J♠6♠Q♣5♠K♠A♦3♦Q♥8♣6♦9♠8♠4♠9♥A♠6♥5♣2♦7♥8♥9♣6♣7♦A♥J♦Q♦9♦2♥3♠J♥4♥K♦
" 51.48.16.22.3.0.19.34.29.1.36.30.12.32.12.29.30.26.14.21.8.12.1.3.10.4.7.17.6.21.8.12.15.15.13.15.7.3.12.11.9.5.5.6.6.3.4.0.3.2.1"])
[51, 48, 16, 23, 3, 0, 22, 39, 34, 2, 44, 37, 15, 42, 17, 40, 43, 35, 20, 30, 11, 19, 4, 7, 21, 9, 14, 36, 13, 49, 25, 31, 41, 45, 33,
47, 24, 8, 46, 38, 29, 18, 26, 28, 32, 10, 27, 1, 50, 12, 6, 5]
2♣5♣J♥4♥J♠A♠5♥A♣6♦Q♠9♣3♦Q♥J♣T♥K♣T♣5♦7♥T♦3♠8♥T♠7♠6♥5♠K♥4♦A♥4♣2♥9♦Q♣8♣7♦6♣3♥6♠7♣2♦J♦9♥A♦Q♦8♦4♠K♦K♠3♣2♠8♠9♠
My random shuffle:
51.24.34.29.32.37.38.5.37.24.25.14.25.23.18.10.29.1.1.27.20.0.5.17.3.5.16.21.4.21.20.17.14.1.0.12.14.12.7.2.1.0.2.7.3.5.5.3.1.0.1
[5, 0, 14, 46, 39, 16, 12, 48, 40, 22, 45, 18, 21, 42, 23, 6, 20, 7, 36, 10, 35, 37, 15, 3, 32, 9, 29, 47, 28, 27, 2, 49, 11, 4, 34, 51,
2♣3♥5♦T♦6♦Q♣T♣9♠9♣A♦Q♦Q♥9♦K♦7♥3♠J♣K♠Q♠8♣8♦A♠5♠J♦7♠2♠4♦6♣4♠4♣5♣A♣7♦T♠J♠3♦7♣2♦8♥A♥6♠8♠T♥K♣6♥2♥3♣5♥J♥K♥4♥9♥
8, 41, 13, 31, 43, 38, 1, 44, 24, 17, 25, 26, 30, 50, 19, 33]
9♠A♠K♥7♣A♣J♥2♠5♣K♣5♥8♣9♥6♥J♣4♥8♠7♥7♠4♦4♠5♦3♦Q♥J♠8♦5♠J♦6♣Q♦K♦Q♠4♣3♠T♠6♦2♣6♠Q♣A♥9♦T♣2♦K♠9♣3♥T♥2♥A♦T♦3♣8♥7♦
</pre>
 
4,102

edits