← all problems

countBlueTiles 🌶️

A gym floor is tiled in rows rows of cols tiles. The rows and columns are numbered from 0, and the tile in row r and column c is painted blue when r + c is even. (So the top-left tile is blue, and the colors alternate like a checkerboard.)

Write a method countBlueTiles that takes rows and cols (both 1 or more) and returns how many tiles are blue.

For example, countBlueTiles(3, 3) is 5.