06. Summation Pairs
Здравейте колеги, на тази задача не можах да рабера какво точно се очва от мен или греша в решението. Някой може ли да ми даде насоки?
1.Summation Pairs
On the first line, you will receive a string of numbers separated by space. On the second line, you'll receive a target number. Your task is to find all pairs of numbers whose sum equals the target number.
For each found pair print "{number} + {number} = {target_number}".
Then, save only the unique pairs. Note: (1, 2) and (2, 1) are unique.
Also, you should keep track of how many iterations you've done.
At the end print all the iterations done in format: "Iterations done: {total_number_of_iterations}".
On the following lines, print the unique pairs in the format: "(first_number, second_number)".
The order in which we print the result does not matter.
Examples
Input |
Output |
1 5 4 2 2 3 1 3 2 4 |
1 + 3 = 4 1 + 3 = 4 2 + 2 = 4 2 + 2 = 4 2 + 2 = 4 3 + 1 = 4 1 + 3 = 4 Iterations done: 36 (3, 1) (1, 3) (2, 2) |
11 8 5 6 9 2 9 7 3 4 11 |
8 + 3 = 11 5 + 6 = 11 9 + 2 = 11 2 + 9 = 11 7 + 4 = 11 Iterations done: 45 (7, 4) (9, 2) (2, 9) (8, 3) (5, 6) |
Моя код с решението е този. Но не ми илизат добре изходите
https://pastebin.com/0umF9RmP