Skip to content

Commit

Permalink
forgot to add
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroQLi committed Nov 22, 2024
1 parent fedf1ee commit 085e59b
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions AOC_7.P1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
f = open('test.txt', 'r').readlines()

labels=['A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2']

kind5, kind4, FullH, kind3, twoP, oneP, HC = [],[],[],[],[],[],[]


for i in f:
hand, bid = i.split(' ')

uhand = set(hand)
print(hand)

if len(uhand) == 1:
kind5.append(hand)
continue

if len(uhand) == 2:
x = hand[0]
if hand.count(x) == 4 or hand.count(x)== 1:
kind4.append(hand)
continue
else:
FullH.append(hand)
continue

if len(uhand) == 3:
y = hand[0]
if hand.count(y) == 3:
kind3.append(hand)
continue
elif hand.count(y) == 2:
twoP.append(hand)
continue
else:
if hand.count(hand[1]) == 3:
kind3.append(hand)
continue
else:
twoP.append(hand)
continue

elif len(uhand) == 4:
oneP.append(hand)
continue

elif len(uhand) == 5:
HC.append(hand)
continue
types = list((kind5, kind4, FullH, kind3, twoP, oneP, HC))

for kind in types:
if len(kind) == 1:
print(kind)
else:
for i, j in enumerate(kind):
print(i,j)
if labels.index(j[0]) > labels.index(kind[i+1][0]):
print(j)
continue

0 comments on commit 085e59b

Please sign in to comment.