Answer the question
In order to leave comments, you need to log in
I don’t understand by what formula to calculate the X and Y matrices to fill it in?
Help me think of
such a task: to calculate X and Y through mathematical formulas, but at the same time, only the element number should be transferred to the function that calculates all this.
If you rotate the matrix counterclockwise, then it seems to become clearer how the algorithm is built. Then the row coordinate will mean the number of iterations to the right or left. But what formula will calculate the line number? rows go from 0 to 6, and they should be calculated in such a way that only the first number is the number in the sequence, and the second should be calculated somehow, most likely from the column number.
I understand that 3 functions are needed to implement this algorithm. Before the diagonal, the diagonal itself and after the diagonal.
Answer the question
In order to leave comments, you need to log in
Here is a function to calculate the row in a triangle up to the diagonal
ceil((sqrt(8*n + 1) - 1)/2)
. To calculate the column, you need to take into account the evenness of the row (for direction).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question