Back
Close

Mountain Map Convergence

Statement

 Goal

"We don't make mistakes, just happy little accidents." - Bob Ross

While creating mountains in ASCII, you realized that taller mountains could start off from the smaller ones, so why not make some more mountains?



Rules:

- You will be given a list of the heights of mountain peaks along a row.

- The starting height is considered as 0.

- Each step of rise in altitude is represented by '/' and fall by '\'.

- Each peak consists of a rise and fall '/\' at the appropriate height.

- Once a peak has been drawn, proceed either up or down to the next peak. Do not return to 0 between peaks.

- After generating the mountains, end at height 0.

- You may need to draw below 0. Remember, mountains are made from a step lower than their peak. Example, for -1 :
\    /   
\/\/
which demonstrates the tip of the mountain at -1 height, given that the starting and ending point are at height 0.


This is an extension of "Mountain Map": https://www.codingame.com/ide/puzzle/mountain-map
Input
Line 1: A single integer n representing the number of mountains
Line 2: n, space-separated integers that represent the height of each mountain in sequential order
Output
An ASCII representation of the mountains where each rise in altitude is represented by '/' and fall by '\'.
(Output lines shouldn't contain trailing spaces)
Constraints
0 < n < 15
-15 < height <15

Note: The height must always end at 0.
Example
Input
3
1 2 1
Output
   /\
/\/  \/\

Tags
Ascii Art

Difficulty
Easy

Test cases
Familiar Test
Input
3 1 2 1
Output
/\ /\/ \/\

Familiar Validator
Input
4 2 1 2 1
Output
/\ /\ / \/\/ \/\

Wait I was correct on the last one Test
Input
4 3 7 2 9
Output
/\ / \ /\ / \ / \ / \ / \ / \ / \ / \ /\/ \ / \ / \/\/ \ / \

Wait I was correct on the last one Validator
Input
6 2 10 2 5 8 3
Output
/\ / \ / \ /\ / \ / \ / \ / \ / \ /\/ \ / \ / \ / \ / \/\ /\/ \/\/ \ / \

Twin Peaks Test
Input
7 2 3 2 6 6 4 3
Output
/\/\ / \ / \/\ /\ / \/\ /\/ \/\/ \ / \

Twin Peaks Validator
Input
9 2 2 6 4 4 5 6 6 2
Output
/\ /\/\ / \ /\/ \ / \/\/\/ \ / \ /\/\/ \/\ / \

Negatives Test
Input
4 2 4 -2 3
Output
/\ / \ /\ /\/ \ / \ / \ / \ \ / \ / \/\/

Negatives Validator
Input
6 2 -1 -2 -2 3 4
Output
/\ /\/ \ /\ / \ / \ / \ \ / \/\ / \/\/\/

Tricky Negatives Test
Input
5 2 7 -2 -2 -3
Output
/\ / \ / \ / \ / \ /\/ \ / \ \ / \ / \/\/\ / \/\/

Tricky Negatives Validator
Input
5 1 -2 -2 -2 -3
Output
/\ \ / \ / \/\/\/\ / \/\/

More Tricky Negatives Test
Input
6 -6 4 -1 3 -3 -3
Output
/\ / \ /\ / \ / \ / \ / \ \ / \ / \ / \ / \/\/ \ / \ / \ / \ / \/\/\/ \ / \ / \/\/

More Tricky Negatives Validator
Input
5 -2 4 -1 -1 -2
Output
/\ / \ / \ / \ \ / \ / \ / \/\/\ / \/\/ \/\/

Crazy Mountains Test
Input
14 -2 -4 4 -1 2 -1 -2 4 -3 4 -5 2 -4 -3
Output
/\ /\ /\ / \ / \ / \ / \ /\ / \ / \ /\ / \ / \ / \ / \ / \ \ / \ / \ / \ / \ / \ / \ / \/\/ \/\ / \ / \ / \ / \/\ / \/\/ \ / \ / \ / \ / \/\/ \ / \ /\/ \/\/ \ / \/\/ \/\/

Crazy Mountains Validator
Input
14 6 4 -1 -3 2 -1 -5 4 2 4 5 -2 4 3
Output
/\ / \ /\ / \/\ /\ /\/ \ /\ / \ / \ / \ / \/\ / \ /\ / \/\/ \ / \ / \ / \ / \ / \ \ / \ / \ / \/\ / \/\ / \ / \ / \ / \/\/ \/\/ \ / \ / \/\/

Solution language

Solution

Stub generator input