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
Similar Kata:
Stats:
Created | Nov 21, 2017 |
Published | Nov 21, 2017 |
Warriors Trained | 229 |
Total Skips | 22 |
Total Code Submissions | 676 |
Total Times Completed | 41 |
Java Completions | 41 |
Total Stars | 7 |
% of votes with a positive feedback rating | 67% of 18 |
Total "Very Satisfied" Votes | 8 |
Total "Somewhat Satisfied" Votes | 8 |
Total "Not Satisfied" Votes | 2 |
Total Rank Assessments | 3 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 7 kyu |