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(); }
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; }
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(); }
public int GetScore(InputData inputData, OutputData outputData) { return inputData.ColumnsNumber * inputData.RowsNumber - outputData.Commands.Count; }