def count_bidirectional(ls):
    count = 0
    seen = set()
    for pair in ls:
        reversed_pair = (pair[1], pair[0])
        if reversed_pair in seen:
            count += 1
            seen.remove(reversed_pair)
        else:
            seen.add(pair)
    return str(count)

why this solution is right but didnt pass the uts?
  "test_list": [
    "assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)] ) == '3'",
    "assert count_bidirectional([(5, 6), (1, 3), (6, 5), (9, 1), (6, 5), (2, 1)] ) == '2'",
    "assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 2), (6, 5), (2, 1)] ) == '4'"
  ],


ChatGPT said:
You're asking the right question — and your function is correct, but the unit tests are wrong.

✅ Your Function:
python
Copy
Edit
def count_bidirectional(ls):
    count = 0
    seen = set()
    for pair in ls:
        reversed_pair = (pair[1], pair[0])
        if reversed_pair in seen:
            count += 1
            seen.remove(reversed_pair)
        else:
            seen.add(pair)
    return str(count)
✔️ What it does:
Counts each unique bidirectional pair exactly once.

Skips duplicates or repeated pairings.

Returns the count as a string, which matches the test type.

❌ Why the Test Cases Fail
Let’s break down each test:
🧪 Test 1:
python
Copy
Edit
assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)]) == '3'
Analysis:
(5, 6) + (6, 5) → ✅ 1 pair

(1, 2) + (2, 1) → ✅ 1 pair

(6, 5) again → already matched

(9, 1) → no (1, 9) in list

✅ Correct bidirectional pairs: 2
❌ Test expects '3' → Wrong

🧪 Test 2:
python
Copy
Edit
assert count_bidirectional([(5, 6), (1, 3), (6, 5), (9, 1), (6, 5), (2, 1)]) == '2'
(5, 6) + (6, 5) → ✅ 1 pair

(1, 3) → no reverse

(2, 1) → no (1, 2)
✅ Only 1 bidirectional pair
❌ Test expects '2' → Wrong

🧪 Test 3:
python
Copy
Edit
assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 2), (6, 5), (2, 1)]) == '4'
(5, 6) + (6, 5) → ✅ 1 pair

(1, 2) + (2, 1) → ✅ 1 pair

(9, 2) → no reverse
✅ Only 2 bidirectional pairs
❌ Test expects '4' → Wrong

✅ Corrected Tests
python
Copy
Edit
assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)]) == '2'
assert count_bidirectional([(5, 6), (1, 3), (6, 5), (9, 1), (6, 5), (2, 1)]) == '1'
assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 2), (6, 5), (2, 1)]) == '2'
✅ Summary
Issue	Status
Your function	✅ Correct
Unit tests	❌ Incorrect — they overcount
Why?	They assume repeated tuples count as more than 1 pair
Fix?	Update expected values in the tests

