lynulx

Untitled

Dec 19th, 2021
916
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. def inside_box(pos, k):
  2.     return abs(pos[0] - k) > k and abs(pos[1] - k) > k
  3.  
  4. def jopa():
  5.     walks = [
  6.         int(input()),
  7.         int(input()),
  8.         -int(input()),
  9.         -int(input())
  10.     ]
  11.     k = int(input()
  12.    
  13.     pos = [0, 0]
  14.     walk_counter = 0
  15.     index_govna = 1
  16.     while True:
  17.         for walk in walks:
  18.             pos[index] += walk
  19.             if inside_box(pos, k):
  20.                 walk_counter += abs(walk)
  21.             else:
  22.                 return walk_counter + abs(walk) - (max(abs(p[0], p[1])) - k)
  23.             index_govna = ~index_govna
  24. print(jopa())
Advertisement
Add Comment
Please, Sign In to add comment