omega-rosetta
aien-dev/omega-rosetta
Brought by drakestapleton
omega-rosetta / tasks / mandelbrot-set / oracle.py
| 1 | # Independent reference for "Mandelbrot set" (Python 3, standard library only). |
| 2 | # expected.txt is this program's stdout; omc never produced it. |
| 3 | pal = " .:-=+*%" |
| 4 | for r in range(24): |
| 5 | ci = 1.15 - float(r) * 0.1 |
| 6 | line = "" |
| 7 | for c in range(72): |
| 8 | cr = float(c) * 0.0375 - 2.2 |
| 9 | zr = zi = 0.0 |
| 10 | it = 0 |
| 11 | while it < 50: |
| 12 | zr2 = zr * zr |
| 13 | zi2 = zi * zi |
| 14 | if zr2 + zi2 > 4.0: |
| 15 | break |
| 16 | zi = 2.0 * zr * zi + ci |
| 17 | zr = zr2 - zi2 + cr |
| 18 | it += 1 |
| 19 | line += "#" if it == 50 else pal[it % 8] |
| 20 | print(line) |