"""
    Pick a word from /usr/share/dict/words
"""

import subprocess
import random


def choose(difficulty):
    (min, max) = difficulty
    cmd = """/usr/bin/grep -E '^.{{{},{}}}$' """ \
          """/usr/share/dict/words""".format(min, max)
    obj = subprocess.run(cmd,
                         shell=True,
                         stdout=subprocess.PIPE)
    result = obj.stdout.decode('utf-8').strip().split("\n")
    return random.choice(result)


if __name__ == "__main__":
    choose((3, 8))

"""
    Pick a word from /usr/share/dict/words
"""

import subprocess
import random


def choose(difficulty):
    (min, max) = difficulty['word length']
    file = 'data/easy.words'
    if difficulty['commonality'] < 0.5:
        file = 'data/hard.words'
    cmd = """/usr/bin/grep -E '^.{{{},{}}}$' {}""".format(min, max, file)
    obj = subprocess.run(cmd,
                         shell=True,
                         stdout=subprocess.PIPE)
    result = obj.stdout.decode('utf-8').strip().split("\n")
    return random.choice(result)


if __name__ == "__main__":
    choose((3, 8))

update words.py to take advantage of new 'hard' and 'easy' lists