Решение на Тесте карти от Александър Михайлов

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

Към профила на Александър Михайлов

Резултати

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

Код

class Rank:
def __init__(self, symbol):
self.symbol = symbol
def __eq__(self,other):
return self.symbol == other.symbol
def __str__(self):
return str(self.symbol)
class Two(Rank):
def __init__(self):
Rank.__init__(self)
class Three(Rank):
def __init__(self):
Rank.__init__(self)
class Four(Rank):
def __init__(self):
Rank.__init__(self)
class Five(Rank):
def __init__(self):
Rank.__init__(self)
class Six(Rank):
def __init__(self):
Rank.__init__(self)
class Seven(Rank):
def __init__(self):
Rank.__init__(self)
class Eight(Rank):
def __init__(self):
Rank.__init__(self)
class Nine(Rank):
def __init__(self):
Rank.__init__(self)
class Ten(Rank):
def __init__(self):
Rank.__init__(self)
class Jack(Rank):
def __init__(self):
Rank.__init__(self)
class Queen(Rank):
def __init__(self):
Rank.__init__(self)
class King(Rank):
def __init__(self):
Rank.__init__(self)
class Ace(Rank):
def __init__(self):
Rank.__init__(self)
class Suit:
def __init__(self,color):
self.color = color
def __eq__(self,other):
return type(self).__name__ == type(other).__name__
def __str__(self):
return str(self.color)
class Hearts(Suit):
def __init__(self):
Suit.__init__(self)
class Clubs(Suit):
def __init__(self):
Suit.__init__(self)
class Diamonds(Suit):
def __init__(self):
Suit.__init__(self)
class Spades(Suit):
def __init__(self):
Suit.__init__(self)
RANKS = {'Two':Two,'Three':Three,'Four':Four,'Five':Five,'Six':Six,
'Seven':Seven,'Eight':Eight,'Nine':Nine,'Ten':Ten,'Jack':Jack,
'Queen':Queen,'King':King,'Ace':Ace}
SUITS = {'Hearts':Hearts,'Clubs':Clubs,'Diamonds':Diamonds,'Spades':Spades}
class Card:
def __init__(self, rank,suit):
super(Card, self).__setattr__('rank', rank())
super(Card, self).__setattr__('suit', suit())
def __eq__(self,other):
return self.rank == other.rank and self.suit == other.suit
def __str__(self):
return str(self.rank) and str(self.suit)
KEY_ORDERS=list(['King', 'Queen', 'Jack', 'Ten', 'Nine', 'Eight', 'Seven',
'Six', 'Five', 'Four', 'Three', 'Two', 'Ace'])
DECK = [Card(RANKS[R], SUITS[S]) for S in KEY_ORDERS for R in KEY_ORDERS]
class CardCollection:
def __init__(self,collection):
self.collection = collection
def __len__(self):
return len(CardCollection)
def draw(self, index):
return selfcollection.pop(index)
def draw_from_top(self):
return self.collection.pop(obj=len(collection))
def draw_from_bottom(self):
return collection.pop(obj=collection[0])
def top_card(self):
return self.collection[len(collection)]
def bottom_card(self):
return self.collection[0]
def add(self,card):
return self.collection.append(card)
def index(self,card):
return self.collection.index(card)

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

File "lib/language/python/runner.py", line 99, in main
    test = imp.load_source('test', test_module)
  File "/opt/python3.3/lib/python3.3/imp.py", line 109, in load_source
    return _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 869, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/tmp/d20140407-19315-1x63vgd/test.py", line 4, in <module>
    import solution
  File "/tmp/d20140407-19315-1x63vgd/solution.py", line 134, in <module>
    DECK = [Card(RANKS[R], SUITS[S]) for S in KEY_ORDERS for R in KEY_ORDERS]
  File "/tmp/d20140407-19315-1x63vgd/solution.py", line 134, in <listcomp>
    DECK = [Card(RANKS[R], SUITS[S]) for S in KEY_ORDERS for R in KEY_ORDERS]

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

Александър обнови решението на 26.03.2014 16:53 (преди над 10 години)

