why wouldn't this simpler code work?
why wouldn't this simpler code work?
The attached code, based on the description:
There is also an inverse permutation P-1 for which P-1 P = P P-1 =
I. It can be found by taking the functional inverse, or by reversing
each ordered pair in the definition of a function as a set of
ordered pairs (and then sorting the ordered pairs by their new first
elements).
For example, the inverse of {2,3,1} is the inverse of {(1,2), (2,3),
(3,1)}, which is {(2,1), (3,2), (1,3)}, or {(1,3), (2,1), (3,2)}, or
{3,1,2}.
from:
http://www.efgh.com/math/algebra/permutations.htm
is much simpler (only 1 loop instead of 4 loops). Why not use
this much simpler code?
31 Dec 11, 10:50PM
I've looked into this page and a variety of sources on this and I have to admit I'm inclined to agreed with you. I think Lucian has made this harder that is actually needed to be.
Where your function would differ over the existing one is when
does not contain a perfect sequence of integers. i.e. {4,1,2,7,3}. However, I can't see when it would be logical to do this.
I'll await feedback from Lucian, but upload you code as a draft for now.
Login