12
0
Santa was able to remanufacture all of the presents that the elves stole overnight! Now he has to send them to the assembly line for packaging. He usually has a camera to supervise the assembly line both to make sure the elves are doing a good job and because assembly line pictures look nice on advertising posters [citation-needed]
Unfortunately, his camera broke, so he would like you to draw out a simulation of what the assembly line would look like!
In order to keep to assembly line working at maximum efficiency and to reduce the risk of error or failure, all present boxes have the same width so that they fit perfectly on the conveyor belt.
Challenge
Given a list of presents represented by their dimensions, output a conveyor belt with all of the presents.
A present is drawn like such:
+----+
/ /|
+----+ |
| | +
| |/
+----+
This present has width 1, height 2, and length 4. Note that the plus-signs don't count for the side-length, so a present with length 4 actually spans 6 positions.
All presents are drawn next to each other with one space between the closest two characters; that is, the bottom-left corners of the presents are spaced such that if a present box has length l
and width w
, the next present box's bottom-left corner will be exactly l + w + 4
positions right of the bottom-left corner of the previous box.
After all present boxes are drawn, the conveyor belt is drawn by replacing the space between boxes on each of the last width + 2
lines with underscores.
The final output for present boxes with (l, w, h)
of [(4, 1, 2), (8, 1, 3), (1, 1, 1)]
would be:
+--------+
+----+ / /|
/ /| +--------+ | +-+
+----+ | | | | / /|
| | +_| | +_+-+ +
| |/__| |/__| |/
+----+___+--------+___+-+
Formatting Specifications
You can choose either to take a list of 3-tuples where one of the elements is consistent across the whole list (that would be the width), or you can take the present width and then a list of 2-tuples representing the length and height of each present. You can take the inputs in any order and in any reasonable format, but the presents must be displayed in the same order that they are given as input.
You may choose any reasonable output format for the ASCII-art (including returning from a function).
Test Cases
These test cases are given as [(l, w, h), ...]
format.
[(4, 1, 2), (8, 1, 3), (1, 1, 1)]:
+--------+
+----+ / /|
/ /| +--------+ | +-+
+----+ | | | | / /|
| | +_| | +_+-+ +
| |/__| |/__| |/
+----+___+--------+___+-+
[(5, 3, 4), (8, 3, 1), (1, 3, 7)]:
+-+
/ /|
/ / |
+-----+ / / |
/ /| +-+ |
/ / | | | |
/ / | +--------+ | | |
+-----+ | / /| | | |
| | +___/ / +_| | +
| | /___/ / /__| | /
| | /___+--------+ /___| | /
| |/____| |/____| |/
+-----+_____+--------+_____+-+
[(0, 0, 0)] (this is the most interesting test case ever :P)
++
+++
++
[(8, 3, 0), (0, 3, 8)] (more zero cases)
++
//|
// |
// |
++ |
|| |
|| |
|| |
+--------+ || |
/ /+_|| +
/ //__|| /
/ //___|| /
+--------+/____||/
+--------+_____++
Rules
- Standard Loopholes Apply
- This is code-golf, so the shortest answer in bytes wins
- No answer will be accepted
Note: I drew inspiration for this challenge series from Advent Of Code. I have no affiliation with this site
You can see a list of all challenges in the series by looking at the 'Linked' section of the first challenge here.
@AdmBorkBork all present boxes have the same width – Erik the Outgolfer – 2017-12-04T15:50:44.303
1If Charcoal doesn't wreck this, I don't know what will. – totallyhuman – 2017-12-04T16:05:25.713
@totallyhuman actually, brainf**k will win this challenge :P – HyperNeutrino – 2017-12-04T17:04:18.190
Can you make a post on meta to index all of these questions? – RamenChef – 2017-12-04T20:05:51.260
@RamenChef Hm good idea. I might do that :P – HyperNeutrino – 2017-12-05T00:03:07.597