+class Rank:
+ def __init__(self, symbol):
+ self.symbol = symbol
+
+ def __eq__(self,other):
+ return self.symbol == other.symbol
+
+ def __str__(self):
+ return str(self.symbol)
+
+
+class Two(Rank):
+ def __init__(self):
+ Rank.__init__(self)
+
+
+
+class Three(Rank):
+ def __init__(self):
+ Rank.__init__(self)
+
+
+
+class Four(Rank):
+ def __init__(self):
+ Rank.__init__(self)
+
+
+
+class Five(Rank):
+ def __init__(self):
+ Rank.__init__(self)
+
+
+class Six(Rank):
+ def __init__(self):
+ Rank.__init__(self)
+
+
+class Seven(Rank):
+ def __init__(self):
+ Rank.__init__(self)
+
+
+class Eight(Rank):
+ def __init__(self):
+ Rank.__init__(self)
+
+
+class Nine(Rank):
+ def __init__(self):
+ Rank.__init__(self)
+
+
+class Ten(Rank):
+ def __init__(self):
+ Rank.__init__(self)
+
+
+class Jack(Rank):
+ def __init__(self):
+ Rank.__init__(self)
+
+
+class Queen(Rank):
+ def __init__(self):
+ Rank.__init__(self)
+
+
+class King(Rank):
+ def __init__(self):
+ Rank.__init__(self)
+
+
+class Ace(Rank):
+ def __init__(self):
+ Rank.__init__(self)
+
+
+class Suit:
+ def __init__(self,color):
+ self.color = color
+
+ def __eq__(self,other):
+ return type(self).__name__ == type(other).__name__
+
+ def __str__(self):
+ return str(self.color)
+
+
+class Hearts(Suit):
+ def __init__(self):
+ Suit.__init__(self)
+
+
+class Clubs(Suit):
+ def __init__(self):
+ Suit.__init__(self)
+
+
+class Diamonds(Suit):
+ def __init__(self):
+ Suit.__init__(self)
+
+
+class Spades(Suit):
+ def __init__(self):
+ Suit.__init__(self)
+
+
+RANKS = {'Two':Two,'Three':Three,'Four':Four,'Five':Five,'Six':Six,
+ 'Seven':Seven,'Eight':Eight,'Nine':Nine,'Ten':Ten,'Jack':Jack,
+ 'Queen':Queen,'King':King,'Ace':Ace}
+
+
+SUITS = {'Hearts':Hearts,'Clubs':Clubs,'Diamonds':Diamonds,'Spades':Spades}
+
+
+class Card:
+ def __init__(self, rank,suit):
+ super(Card, self).__setattr__('rank', Rank())
+ super(Card, self).__setattr__('suit', Suit())
+ self.__dict__[Rank] = suit
+ self.__dict__[Rank]= rank
+
+ def __eq__(self,other):
+ return self.rank == other.rank and self.suit == other.suit
+
+ def __str__(self):
+ return str(self.rank) and str(self.suit)
+
+
+KEY_ORDERS=list(['King', 'Queen', 'Jack', 'Ten', 'Nine', 'Eight', 'Seven',
+ 'Six', 'Five', 'Four', 'Three', 'Two', 'Ace'])
+
+DECK = [Card(RANKS[R], SUITS[S]) for S in KEY_ORDERS for R in KEY_ORDERS]
+
+
+class CardCollection:
+ def __init__(self,collection):
+ self.collection = collection
+
+ def __len__(self):
+ return len(CardCollection)
+
+ def draw(self, index):
+ return selfcollection.pop(index)
+
+ def draw_from_top(self):
+ return self.collection.pop(obj=len(collection))
+
+ def draw_from_bottom(self):
+ return collection.pop(obj=collection[0])
+
+ def top_card(self):
+ return self.collection[len(collection)]
+
+ def bottom_card(self):
+ return self.collection[0]
+
+ def add(self,card):
+ return self.collection.append(card)
+
+ def index(self,card):
+ return self.collection.index(card)

Александър обнови решението на 26.03.2014 16:56 (преди над 10 години)

class Rank:
def __init__(self, symbol):
self.symbol = symbol
def __eq__(self,other):
return self.symbol == other.symbol
def __str__(self):
return str(self.symbol)
class Two(Rank):
def __init__(self):
Rank.__init__(self)
class Three(Rank):
def __init__(self):
Rank.__init__(self)
class Four(Rank):
def __init__(self):
Rank.__init__(self)
class Five(Rank):
def __init__(self):
Rank.__init__(self)
class Six(Rank):
def __init__(self):
Rank.__init__(self)
class Seven(Rank):
def __init__(self):
Rank.__init__(self)
class Eight(Rank):
def __init__(self):
Rank.__init__(self)
class Nine(Rank):
def __init__(self):
Rank.__init__(self)
class Ten(Rank):
def __init__(self):
Rank.__init__(self)
class Jack(Rank):
def __init__(self):
Rank.__init__(self)
class Queen(Rank):
def __init__(self):
Rank.__init__(self)
class King(Rank):
def __init__(self):
Rank.__init__(self)
class Ace(Rank):
def __init__(self):
Rank.__init__(self)
class Suit:
def __init__(self,color):
self.color = color
def __eq__(self,other):
return type(self).__name__ == type(other).__name__
def __str__(self):
return str(self.color)
class Hearts(Suit):
def __init__(self):
Suit.__init__(self)
class Clubs(Suit):
def __init__(self):
Suit.__init__(self)
class Diamonds(Suit):
def __init__(self):
Suit.__init__(self)
class Spades(Suit):
def __init__(self):
Suit.__init__(self)
RANKS = {'Two':Two,'Three':Three,'Four':Four,'Five':Five,'Six':Six,
'Seven':Seven,'Eight':Eight,'Nine':Nine,'Ten':Ten,'Jack':Jack,
'Queen':Queen,'King':King,'Ace':Ace}
SUITS = {'Hearts':Hearts,'Clubs':Clubs,'Diamonds':Diamonds,'Spades':Spades}
class Card:
def __init__(self, rank,suit):
- super(Card, self).__setattr__('rank', Rank())
- super(Card, self).__setattr__('suit', Suit())
- self.__dict__[Rank] = suit
- self.__dict__[Rank]= rank
+ super(Card, self).__setattr__('rank', rank())
+ super(Card, self).__setattr__('suit', suit())
def __eq__(self,other):
return self.rank == other.rank and self.suit == other.suit
def __str__(self):
return str(self.rank) and str(self.suit)
KEY_ORDERS=list(['King', 'Queen', 'Jack', 'Ten', 'Nine', 'Eight', 'Seven',
'Six', 'Five', 'Four', 'Three', 'Two', 'Ace'])
DECK = [Card(RANKS[R], SUITS[S]) for S in KEY_ORDERS for R in KEY_ORDERS]
class CardCollection:
def __init__(self,collection):
self.collection = collection
def __len__(self):
return len(CardCollection)
def draw(self, index):
return selfcollection.pop(index)
def draw_from_top(self):
return self.collection.pop(obj=len(collection))
def draw_from_bottom(self):
return collection.pop(obj=collection[0])
def top_card(self):
return self.collection[len(collection)]
def bottom_card(self):
return self.collection[0]
def add(self,card):
return self.collection.append(card)
def index(self,card):
return self.collection.index(card)
+