#!/bin/ruby def printShortestPath(n, i_start, j_start, i_end, j_end) # Print the distance along with the sequence of moves. i_diff = (i_start.to_i - i_end.to_i).abs j_diff = (j_start.to_i - j_end.to_i).abs if i_diff % 2 != 0 || (i_diff % 4 == 0 && j_diff % 2 == 0) || (i_diff %2 != 4 && j_diff % 2 != 0) puts "Impossible" else if i_start == i_end x = j_diff/2 for i in [1..x] puts (j_start.to_i < j_end.to_i) ? "R" : "L" end end end end n = gets.strip.to_i i_start, j_start, i_end, j_end = gets.strip.split(' ') 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)