# from math import from tkinter import int input root Tk canv Canvas roo

 ``` 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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74``` ```from math import * from tkinter import * k= int(input()) root = Tk() canv = Canvas(root, width = 600,height = 600, bg = 'lightblue') x1,y1 = map(int, input().split()) x2,y2 = map(int, input().split()) x6,y6 = map(int, input().split()) def Gen(x1,y1,x2,y2,k): if k == 0: return l=int(sqrt((x2-x1)**2+(y2-y1)**2)) h = l/(2*sqrt(3)) x3 = x1 +int((x2-x1)/3+0.5) y3 = y1 +int((y2- y1)/3 +0.5) x4 = x1 +int(2*(x2-x1)/3+0.5) y4 = y1 +int(2*(y2- y1)/3 +0.5) x5 = int((x2+x1)/2+(h*(y2-y1)/l)) y5 = int((y2+y1)/2+(h*(x2-x1)/l)) canv.create_line(x1, y1,x3,y3 , width =2) canv.create_line( x3, y3,x5,y5 , width =2) canv.create_line( x5, y5,x4,y4 , width =2,smooth = 1) canv.create_line( x4, y4,x2,y2 , width =2,smooth = 1) canv.create_line( x3, y3,x4,y4 , width =3, fill = 'lightblue') Gen(x1, y1,x3,y3, k-1) Gen(x3, y3,x5,y5 ,k-1) Gen(x5, y5,x4,y4 ,k-1) Gen(x4, y4,x2,y2 ,k-1) def Gen1(x2,y2,x6,y6,k): if k == 0: return l=int(sqrt((x6-x2)**2+(y6-y2)**2)) h = l/(2*sqrt(3)) x32 = x1 +int((x6 - x2)/3+0.5) y32 = y1 +int((y6 - y2)/3 +0.5) x42 = x1 +int(2*(x6-x2)/3+0.5) y42 = y1 +int(2*(y6- y2)/3 +0.5) x52 = int((x6+x2)/2+(h*(y6-y2)/l)) y52 = int((y6+y2)/2+(h*(x6-x2)/l)) canv.create_line(x2, y2,x32,y32 , width =2) canv.create_line( x32, y32,x52,y52 , width =2) canv.create_line( x52, y52,x42,y42 , width =2,smooth = 1) canv.create_line( x42, y42,x6,y6 , width =2,smooth = 1) canv.create_line( x32, y32,x42,y42 , width =3, fill = 'lightblue') Gen1(x2, y2,x32,y32, k-1) Gen1(x32, y32,x52,y52 ,k-1) Gen1(x52, y52,x42,y42 ,k-1) Gen1(x42, y42,x6,y6 ,k-1) def Gen2(x6,y6,x1,y1,k): if k == 0: return l=int(sqrt((x1-x6)**2+(y1-y6)**2)) h = l/(2*sqrt(3)) x31 = x1 +int((x1 - x6)/3+0.5) y31 = y1 +int((y1 - y6)/3 +0.5) x41 = x1 +int(2*(x1-x6)/3+0.5) y41 = y1 +int(2*(y1- y6)/3 +0.5) x51 = int((x1+x6)/2+(h*(y1-y6)/l)) y51 = int((y1+y6)/2+(h*(x1-x6)/l)) canv.create_line(x6, y6,x31,y31 , width =2) canv.create_line( x31, y31,x51,y51 , width =2) canv.create_line( x51, y51,x41,y41 , width =2,smooth = 1) canv.create_line( x41, y41,x1,y1 , width =2,smooth = 1) canv.create_line( x31, y31,x41,y41 , width =3, fill = 'lightblue') Gen2(x6, y6,x31,y31, k-1) Gen2(x31, y31,x51,y51 ,k-1) Gen2(x51, y51,x41,y41 ,k-1) Gen2(x41, y41,x1,y1 ,k-1) Gen(x1,y1,x2,y2,k) Gen1(x2,y2,x6,y6,k) Gen2(x6,y6,x1,y1,k) canv.pack() root.mainloop() ```