Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def def_color(x, y):
- return 1 if (x + y) % 2 == 0 else 0
- def get_direction(cur_coords, target_coords):
- x_dir = 0
- y_dir = 0
- x_s, y_s = cur_coords
- x_f, y_f = target_coords
- if x_f - x_s >= 0:
- x_dir = 1
- else:
- x_dir = 0
- if y_f - y_s >= 0:
- y_dir = 1
- else:
- y_dir = 0
- return (x_dir, y_dir)
- def make_step(coords, direction):
- x, y = coords
- if sum(direction) == 2:
- return (x + 1, y + 1)
- elif sum(direction) == 0:
- return (x - 1, y - 1)
- else:
- if direction[0] == 0:
- if direction[1] == 1:
- return (x - 1, y + 1)
- else:
- return (x + 1, y - 1)
- def main():
- start_x = int(input())
- start_y = int(input())
- target_x = int(input())
- target_y = int(input())
- finish_coords = (target_x, target_y)
- step_hist = [[start_x, start_y]]
- if def_color(start_x, start_y) != def_color(target_x, target_y):
- print("No")
- return
- while True:
- direction = get_direction(step_hist[-1], finish_coords)
- step_hist.append(make_step(step_hist[-1], direction))
- if step_hist[-1] == finish_coords:
- break
- print("Yes")
- step_hist.pop(0)
- print(len(step_hist))
- for x, y in step_hist:
- print(x, y)
- return
- main()
Advertisement
Add Comment
Please, Sign In to add comment