Skip to content

Conversation

@rhyspowell
Copy link
Contributor

ATTENTION: before clicking "Create Pull Request" please submit some meta data, thanks!

Difficulty level (1-10): [8]
Estimated time spent (hours): [2.5]
Completed (yes/no): [yes]
I stretched my coding skills (if yes what did you learn?): [itertools]
Other feedback (what can we improve?): []

def get_possible_dict_words(draw):
"""Get all possible words from draw which are valid dictionary words.
Use the _get_permutations_draw helper and DICTIONARY constant"""
all_options = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant / gets overwritten in next statement

[int(letter.value) for letter in distribution]
))

assert LETTER_SCORES['A'] == 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would these asserts be better placed in a the tests?

all_options = _get_permutations_draw(draw)

dictionary_words = []
for word in all_options:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use a listcomp:

[word for word in all_options if word.lower() in DICTIONARY]

else:
raise ValueError("You need to use the letters shown")

if word.lower() not in DICTIONARY:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could possibly drop this check, because get_possible_dict_words() already filters dictionary only words, however that does mean that it always need to be called before this function = coupling, so could leave in as well

@bbelderbos bbelderbos merged commit 0ac88a7 into pybites:community Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants