Skip to content

Instantly share code, notes, and snippets.

@yixizhang
Last active October 12, 2015 04:47
Show Gist options
  • Save yixizhang/3972611 to your computer and use it in GitHub Desktop.
Save yixizhang/3972611 to your computer and use it in GitHub Desktop.
engineering challenge @ twice
#!/usr/bin/env python -*- coding: utf-8 -*-
import sys
import itertools
f = open('dictionary.txt')
dictionary = [w.strip() for w in f.readlines()]
f.close()
def jumble(word):
return [w for w in itertools.permutations(word) if w in dictionary]
def main():
for word in jumble(sys.argv[1]):
print word
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment