0

how's it going?

I'm now working on Tideman but I'm now having a hard time why my code does not satisfy all the condition, only the first one:

:) lock_pairs locks all pairs when no cycles

These two aren't satisfied:

:( 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

I've seen people using recursion to solve this particular function (a concept that I'm still trying to internalize) but I'd like to know whether I'm potentially missing something (I'll be happy if you could help me see the missing piece(s)) and also potential enhancements (am I writing unnecessary lines of code)?

Here's my lock_pairs function:

void lock_pairs(void)
{
    for (int i = 0; i < pair_count; i++)
    {
        if (i == (pair_count - 1))
        {
            if(pairs[i].loser == pairs[i - 1].winner)
                continue;
            else
                locked[pairs[i].winner][pairs[i].loser] = true;
        }
        else
            locked[pairs[i].winner][pairs[i].loser] = true;
    }
    return;
}

I appreciate your support!

You must log in to answer this question.

Browse other questions tagged .