Skip to content

Instantly share code, notes, and snippets.

@miku
Last active November 25, 2020 10:40
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 miku/c1220715060babc2374a440bd742a410 to your computer and use it in GitHub Desktop.
Save miku/c1220715060babc2374a440bd742a410 to your computer and use it in GitHub Desktop.
combinations for the command line
#!/usr/bin/env python
import fileinput
import itertools
vs = set()
for line in fileinput.input():
line = line.strip()
if not line:
continue
vs.add(line)
for a, b in itertools.combinations(sorted(vs), r=2):
print("{}\t{}".format(a, b))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment