SP8594 TAILS - Tails all the way
Description
John and James planned to play a game with coins. John has 20 coins and he places it on the table in a random manner(i.e either with heads(1) or tails(0) facing up). John asked james to convert all heads into tails in minimum number of flips with the condition that if a coin is flipped the coins present to the right and left of the chosen coin should also be flipped.
Input Format
A single line with 20 space-separated integers
Output Format
The minimum number of coin flips necessary to convert all heads into tails (i.e., to 0). For the inputs given, it will always be possible to find some combination of flips that will manipulate the coins to 20 tails.