import json


fp = open("wordlist.txt")
d = {}
for line in fp.readlines():
    l = line.strip()
    if len(l) not in d:
        d[len(l)] = []
    d[len(l)].append(l)

m = max(d.keys())
o = ["", "", ""]  # no zero, one, or two letter words
for i in range(3, m + 1):
    s = d.get(i, [])
    s.sort()
    o.append("".join(s))
fp = open("binarydict.js", "w")
fp.write("var wordlist = ")
fp.write(json.dumps(o, indent=2))
fp.write(";")
fp.close()
