Draft
Non-recursive Island Count
35finetype
Description:
Given a string representation of a 2d map, return the number of islands in the map.
- Land spaces are denoted by a zero.
- Water is denoted by a dot.
- Rows are denoted by newlines ('\n').
- Two land spaces are considered connected if they are adjacent (horizontal or vertical, but not diagonal).
Too hard? Try solving it with recursion.
Example:
You may be given the string ".0...\n.00..\n....0" as input.
This correlates to a grid, like this:
.0...
.00..
....0
This would be an example of a map that contains two islands; one with 3 pieces of land, one with 1 piece of land.
More example:
This is 5 islands:
0...0
..0..
0...0
This is 3 islands:
..000.
..000.
..000.
.0....
..000.
Puzzles
Similar Kata:
Stats:
Created | Oct 5, 2015 |
Warriors Trained | 149 |
Total Skips | 14 |
Total Code Submissions | 121 |
Total Times Completed | 35 |
JavaScript Completions | 35 |
Total Stars | 4 |
% of votes with a positive feedback rating | 71% of 17 |
Total "Very Satisfied" Votes | 10 |
Total "Somewhat Satisfied" Votes | 4 |
Total "Not Satisfied" Votes | 3 |
Total Rank Assessments | 19 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 3 kyu |
Lowest Assessed Rank | 7 kyu |