I am writing a python script, that looks like this so far:
import sys
fname = sys.argv[1]
letters = str.lower(sys.argv[2])
letaray = list(letters)
charcount = int(letters.count("")) - 1
lines = tuple(open(fname, 'r'))
wordlist = map(str.lower,open(fname).read().splitlines())
scores = {"a": 1, "c": 3, "b": 3, "e": 1, "d": 2, "g": 2, "f": 4, "i": 1, "h": 4, "k": 5, "j": 8, "m": 3, "l": 1, "o": 1, "n": 1, "q": 10, "p": 3, "s": 1, "r": 1, "u": 1, "t": 1, "w": 4, "v": 4, "y": 4, "x": 8, "z": 10}
# char count
if charcount != 7:
print "Not 7 characters"
exit()
def file_len(fname):
with open(fname) as f:
for i, l in enumerate(f):
pass
return i + 1
file_len(fname)
The program is ran by:
python main.py wordlist.txt XXXXXXX
Where X
is whatever the letters for the scrabble board for example: AGJBTGE
.
These letters are then parsed into an array like so:
['a', 'g', 'j', 'b', 't', 'g', 'e']
The textfile is then thrown line-by-line into the variable wordlist
.
How can I create another list with all the possible combos of words that can be made from the letters?
for example: age, jab
etc.
Note: is there is only 1 G
, then only 1 G
can be used, if there are 2 G
's, only 2 can be used, and so on. I may have not provided everything needed, please let me know.