From d928fcd3abb683b79b79d8821998aa19025cbed5 Mon Sep 17 00:00:00 2001 From: Benjamin Mako Hill Date: Tue, 21 Apr 2015 20:12:27 -0700 Subject: [PATCH] added new python programs with solutions for the ideas listed on the wordplay page --- README.md | 13 +++++++++++++ idea_1.py | 7 +++++++ idea_2.py | 10 ++++++++++ idea_3.py | 27 +++++++++++++++++++++++++++ idea_4.py | 13 +++++++++++++ idea_5.py | 16 ++++++++++++++++ 6 files changed, 86 insertions(+) create mode 100644 idea_1.py create mode 100644 idea_2.py create mode 100644 idea_3.py create mode 100644 idea_4.py create mode 100644 idea_5.py diff --git a/README.md b/README.md index ddf9803..2637489 100644 --- a/README.md +++ b/README.md @@ -42,3 +42,16 @@ b: bezzazzes, 47 e: embezzlements, 37 d: decitizenizing, 36 ..... + + +### Wordplay Project Ideas + +The [Wordplay wiki page](http://wiki.communitydata.cc/Wordplay) also include +several ideas for projects. These are listed as idea\_1.py, etc. in the +directory: + +1. Find and print the words that start with "ee". +2. Find and print the words that end in "mt". How about "gry"? +3. Find and print the longest word that has no vowels. +4. Find an print the words that contain 4 or more 'l's. +5. Find and print the words that have all 5 vowels in alphabetical order. diff --git a/idea_1.py b/idea_1.py new file mode 100644 index 0000000..640761c --- /dev/null +++ b/idea_1.py @@ -0,0 +1,7 @@ +# 1. Find and print the words that start with "ee". + +import scrabble + +for word in scrabble.wordlist: + if word[0:2] == "ee": + print(word) diff --git a/idea_2.py b/idea_2.py new file mode 100644 index 0000000..2bf1d7d --- /dev/null +++ b/idea_2.py @@ -0,0 +1,10 @@ +# 2. Find and print the words that end in "mt". How about "gry"? + +import scrabble + +for word in scrabble.wordlist: + if word[-2:] == "mt": + print(word) + elif word[-3:] == "gry": + print(word) + diff --git a/idea_3.py b/idea_3.py new file mode 100644 index 0000000..46c6aec --- /dev/null +++ b/idea_3.py @@ -0,0 +1,27 @@ +# 3. Find and print the longest word that has no vowels. + +import scrabble + +vowels = ['a', 'e', 'i', 'o', 'u'] +words_without_vowels = [] + +for word in scrabble.wordlist: + vowel_in_word = False + for vowel in vowels: + if vowel in word: + vowel_in_word = True + if not vowel_in_word: + words_without_vowels.append(word) + +longest_word_length = 0 +longest_words = [] +for word in words_without_vowels: + if len(word) > longest_word_length: + longest_words = [word] + longest_word_length = len(word) + elif len(word) == longest_word_length: + longest_words.append(word) + +for word in longest_words: + print(word) + diff --git a/idea_4.py b/idea_4.py new file mode 100644 index 0000000..352b66c --- /dev/null +++ b/idea_4.py @@ -0,0 +1,13 @@ +# 4. Find an print the words that contain 4 or more 'l's. + +import scrabble + +for word in scrabble.wordlist: + number_of_ls = 0 + for letter in word: + if letter == "l": + number_of_ls = number_of_ls + 1 + + if number_of_ls >= 4: + print(word) + diff --git a/idea_5.py b/idea_5.py new file mode 100644 index 0000000..e4fee38 --- /dev/null +++ b/idea_5.py @@ -0,0 +1,16 @@ +# 5. Find and print the words that have all 5 vowels in alphabetical order. + +import scrabble + +vowels = ["a", "e", "i", "o", "u"] + +for word in scrabble.wordlist: + found_vowels = [] + + for letter in word: + if letter in vowels: + found_vowels.append(letter) + + if found_vowels == vowels: + print(word) + -- 2.30.2