0 out of 464 challenges solved

Count Pairs with Sum

Write a Python function `get_pairs_count(arr, target_sum)` that takes a list of integers `arr` and an integer `target_sum` as input. The function should return the number of unique pairs `(a, b)` in the list such that `a + b == target_sum`. Each pair should be counted only once, and the order of elements in the pair does not matter.

#### Example Usage
```python [main.nopy]
get_pairs_count([1, 1, 1, 1], 2)  # Output: 6
get_pairs_count([1, 5, 7, -1, 5], 6)  # Output: 3
get_pairs_count([1, -2, 3], 1)  # Output: 1
get_pairs_count([-1, -2, 3], -3)  # Output: 1
```

#### Constraints
- The input list can contain both positive and negative integers.
- The input list may contain duplicate values.
- The function should handle an empty list gracefully by returning `0`.
def get_pairs_count(arr, target_sum):
    """
    Count the number of unique pairs in the list whose sum equals the target_sum.

    Args:
    arr (list): List of integers.
    target_sum (int): The target sum for the pairs.

    Returns:
    int: The number of pairs whose sum equals target_sum.
    """
    # Initialize a counter for the pairs
    count = 0
    # Placeholder for the solution
    return count