Description
Waffle Choppers
Design a hardware module that determines if a waffle grid can be cut into equal rectangular pieces with the same number of chocolate chips. Given an R×C grid with chocolate positions, find if horizontal and vertical cuts can create equal portions.
Example: For 2×3 grid with chip pattern [[1,0,1],[0,1,0],[1,0,1]], check if cuts can create equal pieces with same chip count.
Source: Google Code Jam 2018 Round 1A - Problem B: Waffle Choppers
Input
r
32-bit Unsigned IntegerNumber of horizontal cuts.
c
32-bit Unsigned IntegerNumber of vertical cuts.
h
2D Array of 32-bit Unsigned IntegerWaffle grid with chocolate chips.
Output
32-bit Unsigned Integer
1 if waffle can be divided equally, 0 otherwise.