41 lines
896 B
Python
Executable File
41 lines
896 B
Python
Executable File
#!/usr/bin/env python
|
|
|
|
class HandClass:
|
|
def __init__(self, bid, cards):
|
|
self.bid = bid
|
|
self.cards = cards
|
|
x = [*cards]
|
|
x.sort(key=self.cardumber, reverse=True)
|
|
self.sorted = x
|
|
|
|
def cardumber(self, x: str):
|
|
if x.isdigit():
|
|
return int(x)
|
|
if x == "T":
|
|
return 10
|
|
if x == 'J':
|
|
return 11
|
|
if x == 'Q':
|
|
return 12
|
|
if x == 'K':
|
|
return 13
|
|
if x == 'A':
|
|
return 14
|
|
return 0
|
|
|
|
def __str__(self):
|
|
return f"Cards: {self.cards} Bid: {self.bid}, sorted: {self.sorted}"
|
|
|
|
def __repr__(self):
|
|
return str(self)
|
|
|
|
|
|
with open("data.txt") as file:
|
|
lines = [line.rstrip() for line in file]
|
|
|
|
hands = []
|
|
for line in lines:
|
|
halves = line.split(' ')
|
|
hands.append(HandClass(halves[1], halves[0]))
|
|
print(hands[-1])
|