private void PopulateTree() { foreach (var value in Input.OrderByDescending(i => i)) { var node = new JoltNode(_joltTree, value, _pathTree); node.PopulateProceedingNodes(Input.ToList()); node.PopulatePathCount(); } }
public void PopulateProceedingNodes(List <int> input) { for (var i = 1; i < 4; i++) { if (!input.Contains(Value + i)) { continue; } if (_joltTree.TryGetNode(Value + i, out var existingNode)) { _proceedingNodes.Add(existingNode); continue; } var newNode = new JoltNode(_joltTree, Value + 1, _pathTree); newNode.PopulateProceedingNodes(input); _proceedingNodes.Add(newNode); } _joltTree.AddNode(this); }