In n-dimensional grid (Max. 10^7 dimensions) are two points. They have imaginary sensors on every axis. I need algorithm what will calculate all possible options when these two points can spot themselves.
Formal written from my task document (translated to english):
Let A with the coordinates (a1, a2, ..., an) and B with the coordinates (b1, b2, ..., bn)
are two points in n-dimensional space and exists i ∈ 1, 2, ..., n such that ai = bi then A and B sees each other
Example:
In 1-dimensional space with length 10 is total 45 combinations how to put 2 points when they see each other (They see each other every time).
It is easy combination 10C2 (10 of 2) = 45
How to calculate it in 2,3,4,...,10^7 dimensions by program (I prefer C#)?
Proper test data what i have:
Input:
1
10
Output: 45
Input:
2
5 8
Output: 220
Input:
3
8 12 11
Output: 14784
More explanation:
Output is number of combinations when two points in space see each other (are on same axis). In 1 dimensional space is only one axis so they see each other always. In 2 dimensional space are 2 axis, so they can see each other only in some case