Domino Covering Board in Python

Suppose we have two numbers n and m representing a board of size n x m. We also have an unlimited number of 1 x 2 dominos. We have to find the maximum number of dominos that can be placed on the board such that they don't overlap and every domino lies completely within the board.

Each domino covers exactly 2 squares, so the maximum number of dominos we can place is limited by the total number of squares divided by 2.

Understanding the Problem

For a board of size n x m:

  • Total squares = n * m
  • Each domino covers 2 squares
  • Maximum dominos = floor(total squares / 2)

Solution Approach

To solve this, we will follow these steps ?

  • Calculate total squares: t := n * m
  • Return quotient of (t / 2) using integer division

Example

Let's implement the solution for a 5 x 3 board ?

class Solution:
    def solve(self, n, m):
        t = n * m
        return t // 2

# Test the solution
ob = Solution()
result = ob.solve(5, 3)
print(f"Board size: 5 x 3")
print(f"Total squares: {5 * 3}")
print(f"Maximum dominos: {result}")
Board size: 5 x 3
Total squares: 15
Maximum dominos: 7

Why This Works

Since each domino covers exactly 2 squares, we can place at most floor(total_squares / 2) dominos. For a 5 x 3 board with 15 squares, we can place at most 7 dominos, leaving 1 square uncovered.

5 x 3 Board (7 Dominos) 1 square remains uncovered

Conclusion

The maximum number of dominos that can be placed on an n x m board is floor((n * m) / 2). This works because each domino covers exactly 2 squares, so we divide the total area by 2.

Updated on: 2026-03-25T10:20:32+05:30

305 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements