Guest User

Untitled

a guest
Apr 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. import re
  2.  
  3. def find_words(filename, letters):
  4.     words = [line for line in open(filename)]
  5.     words = [w[:len(w)-1] for w in words if re.match(r'^([%s]+)\n' % letters, w)]
  6.     max_length = max([len(w) for w in words])
  7.     words = [w for  w in words if len(w) == max_length]
  8.     for w in words:
  9.         print w
  10.    
  11. if __name__ == "__main__":
  12.     import sys
  13.    
  14.     if len(sys.argv) < 3:
  15.         print 'Usage: scrabble.py dictionary [letter... ]'
  16.         sys.exit()
  17.    
  18.     find_words(sys.argv[1], str.join('', sys.argv[2:]))
Add Comment
Please, Sign In to add comment