Skip to content

high-scores: incorrect solution can pass the tests #1745

@ali1234

Description

@ali1234

Consider the following partial solution to this problem:

class HighScores(object):
    def __init__(self, scores):
        self.scores = scores

    def latest(self):
        return self.scores[-1]

    def personal_best(self):
        self.scores.sort()
        return self.scores[-1]

This will pass the tests for the functions it implements. However, if latest is called after calling personal_best, it can give the wrong answer. The current tests do not check for this situation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions