From c338a9cc8416dfd3722442728819a1fe996743de Mon Sep 17 00:00:00 2001 From: Qiusi Agre Date: Tue, 16 Sep 2025 17:44:50 -0400 Subject: [PATCH 1/7] made a change hi --- adagrams/game.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/adagrams/game.py b/adagrams/game.py index 1467ce47..a8ecece5 100644 --- a/adagrams/game.py +++ b/adagrams/game.py @@ -1,8 +1,10 @@ from random import randint def draw_letters(): + hi pass + def uses_available_letters(word, letter_bank): pass From 0ac6b1a6783a74359bd797f998099e2cb59066ae Mon Sep 17 00:00:00 2001 From: Qiusi Agre Date: Wed, 17 Sep 2025 11:25:35 -0400 Subject: [PATCH 2/7] Drawing 10 letters randomly from the pool 1. Build helper_function get extend the data pool 2. Use radint and for loop to draw 10 times from the extended pool to get random index of the list of extend data pool 3. Append the list[index] to the list of random drawing letters --- adagrams/game.py | 64 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/adagrams/game.py b/adagrams/game.py index a8ecece5..63321355 100644 --- a/adagrams/game.py +++ b/adagrams/game.py @@ -1,15 +1,63 @@ from random import randint +LETTER_POOL = { + 'A': 9, + 'B': 2, + 'C': 2, + 'D': 4, + 'E': 12, + 'F': 2, + 'G': 3, + 'H': 2, + 'I': 9, + 'J': 1, + 'K': 1, + 'L': 4, + 'M': 2, + 'N': 6, + 'O': 8, + 'P': 2, + 'Q': 1, + 'R': 6, + 'S': 4, + 'T': 6, + 'U': 4, + 'V': 2, + 'W': 2, + 'X': 1, + 'Y': 2, + 'Z': 1 +} + +def get_draw_pool(): + draw_pool = [] + + for letter, num in LETTER_POOL.items(): + while num > 0: + draw_pool.append(letter) + num -= 1 + # print(num) + return draw_pool + +# print(get_draw_pool()) + + def draw_letters(): - hi - pass + get_letter = [] + draw_pool = get_draw_pool() + for i in range(0, 10): + r = randint(0, len(get_draw_pool())-1) + get_letter.append(draw_pool[r]) + return get_letter + +# print(draw_letters()) -def uses_available_letters(word, letter_bank): - pass +# def uses_available_letters(word, letter_bank): +# def helper_function(): -def score_word(word): - pass +# def score_word(word): +# pass -def get_highest_word_score(word_list): - pass \ No newline at end of file +# def get_highest_word_score(word_list): +# pass \ No newline at end of file From e362ba49bc241776a1249d11e347beacf8fb2d6e Mon Sep 17 00:00:00 2001 From: Qiusi Agre Date: Wed, 17 Sep 2025 16:46:43 -0400 Subject: [PATCH 3/7] wave1: correct the misunderstanding of return hand to pool --- adagrams/game.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/adagrams/game.py b/adagrams/game.py index 63321355..3b9495f4 100644 --- a/adagrams/game.py +++ b/adagrams/game.py @@ -45,12 +45,15 @@ def get_draw_pool(): def draw_letters(): get_letter = [] draw_pool = get_draw_pool() - for i in range(0, 10): - r = randint(0, len(get_draw_pool())-1) + + for _ in range(10): + r = randint(0, len(draw_pool)-1) get_letter.append(draw_pool[r]) + draw_pool.pop(r) + return get_letter -# print(draw_letters()) +print(draw_letters()) # def uses_available_letters(word, letter_bank): From 44cbc209ff8d3c88a567f3c11e722eaaa812cc92 Mon Sep 17 00:00:00 2001 From: Qiusi Agre Date: Wed, 17 Sep 2025 19:48:41 -0400 Subject: [PATCH 4/7] finish the wave_02 --- adagrams/game.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/adagrams/game.py b/adagrams/game.py index 3b9495f4..b4d55469 100644 --- a/adagrams/game.py +++ b/adagrams/game.py @@ -53,14 +53,25 @@ def draw_letters(): return get_letter -print(draw_letters()) -# def uses_available_letters(word, letter_bank): -# def helper_function(): +def uses_available_letters(word, letter_bank): + pool = [] + for i in letter_bank: + pool.append(i) -# def score_word(word): -# pass + for cha in word.upper(): + # cha = chara.capitalize() + if cha in pool: + pool.remove(cha) + else: + return False + + return True + + +def score_word(word): + pass -# def get_highest_word_score(word_list): -# pass \ No newline at end of file +def get_highest_word_score(word_list): + pass \ No newline at end of file From 77be04e8b0a0b6e828b263e06625a41b3a6a880b Mon Sep 17 00:00:00 2001 From: Qiusi Agre Date: Thu, 18 Sep 2025 15:47:57 -0400 Subject: [PATCH 5/7] implement score_word, finished wave_03 --- adagrams/game.py | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/adagrams/game.py b/adagrams/game.py index b4d55469..4260c93b 100644 --- a/adagrams/game.py +++ b/adagrams/game.py @@ -29,6 +29,26 @@ 'Z': 1 } +SCORE_CHART = { + 1: ["A", "E", "I", "O", "U", "L", "N", "R", "S", "T"], + 2: ["D", "G"], + 3: ["B", "C", "M", "P"], + 4: ["F", "H", "V", "W", "Y"], + 5: ["K"], + 8: ["J","X"], + 10: ["Q","Z"] +} + +# SCORE_CHART_A = { +# "AEIOULNRST": 1, +# "DG": 2, +# "BCMP": 3, +# "FHVWY": 4, +# "K": 5, +# "JX": 8, +# "QZ":10 +# } + def get_draw_pool(): draw_pool = [] @@ -56,9 +76,9 @@ def draw_letters(): def uses_available_letters(word, letter_bank): - pool = [] - for i in letter_bank: - pool.append(i) + pool = letter_bank[:] + # for i in letter_bank: + # pool.append(i) for cha in word.upper(): # cha = chara.capitalize() @@ -68,10 +88,19 @@ def uses_available_letters(word, letter_bank): return False return True - def score_word(word): - pass + the_score = 0 + for cha in word.upper(): + for score, k in SCORE_CHART.items(): + if cha in k: + the_score += score + + if 7 <= len(word) <= 10: + the_score += 8 + + return the_score + def get_highest_word_score(word_list): pass \ No newline at end of file From e1b327286c70ddbcd6e187bb56731119f37e6b39 Mon Sep 17 00:00:00 2001 From: Qiusi Agre Date: Thu, 18 Sep 2025 21:21:48 -0400 Subject: [PATCH 6/7] finished the wave_04 --- adagrams/game.py | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/adagrams/game.py b/adagrams/game.py index 4260c93b..87799c29 100644 --- a/adagrams/game.py +++ b/adagrams/game.py @@ -103,4 +103,49 @@ def score_word(word): def get_highest_word_score(word_list): - pass \ No newline at end of file + win_word = [] + for w in word_list: + win_word.append(score_word(w)) + + highest_score = win_word[0] + highest_index = 0 + + for i in range(1, len(win_word)): # shouldn't be len()-1? watch out the range() + if win_word[i] == highest_score: + if len(word_list[i]) == len(word_list[highest_index]): + continue + elif len(word_list[highest_index]) == 10: + pass + elif len(word_list[i]) == 10 or len(word_list[highest_index]) > len(word_list[i]): + highest_score = win_word[i] + highest_index = i + elif win_word[i] > highest_score: + highest_index = i + highest_score = win_word[highest_index] + + highest_word = (word_list[highest_index], highest_score) + + return highest_word + + # below could replace line 114 - 124 + # if win_word[i] > highest_score: + # highest_index = i + # highest_score = win_word[highest_index] + # elif win_word[i] < highest_score: + # highest_index = highest_index + # highest_score = win_word[highest_index] + # elif win_word[highest_index] == highest_score: + # if len(word_list[highest_index]) == 10: + # highest_score = win_word[highest_index] + # highest_index = highest_index + # elif len(word_list[i]) == 10: + # highest_score = win_word[i] + # highest_index = i + # elif len(word_list[highest_index]) < len(word_list[i]): + # highest_score = win_word[highest_index] + # highest_index = highest_index + # elif len(word_list[highest_index]) > len(word_list[i]): + # highest_score = win_word[i] + # highest_index = i + # elif win_word[i] == highest_score and len(word_list[i]) == len(word_list[highest_index]): + # continue \ No newline at end of file From 4c57eef84bdc9017ca5af7c349a0655d6a6e5c47 Mon Sep 17 00:00:00 2001 From: Qiusi Agre Date: Thu, 18 Sep 2025 21:55:29 -0400 Subject: [PATCH 7/7] implement all functions in game file --- adagrams/game.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/adagrams/game.py b/adagrams/game.py index 87799c29..8facaddb 100644 --- a/adagrams/game.py +++ b/adagrams/game.py @@ -39,16 +39,6 @@ 10: ["Q","Z"] } -# SCORE_CHART_A = { -# "AEIOULNRST": 1, -# "DG": 2, -# "BCMP": 3, -# "FHVWY": 4, -# "K": 5, -# "JX": 8, -# "QZ":10 -# } - def get_draw_pool(): draw_pool = [] @@ -148,4 +138,15 @@ def get_highest_word_score(word_list): # highest_score = win_word[i] # highest_index = i # elif win_word[i] == highest_score and len(word_list[i]) == len(word_list[highest_index]): - # continue \ No newline at end of file + # continue + +# This is another way to imolement score_word(word) +# SCORE_CHART_A = { +# "AEIOULNRST": 1, +# "DG": 2, +# "BCMP": 3, +# "FHVWY": 4, +# "K": 5, +# "JX": 8, +# "QZ":10 +# } \ No newline at end of file