Problem #502
✰ - click to bookmark
★ - in your bookmarks
Tags:
implementation
pretty-print
This problem was initially posted at our side-project ca4pro but now is transferred here. Please tell admin if you need your solution from
there to be migrated.
Not 100% sure, but probably this simple exercise was proposed by my first school programming teacher Sergey Stolyar for kids of age about 12-13. Later I encountered it in similar form at some junior grade interview at the company long ceased to exist :)
The task is to print a chessboard, given the following parameters: cell_width, cell_height, board_size, border_h, border_v.
The first two give the cell (square) size in characters, next comes board size (in squares) and at last width and height of border, surrounding the board. Regard the example below.
"Black" squares are to be filled with "X" characters, "White" with " " (space). And border should be filled with - (simple dash).
Note that lower left corner is always black.
First time here? Write some code to solve the problem - particularly, to produce the desired output. Put both your code and
your output to the areas below. For problems marked with any-lang only the answer is actually checked, while code is stored for your
convenience. On pressing Submit the site will verify your output and tell if anything is wrong or all is OK. Good luck!
Input:
5 3 4 3 2
Output:
--------------------------
--------------------------
--- XXXXX XXXXX---
--- XXXXX XXXXX---
--- XXXXX XXXXX---
---XXXXX XXXXX ---
---XXXXX XXXXX ---
---XXXXX XXXXX ---
--- XXXXX XXXXX---
--- XXXXX XXXXX---
--- XXXXX XXXXX---
---XXXXX XXXXX ---
---XXXXX XXXXX ---
---XXXXX XXXXX ---
--------------------------
--------------------------