# Draw a tiled cube of any size

Draw a tiled cube of any size, in ASCII art.

You will be given three numbers `a`, `b` and `c`, and the program should output an a*b*c sized cube.

Examples

`3 3 3` ->

``````    ____ ____ ____
/____/____/____/|
/____/____/____/||
/____/____/____/|||
|____|____|____|||/
|____|____|____||/
|____|____|____|/
``````

`5 2 3` ->

``````    ____ ____ ____ ____ ____
/____/____/____/____/____/|
/____/____/____/____/____/||
/____/____/____/____/____/||/
|____|____|____|____|____||/
|____|____|____|____|____|/
``````

`4 6 5` ->

``````      ____ ____ ____ ____
/____/____/____/____/|
/____/____/____/____/||
/____/____/____/____/|||
/____/____/____/____/||||
/____/____/____/____/|||||
|____|____|____|____||||||
|____|____|____|____|||||/
|____|____|____|____||||/
|____|____|____|____|||/
|____|____|____|____||/
|____|____|____|____|/
``````

Shortest code wins.

-
I think it would look slightly better if the bottom-right piece was `/` instead of `|` so it matches the top, and the number of pipes in each vertical line be identical. – mellamokb Aug 14 '12 at 18:13
Also, what are the valid ranges for `a`, `b`, and `c`? For example, are any of the dimensions allowed to be `0`? – mellamokb Aug 14 '12 at 18:15
@stevether: I didn't think about "tiled cube", that's a better name. – beary605 Aug 14 '12 at 18:33
A cube has equal edges. Better to call it a tiled parallelepiped or brick. – David Carraher Aug 15 '12 at 16:27
@beary605 I'm not a mathematician, but I think you may be referring to a rectangular cuboid. (en.wikipedia.org/wiki/Cuboid) A cube, a particular type of rectangular cuboid, has square faces. (en.wikipedia.org/wiki/Cube) As far as I know, the name of the shape of the object doesn't change when the object is tiled. – David Carraher Aug 15 '12 at 18:03

## Python, 145 chars

``````a,b,c=map(int,raw_input().split())
for i in range(b+c+1):print(' '*(c-i)+((' /|'[(i>c)+(i>0)]+'_'*4)*(a+1))[:-4]+('|'*(b+c-i))[:b]+'/')[:5*a+c+1]

\$ echo "5 6 3" | ./cube.py
____ ____ ____ ____ ____
/____/____/____/____/____/|
/____/____/____/____/____/||
/____/____/____/____/____/|||
|____|____|____|____|____||||
|____|____|____|____|____||||
|____|____|____|____|____||||
|____|____|____|____|____|||/
|____|____|____|____|____||/
|____|____|____|____|____|/
``````
-
 Could we see a picture of the printout? – David Carraher Aug 15 '12 at 17:23 @DavidCarraher: done. – Keith Randall Aug 15 '12 at 18:53 +1 Very lovely. – David Carraher Aug 15 '12 at 19:13

# Mathematica 148 143 139 chars

I decided to use transparent glass tiles.

The following code prints ASCII characters "-" in the form of a cuboid with edges, a, b, and c. The only thing you see in the figure below are hyphens.

``````w_~e~_ := {Arrowheads@Table[{1, p/9, Graphics@Style[Text["-"], Red]}, {p, 9}], White,Arrow@w};
GridGraph[{a, b, c} + 1, VertexSize -> 0, EdgeShapeFunction -> e]
``````

-
That's not ascii... cool idea, but no. – boothby Aug 16 '12 at 8:42
It was admittedly cheeky on my part. Thanks for the feedback. – David Carraher Aug 16 '12 at 11:09

## Python3 (188)

``````a,b,c=map(int,input().split())
x=a+1
k="_"*4
p=print
l=5*a+c+1
p(" "*c+k.join(" "*x))
r=" "*c+k.join("/"*x)+"|"*b+"/"
exec("r=r[1:];p(r[:l]);"*c+'b-=1;p((k.join("|"*x)+"|"*b+"/")[:l]);'*b)
``````

It is beaten already, but idea could help someone-else.

-

## C, 226, 212

``````s(x,y){x<1?:putchar(" |/_\n"[y],s(x-1,y));}i,j,x,y,z;main(){for(scanf("%d%d%d",&x,&y,&z);j<=y+z;s(i,1),s(j++>y,2),s(1,4)){s(z-j,0);for(i=x;s(1,j?j>z?1:2:0),i;i--)s(4,3);i=y+z-j;if(i>j)i=j;if(i>z)i=z;if(i>y)i=y;}}
``````

Once again a poor score compared to other langs - so any C golf gurus able to improve?

-