from math import from tkinter import def koka x1 y1 x2 y2 if return sq

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from math import *
from tkinter import *
def koka(x1, y1, x2, y2, k):
if k == 0:
return
l = sqrt((x2 - x1)**2 + (y2 - y1)**2)
h = int( l/6)
x3 = x1 + int((x2 - x1)/3)
y3 = y1 + int((y2 - y1)/3)
x4 = x1 + int(2*(x2 - x1)/3)
y4 = y1 + int(2*(y2 - y1)/3)
x0 = int(((x2 + x1)/2 + h*(sqrt(2))/2))
y0 = int((y2 + y1)/2 - h*(sqrt(2))/2)
x5 =int(2*x0-x4)
y5 =int(2*y0-y4)
x6 =int(2*x0-x3)
y6 =int(2 *y0-y3)
canv.create_line(x1, y1, x3, y3, width = 1)
canv.create_line(x3, y3, x5, y5, width = 1)
canv.create_line(x5, y5, x6, y6, width = 1, smooth = 1)
canv.create_line(x6, y6, x4, y4, width = 1, smooth = 1)
canv.create_line(x4, y4, x2, y2, width = 1)
canv.create_line(x3, y3, x4, y4, width = 3, fill = 'lightblue')
koka(x1, y1, x3, y3, k - 1)
koka(x3, y3, x5, y5, k - 1)
koka(x5, y5, x6, y6, k - 1)
koka(x6, y6, x4, y4, k - 1)
koka(x4, y4, x2, y2, k - 1)
root = Tk()
k = int(input())
if k <= 5:
canv = Canvas(root, width = 750, height = 750, bg = 'lightblue')
x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x3, y3 = map(int, input().split())
l = sqrt((x2 - x1)**2 + (y2 - y1)**2)
koka(x1, y1, x2, y2, k)
canv.pack()
root.mainloop()