Chess Board Rendering


Submit solution

Points: 1
Time limit: 2.0s
Memory limit: 1G

Author:
Problem type

Alexei was a child chess prodigy who has become distracted in their teen years by the dreaded computer. Without access to the Internet, however, Alexei wants to play chess with the computer, the first step is to render boards to his screen.

Given the description of \(N\) chess pieces on a standard chessboard including their type and location, print out a basic visualisation of the chessboard. There is no need to consider whether the described chess board is accurate, nor is there any need to consider the colour of any pieces, Alexei just wants to see what type and where the pieces are placed.

Input Specification

The input will be a single line of comma-separated entries. Each entry describes the type and position of a chess piece on a standard \(8\times 8\) chessboard.

We borrow the standard Portable Game Notation (PGN) standard but simplify it for this problem:

  • Positions are specified by [Type][Column][Row]
  • Type can be one of
    • K - King
    • Q - Queen
    • R - Rook (castle)
    • B - Bishop
    • N - Knight (I hate it too)
    • - Pawns are blank
  • Column is a lowercase letter [a-h]
  • Row is a number from [1-8]

Columns begin from the left of the board, rows begin from the bottom.

  • a1 would indicate a pawn in the bottom left corner
  • Qd6 describes a queen in the fourth column from the left and third row from the top (sixth from the bottom)

Pieces are not guaranteed to appear in any order

Output Specification

Alexei wants ASCII art-ish pictures of the chessboard. Print \(8\) rows of \(8\) columns, separated as pairs of | characters.

If a piece occupies a particular cell, the cell should contain its [Type] specifier or a * in the case of a pawn. If a cell is unoccupied, it should contain a single space .

Bounds

All test cases assume a standard \(8\times 8\) board.

\(1 \leq N \leq 64\)

Sample Input 1

d4,e6,Ra1

Sample Output 1

| | | | | | | | |
| | | | | | | | |
| | | | |*| | | |
| | | | | | | | |
| | | |*| | | | |
| | | | | | | | |
| | | | | | | | |
|R| | | | | | | |

Sample Input 2

Ra1,Nb1,Bc1,Qd1,Ke1,Bf1,Ng1,Rh1,Ra8,Nb8,Bc8,Qd8,Ke8,Bf8,Ng8,Rh8,a2,b2,c2,d2,e2,f2,g2,h2,a7,b7,c7,d7,e7,f7,g7,h7

Sample Output 2

|R|N|B|Q|K|B|N|R|
|*|*|*|*|*|*|*|*|
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
|*|*|*|*|*|*|*|*|
|R|N|B|Q|K|B|N|R|

Comments

There are no comments at the moment.