diff --git a/2022/python/day13.py b/2022/python/day13.py index 5a59149..85c2ccf 100644 --- a/2022/python/day13.py +++ b/2022/python/day13.py @@ -67,26 +67,23 @@ def check_group(left, right): return None def part2(rows): + two, six = 0, 0 rows = [eval(r) for r in rows if r] rows.append([[2]]) rows.append([[6]]) - print("---") - wat = {True: 1,False: -1,} 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) - - two = 0 - six = 0 - for idx, r in enumerate(s): + idx = 0 # ew 1 based lists, jeeeze AoC + for r in sorted(rows, key=functools.cmp_to_key(cmp), reverse=True): + idx += 1 if r == [[2]]: - two = idx+1 + two = idx if r == [[6]]: - six = idx+1 - break + six = idx + break # will come 2nd logically, so we can break here to save time print(two * six)