dop2000 Thanks! That's almost exactly what I need. However, I can't figure out this detail: I need to fill the tiles in a particular order. Serial number for each tile is storred in the array. Here's what I'm trying to do:
But it fills all of them instantly, although not all numbers are 0. What am I missing here? I guess it breaks the logics as it changes n value before it can be used?