Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def inside_box(pos, k):
- return abs(pos[0] - k) > k and abs(pos[1] - k) > k
- def jopa():
- walks = [
- int(input()),
- int(input()),
- -int(input()),
- -int(input())
- ]
- k = int(input()
- pos = [0, 0]
- walk_counter = 0
- index_govna = 1
- while True:
- for walk in walks:
- pos[index] += walk
- if inside_box(pos, k):
- walk_counter += abs(walk)
- else:
- return walk_counter + abs(walk) - (max(abs(p[0], p[1])) - k)
- index_govna = ~index_govna
- print(jopa())
Advertisement
Add Comment
Please, Sign In to add comment