This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
fast_perm_check [2023/03/21 19:07] harshec |
fast_perm_check [2023/04/19 14:30] (current) harshec |
||
---|---|---|---|
Line 1: | Line 1: | ||
====Fast-Perm-Check==== | ====Fast-Perm-Check==== | ||
- | This algorithm was created by Landon Kryger to solve the problem of testing if a set of dice is permutation fair. If you have //n// players and //s// sides, the standard approach would require you to test every roll and would run in O(// | + | This algorithm was created by Landon Kryger to solve the problem of testing if a set of dice is permutation fair. If you have //n// players and //s// sides, the standard approach would require you to test every roll and would run in O(// |
This algorithm also works with dice with different number of sides. | This algorithm also works with dice with different number of sides. | ||
- | Python Code | + | ===Python Code=== |
< | < | ||
1 s = " | 1 s = " | ||
Line 21: | Line 21: | ||
* We don't need to look at strings like ' | * We don't need to look at strings like ' | ||
* k2 is the new string concatenated with the current die/number we're processing. | * k2 is the new string concatenated with the current die/number we're processing. | ||
- | * The simplest way to explain this is with an example. Let's say the current letter is a c. The number of ways to make ' | + | * The simplest way to explain this is with an example. Let's say the current letter is a c. The number of ways to make ' |
- | count[' | + | [[http:// |