Васил обнови решението на 23.03.2014 01:34 (преди над 11 години)
+from functools import cmp_to_key
+
+
+class Rank:
+    def __init__(self, symbol):
+        self._symbol = symbol
+
+    def symbol(self):
+        return self._symbol
+
+    def __str__(self):
+        return self.__class__.__name__
+
+    def __eq__(self, other):
+        return self.__class__.__name__ == other.__class__.__name__
+
+
+class Two(Rank):
+    def __init__(self):
+        Rank.__init__(self, "2")
+
+
+class Three(Rank):
+    def __init__(self):
+        Rank.__init__(self, "3")
+
+
+class Four(Rank):
+    def __init__(self):
+        Rank.__init__(self, "4")
+
+
+class Five(Rank):
+    def __init__(self):
+        Rank.__init__(self, "5")
+
+
+class Six(Rank):
+    def __init__(self):
+        Rank.__init__(self, "6")
+
+
+class Seven(Rank):
+    def __init__(self):
+        Rank.__init__(self, "7")
+
+
+class Eight(Rank):
+    def __init__(self):
+        Rank.__init__(self, "8")
+
+
+class Nine(Rank):
+    def __init__(self):
+        Rank.__init__(self, "9")
+
+
+class Ten(Rank):
+    def __init__(self):
+        Rank.__init__(self, "10")
+
+
+class Jack(Rank):
+    def __init__(self):
+        Rank.__init__(self, "J")
+
+
+class Queen(Rank):
+    def __init__(self):
+        Rank.__init__(self, "Q")
+
+
+class King(Rank):
+    def __init__(self):
+        Rank.__init__(self, "K")
+
+
+class Ace(Rank):
+    def __init__(self):
+        Rank.__init__(self, "A")
+
+
+RANKS = {
+    "Two": Two().__class__, "Three": Three().__class__,
+    "Four": Four().__class__, "Five": Five().__class__,
+    "Six": Six().__class__, "Seven": Seven().__class__,
+    "Eight": Eight().__class__, "Nine": Nine().__class__,
+    "Ten": Ten().__class__, "Jack": Jack().__class__,
+    "Queen": Queen().__class__, "King": King().__class__,
+    "Ace": Ace().__class__
+}
+
+
+class Suit:
+    def __init__(self, color):
+        self._color = color
+
+    def color(self):
+        return self._color
+
+    def __str__(self):
+        return self.__class__.__name__
+
+    def __eq__(self, other):
+        return self.__class__.__name__ == other.__class__.__name__
+
+
+class Hearts(Suit):
+    def __init__(self):
+        Suit.__init__(self, "red")
+
+
+class Diamonds(Suit):
+    def __init__(self):
+        Suit.__init__(self, "red")
+
+
+#Pika
+class Spades(Suit):
+    def __init__(self):
+        Suit.__init__(self, "black")
+
+
+#Spatia
+class Clubs(Suit):
+    def __init__(self):
+        Suit.__init__(self, "black")
+
+
+SUITS = {
+    "Hearts": Hearts().__class__, "Diamonds": Diamonds().__class__,
+    "Spades": Spades().__class__, "Clubs": Clubs().__class__
+}
+
+
+class Card:
+    def __init__(self, rank, suit):
+        self.__rank__ = rank
+        self.__suit__ = suit
+
+    @property
+    def rank(self):
+        return self.__rank__
+
+    @property
+    def suit(self):
+        return self.__suit__
+
+    def __str__(self):
+        return "{0} of {1}".format(str(self.rank()), str(self.suit()))
+
+    def __eq__(self, other):
+        return str(self) == str(other)
+
+    def __repr__(self):
+        return str(self)
+
+
+class CardCollection:
+    def __init__(self, collection=[]):
+        self._collection = collection
+
+    def draw(self, index):
+        card_on_index = self._collection[index]
+        self._collection.pop(index)
+        return card_on_index
+
+    def draw_from_top(self):
+        return self.draw(-1)
+
+    def draw_from_bottom(self):
+        return self.draw(0)
+
+    def top_card(self):
+        return self._collection[-1]
+
+    def bottom_card(self):
+        return self._collection[1]
+
+    def add(self, card):
+        self._collection.append(card)
+
+    def index(self, card):
+        for i in range(0, len(self._collection)):
+            if(card == self._collection[i]):
+                return i
+        raise ValueError("<Card {0}> is not in list".format(str(card)))
+
+    def __getitem__(self, key):
+        return self._collection[key]
+
+    def __iter__(self):
+        return iter(self._collection)
+
+    def __str__(self):
+        return str(self._collection)
+
+    def __repr__(self):
+        return repr(self._collection)
+
+    def __len__(self):
+        return len(self._collection)
+
+
+def card_comparer(card_one, card_two):
+    rank_priorities = {
+        RANKS["Ace"]: 1, RANKS["Two"]: 2, RANKS["Three"]: 3,
+        RANKS["Four"]: 4, RANKS["Five"]: 5, RANKS["Six"]: 6,
+        RANKS["Seven"]: 7, RANKS["Eight"]: 8, RANKS["Nine"]: 9,
+        RANKS["Ten"]: 10, RANKS["Jack"]: 11, RANKS["Queen"]: 12,
+        RANKS["King"]: 13
+    }
+    suit_priorities = {
+        SUITS["Diamonds"]: 4, SUITS["Clubs"]: 3,
+        SUITS["Hearts"]: 2, SUITS["Spades"]: 1
+    }
+    if suit_priorities[card_one.suit] < suit_priorities[card_two.suit]:
+        return 1
+    elif suit_priorities[card_one.suit] > suit_priorities[card_two.suit]:
+        return -1
+    if rank_priorities[card_one.rank] < rank_priorities[card_two.rank]:
+        return 1
+    elif rank_priorities[card_one.rank] > rank_priorities[card_two.rank]:
+        return -1
+    else:
+        return 0
+
+
+def StandardDeck():
+    standard_deck = CardCollection([])
+    for rank in RANKS:
+        for suit in SUITS:
+            standard_deck.add(Card(RANKS[rank], SUITS[suit]))
+    standard_deck = sorted(standard_deck, key=cmp_to_key(card_comparer))
+    return standard_deck
+
+
+def BeloteDeck():
+    cards_not_in_belote = {
+        "Two", "Three", "Four", "Five", "Six"
+    }
+    belote_deck = CardCollection([])
+    for rank in RANKS:
+        if rank not in cards_not_in_belote:
+            for suit in SUITS:
+                belote_deck.add(Card(RANKS[rank], SUITS[suit]))
+    belote_deck = sorted(belote_deck, key=cmp_to_key(card_comparer))
+    return belote_deck
+
+
+def SixtySixDeck():
+    cards_not_in_sixty_six = {
+        "Two", "Three", "Four", "Five", "Six", "Seven", "Eight"
+    }
+    sixty_six_deck = CardCollection([])
+    for rank in RANKS:
+        if rank not in cards_not_in_sixty_six:
+            for suit in SUITS:
+                sixty_six_deck.add(Card(RANKS[rank], SUITS[suit]))
+    sixty_six_deck = sorted(sixty_six_deck, key=cmp_to_key(card_comparer))
+    return sixty_six_deck
