Faceting a Categorical Plot by a Third Variable
The Ravensworth Group now reports by region as well as by team, and one chart holding every region at once has become a thicket. The new layout gives each region its own small panel, all sharing one scale so the panels can be read against each other. The page has to be sized before the chart is built, which means knowing the panel count.
Task: Print how many different regions appear.
Input
The first line holds one integer n, the number of records, where 1 <= n <= 1000. Then come n lines, each holding a region name, a team label and a score, separated by single spaces. Names and labels contain no spaces, and a region may appear on any number of lines.
Output
One line holding a whole number: how many distinct region names there are. A region filing twenty records still gets one panel, and counts once.
Example:
Input:
4
East A 10
West A 20
East B 15
North A 5
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