cleanup more
This commit is contained in:
parent
0e70268aa3
commit
0a168874f0
@ -67,26 +67,23 @@ def check_group(left, right):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def part2(rows):
|
def part2(rows):
|
||||||
|
two, six = 0, 0
|
||||||
rows = [eval(r) for r in rows if r]
|
rows = [eval(r) for r in rows if r]
|
||||||
rows.append([[2]])
|
rows.append([[2]])
|
||||||
rows.append([[6]])
|
rows.append([[6]])
|
||||||
print("---")
|
|
||||||
|
|
||||||
wat = {True: 1,False: -1,}
|
|
||||||
|
|
||||||
def cmp(x, y):
|
def cmp(x, y):
|
||||||
return wat[check_group(x, y)]
|
return {True: 1,False: -1,}[check_group(x, y)]
|
||||||
|
|
||||||
s = sorted(rows, key=functools.cmp_to_key(cmp), reverse=True)
|
idx = 0 # ew 1 based lists, jeeeze AoC
|
||||||
|
for r in sorted(rows, key=functools.cmp_to_key(cmp), reverse=True):
|
||||||
two = 0
|
idx += 1
|
||||||
six = 0
|
|
||||||
for idx, r in enumerate(s):
|
|
||||||
if r == [[2]]:
|
if r == [[2]]:
|
||||||
two = idx+1
|
two = idx
|
||||||
if r == [[6]]:
|
if r == [[6]]:
|
||||||
six = idx+1
|
six = idx
|
||||||
break
|
break # will come 2nd logically, so we can break here to save time
|
||||||
|
|
||||||
print(two * six)
|
print(two * six)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user