Skip to content

Instantly share code, notes, and snippets.

@saxbophone
Created July 11, 2015 16:00
Show Gist options
  • Select an option

  • Save saxbophone/e45f8849b2f195ad65b0 to your computer and use it in GitHub Desktop.

Select an option

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).
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