Figure 1. A flip and a shift
The goal of this puzzle is to gather the disks of the same color in adjacent positions using flips and shifts. (Figure 2)Figure 2. A goal sequence
You are to write a program which decides whether a given sequence can reach a goal or not. If a goal is reachable, then write a message “YES”; otherwise, write a message “NO”.2
18 0 0 1 0 1 1 1 1 0 1 0 0 1 0 0 0 0 1
14 1 1 0 0 1 1 1 0 0 1 1 0 1 0
YES
NO