Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
import turtle import math def fractal(aturt, depth, maxdepth): if depth > maxdepth: return length = 100*((math.sqrt(2)/2)**depth) anotherturt = aturt.clone() aturt.forward(length) aturt.left(45) fractal(aturt, depth+1, maxdepth) anotherturt.right(90) anotherturt.forward(length) anotherturt.left(90) anotherturt.forward(length) if depth != maxdepth: turt3 = anotherturt.clone() turt3.left(45) turt3.forward(100*((math.sqrt(2)/2)**(1+depth))) turt3.right(90) fractal(turt3, depth+1, maxdepth) anotherturt.left(90) anotherturt.forward(length) def draw_fractal(): window = turtle.Screen() turt = turtle.Turtle() turt.hideturtle() turt.penup() turt.goto(-40, -180) turt.pendown() turt.speed(0) turt.left(90) #change the second argument to get a bigger tree! fractal(turt, 1, 2) window.exitonclick() draw_fractal()
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)