Skip to content

Commit 6be45e0

Browse files
author
SlithyMatt
committed
Made compatible with MicroPython
1 parent 11917dc commit 6be45e0

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

modern/mandelbrot.py

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1-
import datetime
2-
3-
start = datetime.datetime.now()
1+
import time
42

53
pixels = " .:~÷+<*/([{@%&$"
6-
for py in range(0,22):
7-
for px in range(0,32):
8-
xz = px*3.5/32-2.5
9-
yz = py*2/22-1
10-
x = 0
11-
y = 0
12-
for i in range(0,15):
13-
if x*x+y*y > 4:
14-
break
15-
xt = x*x - y*y + xz
16-
y = 2*x*y + yz
17-
x = xt
18-
print(pixels[i-1],end="")
19-
print("")
20-
21-
delta = datetime.datetime.now() - start
22-
print("Time = " + str(delta.total_seconds()) + " seconds")
4+
5+
def mand():
6+
start = time.time_ns()
7+
for py in range(0,22):
8+
for px in range(0,32):
9+
xz = px*3.5/32-2.5
10+
yz = py*2/22-1
11+
x = 0
12+
y = 0
13+
for i in range(0,15):
14+
if x*x+y*y > 4:
15+
break
16+
xt = x*x - y*y + xz
17+
y = 2*x*y + yz
18+
x = xt
19+
print(pixels[i-1],end="")
20+
print("")
21+
delta = time.time_ns() - start
22+
print("Time = " + str(delta/1000000000) + " seconds")
23+
24+
mand()
25+

0 commit comments

Comments
 (0)