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
|
||||
match type_id:
|
||||
case 4:
|
||||
# literal
|
||||
end = False
|
||||
literal = 0
|
||||
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)
|
||||
idx += 4
|
||||
payload = literal
|
||||
# print('l', version, type_id, literal)
|
||||
case _:
|
||||
length_id = int(msg[idx:idx + 1], 2)
|
||||
idx += 1
|
||||
@@ -35,13 +33,11 @@ def get_next_packet(msg, start, packets, res=0):
|
||||
if length_id:
|
||||
length = int(msg[idx:idx + 11], 2)
|
||||
idx += 11
|
||||
# print('o', version, type_id, length_id, length)
|
||||
for _ in range(length):
|
||||
idx, res = get_next_packet(msg, idx, payload, res)
|
||||
else:
|
||||
length = int(msg[idx:idx + 15], 2)
|
||||
idx += 15
|
||||
# print('o', version, type_id, length_id, length)
|
||||
next_idx = idx + length
|
||||
while idx < next_idx:
|
||||
idx, res = get_next_packet(msg, idx, payload, res)
|
||||
|
||||
Reference in New Issue
Block a user