part1 (2056B)
1--- Day 8: Memory Maneuver --- 2 3The sleigh is much easier to pull than you'd expect for something its weight. Unfortunately, neither 4you nor the Elves know which way the North Pole is from here. 5 6You check your wrist device for anything that might help. It seems to have some kind of navigation 7system! Activating the navigation system produces more bad news: "Failed to start navigation 8system. Could not read software license file." 9 10The navigation system's license file consists of a list of numbers (your puzzle input). The numbers 11define a data structure which, when processed, produces some kind of tree that can be used to 12calculate the license number. 13 14The [1m[97mtree[0m is made up of [1m[97mnodes[0m; a single, outermost node forms the tree's [1m[97mroot[0m, and it contains all 15other nodes in the tree (or contains nodes that contain nodes, and so on). 16 17Specifically, a node consists of: 18 19 20 - A [1m[97mheader[0m, which is always exactly two numbers: 21 22 - The quantity of child nodes. 23 24 - The quantity of metadata entries. 25 26 27 - Zero or more [1m[97mchild nodes[0m (as specified in the header). 28 29 - One or more [1m[97mmetadata entries[0m (as specified in the header). 30 31 32 33Each child node is itself a node that has its own header, child nodes, and metadata. For example: 34 352 3 0 3 10 11 12 1 1 0 1 99 2 1 1 2 36A---------------------------------- 37 B----------- C----------- 38 D----- 39 40In this example, each node of the tree is also marked with an underline starting with a letter for 41easier identification. In it, there are four nodes: 42 43 44 - A, which has 2 child nodes (B, C) and 3 metadata entries (1, 1, 2). 45 46 - B, which has 0 child nodes and 3 metadata entries (10, 11, 12). 47 48 - C, which has 1 child node (D) and 1 metadata entry (2). 49 50 - D, which has 0 child nodes and 1 metadata entry (99). 51 52 53The first check done on the license file is to simply add up all of the metadata entries. In this 54example, that sum is 1+1+2+10+11+12+2+99=[1m[97m138[0m. 55 56[1m[97mWhat is the sum of all metadata entries?[0m 57 58