Count positions with sum partners

Write codeMedium14 min

Your task

Given a list of integers and a target, count how many positions hold a value that can be matched with some other position so the two values sum exactly to target. Each position is counted at most once, and the partner must be a different position (the same value at another index is allowed). For example, in [3, 7, 3, 1] with target 10, both 3s pair with the 7 and the 7 pairs with a 3, so three positions qualify and the answer is 3; the 1 has no partner. Return the count of qualifying positions.

Examples

partnered_count(nums: list[int], target: int) -> int
Example 1
Inputpartnered_count([3, 7, 3, 1], 10)
Output3