Skip to content

Commit

Permalink
also re-use challenge 01 methods in advanced template
Browse files Browse the repository at this point in the history
  • Loading branch information
pybites committed Jan 13, 2017
1 parent df5c95b commit 9540bba
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions 02/game-nohelp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@

NUM_LETTERS = 7


# re-use from challenge 01
def calc_word_value(word):
"""Calc a given word value based on Scrabble LETTER_SCORES mapping"""
return sum(LETTER_SCORES.get(char.upper(), 0) for char in word)


# re-use from challenge 01
def max_word_value(words):
"""Calc the max value of a collection of words"""
return max(words, key=lambda w: calc_word_value(w))


def main():
pass

Expand Down

0 comments on commit 9540bba

Please sign in to comment.