Given two different positions on a chess board and the type of piece, output the minimum number of moves it will take for that piece to go from one position to another.
The given piece can be King,Queen,Rook,Knight and Bishop. (This input can be taken as any 5 unique characters)
The 2 positions can be taken in any convenient format,
Example: a8 b8 c8 d8 ... h8 a7 b7 c7 d7 ... h7 ... ... a1 b1 c1 d1 ... h1
In case the piece cannot reach there, output anything other than a positive integer.
i/p ---- o/p King a1,a4 3 a1,h6 7 b3,h5 6 Queen a1,a4 1 a1,h6 2 b3,f7 1 Rook a1,a4 1 a1,h6 2 h2,c7 2 Knight a1,a4 3 a1,h6 4 b2,d3 1 b2,c3 2 b3,c3 3 a1,b2 4 Bishop a1,a4 -1 a1,h6 2 b2,d3 -1 e1,h4 1