Finished 2023-12-07 part1

This commit is contained in:
FrederikBaerentsen 2023-12-07 20:39:43 +01:00
parent bb1ec64afc
commit 22fe83f156

View File

@ -99,9 +99,63 @@ for idx,i in enumerate(d):
#d.sort()
d = sorted(d, key=lambda x: x[2])
#d = sorted(d, key=lambda x: x[2])
print()
def pp(x):
for p in x:
for q in p:
print(q,end='\t')
print()
x_1 = []
x_2 = []
x_3 = []
x_4 = []
x_5 = []
x_6 = []
x_7 = []
for y in d:
if y[2] == 1:
x_1.append(y+[[strength.index(c) for c in y[0]]])
if y[2] == 2:
x_2.append(y+[[strength.index(c) for c in y[0]]])
if y[2] == 3:
x_3.append(y+[[strength.index(c) for c in y[0]]])
if y[2] == 4:
x_4.append(y+[[strength.index(c) for c in y[0]]])
if y[2] == 5:
x_5.append(y+[[strength.index(c) for c in y[0]]])
if y[2] == 6:
x_6.append(y+[[strength.index(c) for c in y[0]]])
if y[2] == 7:
x_7.append(y+[[strength.index(c) for c in y[0]]])
x_1 = sorted(x_1, key=lambda x: x[3],reverse=True)
x_2 = sorted(x_2, key=lambda x: x[3],reverse=True)
x_3 = sorted(x_3, key=lambda x: x[3],reverse=True)
x_4 = sorted(x_4, key=lambda x: x[3],reverse=True)
x_5 = sorted(x_5, key=lambda x: x[3],reverse=True)
x_6 = sorted(x_6, key=lambda x: x[3],reverse=True)
x_7 = sorted(x_7, key=lambda x: x[3],reverse=True)
#def sortkey_part1(hand):
# return [score_hand(hand)] + ['23456789TJQKA'.index(c) for c in hand]
e = []
X = [x_1,x_2,x_3,x_4,x_5,x_6,x_7]
for n in X:
for m in n:
e.append(m)
pprint(e)
"""
pprint(d)
print()
for idx,i in enumerate(d):
@ -118,13 +172,11 @@ for idx,i in enumerate(d):
if strength.find(tmp[x]) < strength.find(tmp2[x]):
d[idx],d[idx+1] = d[idx+1],d[idx]
break
"""
result = 0
for idx,i in enumerate(d):
for idx,i in enumerate(e):
x = i[1]
result += (int(x) * (idx+1))
pprint(d)
print(result)