A Basic pairplot Grid
Thornbury Labs tests each batch of material on a bank of instruments and gets one number back per instrument per sample. Different batches go through different banks, so every file opens by naming the instruments that ran it -- one batch carries two measurements, the next carries five. Before anyone models anything, the lab looks at a grid of small charts: every measurement plotted against every other, with each measurement's own spread shown where it meets itself. The page layout is fixed by how many of those panels compare two different measurements.
Task: Print how many panels in the grid compare two different measurements.
Input
The first line names the measurements this batch carries: labels separated by single spaces, all different, and there is at least one. The second line holds one integer n, the number of samples, where 1 <= n <= 1000. Then come n lines, each holding one number per label, separated by single spaces and given in the same order as the labels.
Output
One line holding a whole number. The grid has one panel for every ordered pairing of the measurements this batch carries, and the answer excludes the ones where a measurement meets itself. Both directions count: a-against-b and b-against-a are separate panels. A batch carrying a single measurement therefore has no comparison panels at all.
Example:
Input:
a b c
3
1 2 3
4 5 6
7 8 9
Output:
6
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