Factorial base numbers indexing permutations of a collection: Difference between revisions
Factorial base numbers indexing permutations of a collection (view source)
Revision as of 06:59, 17 January 2019
, 5 years ago→{{header|Julia}}
Line 358:
function factbasenums()
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, ".")], [▼
"
"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"])▼
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♣", "")
▲ printcardshuffle(c, o) = (println(o); for i in 1:length(o) print(c[o[i] + 1]) end; println())
println("\nTask shuffles:")
▲ printcardshuffle(cards, ordering)
perm = facmap(
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
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♦
▲
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
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♥
</pre>
|