Connecting Dots
We define a type of question on the test, connecting the dots
Question parameters
There are two parameters. Suppose they are 5
and 4
. The second one must be less than or equal to the first one.
Thus, the question will look like this:
*
*
*
*
*
*
*
*
*
Possible answers
An answer is termed logically possible
if and only if:
Each dot on the left corresponds to one and only one dot on the right
Each dot on the right corresponds to at least one dot on the left (there is no maximum)
We describe an answer using a matrix
, or list of lists
.
For instance, [[0,0],[1,0],[2,1]]
will link the dot indexed 0 on the left to the dot indexed 0 on the right, et cetera. You may choose to use 0-indexed or 1-indexed.
We define an answer's complexity
...
...as the number of intersections there are. For instance, the complexity of the answer [[0,2],[1,1],[2,0]]
to be 1
as they intersect at the same point (assuming they are evenly spaced out).
Purpose
- Calculate the complexity of a given solution
Grading
This is code golf
.
f: A -> B
, where the cardinality ofA
andB
are respectively the question parameters? \$\endgroup\$