static char[,] ExpandProblem(char[,] arr) { Span2D <char> insert = new char[, ] { { ' ', ' ', '#', 'D', '#', 'C', '#', 'B', '#', 'A', '#', ' ', ' ' }, { ' ', ' ', '#', 'D', '#', 'B', '#', 'A', '#', 'C', '#', ' ', ' ' }, }; var span = arr.AsSpan2D(); var expanded = new char[span.Height + 2, span.Width]; var expandedSpan = expanded.AsSpan2D(); span[0..3, ..].CopyTo(expandedSpan[0..3, ..]);
public Keypad(char[,] pad) { var span = pad.AsSpan2D(); var builder = ImmutableDictionary.CreateBuilder <Point2d, char>(); for (var y = 0; y < span.Height; y++) { var row = span.GetRowSpan(y); for (var x = 0; x < row.Length; x++) { if (row[x] != ' ') { builder.Add(new Point2d(x, y), row[x]); } } } _keypad = builder.ToImmutable(); FiveKey = _keypad.Where(kvp => kvp.Value == '5').First().Key; }