part2 (2596B)
1--- Part Two --- 2 3Now that you have the structure of your transmission decoded, you can calculate the value of the 4expression it represents. 5 6Literal values (type ID 4) represent a single number as described above. The remaining type IDs are 7more interesting: 8 9 10 - Packets with type ID 0 are [1m[97msum[0m packets - their value is the sum of the values of their 11sub-packets. If they only have a single sub-packet, their value is the value of the sub-packet. 12 13 - Packets with type ID 1 are [1m[97mproduct[0m packets - their value is the result of multiplying together 14the values of their sub-packets. If they only have a single sub-packet, their value is the value of 15the sub-packet. 16 17 - Packets with type ID 2 are [1m[97mminimum[0m packets - their value is the minimum of the values of their 18sub-packets. 19 20 - Packets with type ID 3 are [1m[97mmaximum[0m packets - their value is the maximum of the values of their 21sub-packets. 22 23 - Packets with type ID 5 are [1m[97mgreater than[0m packets - their value is [1m[97m1[0m if the value of the first 24sub-packet is greater than the value of the second sub-packet; otherwise, their value is 25[1m[97m0[0m. These packets always have exactly two sub-packets. 26 27 - Packets with type ID 6 are [1m[97mless than[0m packets - their value is [1m[97m1[0m if the value of the first 28sub-packet is less than the value of the second sub-packet; otherwise, their value is 29[1m[97m0[0m. These packets always have exactly two sub-packets. 30 31 - Packets with type ID 7 are [1m[97mequal to[0m packets - their value is [1m[97m1[0m if the value of the first 32sub-packet is equal to the value of the second sub-packet; otherwise, their value is [1m[97m0[0m. These 33packets always have exactly two sub-packets. 34 35 36Using these rules, you can now work out the value of the outermost packet in your BITS transmission. 37 38For example: 39 40 41 - C200B40A82 finds the sum of 1 and 2, resulting in the value [1m[97m3[0m. 42 43 - 04005AC33890 finds the product of 6 and 9, resulting in the value [1m[97m54[0m. 44 45 - 880086C3E88112 finds the minimum of 7, 8, and 9, resulting in the value [1m[97m7[0m. 46 47 - CE00C43D881120 finds the maximum of 7, 8, and 9, resulting in the value [1m[97m9[0m. 48 49 - D8005AC2A8F0 produces 1, because 5 is less than 15. 50 51 - F600BC2D8F produces 0, because 5 is not greater than 15. 52 53 - 9C005AC2F8F0 produces 0, because 5 is not equal to 15. 54 55 - 9C0141080250320F1802104A08 produces 1, because 1 + 3 = 2 * 2. 56 57 58[1m[97mWhat do you get if you evaluate the expression represented by your hexadecimal-encoded BITS 59transmission?[0m 60 61