Function advent_of_code_2021::day_16::parse_sub_packets[−][src]

fn parse_sub_packets(bits: &mut Vec<bool>) -> (Vec<Packet>, usize)
Expand description

Parse the sub-packets section of an operation packet.

  1. Consume one bit indicating the mode of consuming sub packets
    • If 0 consume the next 15 bits as a bit length
    • If 1 consume the nect 11 bits as a packet count
  2. 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 1 as each packet is consumed.
    • Keep a running total of bits consumed.
  3. Return the list of parsed packets, and the total bits consumed