title: Trim a String without Builtins

text:
# Question
Title: Trim a String without Builtins
Given text, remove leading and trailing whitespace (spaces, tabs, and newlines).

Alternate title: Implement your own string trimming.

# Input

ASCII text (printable + spaces, tabs (`\t`), and newlines (`\n`)), in whatever format you would like. Carriage returns (`\r`) are outside of the scope of the input.

# Output

The same text in the same format, but with (only) trailing and leading spaces, tabs, and newlines removed.

\*Note: If your language naturally outputs a trailing space/newline, please note that in your answer.

# Test Cases

This test case ensures that you can handle `\s` and the like. Please note whitespace in it.

Input

```
 \s test \t\n

```

Output

```
\s test \t\n

```

For the following test cases (but not the above), `\s` is space, `\t` is tab, `\n` is newline. `=>` splits input and output.

```
\s\t\n\s => (empty string)

\stest\s => test

\nt\n\st\t => t\n\st

_ => _

\s\s\n\s1\s+\s1\n => 1\s+\s1

||_\s => ||_

```

No builitins allowed that trim either specific characters or given characters. Builtins that remove arbitrary characters from the beginning/end of a string, or that remove given characters from any position in a string (by default) are allowed.

# Answer
> 1 votes
# Jelly, 8 bytes

```
>⁶TṬo\Tị

```

Try it online!

# Answer
> 3 votes
# Retina, 10 bytes

```
^\s+|\s+$

```

Try it online!

Trailing newline is added automatically and is unavoidable.

# Answer
> 1 votes
# Carrot, 21 bytes

```
#^//\S([\s\S]*\S)?/gS

```

Try it online!

### Explanation

Carrot has several global variables, one for each type: string, float and array. The program starts in string-mode, where all the operators will affect the global string variable. And I call these variables the "stack".

```
#^                     Set the stack-string to the value of all of the input
/                      Get matches of this regex:
 /\S([\s\S]*\S)?/g
                       And set the stack-array to the array containing these matches
                       There will only ever be one or zero matches
S                      Convert to string-mode by joining the elements of the array

```

