Simple Fun #398: Draw the Stereoscopic Graphics of Building Blocks
Description:
Task & Examples
In this kata, your task is to draw the stereoscopic graphics of building blocks.
We define a single block graph is:
..+---+
./ /|
+---+ |
| | +
| |/.
+---+..
As you can see, +
represents the corners of block; | / and -
represents the sides of block; .
represents the background.
The input is a 2D array of positive integers. It's always a n x m
matrix. That is, your output should draw blocks n
rows and m
columns.
The value of each element represents the height of block.
height=1 height=2 height=3
..+---+
./ /|
+---+ |
..+---+ | | +
./ /| | |/|
+---+ | +---+ |
..+---+ | | + | | +
./ /| | |/| | |/|
+---+ | +---+ | +---+ |
| | + | | + | | +
| |/. | |/. | |/.
+---+.. +---+.. +---+..
matrix= matrix= matrix=
[[1]] [[2]] [[3]]
If there are more elements in a row, the output should looks like:
matrix=
[[1]]
..+---+
./ /|
+---+ |
| | +
| |/.
+---+..
matrix=
[[1,1]]
..+---+---+
./ / /|
+---+---+ |
| | | +
| | |/.
+---+---+..
matrix=
[[1,1,1]]
..+---+---+---+
./ / / /|
+---+---+---+ |
| | | | +
| | | |/.
+---+---+---+..
Of course, your code should draw the graphics correctly when it has multi rows and multi columns.
Please see more examples in the sample tests.
Note
The output should be a string, each line is separated by "\n".
In theory, your code should be able to output infinite graphics, if you have an infinitely fast computer and an infinitely large screen. Someone said ;-) But in this kata, you only need to deal with the number of rows,columns greater than 0 and less than 50.
the height of each block(the element in
matrix
) is also greater than 0 and less than 50.8
fixed testcases100
random testcases, testing for correctness of solutionAll inputs are valid.
If my reference solution gives the wrong result in the random tests, please let me know(post an issue).
Similar Kata:
Stats:
Created | Nov 2, 2018 |
Published | Nov 2, 2018 |
Warriors Trained | 398 |
Total Skips | 151 |
Total Code Submissions | 173 |
Total Times Completed | 26 |
JavaScript Completions | 26 |
Total Stars | 25 |
% of votes with a positive feedback rating | 96% of 14 |
Total "Very Satisfied" Votes | 13 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 3 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |