As part of a city planning project, you've gotten the assignment of creating a program or function that will display the city skyline, given some input from the architects. The project is only in the startup phase, so a very rough sketch is sufficient. The easiest approach is of course to simply draw the skyline in ASCII-art.
All buildings will be by the river, thus they are all aligned. The architects will give the height of each building as input, and your code should display the skyline.
The input from the architects will either be an integer or a half-integer. If the number is an integer, the building will have a flat roof, while a half-integer will result in a pitched roof. A zero will just be flat ground. The walls of a building are 3 characters apart, while a zero will be a single character wide. Adjacent buildings share walls.
For details and clarifications regarding the output, please have a look at the examples below:
N = 3 ___ | | | | |___| N = 3.5 _ / \ | | | | |___| N = 6 ___ | | | | | | | | | | |___| n = 0 _
3 3.5 0 2
_ ___ / \ | | | ___ | | | | | |___|___|_|___|
0 0 2.5 3 0 4 1
___ _ ___ | | / \| | | | | | | | |___ __|___|___|_|___|___|
0 2 1 3.5 0 4 2 4 2 4 6 1 6 0 5 1
___ ___ | | | | ___ _ ___ ___ ___| | | | | | / \ | | | | | | | | | | | ___ | | | |___| |___| | | | | | | | |___| | | | | | | | |___| | | |___ _|___|___|___|_|___|___|___|___|___|___|___|___|_|___|___|
The ASCII-characters used are: newline, space, and
/\_| (code points 10, 32, 47, 92, 95, 124).
- It's optional to make a program that only take integers as input, by multiplying all numbers by two. So, instead of taking
3 3.5 2, your program may take
6 7 4. If the second input format is chosen, an input of 6 should result in a 3 story building, 7 should be a 3 story building with pitched roofs etc.
- The output should be exactly as described above, but trailing spaces and newlines are OK.
- The exact format of the input is optional. Whatever is best in your language.
- The result must be displayed on the screen, so that the architects can have a look at it.
- You can assume there will be at least one integer given, and that only valid input will be given.
This is codegolf, so the shortest code in bytes win.