diff --git a/2023/day07/src/part1.py b/2023/day07/src/part1.py index c70d889..368e234 100644 --- a/2023/day07/src/part1.py +++ b/2023/day07/src/part1.py @@ -19,6 +19,7 @@ sames = [] for line in lines: bozo: [str] = line.split() same = get_same(bozo[0]) + same.update({"value": int(bozo[1])}) sames.append(same) @@ -29,10 +30,10 @@ def get_highest(cards1, cards2, i): return 2 if (i != 1 and len(cards1) > len(cards2)): return 1 - for k in range(min(len(cards2), len(cards1))): - if (cards2[k] == cards1[k]): + for char1, char2 in zip(cards1, cards2): + if (char2 == char1): continue - if (CARDS.index(cards1[k]) > CARDS.index(cards2[k])): + if (CARDS.index(char1) > CARDS.index(char2)): return 2 else: return 1 @@ -69,7 +70,8 @@ for i, line in enumerate(lines): key, value = line.split() for j, bozo in enumerate(sort): if (bozo.get("original", "") == key): - _value += (len(lines) - j) * int(value) + _value += (len(lines) - j) * bozo.get("value") + print(f'{(len(lines) - j)}, {bozo.get("value")}') break print(_value) \ No newline at end of file