LINUX.ORG.RU

История изменений

Исправление vvn_black, (текущая версия) :

Или даже так, больше «функциональщины»:

    ...
    def hands(self, players):
        # "сдаём" в players
        players = self.deck.deal(players, per_hand=1)

        least = min(map(lambda x: x.total, players))

        losers = *filter(lambda x: x.total == least, players),
        winners = *filter(lambda x: x.total > least, players),

        players = len(losers) == len(players) and losers or winners

        return len(players) == 1 and players or self.hands(players)

    def play(self):
        w = self.hands(self.players)
        print(f'Champion: {w[0].name} with {w[0].total} points')

Исправление vvn_black, :

Или даже так, больше «функциональщины»:

    ...
    def hands(self, players):
        # "сдаём" в players
        # players = self.deck.deal(players, per_hand=1)

        least = min(map(lambda x: x.total, players))

        losers = *filter(lambda x: x.total == least, players),
        winners = *filter(lambda x: x.total > least, players),

        players = len(losers) == len(players) and losers or winners

        return len(players) == 1 and players or self.hands(players)

    def play(self):
        w = self.hands(self.players)
        print(f'Champion: {w[0].name} with {w[0].total} points')

Исходная версия vvn_black, :

Или даже так, больше «функциональщины»:

    ...
    def hands(self, players):
        self.deck.deal(players, per_hand=1)

        least = min(map(lambda x: x.total, players))

        losers = *filter(lambda x: x.total == least, players),
        winners = *filter(lambda x: x.total > least, players),

        players = len(losers) == len(players) and losers or winners

        return len(players) == 1 and players or self.hands(players)

    def play(self):
        w = self.hands(self.players)
        print(f'Champion: {w[0].name} with {w[0].total} points')