Question: Write a function that returns a chessboard pattern (B for black squares, W for white squares). The function takes a number N as input


Write a function that returns a chessboard pattern ("B" for black squares, 

Write a function that returns a chessboard pattern ("B" for black squares, "W" for white squares). The function takes a number N as input and generates the corresponding board. Input The first line of the input consists of an integer - num, representing the size of the chessboard(N). Output Print N lines consist of N space- separated characters representing the chessboard pattern. Constraints 0 < N Example Input: 5 Output: WBWBW BWBWB WBWBW BWBWB WBWBW Explanation: The size of the chessboard is 5 and the top left square will always be white. So, the output pattern is: [[WBWBW], [BW BW B], [WBWBW], [BW BW B], [WBWBW]]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!