D
D
DunkanMaklaut2020-12-19 09:29:46
Algorithms
DunkanMaklaut, 2020-12-19 09:29:46

I don’t understand by what formula to calculate the X and Y matrices to fill it in?

Help me think of
5fdd94bcf0672059486841.png
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? 5fdd9a209456d730189154.pngrows go from 0 to 6, and they should be calculated in such a way that 5fdd9d2c3a74e141986672.pngonly 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

1 answer(s)
L
Lynn "Coffee Man", 2020-12-19
@DunkanMaklaut

Here is a function to calculate the row in a triangle up to the diagonal 5fddae5049bb2124714331.jpeg
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 question

Ask a Question

731 491 924 answers to any question