# Program to find out number of blocks that can be covered in Python

PythonServer Side ProgrammingProgramming

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### Practical Machine Learning using Python

Best Seller

91 Lectures 23.5 hours

#### Practical Data Science using Python

22 Lectures 6 hours

Suppose there are n blocks in a path, and a worker is putting colored tiles on the blocks. The worker is putting blocks in a way, such that if a block number in the path is divisible by 4 or/and 2 but not 42, he puts a colored tile there. We have to find out the number of blocks he can cover if he has started with k number of colored tiles.

So, if the input is like k = 16, then the output will be 32.

To solve this, we will follow these steps −

• MOD = 10^9 + 7
• quotient := floor value of (k / 20)
• remainder := k mod 20
• if remainder is same as 0, then
• return((42 * quotient - 2) mod MOD)
• otherwise,
• return((42 * quotient + 2 * remainder) mod MOD)

## Example

Let us see the following implementation to get better understanding −

def solve(k):
MOD = 10**9 + 7
quotient = k // 20
remainder = k % 20
if remainder == 0:
return ((42 * quotient - 2) % MOD)
else:
return ((42 * quotient + 2 * remainder) % MOD)

print(solve(16))

## Input

16


## Output

32
Updated on 23-Oct-2021 07:55:05