Решение на От ливадите до Лас Вегас (и назад) от Виктор

Обратно към всички решения

Към профила на Виктор

Резултати

  • 10 точки от тестове
  • 3 бонус точки
  • 13 точки общо
  • 15 успешни тест(а)
  • 0 неуспешни тест(а)

Код

from random import randint, shuffle
_, Card, _, Deck, _, Player, _, Game, Belot, Poker = (Card := type('Card', (), {'__init__': lambda _, s, f: (setattr(_, 's', s), setattr(_, 'f', f))[0], 'get_suit': lambda _: _.s, 'get_face': lambda _: _.f})), Card, (Deck := type('Deck', (), {'__init__': lambda _, ff=['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']: setattr(_, 'd', [Card(s, f) for s in ['clubs', 'diamonds', 'hearts', 'spades'] for f in ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'] if f in ff]),'get_cards': lambda _: _.d, 'shuffle': lambda _: shuffle(_.d),'cut': lambda _: setattr(_, 'd', _.d[(cut := randint(1, len(_.d) - 1)):] + _.d[:cut])})), Deck, (Player := type('Player', (), {'__init__': lambda _: setattr(_, 'c', []), 'get_cards': lambda _: _.c, 'tc': lambda _, cs: _.c.extend(cs), 'rc': lambda _: [_.c.pop() for __ in range(len(_.c))]})), Player, (Game := type('Game', (), {'__init__': lambda _, n, dd, di, df=None: (setattr(_, 'ps', [Player() for _ in range(n)]), setattr(_, 'd', Deck(df) if df else Deck()), setattr(_, 'dd', dd), setattr(_, 'di', di))[0], 'get_players': lambda _: _.ps, 'prepare_deck': lambda _: setattr(_.d, 'd', _.d.d + sum([p.rc() for p in _.ps], [])), 'deal': lambda _, fp: [p.tc([_.d.d.pop() for __ in range(di)]) for o in (_.ps[::1 if _.dd == 'ltr' else -1],) for f in (o.index(fp),) for di in _.di for p in o[f:] + o[:f]], 'get_deck': lambda _: _.d})), Game, type('Belot', (Game,), {'__init__': lambda _: Game.__init__(_, 4, 'ltr', (2, 3, 3), ['7', '8', '9', '10', 'J', 'Q', 'K', 'A'])}), type('Poker', (Game,), {'__init__': lambda _: Game.__init__(_, 9, 'rtl', (1,)*5)})

Лог от изпълнението

...............
----------------------------------------------------------------------
Ran 15 tests in 0.143s

OK

История (2 версии и 0 коментара)

Виктор обнови решението на 15.11.2022 14:43 (преди около 2 години)

+from random import randint, shuffle
+
+_, Card, _, Deck, _, Player, _, Game, Belot, Poker = (Card := type('Card', (), {'__init__': lambda _, s, f: (setattr(_, 's', s), setattr(_, 'f', f))[0], 'get_suit': lambda _: _.s, 'get_face': lambda _: _.f})), Card, (Deck := type('Deck', (), {'__init__': lambda _, ff=['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']: setattr(_, 'd', [Card(s, f) for s in ['clubs', 'diamonds', 'hearts', 'spades'] for f in ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'] if f in ff]),'get_cards': lambda _: _.d, 'shuffle': lambda _: shuffle(_.d),'cut': lambda _: setattr(_, 'd', _.d[(cut := randint(1, len(_.d))):] + _.d[:cut])})), Deck, (Player := type('Player', (), {'__init__': lambda _: setattr(_, 'c', []), 'get_cards': lambda _: _.c, 'tc': lambda _, cs: _.c.extend(cs), 'rc': lambda _: [_.c.pop() for __ in range(len(_.c))]})), Player, (Game := type('Game', (), {'__init__': lambda _, n, dd, di, df=None: (setattr(_, 'ps', [Player() for _ in range(n)]), setattr(_, 'd', Deck(df) if df else Deck()), setattr(_, 'dd', dd), setattr(_, 'di', di))[0], 'get_players': lambda _: _.ps, 'prepare_deck': lambda _: setattr(_.d, 'd', _.d.d + sum([p.rc() for p in _.ps], [])), 'deal': lambda _, fp: [p.tc([_.d.d.pop() for __ in range(di)]) for o in (_.ps[::1 if _.dd == 'ltr' else -1],) for f in (o.index(fp),) for di in _.di for p in o[f:] + o[:f]], 'get_deck': lambda _: _.d})), Game, type('Belot', (Game,), {'__init__': lambda _: Game.__init__(_, 4, 'ltr', (2, 3, 3), ['7', '8', '9', '10', 'J', 'Q', 'K', 'A'])}), type('Poker', (Game,), {'__init__': lambda _: Game.__init__(_, 9, 'rtl', (1,)*5)})

Виктор обнови решението на 15.11.2022 14:51 (преди около 2 години)

from random import randint, shuffle
-_, Card, _, Deck, _, Player, _, Game, Belot, Poker = (Card := type('Card', (), {'__init__': lambda _, s, f: (setattr(_, 's', s), setattr(_, 'f', f))[0], 'get_suit': lambda _: _.s, 'get_face': lambda _: _.f})), Card, (Deck := type('Deck', (), {'__init__': lambda _, ff=['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']: setattr(_, 'd', [Card(s, f) for s in ['clubs', 'diamonds', 'hearts', 'spades'] for f in ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'] if f in ff]),'get_cards': lambda _: _.d, 'shuffle': lambda _: shuffle(_.d),'cut': lambda _: setattr(_, 'd', _.d[(cut := randint(1, len(_.d))):] + _.d[:cut])})), Deck, (Player := type('Player', (), {'__init__': lambda _: setattr(_, 'c', []), 'get_cards': lambda _: _.c, 'tc': lambda _, cs: _.c.extend(cs), 'rc': lambda _: [_.c.pop() for __ in range(len(_.c))]})), Player, (Game := type('Game', (), {'__init__': lambda _, n, dd, di, df=None: (setattr(_, 'ps', [Player() for _ in range(n)]), setattr(_, 'd', Deck(df) if df else Deck()), setattr(_, 'dd', dd), setattr(_, 'di', di))[0], 'get_players': lambda _: _.ps, 'prepare_deck': lambda _: setattr(_.d, 'd', _.d.d + sum([p.rc() for p in _.ps], [])), 'deal': lambda _, fp: [p.tc([_.d.d.pop() for __ in range(di)]) for o in (_.ps[::1 if _.dd == 'ltr' else -1],) for f in (o.index(fp),) for di in _.di for p in o[f:] + o[:f]], 'get_deck': lambda _: _.d})), Game, type('Belot', (Game,), {'__init__': lambda _: Game.__init__(_, 4, 'ltr', (2, 3, 3), ['7', '8', '9', '10', 'J', 'Q', 'K', 'A'])}), type('Poker', (Game,), {'__init__': lambda _: Game.__init__(_, 9, 'rtl', (1,)*5)})
+_, Card, _, Deck, _, Player, _, Game, Belot, Poker = (Card := type('Card', (), {'__init__': lambda _, s, f: (setattr(_, 's', s), setattr(_, 'f', f))[0], 'get_suit': lambda _: _.s, 'get_face': lambda _: _.f})), Card, (Deck := type('Deck', (), {'__init__': lambda _, ff=['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']: setattr(_, 'd', [Card(s, f) for s in ['clubs', 'diamonds', 'hearts', 'spades'] for f in ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'] if f in ff]),'get_cards': lambda _: _.d, 'shuffle': lambda _: shuffle(_.d),'cut': lambda _: setattr(_, 'd', _.d[(cut := randint(1, len(_.d) - 1)):] + _.d[:cut])})), Deck, (Player := type('Player', (), {'__init__': lambda _: setattr(_, 'c', []), 'get_cards': lambda _: _.c, 'tc': lambda _, cs: _.c.extend(cs), 'rc': lambda _: [_.c.pop() for __ in range(len(_.c))]})), Player, (Game := type('Game', (), {'__init__': lambda _, n, dd, di, df=None: (setattr(_, 'ps', [Player() for _ in range(n)]), setattr(_, 'd', Deck(df) if df else Deck()), setattr(_, 'dd', dd), setattr(_, 'di', di))[0], 'get_players': lambda _: _.ps, 'prepare_deck': lambda _: setattr(_.d, 'd', _.d.d + sum([p.rc() for p in _.ps], [])), 'deal': lambda _, fp: [p.tc([_.d.d.pop() for __ in range(di)]) for o in (_.ps[::1 if _.dd == 'ltr' else -1],) for f in (o.index(fp),) for di in _.di for p in o[f:] + o[:f]], 'get_deck': lambda _: _.d})), Game, type('Belot', (Game,), {'__init__': lambda _: Game.__init__(_, 4, 'ltr', (2, 3, 3), ['7', '8', '9', '10', 'J', 'Q', 'K', 'A'])}), type('Poker', (Game,), {'__init__': lambda _: Game.__init__(_, 9, 'rtl', (1,)*5)})