Data Visualization: Choose a chart from data types

Dashboard tools suggest a chart from the types of the fields you drag in. Write that suggestion logic.

What to build

A program that suggests a chart from the types of two fields.

Requirements

  • Each line holds the x type, the y type (each category, number, time or none) and the number of categories.
  • Rules, first match wins: time and number → line chart; category and number → bar chart if there are at most 7 categories, else horizontal bar chart, sorted; number and number → scatter plot; number and none → histogram; category and none → bar chart of counts; anything else → table.
  • Print X + Y -> CHART.

Input

Line 1: n. Then n lines X Y CATEGORIES.

Output

n lines.

Constraints

1 ≤ n ≤ 50; 0 ≤ categories ≤ 1000.

Example

Input:

4
time number 0
category number 5
category number 12
number number 0

Output:

time + number -> line chart
category + number -> bar chart
category + number -> horizontal bar chart, sorted
number + number -> scatter plot

Why it works

Data types narrow the choice: time wants a line, two measures want a scatter plot, and many categories need horizontal, sorted bars to stay readable.

Examples

Example 1 · Input
4
time number 0
category number 5
category number 12
number number 0
Expected output
time + number -> line chart
category + number -> bar chart
category + number -> horizontal bar chart, sorted
number + number -> scatter plot
Example 2 · Input
3
number none 0
category none 4
time time 0
Expected output
number + none -> histogram
category + none -> bar chart of counts
time + time -> table

Prompts inside input() are ignored when checking, so input("n: ") is fine.

Hints

Hint 1

Check the rules in the given order; the first that matches decides.

Hint 2

The number of categories matters only for a category against a number.

Solution

Show one correct solution (try it yourself first)
def suggest(x, y, categories):
    if x == "time" and y == "number":
        return "line chart"
    if x == "category" and y == "number":
        return "bar chart" if categories <= 7 else "horizontal bar chart, sorted"
    if x == "number" and y == "number":
        return "scatter plot"
    if x == "number" and y == "none":
        return "histogram"
    if x == "category" and y == "none":
        return "bar chart of counts"
    return "table"


n = int(input())
for _ in range(n):
    x, y, count = input().split()
    print(f"{x} + {y} -> {suggest(x, y, int(count))}")

Lesson: Choosing the right chart →