The `S` operator is supposed to take a string or number as an argument to join the array on, but apparently it is not needed in this case (I don't understand why).

# Answer
> 1 votes
# JS (ES6), 27 bytes

```
i=>i.replace(/^\s+|\s+$/g,"")

```

# Answer
> 1 votes
# Jelly, ~~11~~ 8 bytes

-2 bytes thanks to Dennis (use direct character conversion, similar to his answer `O>32` -\> `>⁶`
-1 byte thanks to Dennis (removing a redundant quick)

```
>⁶TṂr$Ṁị

```

**Try it online!**

Steering clear of anything that could be considered "trimming".

### How?

```
>⁶TṂr$Ṁị - Main link: list of characters (a.k.a. string)  e.g. "  t xt  "
 ⁶       - literal space character
>        - greater than (vectorises)                           [0,0,1,0,1,1,0,0]
  T      - truthy indexes                                      [    3,  5,6    ]
     $   - last two links as a monad
   Ṃ     -   minimum                                                3
    r    -   inclusive range                                   [[3],[3,4,5],[3,4,5,6]]
      Ṁ  - maximum                                             [3,4,5,6]
       ị - index into the input                                 "t xt"

```

# Answer
> 0 votes
# PHP, 40 Bytes

Regex Version

```
<?=preg_replace("#^\s+|\s+$#","",$argn);

```

Try it online!

## PHP, 77 Bytes

The Regex version was so boring so I would try it without a Regex

```
<?=substr($a=$argn,strspn($a,$c="\t\n "),-strspn(strrev($a),$c)?:strlen($a));

```

Try it online!

# Answer
> 0 votes
# C (gcc) & preprocessor, ~~152~~ 149 bytes

```
#define f(x)(x==32|x==9|x==10)
char*t(char*o){int i=strlen(o);for(;--i>0;){if(!f(o[i]))break;o[i]=0;};while(1){if(f(*o))o=o+1;else break;}return o;}

```

-3 bytes: Ironically, I forgot to remove my spaces.

A function that takes in a `char*` (pointer to the first character of the string (how C implements strings)), and returns a pointer to the first non-space character in the string, and also replaces all trailing spaces with null bytes, C's string terminator.

Ungolfed:

```
#define isspace(x) (x==32|x==9|x==10)
// save bytes by not using this whole thing each time
// (32 is ' ', 9 is '\t', 10 is '\n')
char *trim(char *original) {
    int i=strlen(original);
    for(;--i>0;){                   // start at the end of the string, work backwards
        if(!isspace(original[i]))
            break;              // if the character not is a space character, stop working backwards
        original[i]=0;          // else: replace the character with a null byte, C's string terminator
    }
    while(1){
        if(isspace(original[0]))// shift the pointer until the first char is not a space
            original = original + 1;
        else break;
    }
    return original;            // return the modified pointer
}
```

# Answer
> 0 votes
# Python 2, 44 bytes

```
lambda s:re.sub(r'^\s*|\s*$','',s)
import re

```

Try it online!

## Non-regex: 62 bytes

Takes input as list of characters. Outputs by reference.

```
def f(s):exec'while s[%s].isspace():del s[%s]\n'*2%(0,0,-1,-1)

```

# Answer
> 0 votes
# Japt, 9 bytes

```
e"^%s|%s$

```

Try it online (`-Q` flag used for visualisation only)

# Answer
> 0 votes
# C#, 60 bytes

```
s=>System.Text.RegularExpressions.Replace(s,"^\s+|\s+$","");

```

If I could use built-ins this is only 12 bytes:

```
s=>s.Trim();

```

---
Tags: code-golf, string, restricted-source
---


title: Unshorten Google Links

text:
# Question
Title: Unshorten Google Links
# Challenge

Given a valid `goo.gl` shortened link, output the original URL.

# Example

`goo.gl/qIwi3N` would give something like `https://codegolf.stackexchange.com/`. For input, you can choose to have the `https?://` at the beginning, you can choose to have `www.` before the `goo.gl`, and you can also choose to get rid of the `goo.gl` if you only want the end of the URL. A slash at the end is optional for input and output. So, your input will end up matching the regex `(https?://)?(www\.)?(goo\.gl/)?[A-Za-z0-9]+/?`. For the output, you can choose whether or not to output `https?://`, whether or not to output `www.`, and whether or not to output a trailing slash. However, **you must be consistent with your I/O formatting**.

I will say that you do not have to be consistent with `https` vs. `http` for output (but you must be consistent for input), as long as you are consistent with whether or not you include the whole `https?://` part.

# Test Cases

These are written with no `https://`, no `www.`, no trailing slash in the input; yes `https://`, no `www.`, and yes trailing slash in the output.

```
input -> output
goo.gl/HaE8Au -> https://codegolf.stackexchange.com/
goo.gl/IfZMwe -> https://stackoverflow.com/
goo.gl/JUdmxL -> https://chat.stackexchange.com/rooms/240/the-nineteenth-byte

```

# Assumptions

* You may assume that the shortened link will not point to another shortened link and that the destination site will return a status code of `2xx` or `4xx` (no redirections).

You can go here and enter a URL to apply the inverse operation of this: https://goo.gl/

# Answer
# CJam, 7 bytes

```
lg'"/5=

```

### Test run

```
$ alias cjam
alias cjam='java -jar ~/.local/share/cjam-0.6.5.jar'
$ cjam unshorten.cjam <<< goo.gl/HaE8Au; echo
https://codegolf.stackexchange.com/
$ cjam unshorten.cjam <<< goo.gl/IfZMwe; echo
https://stackoverflow.com/
$ cjam unshorten.cjam <<< goo.gl/JUdmxL; echo
https://chat.stackexchange.com/rooms/240/the-nineteenth-byte

```

### How it works

`lg` reads a line from STDIN and makes a GET request to that URL. The shortened URL issues a 301 redirect, which CJam doesn't follow. For the first test case, this pushes

```
<HTML>
<HEAD>
<TITLE>Moved Permanently</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Moved Permanently</H1>
The document has moved <A HREF="https://codegolf.stackexchange.com/">here</A>.
</BODY>
</HTML>

```

on the stack. Finally, `'"/` splits at double quotes, and `5=` gets the sixth chunk. Output is implicit.
> 11 votes

# Answer
# Bash, ~~28~~ 24 bytes

```
curl -I $1|grep -oehtt.*

```

The output ends with a Windows-style newline, which I assume is acceptable.

### Test run

```
$ bash unshorten.sh 2>&- goo.gl/HaE8Au
https://codegolf.stackexchange.com/
$ bash unshorten.sh 2>&- goo.gl/IfZMwe
https://stackoverflow.com/
$ bash unshorten.sh 2>&- goo.gl/JUdmxL
https://chat.stackexchange.com/rooms/240/the-nineteenth-byte

```

### How it works

`curl -I` sends a HEAD request, so it fetches only the HTTP headers of the specified URL. For the first test case, it prints

```
HTTP/1.1 301 Moved Permanently
Content-Type: text/html; charset=UTF-8
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: Mon, 01 Jan 1990 00:00:00 GMT
Date: Sat, 13 May 2017 05:51:48 GMT
Location: https://codegolf.stackexchange.com/
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Transfer-Encoding: chunked
Accept-Ranges: none
Vary: Accept-Encoding

```

or similar. The output is piped to `grep -oehtt.*`, which displays only parts that match the specified regex, i.e., the string **htt** followed by any amount of characters up to the end of the line.
> 4 votes

# Answer
# Python 2 + requests, 44 bytes

```
from requests import*
print get(input()).url

```

`requests.get(URL)` issues a GET request to the specified URL. The response object's `url` field contains the final URL, after any redirects. A protocol (e.g. `http://`) is required for the input, and the input is expected to be in quotes.
> 3 votes

# Answer
# PHP, 36 Bytes

Input with `https://`

```
<?=substr(get_headers($argn)[7],10);

```

get\_headers

25 Bytes if `Location:` at the beginning must not removed

```
<?=get_headers($argn)[7];

```

if Google changes the HTTP Header here is a safer version

```
preg_match("#Location: \K.*#",join("\n",get_headers($argn)),$t);echo$t[0];

```
> 2 votes

# Answer
# Python 2, 43 bytes

Has no dependencies and is currently shorter than the other Python answer. *shrug* Input must match `https?://goo\.gl/.*?/?`

```
lambda s:urlopen(s).url
from urllib import*

```
> 1 votes

# Answer
# NodeJS, 60 bytes

```
u=>require("http").get(u,r=>console.log(r.headers.location))

```

Input is in the format `http://goo.gl/<id>`.
> 0 votes

---
Tags: code-golf, internet
---


title: Generate a mandelbrot fractal

text:
# Question
Title: Generate a mandelbrot fractal
Your task is to draw the mandelbrot set in ascii. It should look something like

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.

# Answer
## 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
> 23 votes

# Answer
**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.
> 18 votes

# Answer
**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)**

```
                                                  @

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

                                                  @

```
> 12 votes

# Answer
# 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:

---

# 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.

*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...
> 11 votes

# Answer
## , 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 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 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 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 0 0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 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 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

```
> 10 votes

# Answer
### 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:

```
                                        *

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

                                        *

```
> 6 votes

# Answer
# 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:

```
                                        *

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

                                        *

```
> 6 votes

# Answer
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

```

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

```
> 6 votes

# Answer
**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]]

```

**Mathematica 77**

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

```
> 6 votes

# Answer
## 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

```
> 5 votes

# Answer
**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.
> 4 votes

# Answer
**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/
> 3 votes

# Answer
## 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.
> 3 votes

# Answer
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.
> 3 votes

# Answer
**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:
> 3 votes

# Answer
# Brainf\***, 11595 bytes

```
+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[
>>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+
<<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>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BBBB
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.
> 2 votes

# Answer
**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.
> 1 votes

# Answer
**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.):

```
                                       !

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

                                       !

```
> 1 votes

# Answer
## 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:;;<<<<<<======>>>>>>>>>>

```
> 1 votes

# Answer
# 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*;]''+

```
> 1 votes

# Answer
# 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

```
> 1 votes

# Answer
# 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:

```
                                                               *

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

                                                               *

```
> 1 votes

# Answer
# 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

```
> 1 votes

# Answer
# 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

```
> 1 votes

# Answer
# 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),'']

                                                                                #

                                                                                ##
                                                                                #####
                                                                                #############
                                                                                ##################
                                                                                ###################
                                                                                ####################
                                                                                ##################
                                                                                #############
                                                                                ##  ########################## #   #
                                                                                ##    #         ################################################ ####
                                                                                #########  # #########################################################  #        #
                                                                                ######### ##################################################################    ########
                                                                                ##################################################################################
                                                                                #   #####################################################################################
                                                                                # ##################################################################################### #
                                                                                #### ########################################################################################### #
                                                                                # ############################################################################################## #
                                                                                ####################################################################################################
                                                                                ##############################################################################################################
                                                                                ########################################################################################################
                                                                                #                           ##############################################################################################################
                                                                                #####     ############ ###                    ############################################################################################################
                                                                                ##############################               ################################################################################################################
                                                                                ###################################         ###############################################################################################################
                                                                              ## #######################################       ################################################################################################################
                                                                               ###########################################    ############################################################################################################### #
                                                                             ###############################################  ################################################################################################################
                                                                           ################################################## #############################################################################################################
                                                                 #########  ################################################# ###########################################################################################################
                        ##                                   ## ####################################################################################################################################################################
                                                                ######################################################################################################################################################################
                                                                 ########   ################################################# ###########################################################################################################
                                                                             ###############################################  #############################################################################################################
                                                                            ################################################  ##############################################################################################################
                                                                                #########################################      ################################################################################################################
                                                                             # #  ######################################       ###############################################################################################################
                                                                                ################################           ##############################################################################################################
                                                                                ##### #####################  #              #################################################################################################################
                                                                                ####     #    ###   #   #                     ############################################################################################################
                                                                                # ### #########################################################################################################
                                                                                ####################################################################################################### ###
                                                                                # ## ##########################################################################################################
                                                                                # ##################################################################################################
                                                                                ###################################################################################################
                                                                                #################################################################################################
                                                                                ######################################################################################
                                                                                #####################################################################################
                                                                                ############################################################################ #########
                                                                                ########## ################################################################ #    #########
                                                                                #######     ## #################################################### #
                                                                                ########################################### ##  #####
                                                                                ##    # #   #### #### ## ###     #
                                                                                ###############
                                                                                ####################
                                                                                #####################
                                                                                ###################
                                                                                ################## #
                                                                                #########
                                                                                #####
                                                                                #

```
> 1 votes

# Answer
# 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**
> 1 votes

# Answer
**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.
> 0 votes

# Answer
## 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.
> 0 votes

# Answer
# \>\<\>, 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:

```
                                        *

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

                                        *

```
> 0 votes

# Answer
# ;#, 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,/:::,**'%$$$$#######""""""""!!!!!!!!!!!!
        !!!!!!"""""""""""""""""""""""""""###########$$$$$%&&'),:,)'&%$$$#######""""""""!!!!!!!!!!!!!!
         !!!!!!!!""""""""""""""""""""""""""###########$$$$%&'(.,,-*%%$#######"""""""!!!!!!!!!!!!!!!!!

```
> 0 votes

# Answer
# TI-BASIC, 256

```
PROGRAM:M
:Input "ITER. ",D
:For(A,Xmin,Xmax,ΔX)
:For(B,Ymin,Ymax,ΔY)
:0→X
:0→Y
:0→I
:D→M
:While X^2+Y^2≤4 and I<M
:X^2-Y^2+A→R
:2XY+B→Y
:R→X
:I+1→I
:End
:If I≠M
:Then
:I→C
:Else
:0→C
:End
:If C<1
:Pt-On(A,B)
:End
:End
:End

```
> 0 votes

---
Tags: code-golf, ascii-art, fractal
---