10000 Merge pull request #8 from pickfire/patch-2 · stephen-codepython/100DaysOfCode@0d5f240 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0d5f240

Browse files
authored
Merge pull request pybites#8 from pickfire/patch-2
Remove need to convert list to set
2 parents 6397402 + 98c4189 commit 0d5f240

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

039/word_checker.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,8 @@ def load_dictionary():
1212
return words
1313

1414
def check_word(dictionary, word):
15-
valid_words = []
16-
permutations = []
17-
perms = list(itertools.permutations(word))
18-
for i in perms:
19-
permutations.append(''.join(i))
20-
21-
for i in permutations:
22-
if i in dictionary:
23-
valid_words.append(i)
24-
return set(valid_words)
15+
permutations = set(map(''.join, itertools.permutations(word)))
16+
return {w for w in permutations if w in dictionary}
2517

2618
def print_words(words):
2719
for i in words:

0 commit comments

Comments
 (0)
0