# pset3 tideman; can't pass check50 “lock_pairs skips final pair if it creates cycle”

I'm kind of confused about what the last pairs should be if it creates cycle. Like, if a->b, b->c, and the last pair is c->a, should I just skip it or turn it around, make it a->c?

I tried both idea, but neither of them worked, check50 still can't pass "lock_pairs skips final pair if it creates cycle". And here's my code, I'll really appreciate it if somebody can help me. :)

``````void lock_pairs(void)
{
for (int k=0; k<pair_count; k++)
{

//locked2 is same as locked. If a->b, b->c, then lock a->c in locked2.
//To avoid cycle: whether the current arrow is the opposite of previous arrow.
if (!locked2[pairs[k].loser][pairs[k].winner])
{
locked[pairs[k].winner][pairs[k].loser]=true;
locked2[pairs[k].winner][pairs[k].loser]=true;

//In locked2, extend all the arrow with the same direction. If a->b, b->c, then lock a->c in locked2.
for (int i=0; i<candidate_count; i++)
{
for (int j=0; j<candidate_count; j++)
{
if (locked[i][j])
{
if (j==pairs[k].winner)
{
locked2[i][pairs[k].loser]=true;
} else if (i==pairs[k].loser)
{
locked2[pairs[k].winner][j]=true;
}
}
}
}
}
}

return;
}
``````