# Minimum number of switches to align all the clocks at 12

Recently I have asked to solve one problem in interview , the problem is like below .

You have given with a 16 clocks .. all are at different 4 posistions , 12,3,6,9 ..

like below.

int clock[16] ={12, 9, 3, 12 ,6, 6 ,9 ,3 ,12, 9, 12, 9 ,12 ,12, 6 ,6};

And given with a different switchLine .

# define max_switch 10

{
{0,1,2,-1,-1},
{3,7,9,11,-1},
{4,10,14,15,-1},
{0,4,5,6,7},
{6,7,8,10,12},
{0,2,14,15,-1},
{3,14,15,-1,-1},
{4,5,7,14,15},
{1,2,3,4,5},
{3,4,5,9,13}
};

the Goal is using the above swicthes we have to make all clocks aligned to 12

int clock[16] ={12, 9, 3, 12 ,6, 6 ,9 ,3 ,12, 9, 12, 9 ,12 ,12, 6 ,6};

to

int clock[16] ={12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12};

The conditions are below

1. Each switch represents the Clock position, -1 represents no clock position
2. can apply any switchs, any number of times
3. When you Apply a switch, corresponding clock will move by 3, for example 9->12,3->6,6->9,12->3 .

example :

will change the above clock to {3, 12, 6, 12 ,6, 6 ,9 ,3 ,12, 9, 12, 9 ,12 ,12, 6 ,6};

Need to find out the  minimum number of swicthlink required to align the clock at 12...?

I could not solve the problem .. time given was 1 hour ..

Any logics to know the solution ...