From 18ebbace2de90631a01cf558af9789b427227a36 Mon Sep 17 00:00:00 2001 From: Ying G Date: Mon, 28 Mar 2022 11:59:50 -0700 Subject: [PATCH 01/10] Add PLAN.md --- PLAN.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 PLAN.md diff --git a/PLAN.md b/PLAN.md new file mode 100644 index 00000000..ba55148e --- /dev/null +++ b/PLAN.md @@ -0,0 +1,30 @@ +## Access needs +- Ying: I'm still working on time management skills so would require planning in advance for meeting up to work on the project outside of core hours. +- Liqing: I'm pretty flexible with the time arrangement with the partner. Fully understanding of the project problem is requried for me before we start coworking though. Set up 1 - 2 hours for each coworking session also helps that we don't over spend time on one task/wave. + + +## Learning style +- Ying: I learn best when doing it myself while having full independence over my own learning process. In general, I learn better when reading, researching and doing than watching videos or attending classes. +- Liqing: I like reading documentation, googling, taking note to enhance my understanding. We can share resources together too after each session. + + +## How you prefer to receive feedback +- Ying: I prefer to receive written feedback in a direct and concise manner (numbered lists or bullet points preferred) with a specific agreed upon deadline to fix any issues, and be given the time inbetween to work on it on my own. Agree with Liqing re feedback at the end of the project (maybe a retrospective together on Friday or this weekend?) +- Liqing: after each pair programming, I would like to receive any verbal feedback on the collaboration of that particular day and at the end of the project as an overall feedback to improve mine and both. + + +## One team communication skill you want to improve on with this experience +- Ying: I need to work on patience when communicating which can at times come off as dismissive to others. +- Liqing: I want to improve on my communication skills while pair programming in a professional way, make the whole pair programming benefitial for both. + + +## Plan +- 1st session: 03/28 Mon 3-4pm + - Goal: complete wave 1 (30 minutes/30 minutes) +- 2nd session: 03/29 Tue 2-3pm + - Goal: complete wave 2 +- 3rd session: 03/30 Wed 3-4pm + - Goal: complete wave 3 +- 4th session: 03/31 Thu 1-230pm + - Goal: complete wave 4 and manually test + - If we finish earlier this day, we can have a feedback session \ No newline at end of file From 157021324fc1214f887d144e6b701903ec28740b Mon Sep 17 00:00:00 2001 From: Ying G Date: Mon, 28 Mar 2022 16:23:35 -0700 Subject: [PATCH 02/10] pass all wave 1 tests --- adagrams/game.py | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/adagrams/game.py b/adagrams/game.py index 5fb37b11..9c6474de 100644 --- a/adagrams/game.py +++ b/adagrams/game.py @@ -1,5 +1,45 @@ +import random + +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 draw_letters(): - pass + # copy a dictionary so that we don't change the data, it's constant + LETTER_POOL_COPY = LETTER_POOL.copy() + letters_drawn = [] + while len(letters_drawn) < 10: + letter_drawn = random.choice(list(LETTER_POOL_COPY)) + if LETTER_POOL_COPY[letter_drawn] >= 1: + letters_drawn.append(letter_drawn) + LETTER_POOL_COPY[letter_drawn] -= 1 + return letters_drawn def uses_available_letters(word, letter_bank): pass From 0a37e1fcbf8066fb0d19a601f243e5a0b03e466c Mon Sep 17 00:00:00 2001 From: Liqingcathy Date: Tue, 29 Mar 2022 15:40:03 -0700 Subject: [PATCH 03/10] pass wave2,3 tests --- adagrams/game.py | 110 ++++++++++++++++++++++++++++++++++++++++-- tests/test_wave_03.py | 2 +- 2 files changed, 108 insertions(+), 4 deletions(-) diff --git a/adagrams/game.py b/adagrams/game.py index 9c6474de..dee91244 100644 --- a/adagrams/game.py +++ b/adagrams/game.py @@ -1,3 +1,4 @@ +from collections import Counter import random LETTER_POOL = { @@ -29,6 +30,46 @@ 'Z': 1 } +POINT_SYSTEM = { + 'A':1, + 'B':3, + 'C':3, + 'D':2, + 'E':1, + 'F':4, + 'G':2, + 'H':4, + 'I':1, + 'J':8, + 'K':5, + 'L':1, + 'M':3, + 'N':1, + 'O':1, + 'P':3, + 'Q':10, + 'R':1, + 'S':1, + 'T':1, + 'U':1, + 'V':4, + 'W':4, + 'X':8, + 'Y':4, + 'Z':10 +} + + + +# |Letter | Value| +# |:----------------------------:|:----:| +# |A, E, I, O, U, L, N, R, S, T | 1 | +# |D, G | 2 | +# |B, C, M, P | 3 | +# |F, H, V, W, Y | 4 | +# |K | 5 | +# |J, X | 8 | +# |Q, Z | 10 | def draw_letters(): # copy a dictionary so that we don't change the data, it's constant @@ -41,11 +82,74 @@ def draw_letters(): LETTER_POOL_COPY[letter_drawn] -= 1 return letters_drawn + def uses_available_letters(word, letter_bank): - pass + upper_word = word.upper() + copy_letter_bank = letter_bank.copy() + for char in upper_word: + if char not in copy_letter_bank: + return False + else: + copy_letter_bank.remove(char) + return True + + + + + def score_word(word): - pass + points = 0 + for char in word: + points += POINT_SYSTEM[char.upper()] + if len(word) >= 7 and len(word) <= 10: + points += 8 + return points + def get_highest_word_score(word_list): - pass \ No newline at end of file + pass +# max_word = None +# max_score = 0 +# for word in word_list: +# word_score = score_word(word) +# # print(max_word,max_score) +# print(f"word_score:{word_score}") +# print(f"word:{word}") +# if word_score > max_score: +# max_word = word +# max_score = word_score +# elif word_score == max_score: +# print(max_word) # "MMMM" +# print(word) # "WWW" +# if type(max_word) != list: +# max_word = list(max_word) +# print(max_word) +# max_word.append(word) +# else: +# max_word.append(word) +# print(max_word) # ["MMMM","WWW"] +# if type(max_word) == str: +# return (max_word, max_score) +# # print(max_word) + +# max_length = [] # list of each max word's lengths -> max word = all the words with max score +# for word in max_word: +# max_length.append(len(word)) +# max_len_index = None +# max_len = 0 + + +# max_len_index = max_length.index(min(max_length)) +# for i in range(len(max_word)): +# if len(max_word[i]) == 10: +# return (max_word[i], max_score) +# return (max_word[max_len_index],max_score) + +# # - Returns a tuple that represents the data of a winning word and it's score. The tuple must contain the following elements: +# # - index 0 ([0]): a string of a word +# # - index 1 ([1]): the score of that word +# # - In the case of tie in scores, use these tie-breaking rules: +# # - prefer the word with the fewest letters... +# # - ...unless one word has 10 letters. If the top score is tied between multiple words and one is 10 letters long, choose the one with 10 letters over the one with fewer tiles +# # - If the there are multiple words that are the same score and the same length, pick the first one in the supplied list \ No newline at end of file diff --git a/tests/test_wave_03.py b/tests/test_wave_03.py index 5473db39..9ff1a1e1 100644 --- a/tests/test_wave_03.py +++ b/tests/test_wave_03.py @@ -18,7 +18,7 @@ def test_score_zero_for_empty(): # Assert assert score_word("") == 0 -def test_score_extra_points_for_seven_or_longer(): +def test_score_extra_points_for_seven_or_longer(): # bonus points: 7 # Assert assert score_word("XXXXXXX") == 64 assert score_word("XXXXXXXX") == 72 From 08f0e3ec45b4e28a47f19d4079ec379f7f25f46d Mon Sep 17 00:00:00 2001 From: Ying G Date: Tue, 29 Mar 2022 15:49:50 -0700 Subject: [PATCH 04/10] pass wave 4 tests --- adagrams/game.py | 85 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 3 deletions(-) diff --git a/adagrams/game.py b/adagrams/game.py index 9c6474de..1c1277fa 100644 --- a/adagrams/game.py +++ b/adagrams/game.py @@ -1,3 +1,4 @@ +from collections import Counter import random LETTER_POOL = { @@ -29,6 +30,46 @@ 'Z': 1 } +POINT_SYSTEM = { + 'A':1, + 'B':3, + 'C':3, + 'D':2, + 'E':1, + 'F':4, + 'G':2, + 'H':4, + 'I':1, + 'J':8, + 'K':5, + 'L':1, + 'M':3, + 'N':1, + 'O':1, + 'P':3, + 'Q':10, + 'R':1, + 'S':1, + 'T':1, + 'U':1, + 'V':4, + 'W':4, + 'X':8, + 'Y':4, + 'Z':10 +} + + + +# |Letter | Value| +# |:----------------------------:|:----:| +# |A, E, I, O, U, L, N, R, S, T | 1 | +# |D, G | 2 | +# |B, C, M, P | 3 | +# |F, H, V, W, Y | 4 | +# |K | 5 | +# |J, X | 8 | +# |Q, Z | 10 | def draw_letters(): # copy a dictionary so that we don't change the data, it's constant @@ -41,11 +82,49 @@ def draw_letters(): LETTER_POOL_COPY[letter_drawn] -= 1 return letters_drawn + def uses_available_letters(word, letter_bank): - pass + upper_word = word.upper() + copy_letter_bank = letter_bank.copy() + for char in upper_word: + if char not in copy_letter_bank: + return False + else: + copy_letter_bank.remove(char) + return True + def score_word(word): - pass + points = 0 + for char in word: + points += POINT_SYSTEM[char.upper()] + if len(word) >= 7 and len(word) <= 10: + points += 8 + return points + def get_highest_word_score(word_list): - pass \ No newline at end of file + max_word = None + max_score = 0 + for word in word_list: + word_score = score_word(word) + if word_score > max_score: + max_word = word + max_score = word_score + elif word_score == max_score: + if type(max_word) != list: + max_word = list(max_word) + max_word.append(word) + else: + max_word.append(word) + if type(max_word) == str: + return (max_word, max_score) + + min_len = 100 + min_word = None + for word in word_list: + if len(word) == 10: + return (word,score_word(word)) + elif len(word) < min_len: + min_word, min_len = word, len(word) + return (min_word,score_word(min_word)) \ No newline at end of file From 926ebee69af7159817d0fe1c0c1e7b0e21c0414d Mon Sep 17 00:00:00 2001 From: Ying G Date: Tue, 29 Mar 2022 15:54:50 -0700 Subject: [PATCH 05/10] refactor get_highest_word_score --- adagrams/game.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/adagrams/game.py b/adagrams/game.py index 53458c30..89191234 100644 --- a/adagrams/game.py +++ b/adagrams/game.py @@ -109,19 +109,14 @@ def get_highest_word_score(word_list): for word in word_list: word_score = score_word(word) if word_score > max_score: - max_word = word - max_score = word_score + max_word, max_score = word, word_score elif word_score == max_score: if type(max_word) != list: max_word = list(max_word) - max_word.append(word) - else: - max_word.append(word) + max_word.append(word) if type(max_word) == str: return (max_word, max_score) - - min_len = 100 - min_word = None + min_len, min_word = 100, None for word in word_list: if len(word) == 10: return (word,score_word(word)) From 93fbd66ddc90c7e1b553ae05b25a9dfc2934b244 Mon Sep 17 00:00:00 2001 From: Ying G Date: Wed, 30 Mar 2022 20:18:12 -0700 Subject: [PATCH 06/10] refactor get_highest_word_score again --- adagrams/game.py | 49 +++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/adagrams/game.py b/adagrams/game.py index 89191234..63fa8359 100644 --- a/adagrams/game.py +++ b/adagrams/game.py @@ -104,22 +104,37 @@ def score_word(word): def get_highest_word_score(word_list): - max_word = None max_score = 0 + max_word = () for word in word_list: - word_score = score_word(word) - if word_score > max_score: - max_word, max_score = word, word_score - elif word_score == max_score: - if type(max_word) != list: - max_word = list(max_word) - max_word.append(word) - if type(max_word) == str: - return (max_word, max_score) - min_len, min_word = 100, None - for word in word_list: - if len(word) == 10: - return (word,score_word(word)) - elif len(word) < min_len: - min_word, min_len = word, len(word) - return (min_word,score_word(min_word)) + if score_word(word) == max_score: + if len(max_word) == 10: + continue + elif len(word) == 10: + max_word = word + elif len(word) < len(max_word): + max_word = word + elif score_word(word) > max_score: + max_score = score_word(word) + max_word = word + return (max_word, max_score) + + # max_word = None + # max_score = 0 + # for word in word_list: + # word_score = score_word(word) + # if word_score > max_score: + # max_word, max_score = word, word_score + # elif word_score == max_score: + # if type(max_word) != list: + # max_word = list(max_word) + # max_word.append(word) + # if type(max_word) == str: + # return (max_word, max_score) + # min_len, min_word = 100, None + # for word in word_list: + # if len(word) == 10: + # return (word,score_word(word)) + # elif len(word) < min_len: + # min_word, min_len = word, len(word) + # return (min_word,score_word(min_word)) From 8615dfbaf708aba830ffd540c863c22abe67aeef Mon Sep 17 00:00:00 2001 From: Ying G Date: Thu, 31 Mar 2022 13:42:23 -0700 Subject: [PATCH 07/10] refactor uses_available_letters --- adagrams/game.py | 42 +++++++++++------------------------------- tests/test_wave_03.py | 2 +- 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/adagrams/game.py b/adagrams/game.py index 63fa8359..26ed2b1e 100644 --- a/adagrams/game.py +++ b/adagrams/game.py @@ -1,5 +1,6 @@ from collections import Counter import random +from collections import Counter LETTER_POOL = { 'A': 9, @@ -73,26 +74,25 @@ def draw_letters(): # copy a dictionary so that we don't change the data, it's constant - LETTER_POOL_COPY = LETTER_POOL.copy() + letter_pool_copy = LETTER_POOL.copy() letters_drawn = [] while len(letters_drawn) < 10: - letter_drawn = random.choice(list(LETTER_POOL_COPY)) - if LETTER_POOL_COPY[letter_drawn] >= 1: + letter_drawn = random.choice(list(letter_pool_copy)) + if letter_pool_copy[letter_drawn] >= 1: letters_drawn.append(letter_drawn) - LETTER_POOL_COPY[letter_drawn] -= 1 + letter_pool_copy[letter_drawn] -= 1 return letters_drawn def uses_available_letters(word, letter_bank): upper_word = word.upper() - copy_letter_bank = letter_bank.copy() + char_counts = Counter(letter_bank) for char in upper_word: - if char not in copy_letter_bank: + if not char_counts[char]: return False - else: - copy_letter_bank.remove(char) + char_counts[char] -= 1 return True - + def score_word(word): points = 0 @@ -105,7 +105,7 @@ def score_word(word): def get_highest_word_score(word_list): max_score = 0 - max_word = () + max_word = None for word in word_list: if score_word(word) == max_score: if len(max_word) == 10: @@ -117,24 +117,4 @@ def get_highest_word_score(word_list): elif score_word(word) > max_score: max_score = score_word(word) max_word = word - return (max_word, max_score) - - # max_word = None - # max_score = 0 - # for word in word_list: - # word_score = score_word(word) - # if word_score > max_score: - # max_word, max_score = word, word_score - # elif word_score == max_score: - # if type(max_word) != list: - # max_word = list(max_word) - # max_word.append(word) - # if type(max_word) == str: - # return (max_word, max_score) - # min_len, min_word = 100, None - # for word in word_list: - # if len(word) == 10: - # return (word,score_word(word)) - # elif len(word) < min_len: - # min_word, min_len = word, len(word) - # return (min_word,score_word(min_word)) + return (max_word, max_score) \ No newline at end of file diff --git a/tests/test_wave_03.py b/tests/test_wave_03.py index 9ff1a1e1..5473db39 100644 --- a/tests/test_wave_03.py +++ b/tests/test_wave_03.py @@ -18,7 +18,7 @@ def test_score_zero_for_empty(): # Assert assert score_word("") == 0 -def test_score_extra_points_for_seven_or_longer(): # bonus points: 7 +def test_score_extra_points_for_seven_or_longer(): # Assert assert score_word("XXXXXXX") == 64 assert score_word("XXXXXXXX") == 72 From f5d223fba7044223791afacd039ae93aec1b4737 Mon Sep 17 00:00:00 2001 From: Ying G Date: Thu, 31 Mar 2022 13:44:52 -0700 Subject: [PATCH 08/10] refactor get_highest_word_score --- adagrams/game.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/adagrams/game.py b/adagrams/game.py index 26ed2b1e..19b52c62 100644 --- a/adagrams/game.py +++ b/adagrams/game.py @@ -108,9 +108,7 @@ def get_highest_word_score(word_list): max_word = None for word in word_list: if score_word(word) == max_score: - if len(max_word) == 10: - continue - elif len(word) == 10: + if len(word) == 10 and len(max_word) != 10: max_word = word elif len(word) < len(max_word): max_word = word From 0764af9dcbffe30d6f61aa03a556501f1aee039a Mon Sep 17 00:00:00 2001 From: Ying G Date: Thu, 31 Mar 2022 14:04:07 -0700 Subject: [PATCH 09/10] refactor get_highest_word_score again --- adagrams/game.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adagrams/game.py b/adagrams/game.py index 19b52c62..f8e32fd2 100644 --- a/adagrams/game.py +++ b/adagrams/game.py @@ -107,8 +107,8 @@ def get_highest_word_score(word_list): max_score = 0 max_word = None for word in word_list: - if score_word(word) == max_score: - if len(word) == 10 and len(max_word) != 10: + if score_word(word) == max_score and len(max_word) != 10: + if len(word) == 10: max_word = word elif len(word) < len(max_word): max_word = word From b013179be9f77692d6ea6b4ec2b07b30859d567d Mon Sep 17 00:00:00 2001 From: Ying G Date: Fri, 1 Apr 2022 12:56:18 -0700 Subject: [PATCH 10/10] refactor get_highest_word_score again --- adagrams/game.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/adagrams/game.py b/adagrams/game.py index f8e32fd2..5604ae68 100644 --- a/adagrams/game.py +++ b/adagrams/game.py @@ -76,8 +76,9 @@ def draw_letters(): # copy a dictionary so that we don't change the data, it's constant letter_pool_copy = LETTER_POOL.copy() letters_drawn = [] + letter_options = list(letter_pool_copy) while len(letters_drawn) < 10: - letter_drawn = random.choice(list(letter_pool_copy)) + letter_drawn = random.choice(letter_options) if letter_pool_copy[letter_drawn] >= 1: letters_drawn.append(letter_drawn) letter_pool_copy[letter_drawn] -= 1 @@ -108,9 +109,7 @@ def get_highest_word_score(word_list): max_word = None for word in word_list: if score_word(word) == max_score and len(max_word) != 10: - if len(word) == 10: - max_word = word - elif len(word) < len(max_word): + if len(word) == 10 or len(word) < len(max_word): max_word = word elif score_word(word) > max_score: max_score = score_word(word)