#!/bin/python import sys #UL, UR, R, LR, LL, L def printShortestPath(n, i_start, j_start, i_end, j_end): # Print the distance along with the sequence of moves. if (i_start-i_end)%2!=0: print "Impossible" return elif ((i_start-i_end)%4==2 and (j_start-j_end)%2==0): print "Impossible" return elif (i_start-i_end)%4==0 and (j_start-j_end)%2==1: print "Impossible" return else: count=0 path="" if abs(i_end-i_start)>2*abs(j_end-j_start): if i_start>i_end: while abs(i_end-i_start)>2*abs(j_end-j_start): count+=1 path+="UL " i_start-=2 j_start-=1 elif i_start2*abs(j_end-j_start): count+=1 path+="LR " i_start+=2 j_start+=1 if i_start=i_end: if j_start