Oh, sorry, I must have badly explained my problem. Of course, I would use min(, but I expanded my 4x4 matrix to a 6×6 matrix, to simplify my code for movement of the tiles and the code for collision with other tiles of the same power of 2. I must have forgotten to mention this. Due to it simplifying the code very well, I will not change it back to 4×4, just because there are slowing problems in terms of finding out, if the matrix is full. Changing it back, would slow down the program in other lines of code, because the matrix expansion is necessary for some tricks, that I used in movement and collision code.

To conclude, I have to say that „The field is full“ is **not** equivalent to „The Matrix is full“.

But the field is full, if all 16 middle elements of the 36-element-matrix are no-zero(if column elements 1..5 of rows 1..5 are no-zero).

So this is why I dont use min(, but want to use:

Because the outer elements of the matrix (elements, which exist due to the matrix expansion) always contain a 0 and never change, you will just have to count the non-zero elements of the whole matrix and if the number is greater or equal to 16 (4^2), the field is full.

And this is what my code does:

`16≤sum(seq(0≠[A](int(I/6)+1,1+remainder(I,6)),I,0,35`

But this is very slow, because it performs a total of 36 modulo calculations.

Maybe someone knows a better way, to go through the matrix, maybe without modular arithmetics?

And sorry for the inconviniences, I must have explained my problem very badly, which could relie on my bad English (I am from Germany).

Maybe someone can help me now? :)

If you want, I also could first post my whole code (which is functional, but just has this one speed problem in this one line which I want to get rid off), maybe you then will better understand my code and then you can better help me? :)

Edit: Here is a example how a matrix could internally look like and how the calculator sees the 4x4 field, created with LaTex:

(1)
\begin{pmatrix} 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 2 & 8 & 4 & 2 & 0 \\ 0 & 8 & 16 &2&4 & 0 \\ 0 &32 &8& 4 & 8 & 0\\ 0 & 512&4&2&64&0\\ 0 & 0 & 0 & 0 & 0 & 0 \end{pmatrix}

I think that this could help you understand what I mean ;)

Btw. if you are asking yourself, for what purpose I expanded the matrix, I can answer you that it prevents an Invalid Dim Error by cancelling an internal while loop, which increases the index until it finds a 0, otherwise if it would not find a 0, it would go over the „ledge“ of the matrix and return an invalid dim error ;)