Ejemplo n.º 1
0
        public Day11Board Clone()
        {
            Day11Board newBoard = new Day11Board();

            newBoard.ElevatorFloor = ElevatorFloor;
            newBoard.FloorPieces   = new Dictionary <int, List <Day11Piece> >();
            foreach (var kvp in FloorPieces)
            {
                newBoard.FloorPieces.Add(kvp.Key, new List <Day11Piece>(kvp.Value));
            }

            //int totalPieces = newBoard.FloorPieces.Values.Aggregate(0, (i, list) => i + list.Count);
            //if (totalPieces != TotalPieces) throw new Exception("Something went wrong");

            return(newBoard);
        }
Ejemplo n.º 2
0
 public bool Equals(Day11Board other)
 {
     if (other.ElevatorFloor != ElevatorFloor)
     {
         return(false);
     }
     foreach (var kvp in FloorPieces)
     {
         foreach (Day11Piece piece in kvp.Value)
         {
             if (!other.FloorPieces[kvp.Key].Contains(piece))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Ejemplo n.º 3
0
        public List <Day11Board> GetAllBoards()
        {
            List <Day11Move> moves = GetAllMoves();
            var boardList          = new List <Day11Board>();

            foreach (Day11Move move in moves)
            {
                //// reject moves that are crap
                //if (move.ToFloor > move.FromFloor)
                //{
                //    //if (move.PieceCount != 2) continue;  // reject moving up without two pieces
                //}
                //if (move.FromFloor > move.ToFloor)
                //{
                ////    //if (FloorPieces[move.ToFloor].Count == 0) continue;  // reject move of pieces to empty lower floor
                //    if (move.PieceCount == 2) continue;  // reject move of two pieces down
                //}

                Day11Board newBoard = Clone();
                newBoard.ApplyMove(move);
                boardList.Add(newBoard);
            }
            return(boardList);
        }