5 kyu

Fill in an area

Description:

In this Kata, you are given a two dimensional array that contains mostly zeros, but some ones, and a starting point. Your objective is to fill in the area that is surrounded by 1's that contain the starting point. For instance, given

00000000
00011110
00010010
00010010
01110010
010X0010
01111110
00000000

and a starting point of (3,2) (shown by the X in the grid above: this use cartesian coordinates), you would return

00000000
00011110
00011110
00011110
01111110
01111110
01111110
00000000

The given array will always be rectangular, but the shape the 1's make will not.

You have to fill with ones the shape where the starting point is. If the starting point isn't completely surrounded by ones at the beginning, return a grid full of ones, as shown below:

Start at (6,4):

0010000       1111111
0011110       1111111
000001X       1111111
0000010   =>  1111111
0000010       1111111
0000011       1111111
0000000       1111111

Final note: Do not mutate any of the inputs!

Algorithms

Stats:

CreatedNov 21, 2017
PublishedNov 21, 2017
Warriors Trained229
Total Skips22
Total Code Submissions676
Total Times Completed41
Java Completions41
Total Stars7
% of votes with a positive feedback rating67% of 18
Total "Very Satisfied" Votes8
Total "Somewhat Satisfied" Votes8
Total "Not Satisfied" Votes2
Total Rank Assessments3
Average Assessed Rank
5 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • joshua082390 Avatar
  • Blind4Basics Avatar
Ad