Skip to content

Instantly share code, notes, and snippets.

@mjhb
Last active August 29, 2015 14:13
Show Gist options
  • Save mjhb/a8e9dc6bf30c573c7060 to your computer and use it in GitHub Desktop.
Save mjhb/a8e9dc6bf30c573c7060 to your computer and use it in GitHub Desktop.
All consecutive non-overlapping tuples within a range
from itertools import combinations
[p for p in combinations([(i, i+1) for i in range(1,5)],2) if p[0][0] not in p[1] and p[0][1] not in p[1]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment