A year ago I posed the following problem:
_______________________________
given an N-square matrix is there a single formula for the sequential
number of the i-jth element of the off-diagonal upper right triangular
cell?
For example: a 4-square matrix:
J=1 J=2 J=3 J=4
I=1 1 2 3
I=2 4 5
I=3 6
I=4
________________________________
I had many solutions offered and am grateful to all those who
contributed.
Every solution, however, was in terms of I, J and N. In other words,
the size of the square matrix was required.
Some time later I dreamed about the array
(don't niggling problems prey on the mind!).
But in my dream the array was re-arranged as:
J=2 J=3 J=4 J=5 J=6
I=1 1 2 4 7 11
I=2 3 5 8 12
I=3 6 9 13
I=4 10 14
I=5 15
When I awoke, I wrote it down and then found the formula:
1 + i + j * (j - 3) / 2
which is independent of N.
I thought you ought to know!
But now I have another query:
Given a value in the array, is there a direct route, without searching,
to recovering I and J?
For example: value = 13, reveal that I = 3 and J = 6 ??
--
Tony Greenfield
Middle Cottage
Little Hucklow
Derbyshire SK17 8RT
01298 872326
[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|