projects
/
wordplay-cdsw-solutions
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
reworked these examples a bit based on feedback in class
[wordplay-cdsw-solutions]
/
solution_8.py
diff --git
a/solution_8.py
b/solution_8.py
index d183cd2fbfbfb176f104214431a197cd6f95a73e..732deeba12ceb73c1bccb693eafd5d04c4c6f28c 100644
(file)
--- a/
solution_8.py
+++ b/
solution_8.py
@@
-1,22
+1,17
@@
import scrabble
import scrabble
-
# See if you can tell the difference between this solution and the broken solution.
# See if you can tell the difference between this solution and the broken solution.
-
-
max_score = 0
max_word = ''
for word in scrabble.wordlist:
max_score = 0
max_word = ''
for word in scrabble.wordlist:
- if len(word) <= 7 and len(word) >=
5
and word[0] == 'a' and word[3] == 'e':
- score = 0
+ if len(word) <= 7 and len(word) >=
4
and word[0] == 'a' and word[3] == 'e':
+
score = 0
for char in word:
score = score + scrabble.scores[char]
if score > max_score:
for char in word:
score = score + scrabble.scores[char]
if score > max_score:
- max_word = word
- max_score = score
-
-print max_score
-print max_word
+ max_word = word
+ max_score = score
+print(str(max_score) + " : " + max_word)
Benjamin Mako Hill
||
Want to submit a patch?