Small multiples need a shared scale. Convert several series to bar heights from 0 to 10 using one maximum for all of them.
What to build
A program that scales several series to a shared 0–10 range.
Requirements
- Print
axis 0 to M, with M the largest value of all series in:gformat. - Then print
NAME: h1 h2 ...for each series, where each height is the value × 10 ÷ M rounded to the nearest whole number, halves up.
Input
Line 1: n. Then n lines NAME v1 v2 ....
Output
n + 1 lines.
Constraints
1 ≤ n ≤ 20; values are 0 or more; the largest value is over 0.
Example
Input:
2
A 2 4 6 8
B 1 1 2 2
Output:
axis 0 to 8
A: 3 5 8 10
B: 1 1 3 3
Why it works
Dividing every series by the same maximum keeps heights comparable across panels, so a series that grows a little stays small even when it sits beside one that grows a lot.
Examples
Example 1 · Input
2 A 2 4 6 8 B 1 1 2 2
Expected output
axis 0 to 8 A: 3 5 8 10 B: 1 1 3 3
Example 2 · Input
1 S 5 10
Expected output
axis 0 to 10 S: 5 10
Prompts inside input() are ignored when checking, so input("n: ") is fine.
Hints
Hint 1
Find the largest value across all series first.
Hint 2
Each height is int(v × 10 ÷ max + 0.5).
Solution
Show one correct solution (try it yourself first)
n = int(input())
rows = [input().split() for _ in range(n)]
top = max(float(v) for r in rows for v in r[1:])
print(f"axis 0 to {top:g}")
for r in rows:
print(f"{r[0]}:", " ".join(str(int(float(v) * 10 / top + 0.5)) for v in r[1:]))