Loading...
Loading...
Loading...
Two lists hold the ids of customers who bought a phone and who bought a case. Find who bought both, who bought only the phone, and who bought only the case.
Ids are compared and sorted as text.
Both: ..., Only phone: ... and Only case: .... Each list is sorted and separated by spaces. Print a single - when a list is empty.Example
Input
C1 C2 C3 C4 C3 C4 C5
Output
Both: C3 C4 Only phone: C1 C2 Only case: C5
C3 and C4 bought both.
Try the problem first. Open one hint at a time.
These three groups come from the intersection and the two differences of the sets.
Use &, then phone - case, then case - phone. Sort each, and print a dash for an empty one.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor