Skip to content

Commit 1813e91

Browse files
committed
simplified
1 parent 5656445 commit 1813e91

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

2022/13.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,14 @@ def cmp(left, right):
2626
]
2727

2828
print(sum(
29-
i
30-
for i, (left, right) in enumerate(zip(packets[::2], packets[1::2]), start=1)
29+
i + 1
30+
for i, (left, right) in enumerate(zip(packets[::2], packets[1::2]))
3131
if cmp(left, right) <= 0
3232
))
3333

3434
two_six = [[[2]], [[6]]]
3535
print(prod(
36-
i
37-
for i, packet in enumerate(
38-
sorted(packets + two_six, key=cmp_to_key(cmp)),
39-
start=1
40-
)
36+
i + 1
37+
for i, packet in enumerate(sorted(packets + two_six, key=cmp_to_key(cmp)))
4138
if packet in two_six
4239
))

0 commit comments

Comments
 (0)