Conversation
Merge branch 'master' of https://github.com/SabrinaLauredan/adagrams-py
spitsfire
left a comment
There was a problem hiding this comment.
Great job, Sabrina and Shay! Your code was easy to read! I made a few suggestions to dry up your code, but all in all this was nicely done!!
Keep it up!
| LETTERS_POOL = [] | ||
| for letter in LETTERS_DICT: | ||
| letters_string = letter * LETTERS_DICT[letter] | ||
| for letter in letters_string: | ||
| LETTERS_POOL.append(letter) | ||
| ''' | ||
| LETTERS_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'] |
There was a problem hiding this comment.
this works! Though I think since you put in the effort of coding the algorithm out, you should show it off! Maybe we can do something like this:
| LETTERS_POOL = [] | |
| for letter in LETTERS_DICT: | |
| letters_string = letter * LETTERS_DICT[letter] | |
| for letter in letters_string: | |
| LETTERS_POOL.append(letter) | |
| ''' | |
| LETTERS_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'] | |
| def get_letters_pool: | |
| for letter in LETTERS_DICT: | |
| letters_pool = [] | |
| letters_string = letter * LETTERS_DICT[letter] | |
| for letter in letters_string: | |
| letters_pool.append(letter) | |
| return letters_pool | |
| LETTERS_POOL = get_letters_pool() |
There was a problem hiding this comment.
this way, if the letter scores or availability change, then you only need to change the original dictionary!
| "R": 1, "U": 1, "T": 1, "W": 4, "V": 4, "Y": 4, | ||
| "X": 8, "Z": 10} | ||
|
|
||
| def draw_letters(): |
There was a problem hiding this comment.
👍 short and sweet! love it!
| a letter more times than it appears in the letter_bank | ||
| Returns True or False | ||
| ''' | ||
| temp_letter_bank = letter_bank.copy() |
There was a problem hiding this comment.
👍 good job reducing side effects!
| total = 0 | ||
| if len(word) >= 7: | ||
| total += 8 | ||
| total += sum(SCORES[letter] for letter in word.upper()) | ||
| return total |
There was a problem hiding this comment.
ohh interesting doing the +8 points first, then using sum() for the for loop!
| return False | ||
| return True | ||
|
|
||
| def score_word(word): |
| if score_word(word) > highest_score: | ||
| winning_word = word | ||
| highest_score = score_word(word) |
There was a problem hiding this comment.
maybe we can dry this up a bit, so we only use score_word once!
| if score_word(word) > highest_score: | |
| winning_word = word | |
| highest_score = score_word(word) | |
| current_score = score_word(word) | |
| if current_score > highest_score: | |
| winning_word = word | |
| highest_score = current_score |
| elif score_word(word) == highest_score: | ||
| if len(word) == 10 and len(word) != len(winning_word): | ||
| winning_word = word | ||
| highest_score = score_word(word) |
There was a problem hiding this comment.
now that we have the current_score variable, we can do the same to this conditional statement as above!
| highest_score = score_word(word) | ||
| elif len(word) < len(winning_word) and len(winning_word) != 10: | ||
| winning_word = word | ||
| highest_score = score_word(word) |
No description provided.