#!/usr/bin/ruby

func mandelbrot(z) {
    var c = z
    20.times {
        z = (z*z + c)
        z.abs > 2 && return true
    }
    return false
}

for y in (1 `downto` -1 `by` 0.05) {
    for x in (-2 `upto` 0.5 `by` 0.0315) {
        print(mandelbrot(Complex(x, y)) ? ' ' : '#')
    }
    print "\n"
}
