Minimum no. of coin flips (switch) needed so that all coins face the same side (Heads or Tails)
Here is a general algorithm. The maximum number of flips needed is $2^{n-1}-1$.

Input: coin 0, coin 1, coin 2, ..., coin $n-1$

Procedure:
$\quad$  If all coins face the same side, return.

$\quad$  For $i$ from 1 to $2^{n-1}-1$ inclusive:
$\quad\quad$  If $i$ is divisible by $2^k$ but not $2^{k+1}$:
$\quad\quad\quad$  Flip coin $k$
$\quad\quad\quad$  If all coins face the same side, return.



For example, if there are no more than 8 coins, then just flip the coins at the following places successively as long as all faces do not face the same side.

0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,
0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0