Created
July 11, 2015 16:00
-
-
Save saxbophone/e45f8849b2f195ad65b0 to your computer and use it in GitHub Desktop.
Generates random permutations (non-repeating sets of integers guaranteed to hold all integers within a certain range).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from random import randint | |
| from oset import oset | |
| def k(l): | |
| """ | |
| Generate a random set of non-repeating integers, containing all integers from 0 to l. | |
| """ | |
| s = oset() | |
| while len(s) < l: | |
| s.add(randint(0, l-1)) | |
| return s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment