Help me Open the Box
JavaScript ES6, 57 bytes
s=>s[r="replace"](/-+/,s=>s[r](/-/g,`
$'/`))[r](/-/g,' ')
Outputs a leading newline. Works by taking the row of -
s and converting them into a triangle, then replacing the -
s with spaces.
Edit: Saved 5 bytes thanks to @edc65.
Pyth, 16 14 bytes
j+_m+*;d\/Uz.z
Explanation
m Uz - [V for d in range(len(input()))]
+*;d\/ - " "*d + "/"
_ - ^[::-1]
j+ .z - "\n".join(^+rest_of_input())
Thanks @FryAmTheEggman for new algorithm!
Try it here.
pb (NONCOMPETING), 125 bytes
^w[B!0]{>}w[B!45]{<w[B=10]{t[T+1]b[0]}}v[X]vw[T!0]{vb[124]<[X]b[124]>w[B=0]{>}t[T-1]}w[X!1]{<b[95]}<w[B!0]{^}w[Y!-1]{b[47]>^}
The version of pbi that you need to run this answer is newer than the question. It would have worked in older versions except that I never got around to allowing newlines in input. Oh well.
First, this determines the height of the box by counting newlines in the input. Once it knows that, it goes to the Y location of the right side of the box, goes down to where it needs to be and draws the walls and floor, finishing with the lid.
Check out this fun animation!
The long pause is the brush going over the input.
Ungolfed:
^w[B!0]{>} # Go to the end of the input
w[B!45]{< # Head left until hitting a hyphen
w[B=10]{ # For each newline on the way:
t[T+1] # Count it
b[0] # Delete it
}
}
v[X] # Move down as far as it is right + the number of \n
v # ...plus one
w[T!0]{ # While the counting variable is nonzero:
vb[124] # Go down and draw a pipe
<[X]b[124] # Draw a pipe on the left as well
>w[B=0]{>} # Go back to the right side
t[T-1] # Decrement variable
}
w[X!1]{<b[95]} # Draw the bottom of the box
<w[B!0]{^} # Go up the left wall
w[Y!-1]{b[47]>^} # Go up and right, drawing the lid