- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Check if any square (with one colored cell) can be divided into two equal parts in Python

Suppose, we are provided with a square that is a size of n. The n sized square is further divided into n2 smaller squares. The smaller squares are of unit size and one of the squares is colored with a unique color.

Now if we cut the bigger square into two equal parts, we have to cut it in such a way so that the cutting line does not have any points in common with that uniquely colored small square. We have to also consider the fact that the newly cut two pieces are mirror images of one another. So, we have to find out if cutting a square like that is possible given the conditions. We have the value of n and the position of the colored square in the bigger square.

So, if the input is like size = 50, colored_row_pos = 25, colored_col_pos = 25, then the output will be "Cutting is not possible."

To solve this, we will follow these steps −

- middle := floor value of size /2
- if (middle is same as colored_row_pos or middle is same as colored_row_pos - 1) and (middle is same as colored_col_pos or middle is same as colored_col_pos - 1) , then
- return False

- otherwise,
- return True

Let us see the following implementation to get better understanding −

## Example

def solve(size, colored_row_pos, colored_col_pos) : middle = size // 2 if (middle == colored_row_pos or middle == colored_row_pos - 1) and (middle == colored_col_pos or middle == colored_col_pos - 1) : print("Cutting is not possible") else : print("Cutting is possible") size = 50 colored_row_pos, colored_col_pos = 25, 25 solve(size, colored_row_pos, colored_col_pos)

## Input

50, 25, 25

## Output

Cutting is not possible

- Related Questions & Answers
- Check if an array of 1s and 2s can be divided into 2 parts with equal sum in Python
- Find if array can be divided into two subarrays of equal sum in C++
- Check if a large number can be divided into two or more segments of equal sum in C++
- Can array be divided into n partitions with equal sums in JavaScript
- Check if array can be divided into two sub-arrays such that their absolute difference is Ks in Python
- Check if a line at 45 degree can divide the plane into two equal weight parts in C++
- Check if array can be sorted with one swap in Python
- Check if an array can be divided into pairs whose sum is divisible by k in Python
- Partition Array Into Three Parts With Equal Sum in Python
- Minimum Cuts can be made in the Chessboard such that it is not divided into 2 parts in Python
- Find the sums for which an array can be divided into subarrays of equal sum in Python
- Split string into equal parts JavaScript
- Check if a sorted array can be divided in pairs whose sum is k in Python
- Minimum Cuts can be made in the Chessboard such that it is not divided into 2 parts in C++
- Python Pandas – Check if any specific column of two DataFrames are equal or not