{"trustable":false,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003chtml\u003e\n \u003chead\u003e\u003c/head\u003e\n \u003cbody\u003e\n \u003cdiv id\u003d\"problem-body\"\u003e \n \u003cp\u003eAnjali and Nakul are good friends. They both had a quarrel recently while playing chess. Nakul wants to know the minimum number of moves a knight takes to reach from one square to another square of a chess board (8X8). Nakul is brilliant and he had already written a program to solve the problem. Nakul wants to know whether Anjali can do it. Anjali is very weak in programming. Help her to solve the problem.\u003c/p\u003e \n \u003cp\u003eA 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).\u003c/p\u003e\n \n \u003cp\u003e \u003cb\u003e See notes for better understanding \u003c/b\u003e \u003c/p\u003e\n\n \u003ch3\u003eInput\u003c/h3\u003e \n \u003cp\u003eThere are T test cases in total. The next T lines contain two strings (start and destination) separated by a space.\u003c/p\u003e \n \u003cp\u003eThe strings start and destination will only contain two characters - First character is an alphabet between \u0027a\u0027 and \u0027h\u0027 (inclusive), Second character is a digit between \u00271\u0027 and \u00278\u0027 (inclusive) - (Quotes just for clarity).\u003c/p\u003e \n \u003cp\u003eTo know the knight moves more clearly refer to the above figure.\u003c/p\u003e \n \u003ch3\u003eOutput\u003c/h3\u003e \n \u003cp\u003ePrint the minimum number of moves a knight takes to reach from start to destination in a separate line.\u003c/p\u003e \n \u003ch3\u003eConstarints\u003c/h3\u003e \n \u003cp\u003e1 \u0026lt;\u003d T \u0026lt;\u003d 4096\u003c/p\u003e \n \u003ch3\u003eExample\u003c/h3\u003e \n \u003cpre\u003e\u003cstrong\u003eInput:\u003c/strong\u003e\n3\na1 h8\na1 c2\nh8 c3\n\n\u003cstrong\u003eOutput:\u003c/strong\u003e\n6\n1\n4\u003c/pre\u003e \n \u003c/div\u003e\n \u003c/body\u003e\n\u003c/html\u003e"}},{"title":"Notes","value":{"format":"HTML","content":"\u003chtml\u003e\n\u003chead\u003e \u003c/head\u003e\n\u003cbody\u003e\n\n\u003ccenter\u003e \u003ch2\u003e Knight Moves\u003c/h2\u003e \u003c/center\u003e\n\u003cbr\u003e\n\u003ccenter\u003e\n\u003cimg src\u003d\"http://varianceexplained.org/figs/2018-12-10-knight-chess/unnamed-chunk-1-1.png\"/\u003e\n\u003c/center\u003e\n\n\u003cbr\u003e\n\n\u003ccenter\u003e\n\u003ch2\u003e one of the possible moves of the first test case \u003c/h2\u003e\n\u003cbr\u003e\n\u003cimg src\u003d\"https://lh3.googleusercontent.com/B8fm9do3DRm_zQDOzdefFJcRXGmsHL4eXCmedQDP8zkRYS0yThkMFd49ULTZ2prVw_P6Oh1MoFqtr4S3xQLnfo-5CtSVNsjCdUF5Drif_X5xWoRD2nmiX4BC9RdYr__25LMPwO0OhtOlgcUQuF74uS9QogYhPLaZcc8IyhXDwTCzUylPJhDIVyn0t3NWrCNNvnq_llZ_uQqX_WX5hydyTeO77dwHaGLS82ixn0camFZrPeHiQwIxbW12jXSKwqbJr7kvbG24xiGLNK3EIjFXBsGyx9k48g3gcKhMeVqU0dAeAfGsoAGH0VIpfCZgNtabG51HXlZtp_RDI3g7tVz63qGqmE3w2YX6nT5CtUa3Dv2x1--V_BtUKrDRgOXMXIZPRmQxJ6UabbOgeIhfJb7xWqJEJaIwpNiY9sKeSJwhxX8ewo6hsGOLF8zyxxAMfGgI0DZGpg4FG4ag9AiznIpPydQIlCn6__SKayXl0S8LyZ5a1RUgIn-SqDatURAuCmvxyEasd30Thf6XtS-hKF3G9qzfvZ10RWECa3KWsWkSStTbPYsmZhwDPw9-gqRBKKy4I9ChPS1BtP5wBJ4ho9MnQuxFeNgqBLSuuDJSnR4HsOM8umEpEcy3hrbNc0_didSNRFtW3DM8tfcG0yolBB_h9Si9tygrhTUT1_GQFGslBcroQfNDVcALW5tqQksb\u003ds504-no?authuser\u003d0\"\u003e\n\u003c/center\u003e\n\n\u003c/body\u003e\n\u003c/html\u003e"}}]}