static void Main(string[] args)
int[,] original = new int[,] {
{0,0,0,0,0,0,0,0,0,0},
{0,0,2,2,2,2,2,0,0,0},
{0,0,2,0,0,0,2,0,0,0},
{0,0,2,0,0,0,2,0,2,0},
{0,0,2,0,0,0,2,0,2,0},
{0,0,2,0,0,0,2,0,2,0},
{0,0,2,2,2,2,2,2,2,2},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
int[,] expected = new int[,] {
{9,9,9,9,9,9,9,9,9,9},
{9,9,2,2,2,2,2,9,9,9},
{9,9,2,0,0,0,2,9,9,9},
{9,9,2,0,0,0,2,9,2,9},
{9,9,2,0,0,0,2,9,2,9},
{9,9,2,0,0,0,2,9,2,9},
{9,9,2,2,2,2,2,2,2,2},
{9,9,9,9,9,9,9,9,9,9},
{9,9,9,9,9,9,9,9,9,9},
{9,9,9,9,9,9,9,9,9,9},
var result = DoFill(original, x1, y1, fillValue);
Console.WriteLine(IsBitMapEqual(result, expected));
public static int [,] DoFill(int[,] original, int x, int y, int fillValue)
int [,] workingCopy = original;
static bool IsBitMapEqual(int[,] bitmap1, int[,] bitmap2)
for (int y = 0; y < bitmap1.GetLength(1); y++)
for (int x = 0; x < bitmap1.GetLength(0); x++)
if (bitmap1[x, y] != bitmap2[x, y]) return false;
static void PrintBitmap(int[,] bitmap)
for (int y = 0; y < bitmap.GetLength(1); y++)
for (int x = 0; x < bitmap.GetLength(0); x++)
Console.Write($"{bitmap[x, y]},");
static void PrintPosition(int[,] bitmap, int posX, int posY)
for (int y = 0; y < bitmap.GetLength(1); y++)
for (int x = 0; x < bitmap.GetLength(0); x++)
if( x == posX && y == posY)