Let's define a duke as a chess figure that is only allowed to move 1 cell up, down, left or right.
A duke is placed on an n×n board in the cell initPosition. In this problem, columns are marked 'a', 'b', etc. from left to right, and rows are marked '1', '2', etc. from bottom to top. Cells are notated as "cr" (quotes for clarity), where c is the column and r is the row.
Let's describe a duke's path as a dash-separated list of cells visited by the duke. For example, "c5-b5-b4" is a path consisting of two moves. The first move is one cell to the left (from c5 to b5), and the second is one cell down (from b5 to b4).
A path is called simple if it contains no repeated cells.
Return the lexicographically greatest simple path of a duke starting in initPosition. If the length of the path exceeds 40 characters, return only the first 20 and the last 20 characters, separated by three dots. (See Example #1).
|