Beispiel #1
0
        static Node BuildTree(NodeDataProvider input)
        {
            // Header
            int childCount = input.GetNext();
            int metadataCount = input.GetNext();

            Node newNode = new Node(childCount, metadataCount);
            for (int i = 0; i < childCount; i++)
            {
                newNode.Children[i] = BuildTree(input);
            }

            for (int i = 0; i < metadataCount; i++)
            {
                newNode.Metadata[i] = input.GetNext();
            }

            return newNode;
        }
Beispiel #2
0
 public static int Part2(NodeDataProvider input)
 {
     var root = BuildTree(input);
     return root.GetNodeValue();
 }
Beispiel #3
0
 public static int Part1(NodeDataProvider input)
 {
     var root = BuildTree(input);
     return root.SumMetadata();
 }