Exemplo n.º 1
0
 private int GetTowerWeight(Day17Program root, ref int weight)
 {
     weight += root.progWeight;
     foreach (var child in root.GetChildren())
     {
         GetTowerWeight(child, ref weight);
     }
     return(weight);
 }
Exemplo n.º 2
0
        private int FindTowerImbalance(Day17Program prog)
        {
            var tot = prog.GetChildren().Select(a => a.balanceWeight).Max() % prog.GetChildren().Select(a => a.balanceWeight).Min() == 0;

            if (tot == true)
            {
                var heaviest1 = prog.GetParent().GetChildren().Select(a => a).OrderByDescending(a => a.balanceWeight).First();
                var lightest1 = prog.GetParent().GetChildren().Select(a => a).OrderBy(a => a.balanceWeight).First();
                return(heaviest1.progWeight - (heaviest1.balanceWeight - lightest1.balanceWeight));
            }
            return(FindTowerImbalance(prog.GetChildren().Select(a => a).OrderByDescending(a => a.balanceWeight).FirstOrDefault()));
        }
Exemplo n.º 3
0
 public void AssociateChild(Day17Program child)
 {
     this.progChildren.Add(child);
 }
Exemplo n.º 4
0
 public void AssociateParent(Day17Program parent)
 {
     this.progParent = parent;
 }