Let's draw the Triforce

The Triforce is a fictional artifact in The Legend of Zelda, made of three identical-looking equilateral triangles representing power, wisdom and courage. Several games in the saga include an animation when the three parts finally join together.

The purpose of this challenge is to draw a single 2D frame of such a simplified animation, with a given width for the triangles and a given spacing between the parts.

Input

The input consists of two integers: a width $w\ge1$ and a spacing value $s\ge0$.

Output

The frame has to be drawn according to the following specifications:

/\
/  \____________ this part is horizontally centered
/    \
/______\
\___ s empty lines
/
/\          /\
/  \        /  \______ w+1 backslashes
/    \      /    \
/______\    /______\
\_______ 2w underscores
|__|
\_____________ 2s spaces

In the above example, we have $w=3$ and $s=2$.

More examples

$w=1$, $s=0$:

/\
/__\
/\  /\
/__\/__\

$w=2$, $s=0$:

/\
/  \
/____\
/\    /\
/  \  /  \
/____\/____\

$w=3$, $s=3$:

/\
/  \
/    \
/______\

/\            /\
/  \          /  \
/    \        /    \
/______\      /______\

$w=4$, $s=1$:

/\
/  \
/    \
/      \
/________\

/\          /\
/  \        /  \
/    \      /    \
/      \    /      \
/________\  /________\

Rules

• Trailing spaces on each line are optional.
• Extra leading spaces on each line are not allowed.
• You may output a single extra leading newline and/or a single extra trailing newline.
• This is .

Python 2, 197194169167155 144 bytes

w,s=input()
l=['']*(2*-~w+s)
for i in range(-~w):W=w-i;b='/'+'_ '[i<w]*2*i+'\\';l[i::w-~s]=' '*(w+s-~W)+b,' '*W+b+'  '*(W+s)+b
print'\n'.join(l)

Try it online!

Saved:

• -3 bytes, thanks to Mr. Xcoder

Charcoal, 25 bytes

←×_Ｎ↗⊕θ‖Ｍ≔⁺⊕θＮηＣη±η‖ＢＯ⊗⊕θ

Try it online! Link is to verbose version of code. Explanation:

←×_Ｎ

Input w and draw w _s.

↗⊕θ

Draw w+1 /s.

‖Ｍ

Reflect to complete the first triangle.

≔⁺⊕θＮη

Input s and calculate the offset between the left and middle triangles.

Ｃη±η

Copy the left triangle to the middle.

‖ＢＯ⊗⊕θ

Reflect around the middle triangle to complete the triforce.

