Skip to content

C22 - Charday N. #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
101 changes: 97 additions & 4 deletions adagrams/game.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,104 @@
import random

LETTER_POOL = ["A","A","A","A","A","A","A","A","A","B","B","C","C","D","D","D","D","E","E","E","E","E","E","E","E","E","E","E","E","F","F","G","G","G","H","H","I","I","I","I","I","I","I","I","I","J","K","L","L","L","L","M","M","N","N","N","N","N","N","O","O","O","O","O","O","O","O","P","P","Q","R","R","R","R","R","R","S","S","S","S","T","T","T","T","T","T","U","U","U","U","V","V","W","W","X","Y","Y","Z"]

LETTER_POINTS = {
"A" : 1,
"E" : 1,
"I" : 1,
"O" : 1,
"U" : 1,
"L" : 1,
"N" : 1,
"R" : 1,
"S" : 1,
"T" : 1,
"D" : 2,
"G" : 2,
"B" : 3,
"C" : 3,
"M" : 3,
"P" : 3,
"F" : 4,
"H" : 4,
"V" : 4,
"W" : 4,
"Y" : 4,
"K" : 5,
"J" : 8,
"X" : 8,
"Q" : 10,
"Z" : 10
}

def draw_letters():
pass
letter_pool = LETTER_POOL.copy()
chosen_letters = []

while len(chosen_letters) < 10:
random_index = random.randint(0,len(letter_pool)-1)
random_letter = letter_pool.pop(random_index)
chosen_letters.append(random_letter)

return chosen_letters

def uses_available_letters(word, letter_bank):
pass
if len(word) > len(letter_bank):
return False

available_letters_dict = {}
for letter in letter_bank:
if letter in available_letters_dict.keys():
available_letters_dict[letter] += 1
continue
available_letters_dict[letter] = 1

for letter in word.upper():
if letter not in available_letters_dict.keys() or not available_letters_dict[letter] :
return False
available_letters_dict[letter] -= 1

return True

def score_word(word):
pass
score = 0
for letter in word.upper():
if letter in LETTER_POINTS:
score += LETTER_POINTS[letter]

if len(word) >= 7 and len(word) < 11:
score += 8

return score


def get_highest_word_score(word_list):
pass
highest_word = ""
highest_score = 0

for word in word_list:
word_score = score_word(word)

if word_score > highest_score:
highest_word = word
highest_score = word_score

elif word_score == highest_score:
if len(word) == len(highest_word):
continue
elif len(highest_word) == 10:
continue
elif len(word) == 10:
highest_word = word
highest_score = word_score
elif len(word) < len(highest_word):
highest_word = word
highest_score = word_score

return (highest_word, highest_score)






1 change: 1 addition & 0 deletions tests/test_wave_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def test_draw_letters_is_list_of_letter_strings():
assert type(elem) == str
assert len(elem) == 1


def test_letter_not_selected_too_many_times():

for i in range(1000):
Expand Down