A bird flying high above a mountain range is able to estimate the height of the highest peak.
Can you?
Height=3
This challenge comes from dinglemouse at CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email yo+challenge@dev.to with your suggestions!
Top comments (4)
A TypeScript version using reduces and maps to avoid too much mutation.
The main loop early exits if possible (if there are no hills left), otherwise it erodes the mountainscape by one hill. The
starPattern
array determines how this erosion happens, and it seems that the challenge uses up-down-left-right-dot.Tested on Kata in its JS form.
Note that on there the mountains are defined using something like this:
Clojure solution:
Not as elegant as I hoped. Debugging output included.
Some comments may only be visible to logged-in visitors. Sign in to view all comments.