• Uh, check your math on this. This may be 25 characters, but it's 50 to 65 bytes (depending on whether you use UTF-16 or UTF-8 representation, respectively). – Stuart P. Bentley Sep 3 '18 at 21:45
• My bad; apparently, Charcoal and Canvas have their own character mappings, which seems a touch silly to me (if you're going to use arbitrary symbols, why not use an existing selection), but whatever. – Stuart P. Bentley Sep 3 '18 at 21:58
• @StuartP.Bentley The point of this site is to golf program size. Many languages (there are many, many more than just Canvas & Charcoal) opted for utilizing all 8 bits per byte, since that's a very good way to reach closer to maximum golfiness. The pretty unicode is just for making code easier to read and write (you try programming in C by writing bytecode; we are humans too) – dzaima Sep 3 '18 at 22:14

Python 2, 127 124 bytes

w,s=input()
n=2*-~w+s
while n:n-=1;I=w-n+(n>w)*(w-~s);print' '*n+('  '*(n+s)).join(['/'+I*2*' _'[I>=w]+'\\'][I>w:]*-~(n<=w))

Try it online!

Canvas, 2019 16 bytes

＋├：⁸╵＼Ｌ_×；∔║ω╋║↕

Try it here!

Explanation:

+├                s + w + 2
:               duplicated (for both X & Y)
⁸╵\            w+1 sized diagonal
L_×         "_"*width of the diagonal
;∔       prepended before the diagonal
║      palindromize that
ω     and push the argument of ║ (aka the unpalindromized version)
╋    overlap the upside down half-triangle over the upside down triangle at (s+w+2; s+w+2)
║   and palindromize the whole thing
↕  reverse everything vertically

note: in the making of this I fixed a mistake in the code, Without that fix, this would be 18 bytes.

• Like Neil's answer, this may be 16 characters, but in Unicode terms, it's either 32 or 44 bytes, depending on which UTF you use. (I considered that it might be representable in a legacy single-byte character set like code page 437, but there's no ω or ⁸ available there, so it seems to me you'd have to go with a Unicode transformation format.) – Stuart P. Bentley Sep 3 '18 at 21:53
• @StuartP.Bentley Canvas uses a custom codepage, as linked in the title of my post. The github wiki for Charcoal contains its codepage too. It's agreed upon on PPCG that it's okay to answer with unicode formatted answers if there's a codepage/converter backing it up. – dzaima Sep 3 '18 at 21:54
• Tcsh, okay (though at the point that you're using arbitrary converters, it seems to me that you might as well be writing in a language with full names and measuring a compiled VM bytecode instruction length). – Stuart P. Bentley Sep 3 '18 at 22:00
• @StuartP.Bentley Check the Charcoal answers link - it contains human readable code! (so yes, 2 transpilations :p) People here do answer in assembly scoring as machine code, so there's no reason to answer in VMs too – dzaima Sep 3 '18 at 22:03

R, 225, 224, 214, 211, 208 bytes

function(w,s){M=matrix
C=cbind
h=w+1
k=C(apply(m<-diag(h)*60,1,rev)/4,m)
k[row(k)==h&!k]=63
z=rbind(C(a<-M(0,h,h+s),k,a),M(0,s,h*4+2*s),C(k,M(0,h,2*s),k))
z[]=intToUtf8(z+32,T)
apply(z,1,cat,sep='','
')
rm()}

Try it online!

• -1 byte thanks to Giuseppe
• -10 bytes after change of approach
• -3 bytes exploting ASCII code
• -3 bytes thanks to JayCe
• Since I couldn't find anything to add to this... I just renamed variables and also I am suggesting another avenue to return silently... which I am not completely satisfied with TBH. Will keep searching! TIO – JayCe Sep 2 '18 at 1:01
• oh wait ... if(F)0 is acceptable for sure and saves one byte. Or even better rm() for 3 bytes. – JayCe Sep 2 '18 at 1:03
• My suggestion to use q() in my first comment is invalid as per this meta – JayCe Sep 2 '18 at 1:50
• @JayCe: great trick using rm() ! – digEmAll Sep 2 '18 at 8:04

Pascal (FPC), 296 264 bytes

const A='/';B='\';var w,s,i:word;u:string;begin read(w,s);u:=StringOfChar('_',2*w);for i:=1to w do writeln(A:w+3+s+w-i,B:i*2-1);writeln(A:w+2+s,u,B);for i:=1to s do writeln;for i:=1to w do writeln(A:w+2-i,B:i*2-1,A:2*(s+w-i)+3,B:i*2-1);write(A,u,B,A:2*s+1,u,B)end.

Try it online!

Python 2, 256248240228199 195 bytes

A longer program, but slightly different approach:

f,b,o='/\ '
O=o*2
w,s=input()
l=f+'__'*w+b
a=l+O*s+l
m=n=[]
p=lambda g:(len(a)-len(g))/2*o+g
for i in range(w):m=m+[p(f+O*i+b)];t=f+O*i+b;n+=p(t+O*(w-i+s)+t),
print'\n'.join(m+[p(l)]+[o]*s+n+[a])

Try it online!

saved a lot of bytes thanks to ignoring the trailing whitespace, and incorporating some tricks from @ovs
saved even more by defining a variable earlier

• I shall have to fix this tomorrow (it works, but I can do better) – micsthepick Aug 31 '18 at 13:20
• – Jonathan Frech Aug 31 '18 at 18:10
• 216 bytes – ovs Aug 31 '18 at 19:25
• fixed byte count. – mbomb007 Sep 1 '18 at 3:20
• that was a byproduct from when there was two – micsthepick Sep 1 '18 at 8:03

Ruby, 126 bytes

->w,s{(-v=w+1).upto(v){|i|j= ~-i%-~v;$><<[$/*s,$/+' '*(v+s)+t="/#{(j<w ?' ':?_)*j*2}\\".center(w*2+2)+' '*s*2,$/+t*2][0<=>i]}}

Try it online!

\d+

Try it online!