Chessboard

Problem #1

Tags: trainee pretty-print any-lang

Who solved this?

No translations... yet

source: from interview for trainee position and internal courses in Exigen Services (2012)

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     ---
--------------------------
--------------------------
You need to login to get test data and submit solution.