Exemplo n.º 1
0
        internal static string ToString(IReadOnlyPuzzle puzzle)
        {
            int  size      = puzzle.Size;
            bool showBoxes = Boxes.TryIntSquareRoot(size, out int boxSize);

            if (showBoxes)
            {
                return(_ToStringWithBoxes(puzzle, boxSize));
            }
            int maxDigit = puzzle.AllPossibleValuesSpan.FindMax();
            var shape    = new PuzzleShape {
                Size        = size,
                SquareWidth = maxDigit.ToString(NumberFormatInfo.InvariantInfo).Length
            };
            var normalChars = _GetCharsForNormalRow();
            var strBuild    = new StringBuilder();

            for (int row = 0; row < size; row++)
            {
                _AppendDividerRow(shape, _GetCharsForDivider(row, shape), strBuild);
                strBuild.Append(normalChars.RowStart);
                for (int col = 0; col < size; col++)
                {
                    _AppendSquareContents(puzzle[row, col], shape, strBuild);
                    if (col == size - 1)
                    {
                        strBuild.Append(normalChars.RowEnd);
                    }
                    else
                    {
                        strBuild.Append(normalChars.BetweenColumns);
                    }
                }
                strBuild.Append('\n');
            }
            _AppendDividerRow(shape, _GetCharsForDivider(size, shape), strBuild);
            return(strBuild.ToString());
        }
Exemplo n.º 2
0
 public static Mesh GetPuzzleMesh(PuzzleShape Shape)
 {
     return(SortedMeshLookup[(uint)Shape].PuzzleMesh);
 }