Domino Covering Board in Python

PythonServer Side ProgrammingProgramming

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.

So, if the input is like n = 5, m = 3, then the output will be 7

To solve this, we will follow these steps −

  • t := n * m
  • return quotient of (t / 2)

Let us see the following implementation to get better understanding −

Example

 Live Demo

class Solution:
   def solve(self, n, m):
      t = n * m
      return t // 2
ob = Solution()
print(ob.solve(5,3))

Input

5,3

Output

7
raja
Published on 22-Sep-2020 14:56:13
Advertisements