128. Python Program to Count Different Points Using a Set of Tuples
MediumWhich one?
Overview
A point is two fixed numbers: a tuple. A set of tuples drops the repeated points.
Problem Statement
Read lines until the user types done. Each line is a point: two whole numbers x and y, separated by a space, like 1 2. Store every point as a tuple in a list.
Then print how many points were typed, how many different points there are, and every different point on its own line, sorted (sorted() sorts tuples by the first number, then by the second). For example:
Points: 4
Different points: 3
(0, 0)
(1, 2)
(3, 4)
The first line is never done.
Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.
Input
One point per line; the last line is always done. Example:
1 2
3 4
1 2
0 0
done
Output
The output for that example:
Points: 4
Different points: 3
(0, 0)
(1, 2)
(3, 4)
The tests try 3 different inputs.