nq1s788

6 черепаха подсчет повторяющихся точек

May 17th, 2025
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. from turtle import *
  2.  
  3.  
  4. def count_coords(st, f):
  5. global dots, answ
  6. for x in range(int(st[0]), int(f[0]) + 1, k):
  7. for y in range(int(st[1]), int(f[1]) + 1, k):
  8. if (x, y) in dots:
  9. answ += 1
  10. else:
  11. dots.add((x, y))
  12.  
  13.  
  14. screensize(1000, 1000)
  15. tracer(0)
  16. k = 35
  17. #shearfactor(0.5)
  18. dots = set([])
  19. answ = 0
  20. for i in range(4):
  21. for i in range(4):
  22. s = (xcor(), ycor())
  23. forward(k * 6)
  24. f = (xcor(), ycor())
  25. count_coords(s, f)
  26. right(90)
  27. s = (xcor(), ycor())
  28. forward(k * 10)
  29. f = (xcor(), ycor())
  30. count_coords(s, f)
  31. right(90)
  32. s = (xcor(), ycor())
  33. forward(k * 3)
  34. f = (xcor(), ycor())
  35. count_coords(s, f)
  36.  
  37. up()
  38.  
  39. for x in range(-100, 100):
  40. for y in range(-100, 100):
  41. goto(x * k, y * k)
  42. dot(4, 'blue')
  43. print(answ)
  44. done()
Advertisement
Add Comment
Please, Sign In to add comment