#C12886. Unique Pairs Sum Finder
Unique Pairs Sum Finder
Unique Pairs Sum Finder
You are given a list of integers and a target integer. Your task is to find all unique pairs of integers from the list such that the sum of the pair equals the target value. Each pair should appear only once, and the pair should be represented in the form (a, b) where a is less than or equal to b.
The solution should output the list of pairs sorted in ascending order first by the first element and then by the second element. Use the following mathematical representation for the problem:
\( \text{Find all } (a,b) \text{ such that } a + b = T \text{ and } a \leq b \)
If no such pair exists, output an empty list.
inputFormat
Input:
- The first line contains a list of integers separated by spaces.
- The second line contains a single integer, the target sum.
outputFormat
Output:
A list of tuples representing unique pairs whose sum equals the target. The output should be in the format of a Python-style list of tuples, e.g. [(1, 4), (2, 3)]
. If no pair exists, output []
.
1 2 3 4 3 2
5
[(1, 4), (2, 3)]