fork download
  1. def print_coordinates(n):
  2.  
  3. x, y = 10, 10
  4. count = 0
  5. length = 1
  6. switch = -1
  7.  
  8. while count <= n:
  9. for j in range(length):
  10. if count == n:
  11. break
  12. x += switch
  13. count += 1
  14.  
  15. for j in range(length):
  16. if count == n:
  17. break
  18. y += switch
  19. count += 1
  20.  
  21. if count == n:
  22. break
  23. length += 1
  24. switch *= (-1)
  25.  
  26. print((x, y))
  27.  
  28. for n in range(10):
  29. print_coordinates(n)
Success #stdin #stdout 0.01s 27712KB
stdin
Standard input is empty
stdout
(10, 10)
(9, 10)
(9, 9)
(10, 9)
(11, 9)
(11, 10)
(11, 11)
(10, 11)
(9, 11)
(8, 11)