]> projects.mako.cc - wordplay-cdsw-solutions/commitdiff
added new python programs with solutions for the ideas listed on the wordplay page
authorBenjamin Mako Hill <mako@atdot.cc>
Wed, 22 Apr 2015 03:12:27 +0000 (20:12 -0700)
committerBenjamin Mako Hill <mako@atdot.cc>
Wed, 22 Apr 2015 03:12:27 +0000 (20:12 -0700)
README.md
idea_1.py [new file with mode: 0644]
idea_2.py [new file with mode: 0644]
idea_3.py [new file with mode: 0644]
idea_4.py [new file with mode: 0644]
idea_5.py [new file with mode: 0644]

index ddf98030d21821c7fa5fafcaaa192294d1d1265c..26374898b35b1671afdcf4cbff52ec2827353394 100644 (file)
--- a/README.md
+++ b/README.md
@@ -42,3 +42,16 @@ b: bezzazzes, 47
 e: embezzlements, 37
 d: decitizenizing, 36
 .....</pre>
+
+
+### 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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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)
+

Benjamin Mako Hill || Want to submit a patch?