Esempio n. 1
0
        public string GetSerializedOutput(OutputData outputData)
        {
            var result = new StringBuilder();

            result.AppendLine(outputData.Commands.Count.ToString());

            foreach (var command in outputData.Commands)
            {
                result.AppendLine(command.ToString());
            }

            return result.ToString();
        }
Esempio n. 2
0
        public OutputData GetOutputData(InputData inputData)
        {
            var result = new OutputData();

            // TODO: improve solver
            for (var i = 0; i < inputData.RowsNumber; i++)
            {
                for (var j = 0; j < inputData.ColumnsNumber; j++)
                {
                    if (inputData.Map[i, j])
                    {
                        var currentCommand = GetBestCommandForPaintedCell(inputData, i, j);

                        // To erase figure from map
                        currentCommand.Undo();

                        result.Commands.Add(currentCommand);
                    }
                }
            }

            return result;
        }
Esempio n. 3
0
        public string GetSerrializedInput(InputData inputData, OutputData outputData)
        {
            var map = new bool[inputData.RowsNumber, inputData.ColumnsNumber];

            foreach (var command in outputData.Commands)
            {
                command.Map = map;
                command.Do();
            }

            var result = new StringBuilder();

            for (var i = 0; i < inputData.RowsNumber; i++)
            {
                for (var j = 0; j < inputData.ColumnsNumber; j++)
                {
                    result.Append(map[i, j] ? InputDataParser.CellToBePaintedChar : InputDataParser.CellBlankChar);
                }

                result.AppendLine();
            }

            return result.ToString();
        }
Esempio n. 4
0
 public int GetScore(InputData inputData, OutputData outputData)
 {
     return inputData.ColumnsNumber * inputData.RowsNumber - outputData.Commands.Count;
 }