Even sum pairs
Your task
Given a list of integers, count the unordered pairs of positions (i, j) with i < j whose values sum to an even number. Two values sum to an even number exactly when they have the same parity. Aim for a solution that does not compare every pair directly. Example: [1, 2, 3, 4] has 2 such pairs: (1, 3) and (2, 4).
Examples
even_sum_pairs(nums: list[int]) -> intExample 1
Input
even_sum_pairs([1, 2, 3, 4])Output
2