In mountaineering terminology, a "14er" is any mountain with an elevation of 14 000 feet or more. However, there is another distinction. For a peak to count as a 14er, it must also have a "geographic prominence" of 300 or more feet. This means that to move from one 14er to another, you must first descend at least 300 feet before rising again. Take this example. Line 1 counts as 14 000 feet, and each line counts as 100 feet.
/\__/\
/ \
/ \
Now, both of these peaks have enough elevation to count, but there isn't enough drop in elevation between them to count as two separate peaks. Therefore, one of these counts as a 14er, and the other one is just a "partial peak". Here is an example where the two peaks count as two separate 14er:
/\ /\
/ \ / \
/ \/ \
/ \
There can also be a partial peak on the decline between two 14ers. Here's a slightly modified version of the last mountain range:
/\ /\
/ \/\ / \
/ \/ \
/ \
This mountain range also counts as two 14ers.
You must write a program or function that takes an ascii-art representation of a mountain range, and return how many 14ers are in the range. You can take input in whatever format is most convenient for you, be it 2D array of characters, a string with newline, or a string with some other delimiter. You can assume that all inputs will only contain the characters /\_
, and that the length of each line will be the same (including trailing spaces). You can also assume that the mountain range starts on the bottom left corner with either a /
or a _
.
If the last section of a mountain is not on the bottom line, you can assume that the mountain only decreases after that, e.g.
/
/
/
Counts as a single 14er.
You do not have to handle invalid mountain ranges.
Here is some sample I/O:
/\___/\_
/ \ /\
/ \ / \
_/\/ \/ \
/ \
/ \
/ \_
2
/\ /\
/\ / \ /
/\ / \ / \/
/ \ / \ /
/ \/ \/
4
/\
_/\__/ \
/ \
1
/\
/ \ /\
/ \_/ \
/ \
/ \
/ \
/ \
1
/\
/\_/\ / \_
/ \ / \ /\
/ \/ \ /
/ \_/
/
3
_
counts as 100 feet lower than a slash on the same line. At least that's what your last test case suggests. \$\endgroup\$ – Martin Ender Apr 23 '16 at 9:50/ / / _ \ \ \
? Also, I suppose that the highest point in the input should always be counted as a peak but this is not explicitly specified; one could start at a lower peak and end up with a different count. \$\endgroup\$ – feersum Apr 23 '16 at 11:06