I tried to solve this problem. But may be not getting it right... I believe my algo is very close to correcrt.. Any suggestion would be highly appreciated...
This is what i did.
//mapped all the 12 sticks to bit of mask
//ith bit in mask represents the stick is not removed if 0 , and removed if 1
bool iswin(mask,mouse,cheese)
{
// checked weather the mouse is reachable to cheese in present mask condition using dfs
if(reachable)
return false..
flag = 0;
for(i=0;i<12;i++)
{
if(!(mask&(1<<i))) // checked if the ith stick is already removed or not... if not it goes to next step..
{
if(!iswin(mask|(1<<i))) // checks is it a loosing position if ith stick is removed by the player..
{
flag=1; // if he gets a reachable loosing position ...he is in winning position for sure....
break;
}
}
}
return flag;
}
if SOHA is in winning position he is the winner else it is TARA