forked from TruthfulTechnology/regex-exercises
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.py
70 lines (43 loc) · 1.53 KB
/
search.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
Search Exercises
These functions return a list of strings matching a condition.
"""
with open('dictionary.txt') as dict_file:
dictionary = dict_file.read()
def get_extension(filename):
"""Return the file extension for a full file path."""
def tetravocalic(dictionary=dictionary):
"""Return a list of all words that have four consecutive vowels."""
def hexadecimal(dictionary=dictionary):
"""Return a list of all words consisting solely of the letters A to F."""
def hexaconsonantal(dictionary=dictionary):
"""Return a list of all words with six consecutive consonants."""
def possible_words(partial_word, dictionary=dictionary):
"""
Return possible word matches from a partial word.
Underscores in partial words represent missing letters. Examples:
C_T (cat, cot, cut)
_X_ (axe)
"""
def five_repeats(letter, dictionary=dictionary):
"""Return all words with at least five occurrences of the given letter."""
def abbreviate(phrase):
"""Return an acronym for the given phrase."""
def palindrome5(dictionary=dictionary):
"""Return a list of all five letter palindromes."""
def double_double(dictionary=dictionary):
"""
Return words with a double repeated letter with one letter between.
Example double double words:
- freebee
- assessed
- voodoo
"""
def repeaters(dictionary=dictionary):
"""
Return words that consist of the same letters repeated two times.
Example double double words:
- tutu
- cancan
- murmur
"""