# Lock pairs and Recursivity

I've been trying to solve this pset since more than a month and don't want to give up... so this is the first time I'm coming to ask for help.

Basically I separated in two parts the lock_pairs function:

``````
void lock_pairs(void)
{
for (int i = 0; i < MAX * (MAX - 1) / 2 ; i ++)
{
locked[pairs[i].winner][pairs[i].loser] = true;
if(iscycle(pairs[i].winner, pairs[i].loser))
{
locked[pairs[i].winner][pairs[i].loser] = false;
}
}
return;
}
``````

where `MAX * (MAX - 1) / 2` is max the number of pairs and then I created this iscycle function to recursively try to check if there is any cycle with any node

``````bool iscycle(int winner, int loser)
{
if (locked[loser][winner] == true)
{
return true;
}
for (int  i = 0 ; i < candidate_count  ; i++)
{
if (locked[i][winner] == true)
{
if (iscycle(i,loser))
return true;
}
else
{
return false;
}
}
return false;
}
``````

I still got the error:

``````:( lock_pairs skips final pair if it creates cycle
lock_pairs did not correctly lock all non-cyclical pairs
:( lock_pairs skips middle pair if it creates a cycle
lock_pairs did not correctly lock all non-cyclical pairs
``````

Your help is very much appreciated!