Combining hue AND style for Two Categories
Fernbrook Analytics has a panel encoding two things at once: colour for the region and marker shape for the customer tier. Every combination that actually occurs needs its own colour-and-shape pairing in the legend, and legends get unusable fast. So before the panel is built, the tool reports how many pairings the data really produces — which is usually fewer than the arithmetic suggests, because not every tier trades in every region.
Task: Print how many region-and-tier pairings actually occur.
Input
The first line holds one integer n, the number of records. Each of the next n lines holds two measurements, a region name and a tier name, separated by single spaces. Names contain no spaces.
Output
One line holding a single whole number: how many different region-and-tier pairings appear across the records. A pairing counts once however many records carry it, and a pairing that never occurs is not counted at all.
Example:
Input:
4
1 1 East Gold
2 2 East Silver
3 3 West Gold
4 4 East Gold
Output:
3
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in