53
\$\begingroup\$

Your task is to draw the mandelbrot set in ascii. It should look something like enter image description here

The complex number c lies in the mandelbrot set, when the sequence z(n+1) = z(n)^2 + c, z(0) = 0 remains bounded. For the purpose of this challenge you can consider the sequence bounded for c if |z(32)| < 2.

Plot the mandelbrot set on the complex plane from (-2 - i) to (1 + i), and a minimum resolution of 40x30, using ascii characters in your favourite language, using as few characters as possible.

\$\endgroup\$
11
  • 35
    \$\begingroup\$ Since the specification is a little bit unclear with respect to that point I can propose the following low-res ;-) 1-char php solution: * \$\endgroup\$
    – Howard
    Commented Jul 6, 2011 at 17:32
  • 3
    \$\begingroup\$ Well I was hoping I could just say "don't be a jerk" :D. We'll go with at least 40x30 then. \$\endgroup\$
    – Hannesh
    Commented Jul 6, 2011 at 18:40
  • 3
    \$\begingroup\$ I have a personal preference for tasks that solve a class of problems rather than one instance. Making the region to use an input would makes this questions qualify. In any case, the specification is a bit light. In the future you can get help with these kinds of issues on the meta sandbox or the puzzle lab chat before you task goes live \$\endgroup\$ Commented Jul 6, 2011 at 19:16
  • 1
    \$\begingroup\$ @Hannesh, I agree with dmckee. If you change the question, I'll be happy to add arguments. \$\endgroup\$
    – boothby
    Commented Jul 7, 2011 at 0:01
  • 2
    \$\begingroup\$ Here's a source code in the shape of the mandelbrot set, which then generates high resolution mandelbrot set (preshing.com/20110926/…) - OT for this question but I thought people here might like it. \$\endgroup\$
    – DanBeale
    Commented Oct 1, 2011 at 11:54

31 Answers 31

25
\$\begingroup\$

C, 988 chars

Here's mine, which does an ASCII mandelbrot, written as an ASCII mandelbrot, in C.

Oh.. and it also has interactive zoom functionality. (press the keypad numbers 1-9 to zoom in on the respective area)

int main(int argc, char* argv[]){ unsigned
char c='r';double x1,y,y1,t=0,q=78,r=22,x,
x2,y2,a,b,v;do{(c=='r')?(y2=-(y1=-1.6),x1=
-2.0f,x2=0.8):(c=='?')? c=0,   printf("%f\
,%f:%f,%f",x1,y1,x2,y2):(c     <':'&&c>48)
?x=x1,y=y1,*(c>'3'&&c<':'        ?&y1: &t)
+=(y2-y1)/3,*(c>'6'&&c<            ':'?&y1
:&t)+=(y2-y1)/3, *((c               == '8'
||c+3=='8'||c+3 +3==               '8'?&x1
:&t))+=(x2-x1     )/                3,*((c
=='9'||c+3==                        '9'||c
+6=='9'                          ?&x1: &t)
)+=2*(x2-x1)                        /3,x2=
x1+(x2-x)/3,      y2                 =y1+(
y2-y)/3:(c=0);for(y=                y2;y>=
y1&&c;c=1,y-=(y2-y1)/r,            putchar
('\n')) for(x=x1;x<=x2;            x+=(x2-
x1)/q){a=b=c=0; while  (        ++c&&(a=(t
=a)*a)<4&&(v=b*b)<4)a-=v-x     ,b=y+b*2*t;
putchar("#@XMW*N&KPBQYKG$R"   "STEEVxHOUV"
"CT()[]%JL={}eou?/\\|Ili+~<>_-^\"!;:`,. "[
c?c>>2:63]);}} while((c=getchar ())!='x');
return 0;/* Mandelbrot - S.Goodwin.2001*/}

Originally posted here http://marquisdegeek.com/rnd_obs.php

\$\endgroup\$
3
  • \$\begingroup\$ Nice! Be sure to include a language header and byte count when answering code golf questions. Welcome to PPCG! \$\endgroup\$ Commented Mar 11, 2014 at 11:11
  • 4
    \$\begingroup\$ You can participate at the IOCCC with this code \$\endgroup\$ Commented Jun 14, 2016 at 22:03
  • \$\begingroup\$ @TùxCräftîñg: Not so obfuscated ... After all the white space is the documentation! \$\endgroup\$
    – sergiol
    Commented Jan 13, 2017 at 1:59
18
\$\begingroup\$

Common lisp -- 195 chars

(loop for y from -1 to 1 by 1/15 do
  (loop for x from -2 to 1 by .04 do
    (let*((c 126) (z (complex x y)) (a z))
      (loop while (< (abs (setq z (+ (* z z) a))) 2)
            while (> (decf c) 32)) 
      (princ (code-char c))))
  (terpri))

Tested with sbcl and clisp. Result:

~~~~~~~~~~~~~}}}}}}}}}}}}}}}}}}}}||||||||{{{zyvrwum{|||||}}}}}}~~~~~~~~~~~~~
~~~~~~~~~~~}}}}}}}}}}}}}}}}}}}}|||||||||{{{zyxvptwyz{{|||||}}}}}}~~~~~~~~~~~
~~~~~~~~~}}}}}}}}}}}}}}}}}}}}|||||||||{{{{zwLtb huwx{{{{||||}}}}}}}~~~~~~~~~
~~~~~~~~}}}}}}}}}}}}}}}}}}}|||||||||{{zzzyxvn    Knwyz{{{{||||}}}}}}~~~~~~~~
~~~~~~~}}}}}}}}}}}}}}}}}}||||||||{{zzzzyyywuk     qwxyzzzz{{|||}}}}}}~~~~~~~
~~~~~}}}}}}}}}}}}}}}}}}|||||||{{{zxjnpwwtjsqpi   lqrujnxyyxrz{|}}}}}}}}~~~~~
~~~~}}}}}}}}}}}}}}}}}|||||{{{{{zzzxt>  qf             pttfqeqz{|}}}}}}}}~~~~
~~~~}}}}}}}}}}}}}}}|||{{{{{{{{zzzxwup                      sxz{||}}}}}}}~~~~
~~~}}}}}}}}}}}}|||{z{{{{{{{zzzzywkmo                      rwyz{{||}}}}}}}~~~
~~}}}}}}}}}||||{{zwvyyyyyyyyyyyxvsP                        swvz{||}}}}}}}}~~
~~}}}}|||||||{{{zzwrtsww^uwwxxwvr                            iz{|||}}}}}}}~~
~}}}|||||||{{{{{zyxws  mj Ubhuutl                           sxz{|||}}}}}}}}~
~}||||||||{{{{{zyytun         qq                            avz{|||}}}}}}}}~
~|||||||{{zzzyxsvvum           j                            Sz{{|||}}}}}}}}~
~{{{{{yyzzzyyxwtbUP                                        qyz{{||||}}}}}}}~
~                                                        pvxyz{{||||}}}}}}}}
~{{{{{yyzzzyyxwtbUP                                        qyz{{||||}}}}}}}~
~|||||||{{zzzyxsvvum           j                            Sz{{|||}}}}}}}}~
~}||||||||{{{{{zyytun         qq                            avz{|||}}}}}}}}~
~}}}|||||||{{{{{zyxws  mj Ubhuutl                           sxz{|||}}}}}}}}~
~~}}}}|||||||{{{zzwrtsww^uwwxxwvr                            iz{|||}}}}}}}~~
~~}}}}}}}}}||||{{zwvyyyyyyyyyyyxvsP                        swvz{||}}}}}}}}~~
~~~}}}}}}}}}}}}|||{z{{{{{{{zzzzywkmo                      rwyz{{||}}}}}}}~~~
~~~~}}}}}}}}}}}}}}}|||{{{{{{{{zzzxwup                      sxz{||}}}}}}}~~~~
~~~~}}}}}}}}}}}}}}}}}|||||{{{{{zzzxt>  qf             pttfqeqz{|}}}}}}}}~~~~
~~~~~}}}}}}}}}}}}}}}}}}|||||||{{{zxjnpwwtjsqpi   lqrujnxyyxrz{|}}}}}}}}~~~~~
~~~~~~~}}}}}}}}}}}}}}}}}}||||||||{{zzzzyyywuk     qwxyzzzz{{|||}}}}}}~~~~~~~
~~~~~~~~}}}}}}}}}}}}}}}}}}}|||||||||{{zzzyxvn    Knwyz{{{{||||}}}}}}~~~~~~~~
~~~~~~~~~}}}}}}}}}}}}}}}}}}}}|||||||||{{{{zwLtb huwx{{{{||||}}}}}}}~~~~~~~~~
~~~~~~~~~~~}}}}}}}}}}}}}}}}}}}}|||||||||{{{zyxvptwyz{{|||||}}}}}}~~~~~~~~~~~
~~~~~~~~~~~~~}}}}}}}}}}}}}}}}}}}}||||||||{{{zyvrwum{|||||}}}}}}~~~~~~~~~~~~~

Slightly modified from B. Clementson blog.

\$\endgroup\$
3
  • \$\begingroup\$ This is code golf. Don't count indentation if it isn't needed. \$\endgroup\$
    – J B
    Commented Sep 29, 2011 at 8:06
  • \$\begingroup\$ @ JB. I updated the char count. It does not take superfluous spaces into account anymore. I have left the code indented for readability. I also tuned a parameter, the image now follows the size specification. \$\endgroup\$
    – stackman
    Commented Sep 29, 2011 at 19:18
  • \$\begingroup\$ Much better. Upvoted. \$\endgroup\$
    – J B
    Commented Sep 29, 2011 at 20:44
12
\$\begingroup\$

Python, 146 145 143char

z=lambda x,c,n:z(x**2+c,c,n-1)if n*(abs(x)<2)else x
for y in range(-15,16):print''.join(' @'[abs(z(0,x/25.+y/15j,32))<2]for x in range(-50,26))

Had to add the clause (abs(x)<2) to the conditional expression to keep Python from winging about overflows. But... this is a reason I love Sage...

Sage, 133char

z=lambda x,c,n:z(x^2+c,c,n-1)if n else abs(x)<2
for y in range(-15,16):
 print''.join(' +'[z(0,x/25+y/15j,32)]for x in range(-50,26))

Sample output (from python version)

                                                  @                         

                                            @  @                            
                                             @@@@@                          
                                             @@@@@                          
                                              @@@                           
                                    @@@  @@@@@@@@@@@@@                      
                                     @@@@@@@@@@@@@@@@@@@@@@                 
                                    @@@@@@@@@@@@@@@@@@@@@@                  
                                  @@@@@@@@@@@@@@@@@@@@@@@@@                 
                        @        @@@@@@@@@@@@@@@@@@@@@@@@@@@@               
                     @@  @@      @@@@@@@@@@@@@@@@@@@@@@@@@@@                
                     @@@@@@@@@  @@@@@@@@@@@@@@@@@@@@@@@@@@@@                
                    @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@               
                 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                 
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                   
                 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                 
                    @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@               
                     @@@@@@@@@  @@@@@@@@@@@@@@@@@@@@@@@@@@@@                
                     @@  @@      @@@@@@@@@@@@@@@@@@@@@@@@@@@                
                        @        @@@@@@@@@@@@@@@@@@@@@@@@@@@@               
                                  @@@@@@@@@@@@@@@@@@@@@@@@@                 
                                    @@@@@@@@@@@@@@@@@@@@@@                  
                                     @@@@@@@@@@@@@@@@@@@@@@                 
                                    @@@  @@@@@@@@@@@@@                      
                                              @@@                           
                                             @@@@@                          
                                             @@@@@                          
                                            @  @                            

                                                  @                         
\$\endgroup\$
2
  • \$\begingroup\$ I think you can just use 15j in the python version too \$\endgroup\$
    – gnibbler
    Commented Jul 8, 2011 at 4:48
  • \$\begingroup\$ To shave one character add line r=range(-50,26). Then replace range(-15,16) with r[35:66] and replace range(-50,26) with r. \$\endgroup\$ Commented Sep 30, 2011 at 17:51
11
\$\begingroup\$

BASH - 167 165 148

The mb3 file:

eval g={-4096..4096..199}'
'h={-8192..4096..99}'
x=;y=;for((i=0;i<30&&x*x+y*y<1<<26;i++)){((v=(x*x-y*y>>12)+h,y=(x*y>>11)+g,x=v));}
printf $[i%10]
'

(no trailing newline)

Run it in a terminal with line length 125:

mb3 output


BASH - 214 190

for h in {-4096..4096..200};do
for g in {-8192..4096..115};do
x=0;y=0
for((i=0;i<30&&x*x+y*y<1<<26;i++));do((v=((x*x-y*y)>>12)+g));((y=((x*y)>>11)+h))
x=$v
done;printf $[i%10];done;echo;done

This basically is the same code like below with calculations being replaced by hardcoded values and the image got flipped around the x axis.

mb2.bash run snapshot

The version below did not fully fit the rules breaking "from (-2 - i) to (1 + i)".


BASH - 263 261 260 236

Use this source, Luke:

a=-8601;b=2867;c=-4915;d=4915
((e=(b-a)/99));((f=(d-c)/49))
for((h=d;h>=c;h-=f));do
for((g=a;g<=b;g+=e));do
x=0;y=0
for((i=0;i<30&&x*x+y*y<1<<26;i++));do((v=((x*x-y*y)>>12)+g))
((y=((x*y)>>11)+h));x=$v
done
printf $[i%10]
done;echo;done

This code uses integer arithmetic only, so BASH does not need additional helpers for doing floating point maths...

mb.bash run snapshot

\$\endgroup\$
4
  • \$\begingroup\$ In arithmetic evaluations Bash casts the empty strings to 0, so is enough to initialize x=;y=. Shift operators have lower precedence than addition and multiplication, so no need for parenthesis around >>'s left side operand. And you can use {} instead of dodone, like Digital Trauma advises in his tip. And you can put multiple expressions in an arithmetic evaluation, just separate them with ,. \$\endgroup\$
    – manatwork
    Commented Sep 14, 2016 at 7:41
  • \$\begingroup\$ @manatwork ... thanks! ;-) \$\endgroup\$
    – user19214
    Commented Sep 14, 2016 at 10:06
  • \$\begingroup\$ You forgot a pair of parenthesis in (x*x-y*y)>>12. They change nothing. \$\endgroup\$
    – manatwork
    Commented Sep 14, 2016 at 10:17
  • \$\begingroup\$ Yes... it looks sooo mean without the parenthesis... I kinda didn't dare it... :-/ \$\endgroup\$
    – user19214
    Commented Sep 14, 2016 at 10:35
10
\$\begingroup\$

J, 61 characters

