用登山术语来说,“ 14er”是指海拔在14 000英尺或以上的任何山脉。但是,还有另一个区别。要使一个高峰算作14er,它的“地理突出度”也必须达到300英尺或更多。这意味着要从一个14er爬到另一个14er,必须首先下降至少 300英尺,然后才能再次上升。举这个例子。1号线计为14000英尺,每条线计为100英尺。
/\__/\
/ \
/ \
现在,这两个峰的高程足以计数,但它们之间的高程降幅不足以算作两个单独的峰。因此,其中一个算作14er,另一个算作“部分峰”。这是一个示例,其中两个峰算作两个单独的14er:
/\ /\
/ \ / \
/ \/ \
/ \
两个14ers之间的下降也可能会出现部分高峰。这是最后一个山脉的略微修改版本:
/\ /\
/ \/\ / \
/ \/ \
/ \
该山脉也算作两个14人。
您必须编写一个程序或函数,该程序或函数采用一个代表山脉的ascii艺术表示法,并返回该范围内有14个峰。您可以采用最方便的格式输入,包括2D字符数组,带换行符的字符串或带其他定界符的字符串。您可以假定所有输入将仅包含字符/\_
,并且每行的长度将相同(包括尾随空格)。您还可以假设山脉从左下角以a /
或a 开头_
。
如果山峰的最后一段不在底线,则可以假定山峰仅在此之后减小,例如
/
/
/
算作单个14er。
您不必处理无效的山脉。
这是一些示例I / O:
/\___/\_
/ \ /\
/ \ / \
_/\/ \/ \
/ \
/ \
/ \_
2
/\ /\
/\ / \ /
/\ / \ / \/
/ \ / \ /
/ \/ \/
4
/\
_/\__/ \
/ \
1
/\
/ \ /\
/ \_/ \
/ \
/ \
/ \
/ \
1
/\
/\_/\ / \_
/ \ / \ /\
/ \/ \ /
/ \_/
/
3
那么起跑线算作14,000英尺?
—
R. Kap
@ R.Kap是的,我认为这是正确的,假设您说的是底线。
—
Alex A.
我认为您应该在某处提到
—
Martin Ender
_
比同一条线上的斜线低100英尺的地方。至少这就是您的最后一个测试案例所建议的。
规格似乎很薄...我们可以像一个扁平的泥炭
—
feersum '16
/ / / _ \ \ \
吗?另外,我认为输入中的最高点应始终算作一个峰值,但未明确指定。一个人可以从一个较低的峰开始,然后以不同的计数结束。
它会一直持续下去吗?每列最多有一个非空格字符吗?
—
Leaky Nun