public void DefinePosition3()
        {
            int column = InternalFunctions.GetNumberFromLetter(InternalFunctions.GetLetterFromPhoneticLetter(Positions[2].Split('-')[0])) - 1;
            int row    = int.Parse(Positions[2].Split('-')[1]) - 1;

            int count = 0;

            for (int i = 0; i < 6; i++)
            {
                for (int j = 0; j < 6; j++)
                {
                    if (Chessboard[i, j].Piece == "rook")
                    {
                        count++;
                    }
                }
            }

            if (count < 2)
            {
                Chessboard[row, column].Piece = "queen";
            }
            else
            {
                Chessboard[row, column].Piece = "king";
            }

            ChangeOtherTiles(row, column, Chessboard[row, column].Piece);
        }
        public override string Command(Bomb bomb, string command)
        {
            var row    = -1;
            var column = -1;

            foreach (var word in command.Split(' '))
            {
                if (InternalFunctions.GetLetterFromPhoneticLetter(word) != "")
                {
                    column = InternalFunctions.GetNumberFromLetter(InternalFunctions.GetLetterFromPhoneticLetter(word)) - 1;
                }
                if (InternalFunctions.IsNumber(word))
                {
                    row = int.Parse(word) - 1;
                }
                if (row != -1 && column != -1)
                {
                    Positions.Add(InternalFunctions.GetPhoneticLetterFromLetter(InternalFunctions.GetLetterFromNumber(column + 1)) + '-' + (row + 1));
                    row    = -1;
                    column = -1;
                }
            }

            return(Solve(bomb));
        }
        public void DefinePosition4()
        {
            int column = InternalFunctions.GetNumberFromLetter(InternalFunctions.GetLetterFromPhoneticLetter(Positions[3].Split('-')[0])) - 1;
            int row    = int.Parse(Positions[3].Split('-')[1]) - 1;

            Chessboard[row, column].Piece = "rook";

            ChangeOtherTiles(row, column, Chessboard[row, column].Piece);
        }
        public void DefinePosition5()
        {
            int column = InternalFunctions.GetNumberFromLetter(InternalFunctions.GetLetterFromPhoneticLetter(Positions[4].Split('-')[0])) - 1;
            int row    = int.Parse(Positions[4].Split('-')[1]) - 1;

            if (Chessboard[row, column].WhiteSpace)
            {
                Chessboard[row, column].Piece = "queen";
            }
            else
            {
                Chessboard[row, column].Piece = "rook";
            }

            ChangeOtherTiles(row, column, Chessboard[row, column].Piece);
        }
        public void DefinePosition2(bool bombSerialIsOdd)
        {
            int column = InternalFunctions.GetNumberFromLetter(InternalFunctions.GetLetterFromPhoneticLetter(Positions[1].Split('-')[0])) - 1;
            int row    = int.Parse(Positions[1].Split('-')[1]) - 1;

            if (bombSerialIsOdd)
            {
                Chessboard[row, column].Piece = "rook";
            }
            else
            {
                Chessboard[row, column].Piece = "knight";
            }

            ChangeOtherTiles(row, column, Chessboard[row, column].Piece);
        }
        public void DefinePosition1()
        {
            int column  = InternalFunctions.GetNumberFromLetter(InternalFunctions.GetLetterFromPhoneticLetter(Positions[0].Split('-')[0])) - 1;
            int row     = int.Parse(Positions[0].Split('-')[1]) - 1;
            int column5 = InternalFunctions.GetNumberFromLetter(InternalFunctions.GetLetterFromPhoneticLetter(Positions[4].Split('-')[0])) - 1;
            int row5    = int.Parse(Positions[4].Split('-')[1]) - 1;

            if (Chessboard[row5, column5].Piece == "queen")
            {
                Chessboard[row, column].Piece = "king";
            }
            else
            {
                Chessboard[row, column].Piece = "bishop";
            }

            ChangeOtherTiles(row, column, Chessboard[row, column].Piece);
        }
        public void AddCharacter(string input)
        {
            var splittedInput = input.Split(' ');
            var morse         = "";

            foreach (var splitInput in splittedInput)
            {
                if (splitInput == "dash" || splitInput == "dot" || splitInput == "next")
                {
                    morse += splitInput + " ";
                }
            }

            morse = morse.Trim();

            if (input.Contains("first"))
            {
                RecievedCharacter1      = InternalFunctions.GetLetterFromMorse(morse);
                RecievedCharacterValue1 = InternalFunctions.GetNumberFromLetter(RecievedCharacter1);
                return;
            }
            if (input.Contains("second"))
            {
                RecievedCharacter2      = InternalFunctions.GetLetterFromMorse(morse);
                RecievedCharacterValue2 = InternalFunctions.GetNumberFromLetter(RecievedCharacter2);
                return;
            }
            if (input.Contains("third"))
            {
                RecievedCharacter3      = InternalFunctions.GetLetterFromMorse(morse);
                RecievedCharacterValue3 = InternalFunctions.GetNumberFromLetter(RecievedCharacter3);
                return;
            }
            if (input.Contains("last"))
            {
                RecievedCharacter3      = InternalFunctions.GetLetterFromMorse(morse);
                RecievedCharacterValue3 = InternalFunctions.GetNumberFromLetter(RecievedCharacter3);
                return;
            }
        }
        public void DefinePosition6()
        {
            int column      = InternalFunctions.GetNumberFromLetter(InternalFunctions.GetLetterFromPhoneticLetter(Positions[5].Split('-')[0])) - 1;
            int row         = int.Parse(Positions[5].Split('-')[1]) - 1;
            int queenCount  = 0;
            int knightCount = 0;

            for (int i = 0; i < 6; i++)
            {
                for (int j = 0; j < 6; j++)
                {
                    if (Chessboard[i, j].Piece == "queen")
                    {
                        queenCount++;
                    }
                    if (Chessboard[i, j].Piece == "knight")
                    {
                        knightCount++;
                    }
                }
            }

            if (queenCount == 0)
            {
                Chessboard[row, column].Piece = "queen";
            }
            else if (knightCount == 0)
            {
                Chessboard[row, column].Piece = "knight";
            }
            else
            {
                Chessboard[row, column].Piece = "bishop";
            }

            ChangeOtherTiles(row, column, Chessboard[row, column].Piece);
        }
        public override string Solve(Bomb bomb)
        {
            SetInitialPosition(bomb);

            if (StartPosition == null)
            {
                return("Cut all the wires on descending numeral order.");
            }

            var result = "Cut wires ";
            var letter = bomb.GetSerialCharacters()[0];

            while (!StartPosition.Resolved)
            {
                if (!StartPosition.Previous.Resolved || (ReversedOrder && !StartPosition.Next.Resolved))
                {
                    result += StartPosition.Start + "-" + StartPosition.End + ", ";
                    StartPosition.Resolved    = true;
                    StartPosition.ShouldBeCut = true;
                    if (ReversedOrder)
                    {
                        StartPosition = StartPosition.Previous;
                    }
                    else
                    {
                        StartPosition = StartPosition.Next;
                    }
                    continue;
                }

                switch (letter.ToUpper())
                {
                case "A":
                case "N":
                {
                    if (StartPosition.Previous.Color != "yellow" && StartPosition.Previous.Color != "blue" && StartPosition.Previous.Color != "green")
                    {
                        StartPosition.ShouldBeCut = true;
                        result += StartPosition.Start + "-" + StartPosition.End + ", ";
                    }
                    if (ReversedOrder)
                    {
                        StartPosition = StartPosition.Previous;
                        var number = InternalFunctions.GetNumberFromLetter(letter) - 1;
                        if (number == -1)
                        {
                            number = 26;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    else
                    {
                        StartPosition = StartPosition.Next;
                        var number = InternalFunctions.GetNumberFromLetter(letter) + 1;
                        if (number == 27)
                        {
                            number = 1;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    break;
                }

                case "B":
                case "O":
                {
                    if (StartPosition.Start % 2 == 0)
                    {
                        result += StartPosition.Start + "-" + StartPosition.End + ", ";
                        StartPosition.ShouldBeCut = true;
                    }
                    if (ReversedOrder)
                    {
                        StartPosition = StartPosition.Previous;
                        var number = InternalFunctions.GetNumberFromLetter(letter) - 1;
                        if (number == -1)
                        {
                            number = 26;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    else
                    {
                        StartPosition = StartPosition.Next;
                        var number = InternalFunctions.GetNumberFromLetter(letter) + 1;
                        if (number == 27)
                        {
                            number = 1;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    break;
                }

                case "C":
                case "P":
                {
                    if (StartPosition.Previous.ShouldBeCut)
                    {
                        result += StartPosition.Start + "-" + StartPosition.End + ", ";
                        StartPosition.ShouldBeCut = true;
                    }
                    if (ReversedOrder)
                    {
                        StartPosition = StartPosition.Previous;
                        var number = InternalFunctions.GetNumberFromLetter(letter) - 1;
                        if (number == -1)
                        {
                            number = 26;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    else
                    {
                        StartPosition = StartPosition.Next;
                        var number = InternalFunctions.GetNumberFromLetter(letter) + 1;
                        if (number == 27)
                        {
                            number = 1;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    break;
                }

                case "D":
                case "Q":
                {
                    if (StartPosition.Previous.Color == "red" || StartPosition.Previous.Color == "blue" || StartPosition.Previous.Color == "black")
                    {
                        result += StartPosition.Start + "-" + StartPosition.End + ", ";
                        StartPosition.ShouldBeCut = true;
                    }
                    if (ReversedOrder)
                    {
                        StartPosition = StartPosition.Previous;
                        var number = InternalFunctions.GetNumberFromLetter(letter) - 1;
                        if (number == -1)
                        {
                            number = 26;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    else
                    {
                        StartPosition = StartPosition.Next;
                        var number = InternalFunctions.GetNumberFromLetter(letter) + 1;
                        if (number == 27)
                        {
                            number = 1;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    break;
                }

                case "E":
                case "R":
                {
                    var list = new List <string>();
                    if (!list.Exists(x => x == StartPosition.Previous.Previous.Previous.Color))
                    {
                        list.Add(StartPosition.Previous.Previous.Previous.Color);
                    }
                    if (!list.Exists(x => x == StartPosition.Previous.Previous.Color))
                    {
                        list.Add(StartPosition.Previous.Previous.Color);
                    }
                    if (!list.Exists(x => x == StartPosition.Previous.Color))
                    {
                        list.Add(StartPosition.Previous.Color);
                    }
                    if (list.Count == 2)
                    {
                        result += StartPosition.Start + "-" + StartPosition.End + ", ";
                        StartPosition.ShouldBeCut = true;
                    }
                    if (ReversedOrder)
                    {
                        StartPosition = StartPosition.Previous;
                        var number = InternalFunctions.GetNumberFromLetter(letter) - 1;
                        if (number == -1)
                        {
                            number = 26;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    else
                    {
                        StartPosition = StartPosition.Next;
                        var number = InternalFunctions.GetNumberFromLetter(letter) + 1;
                        if (number == 27)
                        {
                            number = 1;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    break;
                }

                case "F":
                case "S":
                {
                    if ((StartPosition.Previous.Previous.Color == StartPosition.Color && StartPosition.Previous.Color != StartPosition.Color) || (StartPosition.Previous.Color == StartPosition.Color && StartPosition.Previous.Previous.Color != StartPosition.Color))
                    {
                        result += StartPosition.Start + "-" + StartPosition.End + ", ";
                        StartPosition.ShouldBeCut = true;
                    }
                    if (ReversedOrder)
                    {
                        StartPosition = StartPosition.Previous;
                        var number = InternalFunctions.GetNumberFromLetter(letter) - 1;
                        if (number == -1)
                        {
                            number = 26;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    else
                    {
                        StartPosition = StartPosition.Next;
                        var number = InternalFunctions.GetNumberFromLetter(letter) + 1;
                        if (number == 27)
                        {
                            number = 1;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    break;
                }

                case "G":
                case "T":
                {
                    if (StartPosition.Previous.Color == "yellow" || StartPosition.Previous.Color == "white" || StartPosition.Previous.Color == "green")
                    {
                        result += StartPosition.Start + "-" + StartPosition.End + ", ";
                        StartPosition.ShouldBeCut = true;
                    }
                    if (ReversedOrder)
                    {
                        StartPosition = StartPosition.Previous;
                        var number = InternalFunctions.GetNumberFromLetter(letter) - 1;
                        if (number == -1)
                        {
                            number = 26;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    else
                    {
                        StartPosition = StartPosition.Next;
                        var number = InternalFunctions.GetNumberFromLetter(letter) + 1;
                        if (number == 27)
                        {
                            number = 1;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    break;
                }

                case "H":
                case "U":
                {
                    if (!StartPosition.Previous.ShouldBeCut)
                    {
                        result += StartPosition.Start + "-" + StartPosition.End + ", ";
                        StartPosition.ShouldBeCut = true;
                    }
                    if (ReversedOrder)
                    {
                        StartPosition = StartPosition.Previous;
                        var number = InternalFunctions.GetNumberFromLetter(letter) - 1;
                        if (number == -1)
                        {
                            number = 26;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    else
                    {
                        StartPosition = StartPosition.Next;
                        var number = InternalFunctions.GetNumberFromLetter(letter) + 1;
                        if (number == 27)
                        {
                            number = 1;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    break;
                }

                case "I":
                case "V":
                {
                    if (StartPosition.Previous.Start + 1 != StartPosition.Start)
                    {
                        result += StartPosition.Start + "-" + StartPosition.End + ", ";
                        StartPosition.ShouldBeCut = true;
                    }
                    if (ReversedOrder)
                    {
                        StartPosition = StartPosition.Previous;
                        var number = InternalFunctions.GetNumberFromLetter(letter) - 1;
                        if (number == -1)
                        {
                            number = 26;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    else
                    {
                        StartPosition = StartPosition.Next;
                        var number = InternalFunctions.GetNumberFromLetter(letter) + 1;
                        if (number == 27)
                        {
                            number = 1;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    break;
                }

                case "J":
                case "W":
                {
                    if (StartPosition.Previous.Color != "white" || StartPosition.Previous.Color != "black" || StartPosition.Previous.Color != "red")
                    {
                        result += StartPosition.Start + "-" + StartPosition.End + ", ";
                        StartPosition.ShouldBeCut = true;
                    }
                    if (ReversedOrder)
                    {
                        StartPosition = StartPosition.Previous;
                        var number = InternalFunctions.GetNumberFromLetter(letter) - 1;
                        if (number == -1)
                        {
                            number = 26;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    else
                    {
                        StartPosition = StartPosition.Next;
                        var number = InternalFunctions.GetNumberFromLetter(letter) + 1;
                        if (number == 27)
                        {
                            number = 1;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    break;
                }

                case "K":
                case "X":
                {
                    if (StartPosition.Previous.Previous.Color != StartPosition.Previous.Color)
                    {
                        result += StartPosition.Start + "-" + StartPosition.End + ", ";
                        StartPosition.ShouldBeCut = true;
                    }
                    if (ReversedOrder)
                    {
                        StartPosition = StartPosition.Previous;
                        var number = InternalFunctions.GetNumberFromLetter(letter) - 1;
                        if (number == -1)
                        {
                            number = 26;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    else
                    {
                        StartPosition = StartPosition.Next;
                        var number = InternalFunctions.GetNumberFromLetter(letter) + 1;
                        if (number == 27)
                        {
                            number = 1;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    break;
                }

                case "L":
                case "Y":
                {
                    if (!(StartPosition.Previous.End <= 6))
                    {
                        result += StartPosition.Start + "-" + StartPosition.End + ", ";
                        StartPosition.ShouldBeCut = true;
                    }
                    if (ReversedOrder)
                    {
                        StartPosition = StartPosition.Previous;
                        var number = InternalFunctions.GetNumberFromLetter(letter) - 1;
                        if (number == -1)
                        {
                            number = 26;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    else
                    {
                        StartPosition = StartPosition.Next;
                        var number = InternalFunctions.GetNumberFromLetter(letter) + 1;
                        if (number == 27)
                        {
                            number = 1;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    break;
                }

                case "M":
                case "Z":
                {
                    var list = new List <string> {
                        "white", "black"
                    };
                    if (!list.Contains(StartPosition.Previous.Previous.Color) || !list.Contains(StartPosition.Previous.Color))
                    {
                        result += StartPosition.Start + "-" + StartPosition.End + ", ";
                        StartPosition.ShouldBeCut = true;
                    }
                    if (ReversedOrder)
                    {
                        StartPosition = StartPosition.Previous;
                        var number = InternalFunctions.GetNumberFromLetter(letter) - 1;
                        if (number == -1)
                        {
                            number = 26;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    else
                    {
                        StartPosition = StartPosition.Next;
                        var number = InternalFunctions.GetNumberFromLetter(letter) + 1;
                        if (number == 27)
                        {
                            number = 1;
                        }
                        letter = InternalFunctions.GetLetterFromNumber(number);
                    }
                    break;
                }
                }

                StartPosition.Previous.Resolved = true;
            }
            Solved = true;
            return(result.Substring(0, result.Length - 2) + ".");
        }
        public string Solution(Bomb bomb)
        {
            PairCharacterValue1 = InternalFunctions.GetNumberFromLetter(bomb.GetSerialCharacterAtPosition(4));
            PairCharacterValue2 = InternalFunctions.GetNumberFromLetter(bomb.GetSerialCharacterAtPosition(5));

            ChangeCharacterValue(bomb.GetLitIndicatorsWithLetter(RecievedCharacter1), 1);
            ChangeCharacterValue(bomb.GetLitIndicatorsWithLetter(RecievedCharacter2), 1);
            ChangeCharacterValue(bomb.GetLitIndicatorsWithLetter(RecievedCharacter3), 1);
            ChangeCharacterValue(bomb.GetUnlitIndicatorsWithLetter(RecievedCharacter1), 2);
            ChangeCharacterValue(bomb.GetUnlitIndicatorsWithLetter(RecievedCharacter2), 2);
            ChangeCharacterValue(bomb.GetUnlitIndicatorsWithLetter(RecievedCharacter3), 2);

            if (InternalFunctions.IsSquare(PairCharacterValue1 + PairCharacterValue2))
            {
                ChangeCharacterValue(4, 1);
            }
            else
            {
                ChangeCharacterValue(-4, 2);
            }

            if (RecievedCharacterValue1 > RecievedCharacterValue2)
            {
                if (RecievedCharacterValue1 > RecievedCharacterValue3)
                {
                    ChangeCharacterValue(RecievedCharacterValue1, 1);
                }
                else
                {
                    ChangeCharacterValue(RecievedCharacterValue3, 1);
                }
            }
            else
            if (RecievedCharacterValue2 > RecievedCharacterValue3)
            {
                ChangeCharacterValue(RecievedCharacterValue2, 1);
            }
            else
            {
                ChangeCharacterValue(RecievedCharacterValue3, 1);
            }

            if (InternalFunctions.IsPrime(RecievedCharacterValue1))
            {
                ChangeCharacterValue(-RecievedCharacterValue1, 1);
            }
            if (InternalFunctions.IsPrime(RecievedCharacterValue2))
            {
                ChangeCharacterValue(-RecievedCharacterValue2, 1);
            }
            if (InternalFunctions.IsPrime(RecievedCharacterValue3))
            {
                ChangeCharacterValue(-RecievedCharacterValue3, 1);
            }

            if (InternalFunctions.IsSquare(RecievedCharacterValue1))
            {
                ChangeCharacterValue(-RecievedCharacterValue1, 2);
            }
            if (InternalFunctions.IsSquare(RecievedCharacterValue2))
            {
                ChangeCharacterValue(-RecievedCharacterValue2, 2);
            }
            if (InternalFunctions.IsSquare(RecievedCharacterValue3))
            {
                ChangeCharacterValue(-RecievedCharacterValue3, 2);
            }

            if (bomb.HasManyBatteries(1))
            {
                if (RecievedCharacterValue1 % bomb.GetBatteries() == 0)
                {
                    ChangeCharacterValue(-RecievedCharacterValue1, 1); ChangeCharacterValue(-RecievedCharacterValue1, 2);
                }
                if (RecievedCharacterValue2 % bomb.GetBatteries() == 0)
                {
                    ChangeCharacterValue(-RecievedCharacterValue2, 1); ChangeCharacterValue(-RecievedCharacterValue2, 2);
                }
                if (RecievedCharacterValue3 % bomb.GetBatteries() == 0)
                {
                    ChangeCharacterValue(-RecievedCharacterValue3, 1); ChangeCharacterValue(-RecievedCharacterValue3, 2);
                }
            }

            if (PairCharacterValue1 == PairCharacterValue2)
            {
                return(InternalFunctions.GetMorseFromLetter(InternalFunctions.GetLetterFromNumber(PairCharacterValue1)));
            }
            else
            if (PairCharacterValue1 > PairCharacterValue2)
            {
                return(InternalFunctions.GetMorseFromLetter(InternalFunctions.GetLetterFromNumber(PairCharacterValue1 - PairCharacterValue2)));
            }
            else
            {
                return(InternalFunctions.GetMorseFromLetter(InternalFunctions.GetLetterFromNumber(PairCharacterValue1 + PairCharacterValue2)));
            }
        }