Take the 2-minute tour ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

Your task is to output a representation of the legendary tree of life, Yggdrasil.

You must write a program whose output is exactly that :

                                       /\
                                      /**\
                                     /****\
                                    /******\
                                    /******\
                                   /********\
                                  /**********\
                                 /************\
                                /**************\
                                 /************\
                                /**************\
                               /****************\
                              /******************\
                             /********************\
                            /**********************\
                              /******************\
                             /********************\
                            /**********************\
                           /************************\
                          /**************************\
                         /****************************\
                        /******************************\
                           /************************\
                          /**************************\
                         /****************************\
                        /******************************\
                       /********************************\
                      /**********************************\
                     /************************************\
                    /**************************************\
                        /******************************\
                       /********************************\
                      /**********************************\
                     /************************************\
                    /**************************************\
                   /****************************************\
                  /******************************************\
                 /********************************************\
                /**********************************************\
                     /************************************\
                    /**************************************\
                   /****************************************\
                  /******************************************\
                 /********************************************\
                /**********************************************\
               /************************************************\
              /**************************************************\
             /****************************************************\
            /******************************************************\
                  /******************************************\
                 /********************************************\
                /**********************************************\
               /************************************************\
              /**************************************************\
             /****************************************************\
            /******************************************************\
           /********************************************************\
          /**********************************************************\
         /************************************************************\
        /**************************************************************\
               /************************************************\
              /**************************************************\
             /****************************************************\
            /******************************************************\
           /********************************************************\
          /**********************************************************\
         /************************************************************\
        /**************************************************************\
       /****************************************************************\
      /******************************************************************\
     /********************************************************************\
    /**********************************************************************\
            /******************************************************\
           /********************************************************\
          /**********************************************************\
         /************************************************************\
        /**************************************************************\
       /****************************************************************\
      /******************************************************************\
     /********************************************************************\
    /**********************************************************************\
   /************************************************************************\
  /**************************************************************************\
 /****************************************************************************\
/******************************************************************************\
                                   |--------|
                                   |--------|
                                   |--------|
                                   |--------|
                                   |--------|
                                   |--------|
                                   |--------|
                                   |--------|
                                   |--------|
                                   |--------|
                                   |--------|
                                   |________|

There is no trailing whitespace. The final newline may be omitted.

To make checking easier, here are the md5 sums of the expected output:

  • 374899e56bc854d04639c43120642e37 - No newline at end.
  • 03afb81d960b8e130fe2f9e0906f0482 - Newline at end

Standard loopholes apply. This is code-golf, so the smallest entry in bytes win!

share|improve this question
7  
Related: codegolf.stackexchange.com/q/15860/15599 . Nax, you should work in marketing. Every household is going to want a Yggdrasil this Christmas. I see you answered the Graham's number question too. You must like pointy things. Let's have some new names for "rocket" and "ice cream cone." –  steveverrill Aug 19 at 14:18
5  
Of course that's an Yggdrasil, and definitely not yet-another-christmas-tree :) –  Nax Aug 19 at 14:25
3  
I'm just imagining what happens if the md5 sums in the OP are incorrect :P –  Mooing Duck Aug 19 at 22:40
1  
@MooingDuck In that case, I didn't waste half an hour manually checking the output. –  Ourous Aug 20 at 1:05
2  
@Nax: since the world tree has fruit, and angiosperms don't, and that is clearly a confiner of some description, unfortunately it looks like you took a picture of the wrong tree :P –  naught101 Aug 21 at 14:28

30 Answers 30

Golfscript, 84 77 76 75 72 characters

Different approach from Howard's. Click on the character count to try it.

10,{.)4*,\3*>{.39\-' '*'/'@2*'*'*'\
'}/}/12,{' '35*'|'@11<'_-'1/=8*1$n}/

Thanks to Howard for saving 3 characters!

Explanation:

This is more or less a straightforward port of my Python solution. Taking some expressive liberties (using named variables instead of keeping track of stack positions, and print is really keeping things on the stack, not printing):

10,{...}/            # for i in range(10):
   .                 #    x = i
   )4*,              #    Y = range((i+1)*4)
   \3*               #    x *= 3
   >                 #    Y = Y[x:]  # y is now range(3*i, (i+1)*4)
   {...}/            #    for j in Y:
      .39\-          #        q = 39 - j
      ' '*           #        print ' '*q  # print right number of spaces
      '/'            #        print '/'
      @2*            #        j *= 2
      '*'*           #        print '*'*j
      '\<NEWLINE>'   #        print "\\\n"
12,{...}/            # for i in range(12):
    ' '35*           #    print ' '*35
    '|'              #    print '|'
    @11<             #    i = i < 11
    '_-'1/=          #    z = "_-"[i] # pick "-" if i < 11, else pick "_"
    8*               #    print z*8
    1$               #    print '|' # (copy from earlier in the stack)
    n                #    print "\n"
share|improve this answer
1  
You may use the same line-break trick as in my solution. Instead of '\\'n pull the newline into the string (+/- 0 characters) and now the backslash no longer needs to be escaped (-1 character). –  Howard Aug 20 at 6:36
1  
Two more: 4*4+ is the same as )4* and '_-'[=] can be written '_-'1/= which makes the last + obsolete. –  Howard Aug 20 at 6:50
3  
an explanation could be useful...? is this too much to ask? –  professorfish Aug 20 at 8:29
    
@professorfish: Coming right up! –  Claudiu Aug 20 at 15:46
    
Don't you need a trailing ';' here? Otherwise there will be two trailing newlines since golfscript by default adds one. –  Nabb Aug 24 at 3:48

Haml & Sass

37 + 277 = 314

Haml:

%link(rel="stylesheet" href="s")
%pre

Sass:

pre:after{$l:"";@for$k from0 to10{@for$i from0 to4+$k{@for$j from0 to40-($k*6+$i*2)/2{$l:$l+' ';}$l:$l+'/';@for$j from0 to$k*6+$i*2{$l:$l+'*';}$l:$l+"\\\a ";}}@for$i from0 to12{@for$j from0 to35{$l:$l+" ";}@if$i<11{$l:$l+"|--------|\a ";}@else{$l:$l+"|________|";}}content:$l;}

*Sass allows control directives, concatenation, and variable dereference. All of which are useful when styling, but verbose while golfing.


gets generated into:

HTML:

<link rel="stylesheet" href="s" /><pre></pre>

CSS:

pre:after {
  content: "                                        /\\\a                                        /**\\\a                                       /****\\\a                                      /******\\\a                                      /******\\\a                                     /********\\\a                                    /**********\\\a                                   /************\\\a                                  /**************\\\a                                   /************\\\a                                  /**************\\\a                                 /****************\\\a                                /******************\\\a                               /********************\\\a                              /**********************\\\a                                /******************\\\a                               /********************\\\a                              /**********************\\\a                             /************************\\\a               
             /**************************\\\a                           /****************************\\\a                          /******************************\\\a                             /************************\\\a                            /**************************\\\a                           /****************************\\\a                          /******************************\\\a                         /********************************\\\a                        /**********************************\\\a                       /************************************\\\a                      /**************************************\\\a                          /******************************\\\a                         /********************************\\\a                        /**********************************\\\a                       /************************************\\\a                      /**************************************\\\a                     /******************************
**********\\\a                    /******************************************\\\a                   /********************************************\\\a                  /**********************************************\\\a                       /************************************\\\a                      /**************************************\\\a                     /****************************************\\\a                    /******************************************\\\a                   /********************************************\\\a                  /**********************************************\\\a                 /************************************************\\\a                /**************************************************\\\a               /****************************************************\\\a              /******************************************************\\\a                    /******************************************\\\a                   /**********************************
**********\\\a                  /**********************************************\\\a                 /************************************************\\\a                /**************************************************\\\a               /****************************************************\\\a              /******************************************************\\\a             /********************************************************\\\a            /**********************************************************\\\a           /************************************************************\\\a          /**************************************************************\\\a                 /************************************************\\\a                /**************************************************\\\a               /****************************************************\\\a              /******************************************************\\\a             /*****************************************************
***\\\a            /**********************************************************\\\a           /************************************************************\\\a          /**************************************************************\\\a         /****************************************************************\\\a        /******************************************************************\\\a       /********************************************************************\\\a      /**********************************************************************\\\a              /******************************************************\\\a             /********************************************************\\\a            /**********************************************************\\\a           /************************************************************\\\a          /**************************************************************\\\a         /****************************************************************\\\a        /*********
*********************************************************\\\a       /********************************************************************\\\a      /**********************************************************************\\\a     /************************************************************************\\\a    /**************************************************************************\\\a   /****************************************************************************\\\a  /******************************************************************************\\\a                                    |--------|\a                                    |--------|\a                                    |--------|\a                                    |--------|\a                                    |--------|\a                                    |--------|\a                                    |--------|\a                                    |--------|\a                                    |--------|\a                                    
|--------|\a                                    |--------|\a                                    |________|"; }

the resulting page

share|improve this answer
1  
You don't see a ton of HTML/CSS solutions on CodeGolf. Nice job. –  Mordred Aug 20 at 20:02
1  
+1 because Haml & Sass –  Mark Aug 21 at 15:23

GolfScript, 79 characters

10,{:^4+,{2*^6*+'*'*.,2/~40+' '*'/'@'\
'}/}/[' '35*]12*'|--------|
'*'||''_'8**

Try the code here. Note that the line breaks aren't optional in this code

share|improve this answer
22  
A multi-line GolfScript solution? I didn't think I'd see the day! –  Ingo Bürk Aug 19 at 17:24

CJam, 62 bytes

A,{I4+,{I3*J+_39\-S*'/@2*'**'\N}fJ}fI{35S*'|'-8*'|N++}C*'-/'_*

Try it online.

How it works

A,           " Push [ 0  …  9 ].                                                   ";
{            " For each I in that array:                                           ";
  I4+,       " Push [ 0  …  I + 3 ].                                               ";
  {          " For each J in that array:                                           ";
    I3*J+_   " Push K := 3 * I + J twice.                                          ";
    39\-S*   " Push a string consisting of 39 - K spaces.                          ";
    '/       " Push a slash.                                                       ";
    @2*'**   " Push a string consisting of 2 * K asterisks.                        ";
    '\N      " Push a backslash and a linefeed.                                    ";
  }fJ        "                                                                     ";
}fI          "                                                                     ";
{            " Do the following 12 times:                                          ";
  35S*       " Push a string consisting of 35 spaces.                              ";
  '|         " Push a vertical bar.                                                ";
  '-8*'|++   " Push the string '--------|\n'.                                      ";
}C*          "                                                                     ";
'-/'_*       " Replace the hyphen-minus signs of the last string with underscores. ";
share|improve this answer
2  
I've got to start using CJam instead of GolfScript... –  Claudiu Aug 20 at 16:10
    
What makes CJam code so compact? Is it just usual features match together well or there is some super-trick? Or it's actually not CJam, but CJam programmers so? –  Vi. Aug 21 at 1:40
2  
@Vi.: It's a mix of both. 1. CJam is stack based, so you usually get away without using any variables. 2. All built-ins' names are at most two characters long. Because of this, you don't need whitespace except for some special cases. 3. Even submissions in golfing languages don't golf themselves. My GolfScript/CJam programs are a lot shorter now than they used to be. –  sudo Aug 21 at 3:29
    
Suggestion for CJam would be to use ASCII codes 128-256 for a whole nother set of built-ins. have some special editor that –  Claudiu Aug 21 at 19:36
    
@Claudiu: Well, that's up to its creator. If I designed my own golfing language, I think I would make it bit-based or encode all instructions arithmetically. –  sudo Aug 21 at 23:30

Python, 148 129 126 121 characters

R=range
for i in R(10):
 for j in R(i*3,4+i*4):print' '*(39-j)+'/'+'**'*j+'\\'
for c in'-'*11+'_':print' '*35+'|'+c*8+'|'

Thanks to Falko for saving 3 characters and to flornquake for brilliantly saving another 5!

share|improve this answer
1  
Python's character multiplication is a bit too perfect for this challenge... –  ipi Aug 19 at 15:24
    
Wait 'till you see my golfscript solution... =P –  Claudiu Aug 19 at 15:25
    
Character multiplication is perfect for any kolmogorov-complexity problem, but that's part of the game! –  Nax Aug 19 at 15:27
2  
Use '**'*j to save 3 characters. Apart from this my solution converges to the exact same code. :) –  Falko Aug 19 at 22:37
1  
You can make the last line shorter by writing for c in'-'*11+'_':print' '*35+'|'+c*8+'|'. –  flornquake Aug 21 at 8:54

Bash, 236 197 193

10 bytes of code + 1-byte filename + 182-byte data file = 193 bytes total

zcat y 2>j

Explanation

y is a file containing the Yggdrasil, without a trailing new line, compressed with the zopfli algorithm (invoked as zopfli --i64) and then with the last 8 bytes removed. zopfli is compatible with gzip, so I can decompress the file with standard Bash utilities designed for gzip. The size of the data file is 182 bytes (229 bytes when normal gzip is used). The size of the original Yggdrasil, without the trailing new line, is 5876 bytes.

The removal of the last 8 bytes causes error messages, which are suppressed by sending standard error to a file called j. If j exists, it will be overwritten.

The base64 of y is (use base64 -d to obtain the original file):

H4sIAAAAAAACA+3SMQoCURDA0N5TWC+IFxK8yD/8Nul9hfDRnamT6J+du83zdUPwOACNNDb0+3Bs
tMPhSscDvusHgM9wIcUNclL+5r/luJXkmlh5rM3r8txkMdVNcEn1Nc2a1AU72XWz3Xd91r5z7eZD
AQKQgAI0PDFf8xJfExpQgQhkpAIdz8ytzK3AQMg6UMIQpLQELU/NQc5B/thBegtqHpOc16jHOX/v
x1mPZg19MfrdrBM=

And the md5sum is:

4a049a80241160cdde0a3cbca323b7f2
share|improve this answer
2  
My finger was itching to hit the "delete" button when I saw the code, until I read the character count and explanation. :P –  Doorknob Aug 19 at 19:13
2  
You can save about 30 bytes by using zopfli to make the compressed file. "zopfli --i100 y" yields a 190-byte file that zcat can decompress. –  Glenn Randers-Pehrson Aug 19 at 22:44
1  
And a few more if you delete the last 10 bytes and close STDERR. –  sudo Aug 19 at 23:57
    
@GlennRanders-Pehrson thanks for pointing this out, I've also edited my answer to 'Molar masses of compounds' codegolf.stackexchange.com/a/35613/16402 to use zopfli, saving 37 bytes –  professorfish Aug 20 at 8:26
    
@Dennis it turned out to be 8 bytes (any more and bits of the Yggdrasil's trunk would be missing), thanks –  professorfish Aug 20 at 8:27

C, 169

i;j;p(a,b){while(b--)putchar(a);}main(){for(;i++<10;)for(j=i*3-4;++j<i*4;p(32,39-j),p(47,1),p(42,j*2),puts("\\"));for(++i;i--;p(32,35),p(124,1),p(i?45:95,8),puts("|"));}

Ungolfed (and slightly disentangled):

int i;
int j;
void p(a,b) {
  while (b--) putchar(a);
}
void main() {
  for (;i++<10;) {
    for (j=i*3-4;++j<i*4;) {
      p(32,39-j);
      p(47,1);
      p(42,j*2);
      puts("\\");
    }
  }
  for (++i;i--;) {
    p(32,35);
    p(124,1);
    p(i?45:95,8);
    puts("|");
  }
}
share|improve this answer

Ruby - 100

puts (0..21).map{|i|i>9??\ *35+?|+(i>20??_:?-)*8+?|:(0..i+3).map{|y|?\ *(39-z=y+3*i)+?/+?**z*2+?\\}}

Puts auto-flattens, so we can collect all the lines even in nested arrays. Needs Ruby 1.9

Try at ideone

share|improve this answer
    
I think it needs some leading spaces. Also, works with Ruby 1.9, but not in 1.8. –  Scott Leadley Aug 19 at 18:28

C# 258 234bytes

Thanks to some annoymous user for the suggested edits making good use of the String.PadLeft method!

using System;class G{static void Main(){Action<string>p=Console.WriteLine;int i=0,j;for(;i++<10;)for(j=i*3-3;j++<i*4;)p("/".PadLeft(41-j)+"\\".PadLeft(2*j-1,'*'));while(i-->0)p("|--------|".PadLeft(45));p("|________|".PadLeft(45));}}

The code is pretty simple, not much left to golf.

Formatted code:

using System;
class G
{
    static void Main()
    {
        Action<string> p = Console.WriteLine;
        int i = 0, j;
        for(; i++ < 10 ;)
            for(j = i*3 - 3; j++ < i*4;)
                p("/".PadLeft(41 - j) + "\\".PadLeft(2*j - 1,'*'));
        while(i-- > 0)
            p("|--------|".PadLeft(45));
        p("|________|".PadLeft(45));
    }
}
share|improve this answer
    
Using \r is pointless here. This is code golf. –  nyuszika7h Aug 19 at 15:56
2  
@nyuszika7h indeed, but it's included in the formatted copy for good measure so that people using notepad can more easily see the glory of the Yggdrasil (it's not included in the score) –  VisualMelon Aug 19 at 16:06
    
Oh, I see. Windows... Feel free to fix my edit then. –  nyuszika7h Aug 19 at 16:07
    
@nyuszika7h thanks for pointing out the Syntax Highlighting wasn't right –  VisualMelon Aug 19 at 16:10

PowerShell 104 101

0..9|%{(3*$_)..(3+$_*4)|%{" "*(39-$_)+"/"+"*"*2*$_+"\"}};0..11|%{" "*35+"|"+("-","_")[$_-eq11]*8+"|"}
share|improve this answer

J, 98 88 84 75

(85 11 1#3 4$' /*\ |-| |_|')#"1~(39&-,1,+:,1:)"0(12$4),~85(-4&+#-:*>:)&i.10
share|improve this answer

Perl, 127

for$i(0..9){for$j($i*3..3+$i*4){print" "x(39-$j),"/","*"x($j*2),"\\\n";}}for$i(0..11){print" "x35,"|",($i>10?"_":"-")x8,"|\n";}

Ungolfed:

for $i (0..9) {
  for $j ($i*3..3+$i*4) {
    print " "x(39-$j) , "/" , "*"x($j*2) , "\\\n";
  }
}
for $i (0..11) {
  print " "x35 , "|" , ($i>10?"_":"-")x8 , "|\n";
}
share|improve this answer
    
Replace $i with $_ and save 4 characters. –  choroba Aug 24 at 17:09

Ruby - 139 129 126 123 121

Hoisted "puts" outside of array creation (suggestion from bitpwner).

puts (0..9).map{|i|(i*3...(i+1)*4).map{|j|"/#{'**'*j}\\".rjust(41+j,' ')}}+["%45s"%'|--------|']*11<<'%45s'%'|________|'


Ungolfed ("puts" unhoisted):


# print fill patterns from the intervals
# [0..3, 3..7, 6..11, 9..15, 12..19, 15..23, 18..27, 21..31, 24..35, 27..39]
# centered on columns 81-82
(0..9).each { |i|
  (i*3...(i+1)*4).each { |j|    # x...y vs x..y-1 saves a char
    puts "/#{'**'*j}\\".rjust(41+j,' ')
  }
}
# print the stump
puts ("%45s\n" % '|--------|') * 11
puts '%45s' % '|________|'
share|improve this answer
    
@bitpwner I think this deserves it's own answer. Go for it. –  Scott Leadley Aug 19 at 16:58
    
Posted. Thanks! =) –  bitpwner Aug 19 at 17:14

PHP 223 202 181 160 156

Edit I figured out how to alias a function with a variable and was able to chop off some more characters. That str_repeat function was really verbose

Edit 2: Thanks everyone for the suggestions!

Golfed:

<?$s=str_repeat;for($i=-1;$i++<9;)for($j=$i*3;$j<4+$i*4;)echo$s(' ',39-$j).'/'.$s('**',$j++)."\\
";for($i=12;$i--;)echo$s(' ',35),'|'.$s($i?'-':'_',8)."|
";

Readable:

    <?

$s=str_repeat;

for($i=-1;$i++<9;)
{
    for($j=$i*3;$j<4+$i*4;)
    {
        echo$s(' ',39-$j).'/'.$s('**',$j++)."\\
        ";
    }
}

for($i=12;$i--;)
{
    echo$s(' ',35),'|'.$s($i?'-':'_',8)."|
    ";
}

Output: http://brobin.me/yggdrasil.php

share|improve this answer
    
You can save 6 chars by removing parenthesis around (39-$j), ($j*2) and ($i==11). -2 by replacing \n with real new line characters (PHP allows it in litterals). -5 chars by replacing (both) for($i=0;$i<12;$i++) with for($i=12;$i-->0;) and $i==11 with $i==0. –  sebcap26 Aug 21 at 10:56
    
After that you can also replace $s(($i==0?'_':'-'),8) with $s($i?'-':'_',8). (==> -5 chars) –  sebcap26 Aug 21 at 11:04
    
-1 Character by replacing $s('*',$j*2) with $s('**',$j). I think that's the last improvement that I can find. –  sebcap26 Aug 21 at 11:44
    
-2 changing ($j*2) in inner for to ($j++*2) and removing $j++ from for() arguments –  avall Aug 21 at 12:47
    
@sebcap26 for($i=12;$i-->0;) can be shortened to for($i=12;$i--;) - another 2 chars. –  avall Aug 21 at 13:23

JavaScript (console.log), 168 166

(Whitespace for readability only)

for(i=c=0;i<11;i++)
  for(j=0;j<4+i&!c;j++)
    l=i*13+j,
    a=Array(n=i-10?3*i+j+1:5).join("*-_"[k=(l>129)+(c=l==141)]),
    console.log(Array(41-n).join(" ")+'/||'[k]+a+a+'\\||'[k])
share|improve this answer

C (219)

Thanks to everyone for the golfing tips -- managed to get it down to 219. Don't think it'll go much lower.

w,W,s,S,i,r;main(){char T[78];memset(T,42,78);for(r=4,s=39;r<14;++r,s-=3,w+=6)for(i=0,S=s,W=w;i<r;++i,W+=2,--S)printf("%*s/%.*s\\\n",S,"",W,T);for(i=0;i<11;i++)printf("%35s|--------|\n","");printf("%35s|________|","");}

Required includes:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
share|improve this answer
    
You should start by removing newlines, they aren't compulsory in C, except for preprocessor directives. Also, you can abuse of C89 implicit int rule, golfing a little more. Nice anyway :) –  Nax Aug 19 at 15:20
    
If he's willing to use C89 he can omit all the includes as well. There is no case in this code where implicit declaration on call screws up. –  Joshua Aug 19 at 15:24
    
@Nax; that gets me to 263 -- and I pulled includes out. Thanks. –  DreamWarrior Aug 19 at 15:24
    
@Joshua -- 64 bit systems and memset could be problematic, but...otherwise, maybe not. Either way, most people remove the includes, so I did, too. –  DreamWarrior Aug 19 at 15:26
    
It's actually 262 characters, you don't need the trailing newline. –  nyuszika7h Aug 19 at 15:49

Haskell, 153 148

Straight-forward, no tricks, just plain golfing:

(a:b:c)%n=(39-n)&' '++a:(2*n)&b++c
n#m=[n..m]++(n+3)#(m+4)
(&)=replicate
main=putStr$unlines$map("/*\\"%)(take 85$0#3)++map("|-|"%)(11&4)++["|_|"%4]

The % operator draws a single line, its first argument being a String of length 3 containing the borders and the fill characters in that line (now assuming exactly 3 Chars, saving 5 bytes), the second, an Int, specifies half the number of fill characters. Pattern matching, cons-ing and appending is used in combination in order to save bytes by taking care of the "glue" between Char and String. In this second version, I also made # infinite and introduced a take 85 to make it finite again (no bytes saved, unfortunately).

The # operator creates the sequence for the n argument to % required for the tree: [0..3], [3..7], ... concatenated.

& is just an infix shorthand for replicate, which occurs three times.

The tree is put together in the last line, the newlines are added by unlines.

share|improve this answer

Delphi 429

Will try to improve later.
Golfed

uses strutils,SysUtils,Classes;const a='|----';b='|____';c:array [0..9,0..1]of int32=((0,3),(3,7),(6,11),(9,15),(12,19),(15,23),(18,27),(21,31),(24,35),(27,39));var t:TStrings;i,j:integer;begin t:=tstringlist.Create;for I:=0to 9do for J:=c[i,0]to c[i,1]do t.Add('/'+StringOfChar('*',j));for I:=0to 10do t.Add(a);t.Add(b);for I:=0to t.Count-1do t[i]:=t[i].PadLeft(40)+ReverseString(t[i]).Replace('/','\');write(T.TEXT);readln;end.

ungolfed

uses
  strutils,SysUtils,Classes;
const
  a='|----';
  b='|____';
  c:array [0..9,0..1]of int32=((0,3),(3,7),(6,11),(9,15),(12,19),(15,23),(18,27),(21,31),(24,35),(27,39));
var
  t:TStrings;
  i,j:integer;
begin
  t:=tstringlist.Create;
  for I:=0to 9do
    for J:=c[i,0]to c[i,1]do
      t.Add('/'+StringOfChar('*',j));
  for I:=0to 10do
    t.Add(a);
  t.Add(b);
  for I:=0to t.Count-1do
    t[i]:=t[i].PadLeft(40)+ReverseString(t[i]).Replace('/','\');
  write(T.TEXT);
  readln;
end.
share|improve this answer

Javascript, 288 281

Chrome hides duplicated console.logs, use IE instead.

function t(w){s="";for(i=0;i++<39-w;)s+=" ";s+="/";for(i=0;i++<w*2;)s+="*";return s+"\\"}function r(l){s="";for(i=0;i++<36;)s+=" ";s+="|";for(i=0;i++<8;)s+=l;return s+"|"}w=0;c=console;for(h=0;h++<10;){for(j=0;j++<3+h;)c.log(t(w++));w-=h}for(j=0;j++<11;)c.log(r('-'));c.log(r('_'))

Ungolfed:

function t(w)
{
    s="";
    for(i=0;i++<39-w;)
        s+=" ";
    s+="/";
    for(i=0;i++<w*2;)
        s+="*";
    return s+"\\"
}
function r(l)
{
    s="";
    for(i=0;i++<36;)
        s+=" ";
    s+="|";
    for(i=0;i++<8;)
        s+=l;
    return s+"|"
}

w=0;
c=console;
for(h=0;h++<10;)
{
    for(j=0;j++<3+h;)
        c.log(t(w++));
    w-=h;
}
for(j=0;j++<11;)
    c.log(r('-'));
c.log(r('_'))
share|improve this answer
    
Use for(i=0;i++<39-w;) instead of for(i=0;i<39-w;++i), and so on. Also, p=console.log instead of c=console and p instead of c.log (although I only tested the latter in Node.js, it doesn't work in Firefox). This saves 12 bytes. –  nyuszika7h Aug 19 at 16:10
    
c=console.log didn't work in Chrome either, so I didn't use it. The for loop tricks save 7 bytes though. –  ipi Aug 19 at 16:33
    
I'm usually quite wary of anything encouraging me to use MSIE... –  professorfish Aug 19 at 17:45
    
This is quite possibly the first time I've ever seen the phrase "use IE instead." O_o However, you can suppress Chrome's behavior by simply running this code in the console instead of from a webpage. –  Doorknob Aug 19 at 19:17
    
Running it in a page and in the console produces the same results for me on both Firefox and Chrome. –  ipi Aug 19 at 20:05

Lua - 164

a=' 'for i=0,9 do for j=i*3,3+i*4 do print(a:rep(39-j)..'/'..(('*'):rep(j*2))..'\\')end end for i=0,11 do print(a:rep(35)..'|'..((i>10 and'_'or'-'):rep(8))..'|')end
share|improve this answer

Mathematica 191 178

For sure not the best solution:

n=Nest;
t=Table;
""<>
    t[
        {n[#<>" "&,"",39-i],"/",n[#<>"*"&,"",2i],"\\\n"}
    ,
        {i,Flatten@t[Range[j+4]-1+3j,{j,0,9}]}
    ]
<>
    t[
        n[#<>" "&,"",35]<>If[i==12,"|________|\n","|--------|\n"]
    ,
        {i,12}
    ]

Not counting newlines. Mathematica skews the output, as it doesn't take the same width for a whitespace as for "*" and "/". But the result is correct.

share|improve this answer
    
(it's my first golf) –  freddieknets Aug 21 at 3:09

Groovy 118

10.times{(it*3).upto 3+it*4,{println' '*(39-it)+'/'+'*'*it*2+'\\'}};12.times{println' '*35+'|'+(it>10?'_':'-')*8+'|'}
share|improve this answer
1  
Why am I not surprised to see a pretty short Groovy solution. My impression of Groovy was that it was done by a Java programmer who hated typing. –  Almo Aug 21 at 13:38

C,194

This code is a hot mess and can definitely be golfed more. Still, it was an opportunity to try out a couple of things I've never done before: using a literal for a string of asterisks, and using the width specifier * with a string in printf.

i,j=5,k=5,n;
main(){
  char d[]={[0 ...77]=42,0};
  for(;i<85;i++)k--,j+=!k,k+=(j-1)*!k,n=39-i+(j-5)*(j-4)/2,printf("%*s/%s\\\n",n,"",d+n*2);
  for(;i<97;i++)printf("%*s|\n",44,i-96?"|--------":"|________");
}
share|improve this answer

C 236

This is my unsuccessful attempt to improve squeamish ossifrage's answer.

Travels left to right on each line, one character at a time, printing the correct character.

Things I learned from j=!j?s+=++c,d++

  • Comma operator can be used in assignment, the left value is processed and ignored.
  • Ternary branches are only evaluated if the condition is met, allowing for strategic ++
s,d,i,j,c;
p(z,y,x,w,v,u)
{
while(i++<z)
printf("%c", i<y?x:i==y?w:i<z?v:u);
puts("");
}
main()
{
for(s=40,j=3,d=4;d<14;i=0,s--,j=!j?s+=++c,d++:j-1)
p(81-s,s,32,47,42,92);      
for(s=35,d=11;d;i=0,d--)
p(46,s,32,'|',45,'|');
i=0;
p(46,s,32,'|',95,'|');
}

Not counting new lines.

And a bit easier to read:

s,d,i,j,c;
int main()
{
    for(s=40,j=3,d=4;d<14;i=0,s--,j=!j?s+=++c,d++:j-1)
    {
        while(i++<=80-s)
        printf("%c", i<s?32:i==s?47:i<=80-s?42:92);
        puts("");
    }

    for(s=35,d=11;d;i=0,d--)
    {
        while(i++<46)
        printf("%c", i<35?32:i==35?'|':i<46?45:'|');
        puts("");
    }

    i=0;
    while(i++<46)
    printf("%c", i<35?32:i==35?'|':i<46?95:'|');
    puts("");

   return 0;
}
share|improve this answer

Java - 286

My first golf.

Golfed:

class M{public static void main(String[]args){int i=0,a,f=0;String s="";for(;i++<11;){for(a=i*3-4;++a<i*4;){if(i>10){a=4;if(++f>12)break;}s+=s.format("%"+(40-a)+"s"+(a>0?"%0"+a+"d":"")+"%3$s",f>0?"|":"/",0,f>0?"|":"\\").replace("0",f<1?"**":f>11?"__":"--")+"\n";}}System.out.println(s);}}

Ungolfed:

class M {
    public static void main(String[] args) {
        int i=0,a,f=0;
        String s = "";
        for(;i++<11;){
            for(a=i*3-4;++a<i*4;a++){
                if(i>10){
                    a=4;
                    if(++f>12)break;
                }
                s+=s.format("%"+(40-a)+"s"+(a>0?"%0"+a+"d":"")+"%3$s",f>0?"|":"/", 0,f>0?"|":"\\").replace("0", f<1?"**":f>11?"__":"--")+"\n";
            }
        }
        System.out.println(s);
    }
}

Test here

share|improve this answer

Cobra - 166 228 260

class P
    def main
        for x in 10,for n in 4+x,print' '.repeat(39-x*3-n)+'/['**'.repeat(x*3+n)]\\'
        w=' '.repeat(35)
        print'[w]|--------|\n'.repeat(11)+w+'|________|'
share|improve this answer

Python (313)

'eJztmEsOwjAMBfecoutIFUfiIjk8FAJNE3+eE0sI6qxnRq3jVZYFOlcQSwnlMPIJeqOFRNgPCsAVq9MH+Lvxhtb4DlcEgpcNUvjBr2IMyWEVQRIc3hKlk/2VYnGeqjEi4NEmJMZwrCpoUi6sErLB7W2THKPGXe9RG+3WN+tNYMA/FoYCcX9/dH+DhboxnKgiE429MhWJ3egSsRttZrLy7kxnSsih8yq5hGL9+Eqsn1TyWz+n0tZySz1ijq2UXGPQi1pey8mXoM9F38rJd5RXZaM='.decode('base64').decode('zip')
share|improve this answer
    
Doesn't output anything. With print,the backslashes and linefeeds seem to be missing. –  sudo Aug 22 at 17:21

Racket 223 220 211 204 198

Golfed:

(for-each display(flatten(let([m make-list])`(,(for*/list([i 10][j(range(* i 3)(* 4(+ 1 i)))])`(,(m(- 39 j)" ")"/",(m j"**")"\\\n")),(for/list([c`(,@(m 11"-")"_")])`(,(m 35" ")"|",(m 8 c)"|\n"))))))

Ungolfed:

(for-each display
     (flatten
      (let([m make-list])
        `(,(for*/list([i 10][j(range(* i 3)(* 4(+ 1 i)))])
             `(,(m(- 39 j)" ")"/",(m j"**")"\\\n"))
          ,(for/list([c`(,@(m 11"-")"_")])
             `(,(m 35" ")"|",(m 8 c)"|\n"))))))
share|improve this answer

Javascript 256 257 255

An improvement on @ipi's submission:

function x(a,b){for(q="";b-->0;)q+=a;return q}function t(a){return x(" ",41-a)+"/"+x("*",2*a)+"\\"}function r(a){return x(" ",36)+" |"+x(a,8)+"|"}for(w=0,c=console,h=1;h++<11;){for(;j++<3+h;)c.log(t(w++));j=0,w-=h}for(;j++<11;)c.log(r("-"));c.log(r("_"));

Expands to:

function x(s,c) {
    q=""
    while(c-- >0) 
      q+=s;
    return q;
}
function t(p)
{
    return x(" ",41-p) + "/" + x("*", p*2) + "\\";
}
function r(l)
{
    return x(" ", 36) + " |" + x(l, 8) + "|";
}
w=0;c=console;
for(h=1;h++<11;)
{
    for(;j++<3+h;)
        c.log(t(w++));
    j=0;
    w-=h;
}
for(;j++<11;)
    c.log(r('-'));
c.log(r('_'))

Required initial condition: j is undefined or equal to 0. This is true for a brand new Node REPL;

share|improve this answer
1  
It is undefined "in a clean environment." I got ReferenceError: j is not defined. Tested in Firefox and Node.JS –  core1024 Aug 19 at 17:25
    
When running your code, I get ReferenceError: j is not defined in a "brand new Node REPL". –  Doorknob Aug 19 at 19:22
    
Curious... what version of Node are you running? –  Dancrumb Aug 19 at 20:23
    
No, it’s not true for a brand new REPL of any kind. Also, incrementing undefined results in NaN anyways. –  minitech Aug 23 at 4:40

Python 2, 117

j=0
while j<40:j-=j/4;exec(j/3+4)*r"print' '*(39-j)+'/'+'**'*j+'\\';j+=1;"
for c in'-'*11+'_':print' '*35+'|'+c*8+'|'

Other versions I tried include:

# 118
for i in range(10):j=i*3;exec(i+4)*r"print' '*(39-j)+'/'+'**'*j+'\\';j+=1;"
for c in'-'*11+'_':print' '*35+'|'+c*8+'|'

# 118
i=j=4
while j:j=52-3*i;exec"j-=1;print' '*j+'/'+'**'*(39-j)+'\\\\';"*i;i+=1
for c in'-'*11+'_':print' '*35+'|'+c*8+'|'

# 118
j=0
for b in'\\'*10:j-=j/4;exec(j/3+4)*"print' '*(39-j)+'/'+'**'*j+b;j+=1;"
for c in'-'*11+'_':print' '*35+'|'+c*8+'|'

# 119
s=40
while s:s+=10-s/4;exec(52-s)/3*r"s-=1;print' '*s+'/'+'**'*(39-s)+'\\';"
for c in'-'*11+'_':print' '*35+'|'+c*8+'|'
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.