Let's I have matrix
A =
1 2 3
1 3 5
1 2 4
2 3 7
The task is to re-arrange the matrix so that in no row two elements are in the same order.
For example, in row 1 and row 2 we have numbers 1 and 3 in the same order. We flip the numbers in 1 and 3 left to right in row 1 and get
3 2 1
1 3 5
1 2 4
2 3 7
My thoughts are this is a search problem, that could be maybe solved with Answer Set Programming? The problem is that if you try to do this with some algorithm, at some point you end up putting two numbers in to the same order as they are in some other row.
This is useful for reorienting triangular surface mesh faces of a mesh where the face normals point to inconsistent directions so that all normals point to inward (or outward)