ITERS = 24
ESCAPE = 4

def mandlebrot(z):
	c = z
	for i in xrange(ITERS):
		z = z*z + c
		if abs(z) > ESCAPE:
			return i
	return 0

def m2c(i):
	return (i == 0) and ' ' or '*'

# size of output image
iw = 80
ih = 40

P = complex
# portion of mandelbrot set to display: corner + size
ll = P(-2.5, -1.5)
w = 4.0
h = 3.0

for i in xrange(ih):
	print ''.join([m2c( mandlebrot(ll + P(j*w/iw, i*h/ih)) ) for j in xrange(iw)])


