Skip to content

Instantly share code, notes, and snippets.

@utgwkk
Created December 5, 2018 08:55
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 utgwkk/c4cdb8075f1747b30c5a34f47f44140f to your computer and use it in GitHub Desktop.
Save utgwkk/c4cdb8075f1747b30c5a34f47f44140f to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import itertools
import sys
users = [x.rstrip() for x in sys.stdin.readlines()]
result = "(" + " OR ".join(map(lambda x: "from:" + x, users)) + " exclude:replies) OR "
pairs = []
for (x, y) in itertools.permutations(users, 2):
pairs.append("(from:{} to:{})".format(x, y))
result += " OR ".join(pairs)
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment