Description
Oversized Pancake Flipper
Design a hardware module that uses a spatula of size K to flip consecutive pancakes in a row. Each flip toggles K consecutive pancakes from plus to minus or vice versa. Determine if it is possible to make all pancakes plus and count the minimum flips needed.
Example: For "---+-++-" with K=3, flip positions to make all plus. Output number of flips or indicate impossible.
Source: Google Code Jam 2017 Qualification Round - Problem A: Oversized Pancake Flipper
Input
pancakes
Stream of Boolean (1-bit)Pancake row: 0=minus, 1=plus.
k
8-bit Unsigned IntegerFlipper size (1-50).
Output
16-bit Unsigned Integer
Min flips needed or 0xFFFF if impossible.