Update day 16 solution
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -16,7 +16,6 @@ def get_next_packet(msg, start, packets, res=0):
|
|||||||
payload = None
|
payload = None
|
||||||
match type_id:
|
match type_id:
|
||||||
case 4:
|
case 4:
|
||||||
# literal
|
|
||||||
end = False
|
end = False
|
||||||
literal = 0
|
literal = 0
|
||||||
while not end:
|
while not end:
|
||||||
@@ -26,7 +25,6 @@ def get_next_packet(msg, start, packets, res=0):
|
|||||||
literal = (literal << 4) | int(msg[idx:idx + 4], 2)
|
literal = (literal << 4) | int(msg[idx:idx + 4], 2)
|
||||||
idx += 4
|
idx += 4
|
||||||
payload = literal
|
payload = literal
|
||||||
# print('l', version, type_id, literal)
|
|
||||||
case _:
|
case _:
|
||||||
length_id = int(msg[idx:idx + 1], 2)
|
length_id = int(msg[idx:idx + 1], 2)
|
||||||
idx += 1
|
idx += 1
|
||||||
@@ -35,13 +33,11 @@ def get_next_packet(msg, start, packets, res=0):
|
|||||||
if length_id:
|
if length_id:
|
||||||
length = int(msg[idx:idx + 11], 2)
|
length = int(msg[idx:idx + 11], 2)
|
||||||
idx += 11
|
idx += 11
|
||||||
# print('o', version, type_id, length_id, length)
|
|
||||||
for _ in range(length):
|
for _ in range(length):
|
||||||
idx, res = get_next_packet(msg, idx, payload, res)
|
idx, res = get_next_packet(msg, idx, payload, res)
|
||||||
else:
|
else:
|
||||||
length = int(msg[idx:idx + 15], 2)
|
length = int(msg[idx:idx + 15], 2)
|
||||||
idx += 15
|
idx += 15
|
||||||
# print('o', version, type_id, length_id, length)
|
|
||||||
next_idx = idx + length
|
next_idx = idx + length
|
||||||
while idx < next_idx:
|
while idx < next_idx:
|
||||||
idx, res = get_next_packet(msg, idx, payload, res)
|
idx, res = get_next_packet(msg, idx, payload, res)
|
||||||
|
|||||||
Reference in New Issue
Block a user