Function advent_of_code_2021::day_16::parse_sub_packets [−][src]
Expand description
Parse the sub-packets section of an operation packet.
- Consume one bit indicating the mode of consuming sub packets
- If
0consume the next 15 bits as a bit length - If
1consume the nect 11 bits as a packet count
- If
- Consume one sub-packet at a time using
parse_packet.- Decrement the bit counter by the number of bits consumed, or the packet counter by
1as each packet is consumed. - Keep a running total of bits consumed.
- Decrement the bit counter by the number of bits consumed, or the packet counter by
- Return the list of parsed packets, and the total bits consumed
