Problem 145697 · easy · Phase 01 Prerequisites & Setup

Checkerboard Grid

nested loops · strings · conditionals

Draw a checkerboard with rows rows and cols columns. Return a list of strings, one per row. The top-left cell is #, and the pattern alternates between # and . both along each row and down each column, exactly like the squares of a chessboard.

Examples

Input:  rows = 2, cols = 3
Output: ["#.#", ".#."]

Input:  rows = 1, cols = 1
Output: ["#"]

Constraints

  • 0 <= rows, cols <= 40
  • If rows is 0 return []; if cols is 0 return rows empty strings.

Goals

  • Use two nested loops to visit every cell of a grid
  • Decide a cell's character from its row and column
Starting Python…