The jumping knight

You have a n × n board, where each position is permitted or prohibited.
Given the initial position of a knight, you must determine if it is
possible that the knight passes exactly once in each permitted position,
doing the jumps of chess (that is, increasing or decreasing one of the
dimensions in a unit, and the other dimension in two units).

Input

Input consists of a natural 3 ≤ n < 10, followed by n lines with n
characters each one: a ’*’ indicates a prohibited position, a dot
indicates a permitted position. Finally, a pair of integer numbers r and
c between 1 and n indicates the initial row and column of the knight;
the corner on the top and on the left is (1, 1). The initial position of
the knight will never be prohibited.

Output

Your program must print a path of the knight for all the permitted
position following the format of the instances. Notice that each
position for which the knight passes is marked with two digits (being
the first digit a 0 if it is needed), starting in @01@ and increasing.

If there are more than a possible path, choose one of them. If the is
not any possible solution, your program must print "no sol".

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:12:40.726Z

© Jutge.org, 2006–2026.
https://jutge.org
