initial commit

This commit is contained in:
hoffmeisterda104361 committed 2026-10-19 20:29:13 +02:00
commit 39f56a3b10
83 files changed
+3583

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
import time
def permute(picked: str, remaining: str):
if remaining == "" :
print(picked + remaining + ", ", end="")
else:
for i in range(len(remaining)):
pick = remaining[i]
front = remaining[:i]
back = remaining[i+1:]
permute(picked + pick, front + back)
def main():
start = time.time()
permute("","abcdefghijk")
end = time.time()
print(end - start)
#"abcdefghijk" takes 85 sec
main()
+29
View File
@@ -0,0 +1,29 @@
import math
import random
from turtle import Turtle
def draw_turtle_line(turtle, start: (float,float), end: (float, float)):
turtle.penup()
turtle.goto(start[0], start[1])
turtle.pendown()
turtle.goto(end[0], end[1])
def draw_branch(turtle, point: (float, float), angle: float, length: float):
if length > 10:
x1 = round(point[0] - math.sin(angle) * length)
y1 = round(point[1] + math.cos(angle) * length)
draw_turtle_line(turtle, point, (x1, y1))
bend_angle = math.radians(random.uniform(-10, 10))
branch_angle = math.radians(random.uniform(-40, 40))
draw_branch(turtle,(x1, y1), bend_angle - branch_angle, length *
random.uniform(0.6, 0.8))
draw_branch(turtle,(x1, y1), bend_angle + branch_angle, length *
random.uniform(0.6, 0.8))
sophia = Turtle()
draw_branch(sophia, (0, 0), 0.0 ,100)
sophia.screen.mainloop()