Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. # python -u "c:\Users\ediso\Documents\Grade 10 Cs\Problems\CrossSpiral.py"
  2. totalWidth = int(input())
  3. totalHeight = int(input())
  4. cutWidth = int(input())
  5. cutHeight = int(input())
  6. steps = int(input())
  7. stepsTaken = 0
  8. house = [[0 for i in range (totalWidth + 2)]for j in range (totalHeight + 2)]
  9. x = cutWidth
  10. y = 1
  11. dr = "r"
  12. pr = "r"
  13. for l in range (totalWidth + 2):
  14. house[0][l] = 1
  15. house[totalHeight + 1][l] = 1
  16. for m in range (totalHeight + 2):
  17. house[m][0] = 1
  18. house[m][totalWidth + 1] = 1
  19.  
  20. for i in range (1, cutHeight + 1):
  21. for j in range (1, cutWidth + 1):
  22. house[i][j] = 1
  23. for z in range (totalWidth - (cutWidth - 1), totalWidth + 1):
  24. house[i][z] = 1
  25. for i in range (totalHeight - (cutHeight - 1), totalHeight + 1):
  26. for j in range (1, cutWidth + 1):
  27. house[i][j] = 1
  28. for z in range (totalWidth - (cutWidth - 1), totalWidth + 1):
  29. house[i][z] = 1
  30.  
  31. while(stepsTaken <= steps):
  32. if (dr == "r"):
  33. if (house[y][x + 1] == 0):
  34. x += 1
  35. house[y][x] = 1
  36. stepsTaken += 1
  37. if (x <= int(totalWidth/2)):
  38. dr = "l"
  39. elif (x > int(totalWidth/2)):
  40. dr = "r"
  41. elif (house[y][x + 1] == 1):
  42. dr = "d"
  43. if (dr == "d"):
  44. if (house[y + 1][x] == 0):
  45. y += 1
  46. house[y][x] = 1
  47. stepsTaken += 1
  48. if (x <= int(totalWidth/2)):
  49. dr = "l"
  50. elif (x > int(totalWidth/2)):
  51. dr = "r"
  52. elif (house[y + 1][x] == 1):
  53. dr = "l"
  54. if (dr == "l"):
  55. if (house[y][x - 1] == 0):
  56. x -= 1
  57. house[y][x] = 1
  58. stepsTaken += 1
  59. if (x <= int(totalWidth/2)):
  60. dr = "l"
  61. elif (x > int(totalWidth/2)):
  62. dr = "r"
  63. elif (house[y][x - 1] == 1):
  64. dr = "u"
  65. if (dr == "u"):
  66. if (house[y - 1][x] == 0):
  67. y -= 1
  68. house[y][x] = 1
  69. stepsTaken += 1
  70. if (x <= int(totalWidth/2)):
  71. dr = "l"
  72. elif (x > int(totalWidth/2)):
  73. dr = "r"
  74. elif (house[y - 1][x] == 1):
  75. dr = "r"
  76. if (house[y + 1][x] == 1 and house[y - 1][x] == 1 and house[y][x + 1] == 1 and house[y][x - 1] == 1):
  77. break
  78.  
  79. print (x)
  80. print (y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement