DRAWM - Draw Mountains
You are a member of a team that is working in a new wonderful graphics program.
Your task is to write a module for drawing skylines of mountains. However, for now the
program is in beta version, so each skyline is discretized. This means that your module
receives as input a sequence of integers representing heights. Each pair of consecutive
heights in the sequence may differ by at most 1 and produces a column of output, each
column containing a single character. The particular character to write and its position
in the column depend on the pair of heights. When both heights are equal an underscore
(“ ”) must be printed. If the heigths within the pair increase or decrease, you must write
a slash (“/”) or a backslash (“\”), respectively. The position of the character in the
column is such that the skyline visually respect the given heights.
For instance, the sequence of heights (1, 2, 3, 2, 3, 3, 2, 1, 0) must produce the skyline shown
in the following figure.
Notice that when the sequence of heights has C + 1 elements, the corresponding skyline
has only C columns. Given a sequence of heights, you must draw the skyline according
to the rules given above. See the examples for further clarification.
The input contains several test cases, each one described in exactly two lines. The first
line contains an integer C indicating the number of columns of the skyline (1 ≤ C ≤ 70).
The second line contains C + 1 integers Hi separated by single spaces representing the
sequence of heights (0 ≤ Hi ≤ 30 for 1 ≤ i ≤ C + 1). You may assume that there exist
an height Hi = 0, and that the difference between succesive heights is at most 1 (i.e.
|Hi − Hi+1 | ≤ 1 for 1 ≤ i ≤ C). The last line of the input contains a single −1 and should
not be processed as a test case.
For each test case output the correponding skyline, followed by a line with exactly three
asterisks (“***”). While writting the skyline, use only regular spaces, newlines, and the
three characters mentioned in the statement. Ths skyline must be left aligned and it
must contain exactly C columns. There must be no trailing spaces at the end of printed
lines, neither empty lines.
1 2 3 2 3 3 2 1 0
1 0 0 1
AC in one go!
Nice One.... :)
Great problem! My 100th on SPOJ :))
I tried the test cases and even tried to print x instead of space like santiago zubieta said, eventhough i got WA, what would the problem be?
:D understud the ques completly wrng :P but when got the ques right :D guess what AC in first attempt :D and random_gal :* u r a genius
Loving Primes Yummy :D :):
What i love the most of this problem, is that the result is fun.
I don't have any trailing spaces
Finally got AC...be aware of whitespaces..:D