fork download
  1. # coding=UTF-8
  2.  
  3. def mandel(x, y, max_iter):
  4. iter = 0
  5. a = 0.0
  6. b = 0.0
  7. while a*a + b*b < 4 and iter < max_iter:
  8. temp = a*a - b*b + x
  9. b = 2*a*b + y
  10. a = temp
  11. iter += 1
  12. return iter
  13.  
  14. Shades = "_.-'"
  15.  
  16. scale = 20
  17. max_iter = 20
  18.  
  19. buffer = ""
  20. for y in range(0, int(2.6*scale)):
  21. y0 = (y - 2.6*scale/2) / scale
  22. for x in range(0, int(3.5*scale)):
  23. x0 = (x - 2.5*scale) / scale
  24. iter = mandel(x0, y0, max_iter)
  25. buffer += Shades[int((len(Shades)-1)*iter/max_iter)]
  26. buffer += "\n"
  27. print buffer
Success #stdin #stdout 0.04s 7896KB
stdin
Standard input is empty
stdout
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________
______________________________________________-.______________________
______________________________________________..______________________
______________________________________________....'___________________
_____________________________________________...'..___________________
_____________________________________________..''..___________________
____________________________________________.'-''--.__________________
___________________________________________..-''''-.__________________
__________________________________________...''''''.._________________
______________________________________.......-''''....___-____________
_____________________________________..'..''''''''''.'...-.___________
_____________________________________..''-''''''''''''.----___________
_____________________________________..'''''''''''''''''''.___________
____________________________________.-.'''''''''''''''''''.___________
__________________________________..'''''''''''''''''''''..___________
________________________.............''''''''''''''''''''-.-__________
________________________.-..........'''''''''''''''''''''''-__________
________________________..-'..'.....''''''''''''''''''''''-.__________
_______________________...-''''''...''''''''''''''''''''''-.__________
_______________________...-'''''''--'''''''''''''''''''''''.__________
_____________________.-..-'''''''''''''''''''''''''''''''''___________
____________________....-'''''''''''''''''''''''''''''''''.___________
______________..._....-''''''''''''''''''''''''''''''''''..___________
___________'''''''''''''''''''''''''''''''''''''''''''''...___________
______________..._....-''''''''''''''''''''''''''''''''''..___________
____________________....-'''''''''''''''''''''''''''''''''.___________
_____________________.-..-'''''''''''''''''''''''''''''''''___________
_______________________...-'''''''--'''''''''''''''''''''''.__________
_______________________...-''''''...''''''''''''''''''''''-.__________
________________________..-'..'.....''''''''''''''''''''''-.__________
________________________.-..........'''''''''''''''''''''''-__________
________________________.............''''''''''''''''''''-.-__________
__________________________________..'''''''''''''''''''''..___________
____________________________________.-.'''''''''''''''''''.___________
_____________________________________..'''''''''''''''''''.___________
_____________________________________..''-''''''''''''.----___________
_____________________________________..'..''''''''''.'...-.___________
______________________________________.......-''''....___-____________
__________________________________________...''''''.._________________
___________________________________________..-''''-.__________________
____________________________________________.'-''--.__________________
_____________________________________________..''..___________________
_____________________________________________...'..___________________
______________________________________________....'___________________
______________________________________________..______________________
______________________________________________-.______________________
______________________________________________________________________
______________________________________________________________________
______________________________________________________________________