#!/bin/ruby def direct_impossible(i_start, j_start, i_end, j_end) i_diff = (i_start - i_end).abs j_diff = (j_start - j_end).abs flag = false flag = true if i_diff == 1 && j_diff == 1 flag = true if j_diff % 2 == 1 flag = true if i_diff % 2 == 0 && j_diff % 2 == 0 flag = true if i_diff % 2 == 1 && j_diff % 4 == 0 flag end def printShortestPath(n, i_start, j_start, i_end, j_end) # Print the distance along with the sequence of moves. puts "Impossible"# if direct_impossible(i_start, j_start, i_end, j_end) end n = gets.strip.to_i #return if n < 5 || n > 200 i_start, j_start, i_end, j_end = gets.strip.split(' ') #return if i_start < 0 || i_start >= n #return if j_start < 0 || j_start >= n #return if i_end < 0 || i_end >= n #return if j_end < 0 || j_end >= n i_start = i_start.to_i j_start = j_start.to_i i_end = i_end.to_i j_end = j_end.to_i printShortestPath(n, i_start, j_start, i_end, j_end)