- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions

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

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

- Related Articles
- C++ program to find out the number of coordinate pairs that can be made
- C++ program to find out the maximum number of cells that can be illuminated
- Problem to Find Out the Maximum Number of Coins that Can be Collected in Python
- Python Program to find out the number of rooms in which a prize can be hidden
- Program to find minimum distance that needs to be covered to meet all person in Python
- Program to count how many blocks are covered k times by walking in Python
- Program to find out how many transfer requests can be satisfied in Python
- C++ Program to find out the number of unique matrices that can be generated by swapping rows and columns
- Program to find out the number of boxes to be put into the godown in Python
- Program to Find Out the Number of Corrections to be Done to Fix an Equation in Python
- Program to find out the number of accepted invitations in Python
- Program to find number of tasks can be finished with given conditions in Python
- C++ program to find out the number of ways a grid with boards can be colored
- Program to find out how many boxes can be put into the godown in Python
- Program to find maximum number of package that can be bought by buyers in C++

Advertisements