{&' *'(2:>[:|([+]*])^:32 ::_:)&0"0(j.1-16%~i.33)+/_2+32%~i.97
                                                                *                                

                                                            **                                   
                                                         ****** *                                
                                                         ********                                
                                                          *****                                  
                                                    *************** *                            
                                               ***********************  ***                      
                                           *   ****************************                      
                                           ********************************                      
                                           *********************************  *                  
                                          ************************************                   
                           ** ******     ************************************                    
                          *************  ************************************                    
                         *************** ***********************************                     
                     ******************************************************                      
 ************************************************************************                        
                     ******************************************************                      
                         *************** ***********************************                     
                          *************  ************************************                    
                           ** ******     ************************************                    
                                          ************************************                   
                                           *********************************  *                  
                                           ********************************                      
                                           *   ****************************                      
                                               ***********************  ***                      
                                                    *************** *                            
                                                          *****                                  
                                                         ********                                
                                                         ****** *                                
                                                            **                                   

                                                                *                                

55 for space-separated 0/1 instead of stars.

(2:>[:|([+]*])^:32 ::_:)&0"0(j.1-16%~i.33)+/_2+16%~i.49
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
\$\endgroup\$
1
  • 9
    \$\begingroup\$ Oh God, my eyes... \$\endgroup\$
    – gobernador
    Commented Jun 18, 2012 at 21:19
6
\$\begingroup\$

Ruby, 95 characters

puts (-20..20).map{|y|(-40..20).map{|x|z=0;32.times{z=z*z+Complex(x,y)/2e1};z.abs<2??*:' '}*''}

Sample output:

                                        *                    
                                                             
                                     *                       
                                   *  *                      
                                    ****                     
                                    *****                    
                                    ****                     
                             *  * ****** * *                 
                             **  **********                  
                             ******************              
                             ******************              
                           * ******************              
                            *******************              
                          ***********************            
                    *      *********************             
                 * ***    **********************             
                 *******  **********************             
                ********* **********************             
                ********************************             
             **********************************              
 *********************************************               
             **********************************              
                ********************************             
                ********* **********************             
                 *******  **********************             
                 * ***    **********************             
                    *      *********************             
                          ***********************            
                            *******************              
                           * ******************              
                             ******************              
                             ******************              
                             **  **********                  
                             *  * ****** * *                 
                                    ****                     
                                    *****                    
                                    ****                     
                                   *  *                      
                                     *                       
                                                             
                                        *                    
\$\endgroup\$
6
\$\begingroup\$

Haskell, 130

import Complex
main=mapM_ putStrLn[[" *"!!fromEnum(magnitude(iterate((+(x:+y)).(^2))0!!32)<2)|x<-[-2,-1.95..1]]|y<-[-1,-0.95..1]]

Output:

                                        *                    

                                     *                       
                                   *  *                      
                                    ****                     
                                    *****                    
                                    ****                     
                             *  * ****** * *                 
                             **  **********                  
                             ******************              
                             ******************              
                           * ******************              
                            *******************              
                          ***********************            
                    *      *********************             
                 * ***    **********************             
                 *******  **********************             
                ********* **********************             
                ********************************             
             **********************************              
 *********************************************               
             **********************************              
                ********************************             
                ********* **********************             
                 *******  **********************             
                 * ***    **********************             
                    *      *********************             
                          ***********************            
                            *******************              
                           * ******************              
                             ******************              
                             ******************              
                             **  **********                  
                             *  * ****** * *                 
                                    ****                     
                                    *****                    
                                    ****                     
                                   *  *                      
                                     *                       

                                        *          
\$\endgroup\$
1
  • \$\begingroup\$ Above my head is full of star****** \$\endgroup\$
    – Jamie
    Commented Apr 26, 2014 at 9:11
6
\$\begingroup\$

Here's a coffee-script answer running on node.js: In black and white:

m=(x,y)->
 a=x
 b=y
 z=0
 for i in [0..99]
  (return if i>60 then '*' else if i>10 then '-' else if i>5 then '.' else ' ') if z>4
  l=y*y
  z=x*x+l
  y=2*x*y+b
  x=x*x-l+a
 '@'
console.log (m x,y for x in [-1.5..0.5] by 2/79).join '' for y in [-1.3..1.3] by 2.6/40

ascii_mandel_color

Adding color:

n='\u001b[0m'
m=(x,y)->
 a=x
 b=y
 z=0
 for i in [0..999]
  (return if i>100 then '\u001b[33m*'+n else if i>10 then '\u001b[34m-'+n else if i>5 then '\u001b[31m.'+n else ' ') if z>4
  l=y*y
  z=x*x+l
  y=2*x*y+b
  x=x*x-l+a
 '\u001b[32m@\u001b[0m'
console.log (m x,y for x in [-1.5..0.5] by 2/79).join '' for y in [-1.3..1.3] by 2.6/40
\$\endgroup\$
1
  • \$\begingroup\$ Do you know looking at green is good for your eyes? \$\endgroup\$
    – Jamie
    Commented Apr 26, 2014 at 9:11
6
\$\begingroup\$

Mathematica 56

RegionPlot[Abs@Nest[#^2+x+I*y&,0,9]<2,{x,-2,1},{y,-1,1}]

Mathematica 77

ArrayPlot[2^-Abs@Nest[#^2+Table[j+i*I,{i,-1.2,1.2,.1},{j,-1.8,0.6,.1}]&,0,6]]

enter image description here

Mathematica 77

Grid@Table[If[Abs@Nest[#^2+y+x*I&,0,30]<2,"*",""],{x,1,-1,-.1},{y,-2,0.5,.1}]

enter image description here

\$\endgroup\$
1
  • \$\begingroup\$ Nice. I tried this approach: GraphicsGrid@ImageData@Binarize@MandelbrotSetPlot[ImageResolution->40]/.{1->" ",0->"*"} but it was 84 characters and the output is not as nice as yours anyway. \$\endgroup\$ Commented Oct 25, 2015 at 16:17
5
\$\begingroup\$

Perl, 153 chars

for(-21..20){$y=$_/20;for(-60..18){$r=($x=$_/30);$i=$y;for(1..99){$t=$r;$r=$r**2-$i**2+$x;$i=$t*$i*2+$y}if($r**2+$i**2<4){print"X"}else{print$"}}print$/}

Output: I can't post a picture because I am a new user, so I will try posting the text of the output.

                                                            X                  


                                                        XX                     
                                                      XXXXXX                   
                                                     XXXXXXX                   
                                                      XXXXX                    
                                                   X X XX X                    
                                            XX   XXXXXXXXXXXXXXXX              
                                            XXXXXXXXXXXXXXXXXXXXXXXXXX         
                                            XXXXXXXXXXXXXXXXXXXXXXXXXX         
                                          X XXXXXXXXXXXXXXXXXXXXXXXXXX          
                                          XXXXXXXXXXXXXXXXXXXXXXXXXXXXX        
                                       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX      
                                        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX        
                          X XXXX       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX       
                          XXXXXXXXX    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX       
                        XXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX       
                        XXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX        
                    XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX        
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX           
                    XX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX        
                        XXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX        
                        XXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX       
                          XXXXXXXXX    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX       
                          X XXXX       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX       
                                        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX        
                                       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX      
                                          XXXXXXXXXXXXXXXXXXXXXXXXXXXXX        
                                         X XXXXXXXXXXXXXXXXXXXXXXXXXX          
                                            XXXXXXXXXXXXXXXXXXXXXXXXXX         
                                            XXXXXXXXXXXXXXXXXXXXXXXXXX         
                                            XX   XXXXXXXXXXXXXXXX              
                                                   X X XX X                    
                                                      XXXXX                    
                                                     XXXXXXX                   
                                                      XXXXXX                   
                                                        XX                     


                                                            X                  
\$\endgroup\$
4
\$\begingroup\$

C# - 304 Chars

When I code, I code with readability and beautiful formatting. I threw up writing this.

using C=System.Console;class Program{static void Main()
{C.WindowWidth=220;C.WindowHeight=80;
int w=220,h=80,m=100;double s=4.0/w,v=4.0/h;
for(int i=0;i<h;i++)for(int j=0;j<w;j++){
double n=s*j-2,u=v*i-2,x=0,y=0;int r=0;
for(r=0;x*x+y*y<4&&r<m;r++){
double t=x*x-y*y+n;y=2*x*y+u;x=t;}
C.Write(r>=m?'#':' ');}C.ReadLine();}}

I am sure my solution can be improved but for reference I shall post it. Note that the windows console squashes the image.

enter image description here

\$\endgroup\$
1
  • 1
    \$\begingroup\$ It looks like a bug! \$\endgroup\$
    – user10766
    Commented Feb 13, 2014 at 2:31
3
\$\begingroup\$

Haskell: 340 char

Well, as I see no haskell answer, I post mine, I tried to minimize it from what I have done so far. I am sure I can reduce it a lot. But here is the first try:

m (x,y) (z,t)=(z*x-y*t,y*z+x*t);
a (x,y) (z,t)=(x+z,y+t);
r=1.0
f c z 0=z
f c z n=f c (a (m z z) c) (n-1)
e (x,y)=sqrt(x*x+y*y)
t c=(e(f c (0.0,0.0) 32)) < 2
b=map (\z -> (t z, (fst z > r-0.01))) [(x,y) | y <- [-r,-r+(1.0/15)..r], x<-[-2*r,-1.96..r]]
s True="\n"
s _=""
g (b,c)=(if (b) then "@" else " ")++s c
main=putStrLn$concat$map g b

And here is the result:

                                                  @                         

                                            @  @                            
                                             @@@@@                          
                                             @@@@@                          
                                              @@@                           
                                    @@@  @@@@@@@@@@@@@                      
                                     @@@@@@@@@@@@@@@@@@@@@@                 
                                    @@@@@@@@@@@@@@@@@@@@@@                  
                                  @@@@@@@@@@@@@@@@@@@@@@@@@                 
                        @        @@@@@@@@@@@@@@@@@@@@@@@@@@@@               
                     @@  @@      @@@@@@@@@@@@@@@@@@@@@@@@@@@                
                     @@@@@@@@@  @@@@@@@@@@@@@@@@@@@@@@@@@@@@                
                    @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@               
                 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                 
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                   
                 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@                 
                    @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@               
                     @@@@@@@@@  @@@@@@@@@@@@@@@@@@@@@@@@@@@@                
                     @@  @@      @@@@@@@@@@@@@@@@@@@@@@@@@@@                
                        @        @@@@@@@@@@@@@@@@@@@@@@@@@@@@               
                                  @@@@@@@@@@@@@@@@@@@@@@@@@                 
                                    @@@@@@@@@@@@@@@@@@@@@@                  
                                     @@@@@@@@@@@@@@@@@@@@@@                 
                                    @@@  @@@@@@@@@@@@@                      
                                              @@@                           
                                             @@@@@                          
                                             @@@@@                          
                                            @  @                            

                                                  @                         

OK - Inspired by some animated obfuscated C code on HN, here is an animated version:

a=27;b=79;c=C(-2.0,-1.0);d=C(1.0,1.0);e=C(-2.501,-1.003)
newtype C = C (Double,Double) deriving (Show,Eq)
instance Num C where C(x,y)*C(z,t)=C(z*x-y*t,y*z+x*t);C(x,y)+C(z,t)=C(x+z,y+t);abs(C(x,y))=C(sqrt(x*x+y*y),0.0)
r(C(x,y))=x;i(C(x,y))=y
f :: C -> C -> Int -> Int
f c z 0=0;f c z n=if(r(abs(z))>2)then n else f c ((z*z)+c) (n-1)
h j k = map (\z->(f (C z) (C(0,0)) 32,(fst z>l - q/2))) [(x,y)|y<-[p,(p+((o-p)/a))..o],x<-[m,(m + q)..l]] where o=i k;p=i j;m=r j;l=r k;q=(l-m)/b
u j k = concat $ map v $ h j k where v (i,p)=(" .,`'°\":;-+oO0123456789=!%*§&$@#"!!i):rst p;rst True="\n";rst False=""
main = putStrLn $ im 0 where cl n (C (x,y))=let cs=(1.1**n-1) in C ((x+cs*(r e))/cs+1,(y+cs*(i e))/cs+1);bl n=cl n c;tr n=cl n d;im n=u (bl n) (tr n)++"\x1b[H\x1b[25A"++im (n+1)

Copy/paste, do a runghc mandel.hs, enjoy!

Here is the kind of result after 50 iterations:

77777777777777777777777777777777777777777777777666666666666666666666666666666666
77777777777777777777777777777777777777777766665555555555566666666666666666666666                                                                                                     
666777777777777777777777777777666666666665543;4445555555555555555555666666666555
66666666666666666666666666666666666666555554300334555555555555555555555555555555 
6666666666666666666666666666666666665555554431:°33345555555555555555555555555544
5566666666666666666666666666666666555555554321 ;00O:3455555555555555555444444444
5555666666666666666666666666666655555555554O+++ :o022334444444444444444444444444
5555556666666666666666666666665555555555543210O-+O112333344444444444444444444444
55555555666666666666666666665555555555444333210o`O012333333444444444444444444444
4555555555566666666666666555555555544444333331O+°°,'0233333334444444444444444433
44444445555555556666555555555444444444433333210o-:O01122333333334444444444443333
44444444444444445555444444444444444444333332211O+ -o1112222223333333344433333222
444444444444433331133334444444444444433332221110o"+O0111222222222222222222222222  
34444444443333330OO03333334444444443332222221100O+-oO001122222222221110-O1111122
22333333333332210--01223333333333322222222211000o-°+o00000122222111110o°;o001111
11OO112222222111O;;O111222222211OO111122211000Oo-" :+ooOOOO.O0000000OOo'°oOO0000
0O;+O01122211000O--O00011221110O+;O00000OO +oooo-: :-+oo++";oOO0000Ooo+;;+oooO00
o+"+oO00OO OOOOoo::ooOOOO°OO00Oo+"+ooOooo+;°---",' ,,";--: ;-+oo+ +++;;°°;;-++:;
,° °':°: ` "`".°°  °° "°".  :'",  '°`°":`°` ,,``     .   . .°°'°° ` ..     `'°. 
+-`-oo+oo+'+o+`--°°;-`+o+"+oo+oo-'-++;+++-:,:::"`    °::°° :-;;--,;-; "  " ;-;":
OO"-O0000000000Oo--oO0000000000O-:oO0000Oo::+++;;: ":"-++-';+oooOOoooo-::-oooo++
10;-111222222110O--O011222222111- 01111110oOOOoo-: :-ooooo`:OO000000OO+;;+OOO000
22122222222222110++0112222222222111222222221000O+:,;.O000001111111100Oo:-OO00000
3344444433333332-,°-2333333344444433322222221100o-;oO00011222222221111O'+0111111
444444444444333320023333444444444444433322221110O.:O0011222222222222211-01112222
44444444444444443333444444444444444444333332211O. -o1112222222223333333333322222
44444444445555555555555555444444444444433333210O-"oO1122223333333444444444433333
444555555555666666666666555555555444444433333' '`:+O0233333333444444444444444433

And a link to a more readable code:

http://yannesposito.com/Scratch/en/blog/Haskell-Mandelbrot/

\$\endgroup\$
3
\$\begingroup\$

J, 70

3 :'try.2>|(y&+&*:)^:32[0 catch.0 end.'"0(1-~15%~i.31)j.~/2-~13%~i.40

Displays members of the set as 1, the rest as 0. Spaces each computed point two characters wide, so as to keep a mostly-square pixel with most fonts.

\$\endgroup\$
3
\$\begingroup\$

QBasic, 222 Characters. Not that short, but QBasic is a pretty verbose language. Also, I updated with a seemingly more correct version

FOR y=1 TO 23
FOR x=1 TO 80
a=0:b=0
c=-2.5+(x/80)*3.5:d=-1+(y/23)*2
FOR i=0 TO 1000
IF a*a+b*b>=4 THEN GOTO E
t=a*a-b*b*c:b=2*a*b+d:a=t
NEXT
E:LOCATE y,x
IF a*a+b*b<4 THEN
?("@")
ELSE
?(" ")
END IF
NEXT
NEXT

Output is as in the following image.

enter image description here

\$\endgroup\$
3
\$\begingroup\$

SpecBAS 201

I know this one is an old question, but we've been playing with Perlin's ascii brot in the BASIC programming forum, and here's mine - in SpecBAS (which is a kind of Sinclair BASIC interpreter) and it really is just text, and one line of code:

1FOR y=-29TO 30:FOR x=-10TO 89:LET m,r=0:FOR k=0TO 224:LET j=r^2-m^2-2+x/25,m=2*r*m+y/25,r=j,l=k,k=IIF(j^2+m^2>11,225,k):NEXT k:PRINT INK l;"ð";:NEXT x:NEXT y

Output: SpecBAS ascii mandelbrot

\$\endgroup\$
4
  • \$\begingroup\$ The output should be in ASCII. (And you can write e.g. any Java program in one line.) \$\endgroup\$
    – flawr
    Commented Oct 25, 2015 at 21:00
  • \$\begingroup\$ Highest voted entry was not ASCII. \$\endgroup\$
    – ZXDunny
    Commented Oct 26, 2015 at 8:00
  • \$\begingroup\$ @flawr Ok, here's the "ascii" version (176 bytes) - and the reason I was quite pleased about it being on one line is that it isn't actually Java... 1FOR y=-29TO 30:FOR x=-10TO 89:LET m,r=0:FOR k=0TO 112:LET j=r^2-m^2-2+x/25,m=2*r*m+y/25,r=j,l=k&15,k=IIF(j^2+m^2>11,113,k):NEXT k:PRINT" .:-;!/>)|&IH%*#"(l+1);:NEXT x:NEXT y. \$\endgroup\$
    – ZXDunny
    Commented Oct 26, 2015 at 8:46
  • \$\begingroup\$ You should put that version in the answer. \$\endgroup\$ Commented May 27, 2017 at 3:28
2
\$\begingroup\$

Brainf***, 11595 bytes

+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[
>>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+
<<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>>
>+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+[>>>>>>[>>>>>>>[-]>>]<<<<<<<<<[<<<<<<<<<]>>
>>>>>[-]+<<<<<<++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<+++++++[-[->>>
>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[[-]>>>>>>[>>>>>
>>[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<+<<<+<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>
[>>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<+<<]>>>>>>>>]<<<<<<<<<[<<<<<<<
<<]>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<<<]>>>>>>>>>+++++++++++++++[[
>>>>>>>>>]+>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>-]+[
>+>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>->>>>[-<<<<+>>>>]<<<<[->>>>+<<<<<[->>[
-<<+>>]<<[->>+>>+<<<<]+>>>>>>>>>]<<<<<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CCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDEEEEEFFFFFGGHJLZ         UKHGFFEEEEEEEEDDDDDCCCCCCCCCCCCBBBBBBBBBBBB
AAAAAAABBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDEEEEFFFFFFGGGGHIKP           KHHGGFFFFEEEEEEDDDDDCCCCCCCCCCCBBBBBBBBBBB
AAAAAAABBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDEEEEEFGGHIIHHHHHIIIJKMR        VMKJIHHHGFFFFFFGSGEDDDDCCCCCCCCCCCCBBBBBBBBB
AAAAAABBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDEEEEEEFFGHK   MKJIJO  N R  X      YUSR PLV LHHHGGHIOJGFEDDDCCCCCCCCCCCCBBBBBBBB
AAAAABBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDEEEEEEEEEFFFFGH O    TN S                       NKJKR LLQMNHEEDDDCCCCCCCCCCCCBBBBBBB
AAAAABBCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDEEEEEEEEEEEEFFFFFGHHIN                                 Q     UMWGEEEDDDCCCCCCCCCCCCBBBBBB
AAAABBCCCCCCCCCCCCCCCCCCCCCCCCCDDDDEEEEEEEEEEEEEEEFFFFFFGHIJKLOT                                     [JGFFEEEDDCCCCCCCCCCCCCBBBBB
AAAABCCCCCCCCCCCCCCCCCCCCCCDDDDEEEEEEEEEEEEEEEEFFFFFFGGHYV RQU                                     QMJHGGFEEEDDDCCCCCCCCCCCCCBBBB
AAABCCCCCCCCCCCCCCCCCDDDDDDDEEFJIHFFFFFFFFFFFFFFGGGGGGHIJN                                            JHHGFEEDDDDCCCCCCCCCCCCCBBB
AAABCCCCCCCCCCCDDDDDDDDDDEEEEFFHLKHHGGGGHHMJHGGGGGGHHHIKRR                                           UQ L HFEDDDDCCCCCCCCCCCCCCBB
AABCCCCCCCCDDDDDDDDDDDEEEEEEFFFHKQMRKNJIJLVS JJKIIIIIIJLR                                               YNHFEDDDDDCCCCCCCCCCCCCBB
AABCCCCCDDDDDDDDDDDDEEEEEEEFFGGHIJKOU  O O   PR LLJJJKL                                                OIHFFEDDDDDCCCCCCCCCCCCCCB
AACCCDDDDDDDDDDDDDEEEEEEEEEFGGGHIJMR              RMLMN                                                 NTFEEDDDDDDCCCCCCCCCCCCCB
AACCDDDDDDDDDDDDEEEEEEEEEFGGGHHKONSZ                QPR                                                NJGFEEDDDDDDCCCCCCCCCCCCCC
ABCDDDDDDDDDDDEEEEEFFFFFGIPJIIJKMQ                   VX                                                 HFFEEDDDDDDCCCCCCCCCCCCCC
ACDDDDDDDDDDEFFFFFFFGGGGHIKZOOPPS                                                                      HGFEEEDDDDDDCCCCCCCCCCCCCC
ADEEEEFFFGHIGGGGGGHHHHIJJLNY                                                                        TJHGFFEEEDDDDDDDCCCCCCCCCCCCC
A                                                                                                 PLJHGGFFEEEDDDDDDDCCCCCCCCCCCCC
ADEEEEFFFGHIGGGGGGHHHHIJJLNY                                                                        TJHGFFEEEDDDDDDDCCCCCCCCCCCCC
ACDDDDDDDDDDEFFFFFFFGGGGHIKZOOPPS                                                                      HGFEEEDDDDDDCCCCCCCCCCCCCC
ABCDDDDDDDDDDDEEEEEFFFFFGIPJIIJKMQ                   VX                                                 HFFEEDDDDDDCCCCCCCCCCCCCC
AACCDDDDDDDDDDDDEEEEEEEEEFGGGHHKONSZ                QPR                                                NJGFEEDDDDDDCCCCCCCCCCCCCC
AACCCDDDDDDDDDDDDDEEEEEEEEEFGGGHIJMR              RMLMN                                                 NTFEEDDDDDDCCCCCCCCCCCCCB
AABCCCCCDDDDDDDDDDDDEEEEEEEFFGGHIJKOU  O O   PR LLJJJKL                                                OIHFFEDDDDDCCCCCCCCCCCCCCB
AABCCCCCCCCDDDDDDDDDDDEEEEEEFFFHKQMRKNJIJLVS JJKIIIIIIJLR                                               YNHFEDDDDDCCCCCCCCCCCCCBB
AAABCCCCCCCCCCCDDDDDDDDDDEEEEFFHLKHHGGGGHHMJHGGGGGGHHHIKRR                                           UQ L HFEDDDDCCCCCCCCCCCCCCBB
AAABCCCCCCCCCCCCCCCCCDDDDDDDEEFJIHFFFFFFFFFFFFFFGGGGGGHIJN                                            JHHGFEEDDDDCCCCCCCCCCCCCBBB
AAAABCCCCCCCCCCCCCCCCCCCCCCDDDDEEEEEEEEEEEEEEEEFFFFFFGGHYV RQU                                     QMJHGGFEEEDDDCCCCCCCCCCCCCBBBB
AAAABBCCCCCCCCCCCCCCCCCCCCCCCCCDDDDEEEEEEEEEEEEEEEFFFFFFGHIJKLOT                                     [JGFFEEEDDCCCCCCCCCCCCCBBBBB
AAAAABBCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDEEEEEEEEEEEEFFFFFGHHIN                                 Q     UMWGEEEDDDCCCCCCCCCCCCBBBBBB
AAAAABBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDEEEEEEEEEFFFFGH O    TN S                       NKJKR LLQMNHEEDDDCCCCCCCCCCCCBBBBBBB
AAAAAABBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDEEEEEEFFGHK   MKJIJO  N R  X      YUSR PLV LHHHGGHIOJGFEDDDCCCCCCCCCCCCBBBBBBBB
AAAAAAABBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDEEEEEFGGHIIHHHHHIIIJKMR        VMKJIHHHGFFFFFFGSGEDDDDCCCCCCCCCCCCBBBBBBBBB
AAAAAAABBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDEEEEFFFFFFGGGGHIKP           KHHGGFFFFEEEEEEDDDDDCCCCCCCCCCCBBBBBBBBBBB
AAAAAAAABBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDEEEEEFFFFFGGHJLZ         UKHGFFEEEEEEEEDDDDDCCCCCCCCCCCCBBBBBBBBBBBB
AAAAAAAAABBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDEEEEEEFFGQPUVOTY   ZQL[MHFEEEEEEEDDDDDDDCCCCCCCCCCCBBBBBBBBBBBBBB
AAAAAAAAAABBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDEEEEEEFFGHIJKS  X KHHGFEEEEEDDDDDDDDDCCCCCCCCCCBBBBBBBBBBBBBBBB
AAAAAAAAAAABBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDEEEEEEFGGHHIKPPKIHGFFEEEDDDDDDDDDCCCCCCCCCCBBBBBBBBBBBBBBBBBB
AAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDEEEEEFFGHIMTKLZOGFEEDDDDDDDDDCCCCCCCCCBBBBBBBBBBBBBBBBBBBBB
AAAAAAAAAAAAABBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDDDEEEEFFFI KHGGGHGEDDDDDDDDDCCCCCCCCCBBBBBBBBBBBBBBBBBBBBBBB
AAAAAAAAAAAAAAABBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDDDDDDEEEFGIIGFFEEEDDDDDDDDCCCCCCCCCBBBBBBBBBBBBBBBBBBBBBBBBBB

And this is why you use automatic Markdown code formatters. Originally written by Erik Bosman.

\$\endgroup\$
3
  • \$\begingroup\$ Given that this answer was copied directly from an outside source, please give credit to the original author. \$\endgroup\$
    – Doorknob
    Commented May 27, 2017 at 1:18
  • \$\begingroup\$ @Doorknob It wasn't copied directly from anywhere, it's a very popular program and I can't find who originally wrote it. (buf if you have the link/name I'll be happy to put it in) \$\endgroup\$
    – MD XF
    Commented May 27, 2017 at 1:21
  • \$\begingroup\$ It was written by Erik Bosman; I believe this is the original source. \$\endgroup\$
    – Doorknob
    Commented May 27, 2017 at 1:59
1
\$\begingroup\$

Perl -- 193 characters

$Y=-1.2;for(0..24){$X=-2;for(0..79){($r,$i)=(0,0);for(0..15){$n=$_;$r=($x=$ r)*$x-($y=$i)*$y+$X;$i=2*$x*$y+$Y;$x*$x+$y*$y>4&&last}print unpack("\@$n a" ,".,:;=+itIYVXRBM ");$X+=3/80}$Y+=2.4/25}

Result

,,,,,,,,,,,::::::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::::::::::::::::::::
,,,,,,,,,:::::::::;;;;;;;;;;;;;;;;;;;;;;======+iRV+++====;;;;;;:::::::::::::::::
,,,,,,,,::::::;;;;;;;;;;;;;;;;;;;;;;========+++itVXYYRi======;;;;;;:::::::::::::
,,,,,,:::::;;;;;;;;;;;;;;;;;;;;;;=========++++ttIR  VIt+++=====;;;;;;;::::::::::
,,,,,::::;;;;;;;;;;;;;;;;;;;;==========+++iitIX        ti++++====;;;;;;;::::::::
,,,,:::;;;;;;;;;;;;;;;;;;;=========++ittttttIYX       VIItiiiii++==;;;;;;;::::::
,,,::;;;;;;;;;;;;;;;;;;======+++++iit     R               RY XX Y++=;;;;;;;;::::
,,::;;;;;;;;;;;;;;;;===+++++++++iiitIVB                        Mti++=;;;;;;;;:::
,,:;;;;;;;;;;;====+XtiiiiiiiiiittIYM                           RIti+==;;;;;;;;::
,:;;;;;=======+++iiI XVVYV VYYIIYYB                               t+===;;;;;;;;:
,;;========++++++ttIY          MRB                               Mi+===;;;;;;;;;
,========+++iiiIRYYX                                             t++====;;;;;;;;
,++iitYttttIIIVXM                                              Yti++====;;;;;;;;
,++iitYttttIIIVXM                                              Yti++====;;;;;;;;
,========+++iiiIRYYX                                             t++====;;;;;;;;
,;;========++++++ttIY          MRB                               Mi+===;;;;;;;;;
,:;;;;;=======+++iiI XVVYV VYYIIYYB                               t+===;;;;;;;;:
,,:;;;;;;;;;;;====+XtiiiiiiiiiittIYM                           RIti+==;;;;;;;;::
,,::;;;;;;;;;;;;;;;;===+++++++++iiitIVB                        Mti++=;;;;;;;;:::
,,,::;;;;;;;;;;;;;;;;;;======+++++iit     R               RY XX Y++=;;;;;;;;::::
,,,,:::;;;;;;;;;;;;;;;;;;;=========++ittttttIYX       VIItiiiii++==;;;;;;;::::::
,,,,,::::;;;;;;;;;;;;;;;;;;;;==========+++iitIX        ti++++====;;;;;;;::::::::
,,,,,,:::::;;;;;;;;;;;;;;;;;;;;;;=========++++ttIR  VIt+++=====;;;;;;;::::::::::
,,,,,,,,::::::;;;;;;;;;;;;;;;;;;;;;;========+++itVXYYRi======;;;;;;:::::::::::::
,,,,,,,,,:::::::::;;;;;;;;;;;;;;;;;;;;;;======+iRV+++====;;;;;;:::::::::::::::::

I think it won the obfuscated perl contest a few years ago.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ So it's not yours? Might be good to say who's it from. \$\endgroup\$ Commented Jan 20, 2014 at 1:16
1
\$\begingroup\$

Python, 115.

r=range
for _ in r(-11,12):
 for f in r(-39,41):
  v=u=f/22.-_/11j;exec"u=u*u+v;"*40;print"\b"+chr(32+(u.real<4)),

Works only on 80x24 terminals, but you can add print after first for to fix it.

Sample output (With additional print instruction.):

                                       !                                        

                                   !!!                                          
                                  !!!!!                                         
                            !  ! !!!!!!!! !                                     
                           !!!!!!!!!!!!!!!!! !!                                 
                        ! !!!!!!!!!!!!!!!!!!!!!                                 
                        !!!!!!!!!!!!!!!!!!!!!!!                                 
              !  !      !!!!!!!!!!!!!!!!!!!!!!!!                                
            !!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!                                
            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                                 
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                                   
            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!                                 
            !!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!                                
              !  !      !!!!!!!!!!!!!!!!!!!!!!!!                                
                        !!!!!!!!!!!!!!!!!!!!!!!                                 
                        ! !!!!!!!!!!!!!!!!!!!!!                                 
                           !!!!!!!!!!!!!!!!! !!                                 
                            !  ! !!!!!!!! !                                     
                                  !!!!!                                         
                                   !!!                                          

                                       !                                        
\$\endgroup\$
1
\$\begingroup\$

c++-11 -- 298 characters

Fully golfed, unparameterized version that does only what is required:

#include <complex>
#include <iostream>
#define C complex<float>
using namespace std;int main(void){C p(-2,1),q(1,-1);char i,j,k;
for(j=0;j<30;++j){for(i=0;i<80;++i){C r=q-p,c((i+0.5)*r.real()/
81+p.real(),(j+0.5)*r.imag()/31+p.imag());r=0;k=64;while
(abs(r)<=2&&(--k!=32))r=r*r+c;cout<<k;}cout<<endl;}}

The implementation is completely unremarkable. Just seeing what can be done using the native complex time (which is, alas, a little wordy).

Ungolfed and parameterized so that it can do regions

#include <complex>
#include <iostream>
using namespace std;
void M/*andlebrot*/(ostream& o, 
            complex<float> p, complex<float> q, 
            int l, int h) {
  char i,j,k;
  for(j=0; j<h; ++j){
    for(i=0; i<l; ++i){
      complex<float> r=q-p,c((i+0.5)*r.real()/(l+1)+p.real(), 
                 (j+0.5)*r.imag()/(h+1)+p.imag() );
      r=0;
      k='@';
      while(abs(r)<=2&&(--k!=' ')){
        r=r*r+c;
      }
      o<<k;
    }
    o<<endl;
  }
}

int main(int argc, char*argv[]){
  M(cout,complex<float>(-2.15,1.25),complex<float>(0.65,-1.25),80,30);
}

Output

$ g++-fsf-4.7  mandelbrot_golf.cc --std=c++11
$ ./a.out
???????>>>>>>=====================<<<<<<<<<;;;;:974048:;<<<<<<======>>>>>>>>>>>>
??????>>>>>=====================<<<<<<<<<<;;;:9872  '89:;;<<<<<<======>>>>>>>>>>
?????>>>>=====================<<<<<<<<<<;;;::8$ /#  &349:;;;;<<<<=======>>>>>>>>
????>>>=====================<<<<<<<<<;;::::9986-     *589::;;;;<<<========>>>>>>
????>>====================<<<<<<<<;;;9988998775/      57889::::9;<<========>>>>>
???>>===================<<<<<<;;;;;:96$.355 &()         2$28887,8:;<========>>>>
??>>==================<<<<;;;;;;;::987.                    2$   )9;<<========>>>
??>================<<<;;;;;;;;;::::8753+                       '8:;;<<========>>
?>=============<<<;::::;;;;;::::997                            589:;<<=========>
?>========<<<<<;;;:85899987999998861%                           (54;<<<========>
?=====<<<<<<<;;;;::8 03564&46677763!                             28:<<<=========
>==<<<<<<<<;;;;;::9873  ,   '  554#                              69;<<<<========
==<<<<<<<<;;;;;:998$3,          00                              -3:;<<<<========
=<<<<<<<;;::::975654)            )                              ,9:;<<<<========
<;;;::99:::999762  #                                            9:;;<<<<========
                                                             /589:;;<<<<========
<;;;::99:::999762  #                                            9:;;<<<<========
=<<<<<<<;;::::975654)            )                              ,9:;<<<<========
==<<<<<<<<;;;;;:998$3,          00                              -3:;<<<<========
>==<<<<<<<<;;;;;::9873  ,   '  554#                              69;<<<<========
?=====<<<<<<<;;;;::8 03564&46677763!                             28:<<<=========
?>========<<<<<;;;:85899987999998861%                           (54;<<<========>
?>=============<<<;::::;;;;;::::997                            589:;<<=========>
??>================<<<;;;;;;;;;::::8753+                       '8:;;<<========>>
??>>==================<<<<;;;;;;;::987.                    2$   )9;<<========>>>
???>>===================<<<<<<;;;;;:96$.355 &()         2$28887,8:;<========>>>>
????>>====================<<<<<<<<;;;9988998775/      57889::::9;<<========>>>>>
????>>>=====================<<<<<<<<<;;::::9986-     *589::;;;;<<<========>>>>>>
?????>>>>=====================<<<<<<<<<<;;;::8$ /#  &349:;;;;<<<<=======>>>>>>>>
??????>>>>>=====================<<<<<<<<<<;;;:9872  '89:;;<<<<<<======>>>>>>>>>>
\$\endgroup\$
2
  • \$\begingroup\$ The parens in the middle add a nice touch :) \$\endgroup\$ Commented Jan 20, 2014 at 1:17
  • \$\begingroup\$ I wish I could claim I planned it, but it just happened. I set the character selection to allow the largest range of printables. \$\endgroup\$ Commented Jan 20, 2014 at 1:24
1
\$\begingroup\$

GolfScript - 77

20{40{0.1{.{;..*2$.*\- 20/3$-@@*10/3$-..*2$.*+1600<}*}32*\;\;@@(}60*;(n\}40*;

It can probably be golfed a lot more. The result is an approximation because I have to use integers.

Output:

000000000000000000000000000000000000000010000000000000000000
000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000001000000000000000000000000
000000000000000000000000000000000000001000000000000000000000
000000000000000000000000000000000000111000000000000000000000
000000000000000000000000000000000000111110000000000000000000
000000000000000000000000000000000000011100000000000000000000
000000000000000000000000000001000110111100010000000000000000
000000000000000000000000000000100111111111110000000000000000
000000000000000000000000000001011111111111110111000000000000
000000000000000000000000000001111111111111111110000000000000
000000000000000000000000000000111111111111111110000000000000
000000000000001000000000000011111111111111111111000000000000
000000000000000000000000000011111111111111111111000000000000
000000000000000000000000000111111111111111111111000000000000
000000000000000000000000001111111111111111111111100000000000
000000000000000001111110001111111111111111111111100000000000
000000000000000011111111101111111111111111111111100000000000
000000000000100111111111111111111111111111111111000000000000
000000000001101111111111111111111111111111111111000000000000
011111111111111111111111111111111111111111111100000000000000
000000000000001111111111111111111111111111111110000000000000
000000000000000111111111111111111111111111111111000000000000
000000000000000001111111111111111111111111111111100000000000
000000000000000001111111101111111111111111111111000000000000
000000000000000001011100000111111111111111111111100000000000
000000000000000000000100000111111111111111111111000000000000
000000000000000100000000001111111111111111111111100000000000
000000000000000100000000000011111111111111111111000000000000
000000000000000000000000000011111111111111111110000000000000
000000000000000000000000000001111111111111111111000000000000
000000000000000000000000000000111111111111111111000000000000
000000000000000000000000000001101111111111111000000000000000
000000000000000000000000000011000011111110100000000000000000
000000000000000000000000000000000000111100000000000000000000
000000000000000000000000000000000000111110000000000000000000
000000000000000000000000000000000000111100000000000000000000
000000000000000000000000000000000000011000000000000000000000
000000000000000000000000000000000000001000000000000000000000
000000000000000000000000000000000000000000000000000000000000

It takes about 9 more bytes to make it use spaces and stars:

20{40{0.1{.{;..*2$.*\- 20/3$-@@*10/3$-..*2$.*+1600<}*}32*' *'=\;\;@@(}60*;(n\}40*;]''+
\$\endgroup\$
1
\$\begingroup\$

GNU bc, 136 bytes

for(y=-1;y<1;y+=.05){for(x=-2;x<1;x+=.05){for(n=i=r=0;r*r+i*i<4&&++n<32;r=t){t=r*r-i*i+x
i=2*r*i+y}
if(n<32)print n%A else print " "}
2}

Output:

1111112222233333333333333334444445567190 54444333322222222222
11111222233333333333333334444444555780 0765444433333222222222
11111222333333333333333344444445556799 1865544443333322222222
11112223333333333333333444444455561 6  7985554444333332222222
111122333333333333333344444445566784    086555544333333222222
111222333333333333333444444556667797    787665554433333222222
111223333333333333344444455678988903    309866625443333322222
11123333333333333344444555673430   0    203 98897543333332222
11223333333333333444455556672  75          224654544333332222
11233333333333344455555566781                  29554333333222
11233333333333445555555666808                   7654333333222
113333333334445666555666782 5                  37654433333322
123333334444557477778777782                    70254433333322
12333344444556749990198881                        64433333322
13334444445556709 25 51902                      4864433333332
13344444455557795      728                      4054443333332
1344444455557792        6                        854443333332
1444444555672919                                 654443333332
144444666678368                                 8654443333332
1556787778915                                  07654443333332
1                                             387654443333332
1556787778915                                  07654443333332
144444666678368                                 8654443333332
1444444555672919                                 654443333332
1344444455557792        6                        854443333332
13344444455557795      728                      4054443333332
13334444445556709 25 51902                      4864433333332
12333344444556749990198881                        64433333322
123333334444557477778777782                    70254433333322
113333333334445666555666782 5                  37654433333322
11233333333333445555555666808                   7654333333222
11233333333333344455555566781                  29554333333222
11223333333333333444455556672  75          224654544333332222
11123333333333333344444555673430   0    203 98897543333332222
111223333333333333344444455678988903    309866625443333322222
111222333333333333333444444556667797    787665554433333222222
111122333333333333333344444445566784    086555544333333222222
11112223333333333333333444444455561 6  7985554444333332222222
11111222333333333333333344444445556799 1865544443333322222222
11111222233333333333333334444444555780 0765444433333222222222
\$\endgroup\$
1
\$\begingroup\$

c++ (260)

Golfed Code:

#include<iostream>
void main(){for(float i=-1;i<=1;i+=0.03125){for(float r=-2;r<=1;r+=.03125){float zr=r,zi=i;for(int n=0;n<31;n++){float nzr=zr*zr-zi*zi;zi=zr*zi*2;zr=nzr;zr+=r;zi+=i;}if(zi*zi+zr*zr<4){std::cout<<"*";}else{std::cout<<" ";}}std::cout<<"\n";}}

Example output:

                                                               *



                                                           **
                                                          ***
                                                        ****** *
                                                        *******
                                                        ********
                                                        *******
                                                         *****
                                             *     *    * ***    * *
                                                   *************** *
                                              *** ******************
                                              ***********************  ***
                                              ****************************
                                          *   ****************************
                                          *  ****************************
                                          ********************************
                                           ********************************
                                          *********************************  *
                                         *************************************
                                         ************************************
                          *   **        ***********************************
                          ** ******     ************************************
                          **********    *************************************
                         *************  ************************************
                        **************  ************************************
                        *************** ***********************************
                        ***************************************************
                    ******************************************************
                    ******************************************************
************************************************************************
                    ******************************************************
                    ******************************************************
                        ***************************************************
                        *************** ***********************************
                        **************  ************************************
                         *************  ************************************
                          **********    *************************************
                          ** ******     ************************************
                          *   **        ***********************************
                                         ************************************
                                         *************************************
                                          *********************************  *
                                           ********************************
                                          ********************************
                                          *  ****************************
                                          *   ****************************
                                              ****************************
                                              ***********************  ***
                                              *** ******************
                                                   *************** *
                                             *     *    * ***    * *
                                                         *****
                                                        *******
                                                        ********
                                                        *******
                                                        ****** *
                                                          ***
                                                           **



                                                               *
\$\endgroup\$
1
  • \$\begingroup\$ you included math for sqrt(x^2+y^2) < 2. You can compare with 4 and remove the sqrt and the include. \$\endgroup\$
    – ilmale
    Commented Apr 22, 2014 at 0:58
1
\$\begingroup\$

CJam, 52 bytes

80,Kdf/2f-_m*{_{_~*2*[\2f#~-\]1$.+}9*\;~mh4<}%80/zN*

Explanation:

80,Kdf/2f-                                             Push [-2, -1.95, ..., 1.95]
          _m*                                          Cartesian product with itself
             {                              }%         Map over each pair [cx, cy]:
              _                                          Push a copy [zx, zy]
               {                  }9*                    Iterate nine times:
                _~*2*                                      Push 2*zx*zy
                     [\2f#~-\]                             Make a pair with zx^2-zy^2
                              1$.+                         Push [cx, cy] and sum vectors
                                     \;                  Destroy [cx, cy]
                                       ~mh               Calculate sqrt(zx^2+zy^2)
                                          4<             1 if bounded, 0 if not
                                              80/      Split into rows of 80 booleans
                                                 z     Transpose this matrix
                                                  N*   Join rows with newlines
\$\endgroup\$
1
\$\begingroup\$

Matlab, 96

[x,y,q]=ndgrid(-1:.03:1,-2:.01:.5,32);c=i*x+y;z=q*0;for i=1:100;z=z.^2+c;end;[q+3*(abs(z)<2),'']


                                                                                                                                                                                                        #                                                  
                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                           
                                                                                                                                                                                            ##                                                             
                                                                                                                                                                                           #####                                                           
                                                                                                                                                                                      #############                                                        
                                                                                                                                                                                    ##################                                                     
                                                                                                                                                                                   ###################                                                     
                                                                                                                                                                                  ####################                                                     
                                                                                                                                                                                   ##################                                                      
                                                                                                                                                                                     #############                                                         
                                                                                                                                                                          ##  ########################## #   #                                             
                                                                                                                                                  ##    #         ################################################ ####                                    
                                                                                                                                                  #########  # #########################################################  #        #                       
                                                                                                                                                 ######### ##################################################################    ########                  
                                                                                                                                                       ##################################################################################                  
                                                                                                                                              #   #####################################################################################                    
                                                                                                                                              # ##################################################################################### #                    
                                                                                                                                        #### ########################################################################################### #                 
                                                                                                                                         # ############################################################################################## #                
                                                                                                                                       ####################################################################################################                
                                                                                                                                    ##############################################################################################################         
                                                                                                                                     ########################################################################################################              
                                                                                                    #                           ##############################################################################################################             
                                                                                    #####     ############ ###                    ############################################################################################################             
                                                                                    ##############################               ################################################################################################################          
                                                                                   ###################################         ###############################################################################################################             
                                                                              ## #######################################       ################################################################################################################            
                                                                               ###########################################    ############################################################################################################### #            
                                                                             ###############################################  ################################################################################################################             
                                                                           ################################################## #############################################################################################################                
                                                                 #########  ################################################# ###########################################################################################################                  
                        ##                                   ## ####################################################################################################################################################################                       
                                                                ######################################################################################################################################################################                     
                                                                 ########   ################################################# ###########################################################################################################                  
                                                                             ###############################################  #############################################################################################################                
                                                                            ################################################  ##############################################################################################################               
                                                                                #########################################      ################################################################################################################            
                                                                             # #  ######################################       ###############################################################################################################             
                                                                                     ################################           ##############################################################################################################             
                                                                                    ##### #####################  #              #################################################################################################################          
                                                                                     ####     #    ###   #   #                     ############################################################################################################            
                                                                                                                              # ### #########################################################################################################              
                                                                                                                                     ####################################################################################################### ###           
                                                                                                                                  # ## ##########################################################################################################          
                                                                                                                                       # ##################################################################################################                
                                                                                                                                        ###################################################################################################                
                                                                                                                                       #################################################################################################                   
                                                                                                                                               ######################################################################################                      
                                                                                                                                                   #####################################################################################                   
                                                                                                                                                   ############################################################################ #########                  
                                                                                                                                                ########## ################################################################ #    #########                 
                                                                                                                                                   #######     ## #################################################### #                                   
                                                                                                                                                                   ########################################### ##  #####                                   
                                                                                                                                                                         ##    # #   #### #### ## ###     #                                                
                                                                                                                                                                                     ###############                                                       
                                                                                                                                                                                  ####################                                                     
                                                                                                                                                                                  #####################                                                    
                                                                                                                                                                                   ###################                                                     
                                                                                                                                                                                  ################## #                                                     
                                                                                                                                                                                       #########                                                           
                                                                                                                                                                                           #####                                                           
                                                                                                                                                                                             #                                                             
                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                           
  
\$\endgroup\$
1
\$\begingroup\$

Python 3, 185 bytes

Translation from perl (193) with some improvements

Y=-1.2
r=range
for _ in r(25):
 X=-2
 for _ in r(80):
  r=i=0
  for n in r(16):
   r,i=r*r-i*i+X,2*r*i+Y
   if r*r+i*i>4:break
  print(".,:;=+itIYVXRBM "[n],end='')
  X+=3/80
 Y+=2.4/25
\$\endgroup\$
1
  • \$\begingroup\$ Beautiful, you rarely see such understandable golfed code \$\endgroup\$ Commented Sep 14, 2020 at 13:57
1
\$\begingroup\$

Befunge, 266 bytes

0>:00p58*`#@_0>:01p78vv$$<
@^+1g00,+55_v# !`\+*9<>4v$
@v30p20"?~^"< ^+1g10,+*8<$
@>p0\>\::*::882**02g*0v >^
`*:*" d":+*:-*"[Z"+g3 < |<
v-*"[Z"+g30*g20**288\--\<#
>2**5#>8*:*/00g"P"*58*:*v^
v*288 p20/**288:+*"[Z"+-<:
>*%03 p58*:*/01g"3"* v>::^
   \_^#!:-1\+-*2*:*85<^

Try it online!

This is a Mandelbrot renderer that I implemented a couple of years ago for a Rosetta Code submission. Since Befunge has no floating point, it uses a form of 14-bit fixed point arithmetic emulated with integer operations. It has a maximum of 94 iterations with the ASCII character set as the "palette".

This was originally implemented with portability in mind rather than size, but it should still be reasonably well golfed as it is.

Sample Output

ASCII art Mandelbrot rendering

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

Python 444

print (lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+y,map(lambda y,Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,Sy=Sy,L=lambda yc,Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,i=IM,Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro,i=i,Sx=Sx,F=lambda xc,yc,x,y,k,f=lambda xc,yc,x,y,k,f:(k<=0)or (x*x+y*y>=4.0) or 1+f(xc,yc,x*x-y*y+xc,2.0*x*y+yc,k-1,f):f(xc,yc,x,y,k,f):chr(64+F(Ru+x*(Ro-Ru)/Sx,yc,0,0,i)),range(Sx))):L(Iu+y*(Io-Iu)/Sy),range(Sy))))(-2.1, 0.7, -1.2, 1.2, 30, 80, 24)

Here's one from the python developers,
which though isn't really short,
is one line which is pretty boss.

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

Minkolang 0.9, 77 74 bytes (INVALID)

This answer is invalid because the language was created well after this challenge, but I'm posting it so that there's a solution in this language. Making it pretty shaved off 3 bytes woo!

1~12$:;56*[i53*$:1-0c*99*[di39*$:2-+048*[d$~2`9&d*2c+]02@ik" "+Oxx]25*Ox].

Try it here.

Output

!!!!!!!!""""""######################$$$$$$$$%%%&&(,**+ %$$$$$$######"""""""""""""
!!!!!!!"""""######################$$$$$$$$$%%%%''(*3+)'&%%$$$$$$######"""""""""""
!!!!!!""""#####################$$$$$$$$$$%%%%&(*--? 5+)(&%%%$$$$$#######"""""""""
!!!!!""""####################$$$$$$$$$$%%&&&&'(,      2)'&%%%%%$$$#######""""""""
!!!!"""####################$$$$$$$$$%%&&&&'''()-      /)('&&&&&%%$$$#######""""""
!!!!""###################$$$$$$$%%%%&)1//))+ ,202    3/.+. ('''(/&%$########"""""
!!!""##################$$$$$%%%%%%&&'),   /               4 +00.2+%%$########""""
!!""################$$$%%%%%%%%%&&&'()+6                        +'&%$$########"""
!!"##############$$%%&%%%%%%%%&&&''2 62                       5,)'&%%$$########""
!!#########$$$$$%%&'.('''''''''''((*/                           ,)+&%$$#########"
!"#####$$$$$$$%%%%&(-,+/)*3+)*(())+                               2&%$$$########"
!###$$$$$$$$%%%%%&'')+1 <56  ;/,++.                              +(&%$$$#########
!#$$$$$$$$%%%%%%&'')+.5         ;/4                              4)&%$$$$########
!$$$$$$$$%%&&&'(4*)+/                                           :=&%%$$$$########
!$%%%%&'&&&&''()+6; 7                                           )'&%%$$$$########
                                                             ?-)'&&%%$$$$########
!$%%%%&'&&&&''()+6; 7                                           )'&%%$$$$########
!$$$$$$$$%%&&&'(4*)+/                                           :=&%%$$$$########
!#$$$$$$$$%%%%%%&'')+.5         ;/4                              4)&%$$$$########
!###$$$$$$$$%%%%%&'')+1 <56  ;/,++.                              +(&%$$$#########
!"#####$$$$$$$%%%%&(-,+/)*3+)*(())+                               2&%$$$########"
!!#########$$$$$%%&'.('''''''''''((*/                           ,)+&%$$#########"
!!"##############$$%%&%%%%%%%%&&&''2 62                       5,)'&%%$$########""
!!""################$$$%%%%%%%%%&&&'()+6                        +'&%$$########"""
!!!""##################$$$$$%%%%%%&&'),   /               4 +00.2+%%$########""""
!!!!""###################$$$$$$$%%%%&)1//))+ ,202    3/.+. ('''(/&%$########"""""
!!!!"""####################$$$$$$$$$%%&&&&'''()-      /)('&&&&&%%$$$#######""""""
!!!!!""""####################$$$$$$$$$$%%&&&&'(,      2)'&%%%%%$$$#######""""""""
!!!!!!""""#####################$$$$$$$$$$%%%%&(*--? 5+)(&%%%$$$$$#######"""""""""
!!!!!!!"""""######################$$$$$$$$$%%%%''(*3+)'&%%$$$$$$######"""""""""""

Explanation

This takes advantage of Python's internal handling of complex numbers, so I can just do 1~12$:; (the equivalent of (-1)**0.5 in Python) to get the imaginary unit. Then there are three nested For loops, which loop through y, x, and z=z^2+c. Breaking out of the innermost loop is necessary (and done by d$~2`9&) because otherwise, numbers will get so large that they become (NaN+Nanj), which apparently has a magnitude less than 2.

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

><>, 118 bytes

1 v
2-\:01-(?;0
*&\0084
?!\}::*{::*$@-}2**}:@@:{+r+::*{::*$@+4(&1-:&*
ao\&~:*$:*+4(}" *"{?$~o1aa+,+:1)22@@?!.~~~1aa+,-

Try it online! Be warned, it takes about 25 seconds to run using TIO, so be patient!

More of a self-challenge than a serious entry. Produces the following output:

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

;#, 150,878 bytes (noncompeting)

It doesn't fit here :(

Output:

         !!!!!!!!"""""""""""""""""""""""""""##########$$$$%%&(.)(*2%$#######""""""""!!!!!!!!!!!!!!!!!
        !!!!!!!"""""""""""""""""""""""""""###########$$$$%%&'(*0+('&%$$#######""""""""!!!!!!!!!!!!!!!
       !!!!!!""""""""""""""""""""""""""############$$$$$%&(**-:::1('&%$$$#######""""""""!!!!!!!!!!!!!
      !!!!!""""""""""""""""""""""""""############$$$%%%&'(+:::::::02*&%$$$$$######""""""""!!!!!!!!!!!
      !!!"""""""""""""""""""""""""############$$%%%%%&&&'(4:::::::8:'&&%%%$$$$$####"""""""""!!!!!!!!!
     !!!""""""""""""""""""""""""##########$$$%&&'2''''(())+7::::::1*)(('&%%%%%'&$###"""""""""!!!!!!!!
    !!!"""""""""""""""""""""""#######$$$$$$%%&(-:0/+*,::2::::::::::::5:::('''(.+&%$##"""""""""!!!!!!!
   !!""""""""""""""""""""""#####$$$$$$$$$%%%&&(*3:::7:::::::::::::::::::::,::8:1)%$$##""""""""""!!!!!
   !""""""""""""""""""""####$$$$$$$$$$$%%%%&'()*.8::::::::::::::::::::::::::::56&%$$###""""""""""!!!!
  !!""""""""""""""""####$%%%$$$$$$$$%%%%%&'):8:5:::::::::::::::::::::::::::::0*(&%%$$##""""""""""!!!!
  !"""""""""""######$$%%(+'&&&&&&&&&&&&&&''),3:::::::::::::::::::::::::::::::::+(()%$###""""""""""!!!
 !"""""""#########$$$$%%)3*()(()4+(('''''(*9::::::::::::::::::::::::::::::::::::::*%$###"""""""""""!!
 !"""##########$$$$$$%%&'(*/:7.13::/:+*))*-:::::::::::::::::::::::::::::::::::::,(&%$####""""""""""!!
 ""##########$$$$$$$%&&&()+0:::::::::::2,,0:::::::::::::::::::::::::::::::::::::::&$$####"""""""""""!
 "#########$$$$$$$%(''((*0:::::::::::::::1::::::::::::::::::::::::::::::::::::::,'%$$#####""""""""""!
 ########$%%%%%%&&'(+.,..5::::::::::::::::::::::::::::::::::::::::::::::::::::::'%%$$#####""""""""""!
 $$$%%&&(&&'''''(,*+.:::::::::::::::::::::::::::::::::::::::::::::::::::::::::*'&%$$$#####""""""""""!
 $$&%%'):)('))((),,,9::::::::::::::::::::::::::::::::::::::::::::::::::::::::,('&%$$$#####""""""""""!
 ##$$$##$%%%%%%&&&'(*8181::::::::::::::::::::::::::::::::::::::::::::::::::::::*&%$$$#####""""""""""!
 "#########$$$$%%%&(+(()*.:::::::::::::::4:::::::::::::::::::::::::::::::::::::::&%$$#####""""""""""!
 ""##########$$$$$$$%&&'+*-2::::::::::::..4::::::::::::::::::::::::::::::::::::::/&$$####"""""""""""!
 """"##########$$$$$$%&&'(*2::4::::::0.**+-:::::::::::::::::::::::::::::::::::::,(&%$####"""""""""""!
 !"""""##########$$$$%%&'-3.-*)*-:+)8(((()*.:::::::::::::::::::::::::::::::::::::,'%$####""""""""""!!
  !"""""""""#######$$$%%'4''&&&')('&&&&&''(+/::::::::::::::::::::::::::::::::::-5+-%$###""""""""""!!!
  !"""""""""""""""####$%&%%%%%%$$$%%%%%&&&')::::::::::::::::::::::::::::::::::.('&%$$###""""""""""!!!
   !"""""""""""""""""""###$$$$$$$$$$$$%%%%%&(-*-1:::::::::::::::::::::::::::::/(&%$$###""""""""""!!!!
   !!"""""""""""""""""""""#####$$$$$$$$$%%%%&'(+::::::::::::::::::::::::::0::::,7%$$##""""""""""!!!!!
    !!"""""""""""""""""""""""#######$$$$$$%%%&*:::4:+-::::::::::::::::::.)):7)+,(%$##""""""""""!!!!!!
    !!!""""""""""""""""""""""""##########$$$%&:)2/)(((+,*+,/::::::/,+))5(&&&&&'+%$##""""""""""!!!!!!!
     !!!!"""""""""""""""""""""""""###########$$%%%%%&&&''),::::::::8('&&%%%%$$$$###"""""""""!!!!!!!!!
      !!!!""""""""""""""""""""""""""############$$$%%%%&'(+::::::::-(&%%$$$$$#####"""""""""!!!!!!!!!!
       !!!!!""""""""""""""""""""""""""############$$$$$%%)+2,/:::,**'%$$$$#######""""""""!!!!!!!!!!!!
        !!!!!!"""""""""""""""""""""""""""###########$$$$$%&&'),:,)'&%$$$#######""""""""!!!!!!!!!!!!!!
         !!!!!!!!""""""""""""""""""""""""""###########$$$$%&'(.,,-*%%$#######"""""""!!!!!!!!!!!!!!!!!
\$\endgroup\$
1
  • \$\begingroup\$ You don't need this much detail. \$\endgroup\$
    – Riker
    Commented May 27, 2017 at 1:53

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