diff --git a/src/inventory_wars/scoring.py b/src/inventory_wars/scoring.py index 832c436..f58d56b 100644 --- a/src/inventory_wars/scoring.py +++ b/src/inventory_wars/scoring.py @@ -34,16 +34,16 @@ class FirstGuess(Scoring): class HighestAmount(Scoring): def __init__(self): - self.shares: set[ItemShare] = set() + self.max: ItemShare | None = None def calculate_score(self, item: ItemShare) -> int: - self.shares.add(item) + if self.max is None or item.count > self.max.count: + self.max = item return 0 def calculate_end_score(self) -> ItemShare | None: - highest = max(self.shares, key=lambda s: s.count) - highest.score = 1 - return highest + self.max.score = 1 + return self.max class FirstThenHighest(Scoring):