Пример #1
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()));
        }
Пример #2
0
 private int GetTowerWeight(Day17Program root, ref int weight)
 {
     weight += root.progWeight;
     foreach (var child in root.GetChildren())
     {
         GetTowerWeight(child, ref weight);
     }
     return(weight);
 }