I am trying to make a basic classification of binary strings in PHP. (The programming language is irrelevant, it is more convenient with PHP).
So basically I have 2 coordinate arrays:
$classA = [ new Point(1,1), new Point(1,2), new Point(3,3), new Point(1,5) ];
$classB = [ new Point(4,1), new Point(5,2), new Point(4,1), new Point(6,6) ];
I need to iterate over these arrays and get 2 pairs of points each time (the pair consists of a point from class A and another from class B). It is important to get all possible combinations. Once a particular point is in a pair, it cannot be present in another pair.
For example, the first two pairs:
$pair1 = [$a[0], $b[0]];
$pair2 = [$a[1], $b[1]];
To better explain myself, this is what I need:
When the first pair contains [1,1], [4,1], all possible combinations for the other pair are highlighted in yellow.
So far this is what I have:
$classA = [ new Point(1,1), new Point(1,2), new Point(3,3)];
$classB = [ new Point(4,1), new Point(5,2), new Point(4,1)];
$combinations = [];
$pair1 = [];
$pair2 = [];
$n = count($classA);
$m = count($classB);
for ($i=0; $i<$n; $i++){
for ($j=0; $j<$m; $j++){
$pair1 = [ $classA[$i], $classB[$j] ];
for ($z=0; $z<$n; $z++){
if($z != $i && $z != $j){
for ($y=0; $y<$m; $y++){
if($y != $i && $y != $j){
$pair2 = [ $classA[$z], $classB[$y] ];
$combinations[] = [$pair1, $pair2];
}
}
}
}
}
}
, , ?