Retired
Simple Fun #85: Polygon Perimeter (retired)
70 of 198myjinxin2015
Description:
Task
You have a rectangular white board with some black cells. The black cells create a connected black figure, i.e. it is possible to get from any black cell to any other one through connected adjacent (sharing a common side) black cells.
Find the perimeter of the black figure assuming that a single cell has unit length.
Example
For
matrix = [[false, true, true ],
[true, true, false],
[true, false, false]]```
the output should be `12`.

For
matrix = [[true, true, true],
[true, false, true],
[true, true, true]]```
the output should be 16
.
Input/Output
[input]
2D boolean arraymatrix
A matrix of booleans representing the rectangular board where true means a black cell and false means a white one.
Constraints:
2 ≤ matrix.length ≤ 10,
2 ≤ matrix[0].length ≤ 10.
[output]
an integer
Puzzles
Similar Kata:
Stats:
Created | Feb 4, 2017 |
Warriors Trained | 400 |
Total Skips | 13 |
Total Code Submissions | 526 |
Total Times Completed | 198 |
JavaScript Completions | 70 |
C# Completions | 34 |
Python Completions | 96 |
Ruby Completions | 15 |
Total Stars | 8 |
% of votes with a positive feedback rating | 95% of 83 |
Total "Very Satisfied" Votes | 75 |
Total "Somewhat Satisfied" Votes | 8 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 6 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |