def finalize_score(puzzle: str, view: str, unguessed_consonants: str, \ current_score: int) -> int: """Return the final score, which is calculated by adding CONSONANT_BONUS points to the current_score for each item from unguessed_consonants in puzzle that appears as HIDDEN in view. >>> finalize_score('apple pies', '^^^le ^^e^', 'dfkpqstz', 0) 8 """ final_score = current_score for letter in unguessed_consonants: if pf.bonus_letter(puzzle, view, letter): final_score = final_score + CONSONANT_BONUS return final_score
def test_bonus_letter_3(self): actual = pf.bonus_letter("heara-smare", "h^^^^-smart", "t") self.assertFalse(actual)
def test_bonus_letter_2(self): actual = pf.bonus_letter("anti-wrinkle cream soda", "a^ti-wri^kle cream soda", "t") self.assertFalse(actual)
def test_bonus_letter_1(self): actual = pf.bonus_letter("anti-wrinkle cream soda", "a^ti-wri^kle cream soda", "n") self.assertTrue(actual)
assert isinstance(result, bool), \ """puzzler_functions.is_win should return a bool, but returned {0} .""".format(type(result)) print(' check complete') # Type check puzzler_functions.game_over print('Checking game_over...') result = pf.game_over('water', '^^te^', pf.CONSONANT) assert isinstance(result, bool), \ """puzzler_functions.game_over should return a bool, but returned {0}.""" \ .format(type(result)) print(' check complete') # Type check puzzler_functions.bonus_letter print('Checking bonus_letter...') result = pf.bonus_letter('water', '^^te^', 'w') assert isinstance(result, bool), \ """puzzler_functions.bonus_letter should return a bool, but returned {0}.""" \ .format(type(result)) print(' check complete') # Type check puzzler_functions.update_letter_view print('Checking update_letter_view...') result = pf.update_letter_view('apple', 'a^^l^', 2, 'x') assert isinstance(result, str), \ """puzzler_functions.update_letter_view should return a str, but returned {0}.""" \ .format(type(result)) print(' check complete') # Type check pf.calculate_score print('Checking calculate_score...')