#!/bin/python import sys def printShortestPath(n, i_start, j_start, i_end, j_end): # Print the distance along with the sequence of moves. # (i,j) indicate the current position of the knight i = i_start j = j_start # the flag variables ensure that once the knight goes up(down) it should not make any move down(up) gone_up = 0 gone_down = 0 # PATH array stores the priority number of the moves of the knight and path is the dictionary for decoding # the priorities to associated move name PATH = [] path = {1:'UL',2:'UR',3:'R',4:'LR',5:'LL',6:'L'} # move the knight only as long as it does not jump out of the board or does not reach its destination or makes an # invalid move as defined by the flag variables while((0<=i=j and not gone_down): gone_up = 1 i = i - 2 j = j + 1 PATH.append(2) # Dest is R to current pos elif(i_end==i and j_end>j): gone_up = 1 gone_down = 1 j = j + 2 PATH.append(3) # Dest is LR (including Down) to current pos elif(i_end>i and j_end>=j and not gone_up): gone_down = 1 i = i + 2 j = j + 1 PATH.append(4) # Dest is LL to current pos elif(i_end>i and j_end