Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # python -u "c:\Users\ediso\Documents\Grade 10 Cs\Problems\CrossSpiral.py"
- totalWidth = int(input())
- totalHeight = int(input())
- cutWidth = int(input())
- cutHeight = int(input())
- steps = int(input())
- stepsTaken = 0
- house = [[0 for i in range (totalWidth + 2)]for j in range (totalHeight + 2)]
- x = cutWidth
- y = 1
- dr = "r"
- pr = "r"
- for l in range (totalWidth + 2):
- house[0][l] = 1
- house[totalHeight + 1][l] = 1
- for m in range (totalHeight + 2):
- house[m][0] = 1
- house[m][totalWidth + 1] = 1
- for i in range (1, cutHeight + 1):
- for j in range (1, cutWidth + 1):
- house[i][j] = 1
- for z in range (totalWidth - (cutWidth - 1), totalWidth + 1):
- house[i][z] = 1
- for i in range (totalHeight - (cutHeight - 1), totalHeight + 1):
- for j in range (1, cutWidth + 1):
- house[i][j] = 1
- for z in range (totalWidth - (cutWidth - 1), totalWidth + 1):
- house[i][z] = 1
- while(stepsTaken <= steps):
- if (dr == "r"):
- if (house[y][x + 1] == 0):
- x += 1
- house[y][x] = 1
- stepsTaken += 1
- if (x <= int(totalWidth/2)):
- dr = "l"
- elif (x > int(totalWidth/2)):
- dr = "r"
- elif (house[y][x + 1] == 1):
- dr = "d"
- if (dr == "d"):
- if (house[y + 1][x] == 0):
- y += 1
- house[y][x] = 1
- stepsTaken += 1
- if (x <= int(totalWidth/2)):
- dr = "l"
- elif (x > int(totalWidth/2)):
- dr = "r"
- elif (house[y + 1][x] == 1):
- dr = "l"
- if (dr == "l"):
- if (house[y][x - 1] == 0):
- x -= 1
- house[y][x] = 1
- stepsTaken += 1
- if (x <= int(totalWidth/2)):
- dr = "l"
- elif (x > int(totalWidth/2)):
- dr = "r"
- elif (house[y][x - 1] == 1):
- dr = "u"
- if (dr == "u"):
- if (house[y - 1][x] == 0):
- y -= 1
- house[y][x] = 1
- stepsTaken += 1
- if (x <= int(totalWidth/2)):
- dr = "l"
- elif (x > int(totalWidth/2)):
- dr = "r"
- elif (house[y - 1][x] == 1):
- dr = "r"
- if (house[y + 1][x] == 1 and house[y - 1][x] == 1 and house[y][x + 1] == 1 and house[y][x - 1] == 1):
- break
- print (x)
- print (y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement