Latin box in Java

0

Good afternoon I have to make a java application that solves the Latin picture using recursion.

0 0 0 0 1
0 0 0 1 2
0 0 1 2 3
0 1 2 3 4
1 2 3 4 5

As the truth I had no idea how to do this, investigate on the internet and I found this method that solves the Latin picture.

public static void latino (int fila, int col, int cont, int orden, int mat[][])
{
    if (fila == 0 && col == 0)
        mat[0][0] = 1;
    else
        if (fila == col)
           latino (fila - 1, orden - 1, orden, orden, mat);
    else
    {
       mat[fila][col] = cont;
       latino (fila, col - 1, orden + 1, orden, mat);
    }
}

Here the problem is that I do not know what parameters to send when the Latin method is invoked from the main.

I wish you could help me with this.

    
asked by 07.03.2018 в 00:43
source

1 answer

1

How can I not give you a comment yet ... I'll explain here several things about your question and your problem in question.

First of all, after looking, analyzing and executing the function that you explain in the question several times, and looking for the source of it, I can say that this function does not make a Latin square, since it does not meet the definition of the problem mathematical. In addition, it is partially biased and does not work correctly since it does not control the recursive trivial cases of each input parameter. In short, it's wrong.

The correct definition of the mathematical problem of the Latin square being the following:

  

A Latin square is a matrix of n × n elements in which each square is occupied by one of the n symbols of such so that each of them appears exactly once in each column and in each row.

     

Definition of the problem in wikipedia: Latin square

     

Definition in English on wikipedia: latin square

The number of results is not unique and that is why some forums usually give as "definition" one of the possible solutions. Specifically, I have seen in most cases that they ask for a square matrix with which their first row contains the first N natural numbers and each of the following N-1 rows contains the rotation of the previous row a place on the right *.

According to this second definition (which does meet the definition of a Latin square), we can give several examples:

Cuadrados latinos de orden 3:

1 2 3
3 1 2
2 3 1    

Cuadrado latino de orden 4:

1 2 3 4
4 1 2 3
3 4 1 2
2 3 4 1

Note: Obviously, at some point, the problem may have been raised as seen in those forums, a small confusion with statements from others has been created problems and finally the solution was extended to the particular case and propagated as gunpowder as the solution to the problem of the Latin square .

    
answered by 07.03.2018 в 12:11