SQL, 182 175 173 187 bytes
Not that this'll ever be the shortest, but it's still amusing to try to minimize sql ;) lol
I did this in Oracle 11, however, these should be basic SQL.
[edit] as pointed out, I didn't apply the when input = 1 rule - only show 2 lines. can't think of a better way to do it, however, I did save a couple bytes by modifying the v logic ;) adding 2 ahead of time saves a couple bytes by not having to repeat it later [/edit]
select decode(&i,1,'',rpad(' ',v,'____')||z)||rpad(' /',v,'\ /')||decode(y,1,'\')||z||rpad('/',v-1,'__\/')||decode(y,1,'__\')from(select 2+floor(&i/2)*4v,mod(&i,2)y,chr(10)z from dual);
[edit1] removed some unnecessary spaces[/edit1]
[edit2] changed &&i to just &i. It cuts down 2 chars, but forces user to input the # of triangles twice ... :P I realized my "good coding habits" using &&i were costing be 2 bytes!! The horror!! [/edit2]
Explanation
(note: I use &&1 in this explanation so it only prompts once, the &1 above saves code space, but prompts multiple times ;) )
select -- line 1
decode(&&1,1,'', -- don't need line 1 if input is 1
rpad(' ',v,'____') || z ) || -- every pair of triangles
-- line 2
rpad(' /',v,'\ /') || -- every pair of triangles
decode(y,1,'\') || z || -- add the final triangle, input: 1,3,5 etc.
-- line 3
rpad('/',v-1,'__\/') || -- every pair of triangles
decode(y,1,'__\') -- add the final triangle, input: 1,3,5 etc.
from (select 2+floor(&&i/2)*4 v, -- common multiplier. 4 extra chars for every triangle pair
mod(&&i,2) y, -- Flag for the final triangle (odd inputs, 1,3,5, etc)
chr(10) z -- CR, here to save space.
from dual);
Output
SQL> accept i
1
SQL> /
/\
/__\
SQL> accept i
2
SQL> /
____
/\ /
/__\/
SQL> accept i
3
SQL> /
____
/\ /\
/__\/__\
SQL> accept i
12
SQL> /
________________________
/\ /\ /\ /\ /\ /\ /
/__\/__\/__\/__\/__\/__\/
SQL>
162striked out 44 is still normal 44 :( – Optimizer – 2015-03-24T08:22:59.603
442. Of course! – mbomb007 – 2015-03-24T21:17:25.370
142 ? We have a winner!! O.o lol – Ditto – 2015-03-25T14:19:40.733
50@Optimizer: I find it endlessly amusing that your sadness over the appearance of 44 has received more votes than the question or this answer. – Alex A. – 2015-03-27T14:23:39.777
13 bytes - doubling with
y
is the same as*4/2
– Maltysen – 2015-03-31T16:53:04.643@Maltysen
*4/1 2 = 0
,y1 = 2
./
is floored, which is necessary behavior. – isaacg – 2015-03-31T18:44:40.0076Just got 10 answers deep in the crossed out 44 chain – Leo – 2017-05-30T09:08:06.430
4@AlexA. I find it endlessly amusing that your amusement over Optimizer's sadness over the appearance of 44 has received more votes than the question or this answer. – isaacg – 2019-01-11T23:43:57.057
1@isaacg Unfortunately false now – Quintec – 2019-01-15T01:52:23.093
@Quintec Fortunately true again! – isaacg – 2019-12-13T00:01:28.077