[Community Puzzle] Where Was This Knight Before? - Puzzle discussion

I have to mention one issue (and solution!) with the board notation that is bugging me. The board square notation is backwards.

The game states:

  • Line 1 : A string pieces containing the uppercase letters (A-Z) that represent the white pieces. (The corresponding lowercase letters represent the black pieces.)
  • Each coordinate is made of one lowercase letter (from a to h for the horizontal position on the board, from left to right) and one digit (from 1 to 8 for the vertical position, from bottom to top), the top left square being a8.

This notation stating that the top left square is a8 is correct from white’s perspective on a standard board.

However, the first test case flips the board, and white (uppercase) is on top. This means we are looking at the board from black’s perspective.

RNBQKBNR
PPPPPPPP
........
........
........
........
pppppppp
rnbqkbnr

The board is laid out wrong (the king and queen are in the incorrect places), and the square at the top left is actually h1. The board is rotated 180 degrees because that is the side the white pieces are on.

That also means that the solution is incorrect.

RNBQKBNR
PPPPPPPP
........
........
........
....p...
pppp.ppp
rnbqkbnr

The solution should be d7-d6, not e2-e3.

But, black should never move first anyways. So, in a proper chess sense, d7-d6 wouldn’t make sense as a first move.

I get it. This is a coding challenge, not a chess challenge. The coding solution to the problem is not affected by chess rules. But, I feel like since you are using chess notation as the basis for the rules of the game, you should follow proper chess rules.

Fortunately there is a very easy solution. Just switch the description of the problem so that white pieces are designated by the lowercase letters, and black pieces by the uppercase letters. That would flip the board into the correct notation, and correct the starting piece layout, without needing to make any other changes.

2 Likes