From a8a2b4608a171fcb77623559ba946daeec2699d8 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Tue, 13 Dec 2022 14:33:55 +0100 Subject: day 13 part 2 --- 22.13/main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/22.13/main.py b/22.13/main.py index 25b09a1..1abc9d1 100644 --- a/22.13/main.py +++ b/22.13/main.py @@ -1,5 +1,6 @@ import json import sys +from functools import cmp_to_key lines = [json.loads(s) for s in sys.stdin.readlines() if s.strip()] @@ -28,3 +29,8 @@ for i in range(0, len(lines), 2): if cmp(a,b) != 1: partOne += i//2+1 print(partOne) + +divs = [ [[2]], [[6]] ] +lines += divs +lines = sorted(lines, key=cmp_to_key(cmp)) +print((lines.index(divs[0]) + 1) * (lines.index(divs[1]) + 1)) -- cgit 1.4.1-2-gfad0