NAKANJC - Minimum knight moves Challenge
Anjali and Nakul are good friends. They had quarrelled and you had written a program for Anjali to know the
minimum number of moves a knight takes to reach from one square to another square of a chess board
Nakul is brilliant and knows Anjali didn't write it herself and says her program is too slow by all standards. He is
unimpressed so she asks you to try solve the problem faster this time using as few keystrokes as possible.
She wants to know whether you can actually do it. Anjali is very weak in programming. Help her to solve the
Since you are busy and tend to forget she reminds you that-
"A knight can move in the shape of an "L" in a chessboard - two squares either forward, backward, left,
or right and then one square to its left or right. A knight move is valid if it moves as mentioned above and
it is within the boundary of the chessboard (8 X 8)."
first solve problem http://www.spoj.com/problems/NAKANJ/
There are T test cases in total. The next T lines contain two strings (start and destination) separated by a
The strings start and destination will only contain two characters - First character is an alphabet between
'a' and 'h' (inclusive), Second character is a digit between '1' and '8' (inclusive) - (Quotes just for clarity).
Print the minimum number of moves a knight takes to reach from start to destination in a separate line.
ExampleInput:EDIT: Time limit increased 28-11-2012. All submissions rejudged3 a1 h8 a1 c2 h8 c3Output:6Score:
4Your source code length (if you are successful in avoiding TLE and WA)The smaller code the better
Cut 4059 B of fully documented wonderfull C++ code to 658 B of unreadable junk. And still did not crack top 100 :(.Last edit: 2018-03-01 06:24:40
C in 365B.
Haskell - 319 BLast edit: 2014-04-13 10:01:23
i would like to congratulate language wise best submissions: