Skip to content

Commit

Permalink
solution (pybites#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
das-dev authored and pybites committed Sep 15, 2018
1 parent e9e95d0 commit e9ff9b2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions 01/das-dev/wordvalue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from data import DICTIONARY, LETTER_SCORES

def load_words():
with open(DICTIONARY, 'r') as f:
return f.read().split()

def calc_word_value(word):
return sum(LETTER_SCORES.get(letter.upper(), 0) for letter in word)

def max_word_value(dictonary=None):
return max(dictonary or load_words(), key=calc_word_value)

if __name__ == "__main__":
pass # run unittests to validate

0 comments on commit e9ff9b2

Please sign in to comment.