fix: optimize code

This commit is contained in:
Dmitry Fedotov
2023-12-16 14:56:58 +03:00
parent 5e10a58298
commit 14e3008925

View File

@@ -55,12 +55,11 @@ class CardSet(object):
copies = [0 for _ in range(len(self.cards))]
for i in range(len(self.cards)):
copies[i] += 1
for _ in range(copies[i]):
matching = self.cards[i]._count_winning_in_have()
if i + matching > len(self.cards):
matching = len(self.cards) - 1 - i
for j in range(1, matching+1):
copies[i+j] += 1
copies[i+j] += 1 * copies[i]
return sum(copies)
if __name__ == '__main__':