Skip to content

Instantly share code, notes, and snippets.

@xiaom
Created February 15, 2013 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xiaom/4963059 to your computer and use it in GitHub Desktop.
Save xiaom/4963059 to your computer and use it in GitHub Desktop.
generate combinations
# generate combinations
#
# http://docs.python.org/2/library/itertools.html#itertools.combinations
#
# combinations(iterable, r) --> combinations object
# Return successive r-length combinations of elements in the iterable.
combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment