Решение на Тесте карти от Теодора Добрева

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

Към профила на Теодора Добрева

Резултати

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

Код

from collections import OrderedDict
class Rank:
def __init__(self, symbol, rank):
self.symbol = symbol
self.rank = rank
def __eq__(self, other):
return self.rank == other.rank
def __str__(self):
return self.rank
class Suit:
def __init__(self, color, suit):
self.color = color
self.suit = suit
def __eq__(self, other):
return self.suit == other.suit
def __str__(self):
return self.suit
class Ace(Rank):
def __init__(self):
Rank.__init__(self, 'A', 'Ace')
class Two(Rank):
def __init__(self):
Rank.__init__(self, '2', 'Two')
class Three(Rank):
def __init__(self):
Rank.__init__(self, '3', 'Three')
class Four(Rank):
def __init__(self):
Rank.__init__(self, '4', 'Four')
class Five(Rank):
def __init__(self):
Rank.__init__(self, '5', 'Five')
class Six(Rank):
def __init__(self):
Rank.__init__(self, '6', 'Six')
class Seven(Rank):
def __init__(self):
Rank.__init__(self, '7', 'Seven')
class Eight(Rank):
def __init__(self):
Rank.__init__(self, '8', 'Eight')
class Nine(Rank):
def __init__(self):
Rank.__init__(self, '9', 'Nine')
class Ten(Rank):
def __init__(self):
Rank.__init__(self, '10', 'Ten')
class Jack(Rank):
def __init__(self):
Rank.__init__(self, 'J', 'Jack')
class Queen(Rank):
def __init__(self):
Rank.__init__(self, 'Q', 'Queen')
class King(Rank):
def __init__(self):
Rank.__init__(self, 'K', 'King')
class Hearts(Suit):
def __init__(self):
Suit.__init__(self, 'red', 'Hearts')
class Clubs(Suit):
def __init__(self):
Suit.__init__(self, 'black', 'Clubs')
class Spades(Suit):
def __init__(self):
Suit.__init__(self, 'black', 'Spades')
class Diamonds(Suit):
def __init__(self):
Suit.__init__(self, 'red', 'Diamonds')
RANKS = OrderedDict([('King', King), ('Queen', Queen), ('Jack', Jack),
('Ten', Ten), ('Nine', Nine), ('Eight', Eight),
('Seven', Seven), ('Six', Six), ('Five', Five),
('Four', Four), ('Three', Three), ('Two', Two),
('Ace', Ace)])
SUITS = OrderedDict([('Diamonds', Diamonds), ('Clubs', Clubs),
('Hearts', Hearts), ('Spades', Spades)])
class Card:
def __init__(self, rank, suit):
object.__setattr__(self, 'rank', rank())
object.__setattr__(self, 'suit', suit())
def __setattr__(self, *args):
raise AttributeError('can\'t set attribute')
def __eq__(self, other):
return self.rank == other.rank and self.suit == other.suit
def __str__(self):
return '{0} of {1}'.format(self.rank, self.suit)
def __repr__(self):
return '<Card {0} of {1}>'.format(self.rank, self.suit)
class CardCollection:
def __init__(self, collection=[]):
self.collection = list(collection)
def draw(self, index):
return self.collection.pop(index)
def draw_from_top(self):
return self.draw(len(self.collection) - 1)
def draw_from_bottom(self):
return self.draw(0)
def top_card(self):
return self.collection[len(self.collection) - 1]
def bottom_card(self):
return self.collection[0]
def add(self, card):
self.collection.append(card)
def index(self, card):
if card in self.collection:
return self.collection.index(card)
else:
raise ValueError('{0} is not in collection'.format(card))
def __getitem__(self, index):
if index >= 0 and index < len(self.collection):
return self.collection[index]
else:
raise IndexError('index out of range')
def __len__(self):
return len(self.collection)
def StandardDeck():
return list(CardCollection([Card(rank, suit)
for suit in SUITS.values()
for rank in RANKS.values()]))
def BeloteDeck():
return list(CardCollection([Card(rank, suit)
for suit in SUITS.values()
for rank in RANKS.values()
if rank().symbol not in
{'2', '3', '4', '5', '6'}]))
def SixtySixDeck():
return list(CardCollection([Card(rank, suit)
for suit in SUITS.values()
for rank in RANKS.values()
if rank().symbol not in
{'2', '3', '4', '5', '6', '7', '8'}]))

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

................
----------------------------------------------------------------------
Ran 16 tests in 0.028s

OK

История (3 версии и 1 коментар)

Теодора обнови решението на 24.03.2014 10:17 (преди над 10 години)

+class Rank:
+ def __init__(self, symbol):
+ self.symbol = symbol
+
+
+class Suit:
+ def __init__(self, color):
+ self.color = color
+
+
+class Ace(Rank):
+ def __init__(self):
+ Rank.__init__(self, 'A')
+
+ def __eq__(self, other):
+ return self.symbol == other.symbol
+
+ def __str__(self):
+ return 'Ace'
+
+
+class Two(Rank):
+ def __init__(self):
+ Rank.__init__(self, '2')
+
+ def __eq__(self, other):
+ return self.symbol == other.symbol
+
+ def __str__(self):
+ return 'Two'
+
+
+class Three(Rank):
+ def __init__(self):
+ Rank.__init__(self, '3')
+
+ def __eq__(self, other):
+ return self.symbol == other.symbol
+
+ def __str__(self):
+ return 'Three'
+
+
+class Four(Rank):
+ def __init__(self):
+ Rank.__init__(self, '4')
+
+ def __eq__(self, other):
+ return self.symbol == other.symbol
+
+ def __str__(self):
+ return 'Four'
+
+
+class Five(Rank):
+ def __init__(self):
+ Rank.__init__(self, '5')
+
+ def __eq__(self, other):
+ return self.symbol == other.symbol
+
+ def __str__(self):
+ return 'Five'
+
+
+class Six(Rank):
+ def __init__(self):
+ Rank.__init__(self, '6')
+
+ def __eq__(self, other):
+ return self.symbol == other.symbol
+
+ def __str__(self):
+ return 'Six'
+
+
+class Seven(Rank):
+ def __init__(self):
+ Rank.__init__(self, '7')
+
+ def __eq__(self, other):
+ return self.symbol == other.symbol
+
+ def __str__(self):
+ return 'Seven'
+
+
+class Eight(Rank):
+ def __init__(self):
+ Rank.__init__(self, '8')
+
+ def __eq__(self, other):
+ return self.symbol == other.symbol
+
+ def __str__(self):
+ return 'Eight'
+
+
+class Nine(Rank):
+ def __init__(self):
+ Rank.__init__(self, '9')
+
+ def __eq__(self, other):
+ return self.symbol == other.symbol
+
+ def __str__(self):
+ return 'Nine'
+
+
+class Ten(Rank):
+ def __init__(self):
+ Rank.__init__(self, '10')
+
+ def __eq__(self, other):
+ return self.symbol == other.symbol
+
+ def __str__(self):
+ return 'Ten'
+
+
+class Jack(Rank):
+ def __init__(self):
+ Rank.__init__(self, 'J')
+
+ def __eq__(self, other):
+ return self.symbol == other.symbol
+
+ def __str__(self):
+ return 'Jack'
+
+
+class Queen(Rank):
+ def __init__(self):
+ Rank.__init__(self, 'Q')
+
+ def __eq__(self, other):
+ return self.symbol == other.symbol
+
+ def __str__(self):
+ return 'Queen'
+
+
+class King(Rank):
+ def __init__(self):
+ Rank.__init__(self, 'K')
+
+ def __eq__(self, other):
+ return self.symbol == other.symbol
+
+ def __str__(self):
+ return 'King'
+
+
+class Hearts(Suit):
+ def __init__(self):
+ Suit.__init__(self, 'red')
+
+ def __eq__(self, other):
+ return isinstance(other, Hearts)
+
+ def __str__(self):
+ return 'Hearts'
+
+
+class Clubs(Suit):
+ def __init__(self):
+ Suit.__init__(self, 'black')
+
+ def __eq__(self, other):
+ return isinstance(other, Clubs)
+
+ def __str__(self):
+ return 'Clubs'
+
+
+class Spades(Suit):
+ def __init__(self):
+ Suit.__init__(self, 'black')
+
+ def __eq__(self, other):
+ return isinstance(other, Spades)
+
+ def __str__(self):
+ return 'Spades'
+
+
+class Diamonds(Suit):
+ def __init__(self):
+ Suit.__init__(self, 'red')
+
+ def __eq__(self, other):
+ return isinstance(other, Diamonds)
+
+ def __str__(self):
+ return 'Diamonds'
+
+
+RANKS = {'Ace': Ace, 'Two': Two, 'Three': Three, 'Four': Four, 'Five': Five,
+ 'Six': Six, 'Seven': Seven, 'Eight': Eight, 'Nine': Nine, 'Ten': Ten,
+ 'Jack': Jack, 'Queen': Queen, 'King': King}
+
+
+SUITS = {'Hearts': Hearts, 'Clubs': Clubs, 'Spades': Spades,
+ 'Diamonds': Diamonds}
+
+
+class Card:
+ def __init__(self, rank, suit):
+ object.__setattr__(self, 'rank', rank())
+ object.__setattr__(self, 'suit', suit())
+
+ def __setattr__(self, *args):
+ raise AttributeError('can\'t set attribute')
+
+ def __eq__(self, other):
+ return self.rank == other.rank and self.suit == other.suit
+
+ def __str__(self):
+ return '{0} of {1}'.format(self.rank, self.suit)
+
+ def __repr__(self):
+ return '<Card {0} of {1}>'.format(self.rank, self.suit)
+
+
+class CardCollection:
+ def __init__(self, collection=[]):
+ self.collection = list(collection)
+
+ def draw(self, index):
+ return self.collection.pop(index)
+
+ def draw_from_top(self):
+ return self.draw(len(self.collection) - 1)
+
+ def draw_from_bottom(self):
+ return self.draw(0)
+
+ def top_card(self):
+ return self.collection[len(self.collection) - 1]
+
+ def bottom_card(self):
+ return self.collection[0]
+
+ def add(self, card):
+ self.collection.append(card)
+
+ def index(self, card):
+ if card in self.collection:
+ return self.collection.index(card)
+ else:
+ raise ValueError('{0} is not in list'.format(card))
+
+ def __getitem__(self, index):
+ if index >= 0 and index < len(self.collection):
+ return self.collection[index]
+ else:
+ raise IndexError('list index out of range')
+
+ def __len__(self):
+ return len(self.collection)
+
+
+RANKS_ORDERED = [King, Queen, Jack, Ten, Nine, Eight, Seven,
+ Six, Five, Four, Three, Two, Ace]
+
+
+SUITS_ORDERED = [Diamonds, Clubs, Hearts, Spades]
+
+
+def StandardDeck():
+ return list(CardCollection([Card(rank, suit)
+ for suit in SUITS_ORDERED
+ for rank in RANKS_ORDERED]))
+
+
+def BeloteDeck():
+ return list(CardCollection([Card(rank, suit)
+ for suit in SUITS_ORDERED
+ for rank in RANKS_ORDERED
+ if rank().symbol not in
+ {'2', '3', '4', '5', '6'}]))
+
+
+def SixtySixDeck():
+ return list(CardCollection([Card(rank, suit)
+ for suit in SUITS_ORDERED
+ for rank in RANKS_ORDERED
+ if rank().symbol not in
+ {'2', '3', '4', '5', '6', '7', '8'}]))

Теодора обнови решението на 24.03.2014 23:53 (преди над 10 години)

+from collections import OrderedDict
+
+
class Rank:
- def __init__(self, symbol):
+ def __init__(self, symbol, rank):
self.symbol = symbol
+ self.rank = rank
+ def __eq__(self, other):
+ return self.rank == other.rank
+ def __str__(self):
+ return self.rank
+
+
class Suit:
- def __init__(self, color):
+ def __init__(self, color, suit):
self.color = color
+ self.suit = suit
-
-class Ace(Rank):
- def __init__(self):
- Rank.__init__(self, 'A')
-
def __eq__(self, other):
- return self.symbol == other.symbol
+ return self.suit == other.suit
def __str__(self):
- return 'Ace'
+ return self.suit
-class Two(Rank):
+class Ace(Rank):
def __init__(self):
- Rank.__init__(self, '2')
+ Rank.__init__(self, 'A', self.__class__.__name__)
- def __eq__(self, other):
- return self.symbol == other.symbol
- def __str__(self):
- return 'Two'
+class Two(Rank):
+ def __init__(self):
+ Rank.__init__(self, '2', self.__class__.__name__)
class Three(Rank):
def __init__(self):
- Rank.__init__(self, '3')
+ Rank.__init__(self, '3', self.__class__.__name__)
- def __eq__(self, other):
- return self.symbol == other.symbol
- def __str__(self):
- return 'Three'
-
-
class Four(Rank):
def __init__(self):
- Rank.__init__(self, '4')
+ Rank.__init__(self, '4', self.__class__.__name__)
- def __eq__(self, other):
- return self.symbol == other.symbol
- def __str__(self):
- return 'Four'
-
-
class Five(Rank):
def __init__(self):
- Rank.__init__(self, '5')
+ Rank.__init__(self, '5', self.__class__.__name__)
- def __eq__(self, other):
- return self.symbol == other.symbol
- def __str__(self):
- return 'Five'
-
-
class Six(Rank):
def __init__(self):
- Rank.__init__(self, '6')
+ Rank.__init__(self, '6', self.__class__.__name__)
- def __eq__(self, other):
- return self.symbol == other.symbol
- def __str__(self):
- return 'Six'
-
-
class Seven(Rank):
def __init__(self):
- Rank.__init__(self, '7')
+ Rank.__init__(self, '7', self.__class__.__name__)
- def __eq__(self, other):
- return self.symbol == other.symbol
- def __str__(self):
- return 'Seven'
-
-
class Eight(Rank):
def __init__(self):
- Rank.__init__(self, '8')
+ Rank.__init__(self, '8', self.__class__.__name__)
- def __eq__(self, other):
- return self.symbol == other.symbol
- def __str__(self):
- return 'Eight'
-
-
class Nine(Rank):
def __init__(self):
- Rank.__init__(self, '9')
+ Rank.__init__(self, '9', self.__class__.__name__)
- def __eq__(self, other):
- return self.symbol == other.symbol
- def __str__(self):
- return 'Nine'
-
-
class Ten(Rank):
def __init__(self):
- Rank.__init__(self, '10')
+ Rank.__init__(self, '10', self.__class__.__name__)
- def __eq__(self, other):
- return self.symbol == other.symbol
- def __str__(self):
- return 'Ten'
-
-
class Jack(Rank):
def __init__(self):
- Rank.__init__(self, 'J')
+ Rank.__init__(self, 'J', self.__class__.__name__)
- def __eq__(self, other):
- return self.symbol == other.symbol
- def __str__(self):
- return 'Jack'
-
-
class Queen(Rank):
def __init__(self):
- Rank.__init__(self, 'Q')
+ Rank.__init__(self, 'Q', self.__class__.__name__)
- def __eq__(self, other):
- return self.symbol == other.symbol
- def __str__(self):
- return 'Queen'
-
-
class King(Rank):
def __init__(self):
- Rank.__init__(self, 'K')
+ Rank.__init__(self, 'K', self.__class__.__name__)
- def __eq__(self, other):
- return self.symbol == other.symbol
- def __str__(self):
- return 'King'
-
-
class Hearts(Suit):
def __init__(self):
- Suit.__init__(self, 'red')
+ Suit.__init__(self, 'red', self.__class__.__name__)
- def __eq__(self, other):
- return isinstance(other, Hearts)
- def __str__(self):
- return 'Hearts'
-
-
class Clubs(Suit):
def __init__(self):
- Suit.__init__(self, 'black')
+ Suit.__init__(self, 'black', self.__class__.__name__)
- def __eq__(self, other):
- return isinstance(other, Clubs)
- def __str__(self):
- return 'Clubs'
-
-
class Spades(Suit):
def __init__(self):
- Suit.__init__(self, 'black')
+ Suit.__init__(self, 'black', self.__class__.__name__)
- def __eq__(self, other):
- return isinstance(other, Spades)
- def __str__(self):
- return 'Spades'
-
-
class Diamonds(Suit):
def __init__(self):
- Suit.__init__(self, 'red')
+ Suit.__init__(self, 'red', self.__class__.__name__)
- def __eq__(self, other):
- return isinstance(other, Diamonds)
- def __str__(self):
- return 'Diamonds'
+RANKS = OrderedDict([('King', King), ('Queen', Queen), ('Jack', Jack),
+ ('Ten', Ten), ('Nine', Nine), ('Eight', Eight),
+ ('Seven', Seven), ('Six', Six), ('Five', Five),
+ ('Four', Four), ('Three', Three), ('Two', Two),
+ ('Ace', Ace)])
-RANKS = {'Ace': Ace, 'Two': Two, 'Three': Three, 'Four': Four, 'Five': Five,
- 'Six': Six, 'Seven': Seven, 'Eight': Eight, 'Nine': Nine, 'Ten': Ten,
- 'Jack': Jack, 'Queen': Queen, 'King': King}
+SUITS = OrderedDict([('Diamonds', Diamonds), ('Clubs', Clubs),
+ ('Hearts', Hearts), ('Spades', Spades)])
-SUITS = {'Hearts': Hearts, 'Clubs': Clubs, 'Spades': Spades,
- 'Diamonds': Diamonds}
-
-
class Card:
def __init__(self, rank, suit):
object.__setattr__(self, 'rank', rank())
object.__setattr__(self, 'suit', suit())
def __setattr__(self, *args):
raise AttributeError('can\'t set attribute')
def __eq__(self, other):
return self.rank == other.rank and self.suit == other.suit
def __str__(self):
return '{0} of {1}'.format(self.rank, self.suit)
def __repr__(self):
return '<Card {0} of {1}>'.format(self.rank, self.suit)
class CardCollection:
def __init__(self, collection=[]):
self.collection = list(collection)
def draw(self, index):
return self.collection.pop(index)
def draw_from_top(self):
return self.draw(len(self.collection) - 1)
def draw_from_bottom(self):
return self.draw(0)
def top_card(self):
return self.collection[len(self.collection) - 1]
def bottom_card(self):
return self.collection[0]
def add(self, card):
self.collection.append(card)
def index(self, card):
if card in self.collection:
return self.collection.index(card)
else:
raise ValueError('{0} is not in list'.format(card))
def __getitem__(self, index):
if index >= 0 and index < len(self.collection):
return self.collection[index]
else:
raise IndexError('list index out of range')
def __len__(self):
return len(self.collection)
-RANKS_ORDERED = [King, Queen, Jack, Ten, Nine, Eight, Seven,
- Six, Five, Four, Three, Two, Ace]
-
-
-SUITS_ORDERED = [Diamonds, Clubs, Hearts, Spades]
-
-
def StandardDeck():
return list(CardCollection([Card(rank, suit)
- for suit in SUITS_ORDERED
- for rank in RANKS_ORDERED]))
+ for suit in SUITS.values()
+ for rank in RANKS.values()]))
def BeloteDeck():
return list(CardCollection([Card(rank, suit)
- for suit in SUITS_ORDERED
- for rank in RANKS_ORDERED
+ for suit in SUITS.values()
+ for rank in RANKS.values()
if rank().symbol not in
{'2', '3', '4', '5', '6'}]))
def SixtySixDeck():
return list(CardCollection([Card(rank, suit)
- for suit in SUITS_ORDERED
- for rank in RANKS_ORDERED
+ for suit in SUITS.values()
+ for rank in RANKS.values()
if rank().symbol not in
{'2', '3', '4', '5', '6', '7', '8'}]))

Тази код е доста усложнен. Винаги, когато извикваш някой дъндър метод се питай дали има смисъл.

class Ace(Rank):
    def __init__(self):
        Rank.__init__(self, 'A', self.__class__.__name__)

raise IndexError('list index out of range') - това не е list

Лоша идея е да използваш mutable колекция за подразбиращ се аргумент.

Теодора обнови решението на 25.03.2014 21:14 (преди над 10 години)

from collections import OrderedDict
class Rank:
def __init__(self, symbol, rank):
self.symbol = symbol
self.rank = rank
def __eq__(self, other):
return self.rank == other.rank
def __str__(self):
return self.rank
class Suit:
def __init__(self, color, suit):
self.color = color
self.suit = suit
def __eq__(self, other):
return self.suit == other.suit
def __str__(self):
return self.suit
class Ace(Rank):
def __init__(self):
- Rank.__init__(self, 'A', self.__class__.__name__)
+ Rank.__init__(self, 'A', 'Ace')
class Two(Rank):
def __init__(self):
- Rank.__init__(self, '2', self.__class__.__name__)
+ Rank.__init__(self, '2', 'Two')
class Three(Rank):
def __init__(self):
- Rank.__init__(self, '3', self.__class__.__name__)
+ Rank.__init__(self, '3', 'Three')
class Four(Rank):
def __init__(self):
- Rank.__init__(self, '4', self.__class__.__name__)
+ Rank.__init__(self, '4', 'Four')
class Five(Rank):
def __init__(self):
- Rank.__init__(self, '5', self.__class__.__name__)
+ Rank.__init__(self, '5', 'Five')
class Six(Rank):
def __init__(self):
- Rank.__init__(self, '6', self.__class__.__name__)
+ Rank.__init__(self, '6', 'Six')
class Seven(Rank):
def __init__(self):
- Rank.__init__(self, '7', self.__class__.__name__)
+ Rank.__init__(self, '7', 'Seven')
class Eight(Rank):
def __init__(self):
- Rank.__init__(self, '8', self.__class__.__name__)
+ Rank.__init__(self, '8', 'Eight')
class Nine(Rank):
def __init__(self):
- Rank.__init__(self, '9', self.__class__.__name__)
+ Rank.__init__(self, '9', 'Nine')
class Ten(Rank):
def __init__(self):
- Rank.__init__(self, '10', self.__class__.__name__)
+ Rank.__init__(self, '10', 'Ten')
class Jack(Rank):
def __init__(self):
- Rank.__init__(self, 'J', self.__class__.__name__)
+ Rank.__init__(self, 'J', 'Jack')
class Queen(Rank):
def __init__(self):
- Rank.__init__(self, 'Q', self.__class__.__name__)
+ Rank.__init__(self, 'Q', 'Queen')
class King(Rank):
def __init__(self):
- Rank.__init__(self, 'K', self.__class__.__name__)
+ Rank.__init__(self, 'K', 'King')
class Hearts(Suit):
def __init__(self):
- Suit.__init__(self, 'red', self.__class__.__name__)
+ Suit.__init__(self, 'red', 'Hearts')
class Clubs(Suit):
def __init__(self):
- Suit.__init__(self, 'black', self.__class__.__name__)
+ Suit.__init__(self, 'black', 'Clubs')
class Spades(Suit):
def __init__(self):
- Suit.__init__(self, 'black', self.__class__.__name__)
+ Suit.__init__(self, 'black', 'Spades')
class Diamonds(Suit):
def __init__(self):
- Suit.__init__(self, 'red', self.__class__.__name__)
+ Suit.__init__(self, 'red', 'Diamonds')
RANKS = OrderedDict([('King', King), ('Queen', Queen), ('Jack', Jack),
('Ten', Ten), ('Nine', Nine), ('Eight', Eight),
('Seven', Seven), ('Six', Six), ('Five', Five),
('Four', Four), ('Three', Three), ('Two', Two),
('Ace', Ace)])
SUITS = OrderedDict([('Diamonds', Diamonds), ('Clubs', Clubs),
('Hearts', Hearts), ('Spades', Spades)])
class Card:
def __init__(self, rank, suit):
object.__setattr__(self, 'rank', rank())
object.__setattr__(self, 'suit', suit())
def __setattr__(self, *args):
raise AttributeError('can\'t set attribute')
def __eq__(self, other):
return self.rank == other.rank and self.suit == other.suit
def __str__(self):
return '{0} of {1}'.format(self.rank, self.suit)
def __repr__(self):
return '<Card {0} of {1}>'.format(self.rank, self.suit)
class CardCollection:
def __init__(self, collection=[]):
self.collection = list(collection)
def draw(self, index):
return self.collection.pop(index)
def draw_from_top(self):
return self.draw(len(self.collection) - 1)
def draw_from_bottom(self):
return self.draw(0)
def top_card(self):
return self.collection[len(self.collection) - 1]
def bottom_card(self):
return self.collection[0]
def add(self, card):
self.collection.append(card)
def index(self, card):
if card in self.collection:
return self.collection.index(card)
else:
- raise ValueError('{0} is not in list'.format(card))
+ raise ValueError('{0} is not in collection'.format(card))
def __getitem__(self, index):
if index >= 0 and index < len(self.collection):
return self.collection[index]
else:
- raise IndexError('list index out of range')
+ raise IndexError('index out of range')
def __len__(self):
return len(self.collection)
def StandardDeck():
return list(CardCollection([Card(rank, suit)
for suit in SUITS.values()
for rank in RANKS.values()]))
def BeloteDeck():
return list(CardCollection([Card(rank, suit)
for suit in SUITS.values()
for rank in RANKS.values()
if rank().symbol not in
{'2', '3', '4', '5', '6'}]))
def SixtySixDeck():
return list(CardCollection([Card(rank, suit)
for suit in SUITS.values()
for rank in RANKS.values()
if rank().symbol not in
{'2', '3', '4', '5', '6', '7', '8'}]))