39
\$\begingroup\$

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!

\$\endgroup\$
  • 10
    \$\begingroup\$ 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." \$\endgroup\$ – Level River St Aug 19 '14 at 14:18
  • \$\begingroup\$ Also related: codegolf.stackexchange.com/q/4244/194 . \$\endgroup\$ – Peter Taylor Aug 19 '14 at 14:52
  • 4
    \$\begingroup\$ @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 \$\endgroup\$ – naught101 Aug 21 '14 at 14:28
  • \$\begingroup\$ @Nax Hmm. You are correct. The pedant (me) is hoist on his own petard. The md5sums have changed. \$\endgroup\$ – Scott Leadley Aug 22 '14 at 13:52
  • 1
    \$\begingroup\$ Err, point of order, Yggdrasil is definitely an ash tree in the eddas, not a fir. Kinda like this. \$\endgroup\$ – Alex P Aug 22 '14 at 15:06

37 Answers 37

0
\$\begingroup\$

Python (313)

'eJztmEsOwjAMBfecoutIFUfiIjk8FAJNE3+eE0sI6qxnRq3jVZYFOlcQSwnlMPIJeqOFRNgPCsAVq9MH+Lvxhtb4DlcEgpcNUvjBr2IMyWEVQRIc3hKlk/2VYnGeqjEi4NEmJMZwrCpoUi6sErLB7W2THKPGXe9RG+3WN+tNYMA/FoYCcX9/dH+DhboxnKgiE429MhWJ3egSsRttZrLy7kxnSsih8yq5hGL9+Eqsn1TyWz+n0tZySz1ijq2UXGPQi1pey8mXoM9F38rJd5RXZaM='.decode('base64').decode('zip')
\$\endgroup\$
  • \$\begingroup\$ Doesn't output anything. With print,the backslashes and linefeeds seem to be missing. \$\endgroup\$ – Dennis Aug 22 '14 at 17:21
0
\$\begingroup\$

Jelly, 56 bytes

4Ḷ4ịr+L}¥¥Ɗ9СẎḤ”*ẋ⁾/\jЀ;⁾-_x11,1¤ẋ8⁾||jƊ€¤µLH40_⁶ẋ;µ€Y

Try it online!

\$\endgroup\$
0
\$\begingroup\$

PHP, 140 138 136 bytes

while($n--||30>$w+=3-$n=3+$i++)echo($p=str_pad)("",39-$w),$p("/",1|2*$w++,"*"),"\\
";while(-~$i)echo$p("",35),$p("|",9,$i--?"-":_),"|
";

less golfed:

for(;$i<10;$w-=$i)for($n=3+$i++;$n--;)
    echo str_pad("",39-$w), str_pad("/",1+2*$w++,"*"),"\\\n";
for($i++;$i--;)
    echo str_pad("",35), str_pad("|",9,$i?"-":_),"|\n";

Run with php -nr '<code>' or try it online. Requires PHP 7.

\$\endgroup\$
0
\$\begingroup\$

Japt -R, 51 50 49 48 bytes

Ao*3 cÈôY+3@'\i'/+Xç*²
cCÆ'|i|+8ç"-_"gXzB})û mx1

Test it

Ao*3 cÈôY+3@'\i'/+Xç*²
A                             :10
 o                            :Range [0,A)
  *3                          :Multuply each by 3
     c                        :Flatten after ...
      È                       :  Map each X at 0-based index Y
       ôY+3                   :    Sorted range [X,X+Y+3]
           @                  :    Map each X
            '\i               :      Prepend "\" with
               '/+            :        "/" appended with
                  Xç          :          X times repeat
                    *²        :            "*" repeated twice
cCÆ'|i|+8ç"-_"gXzB})û mx1
c                             :Concatenate
 C                            :  12
  Æ                           :  Map each X in the range [0,C)
   '|i                        :    Prepend "|" with
      |+                      :      "|" appended with
        8ç                    :        8 times repeat
          "-_"g               :          Get the character in "-_" at index
               Xz             :            X floor divided by
                 B            :              11
                  }           :  End map
                   )          :End concat
                    û         :Centre pad each element with spaces to the length of the longest
                      m       :Map
                       x1     :  Trim right
                              :Implicit output, joined with newlines
\$\endgroup\$
0
\$\begingroup\$

05AB1E, 36 bytes

TLεÌÝN3*+'*×'/ì]˜…|--11и…|__ªº€¨«º.c

Try it online!

TLε            ]       # for y in [1 .. 10]
   ÌÝ                  #  [0 .. y+2]
     N                 #  0-based iteration count (effectively y-1)
      3*               #  times 3
        +              #  add (vectorizes over the range, yielding [3*y-3 .. 4*y-1])
         '*×           #  "*" repeated that many times (vectorizes)
            '/ì        #  prepend "/" (vectorizes)
˜                      # flatten
 …|--                  # literal "|--"
     11и               # repeated 11 times as an array
        …|__           # literal "|__"
            ª          # appended to that array
             º         # mirror (vectorizes: ["|----|", "|----|", ..., "|____|")
              ۬       # remove the last character of each
                «      # merge the two lists (["/", "/*", ..., "|----", ...])
                 º     # mirror
                  .c   # center
\$\endgroup\$
0
\$\begingroup\$

C (gcc), 163 160 159 bytes

-3 -1 bytes thanks to ceilingcat.

j,w,s[99];main(i){for(;++i<12;w-=i-1)for(j=i+2;j--;)printf("%*c%.*s\\\n",40-w++,47,w*2,memset(s,42,99));for(;i--;)printf("%44s|\n",i?"|--------":"|________");}

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Is limiting the number of printed string characters by using "%.*s" in a printf call standard behaviour? \$\endgroup\$ – Jonathan Frech Feb 20 '18 at 17:42
  • \$\begingroup\$ @JonathanFrech Yep, should be. "If the precision is specified, no more than that many bytes are written." - §7.21.6.1 of this document. (It regards fprintf, but the section on printf states that the format string works the same way as for fprintf.) \$\endgroup\$ – gastropner Feb 21 '18 at 0:51
0
\$\begingroup\$

Canvas, 40 bytes

A{3+{╷¹╷3×+*×/×}]⁵-*_∔{4×|×]∔{║L»‾◂∔ ××]

Try it here!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy