# XY array of irregular width

Get help using Construct 2

### » Sun Feb 08, 2015 8:07 am

Since you can't have a XY array of irregular width.

How would you do this best:

Initial width and height is dynamic and calculated at runtime.

Let's say we have this grid of 20 entries width and 10 entries height.

We fill the horizontal entries with 0 up to 19 on each row.

Then a loop for every horizontal row, you pick one cell at random, and then delete it. Making the width of THAT row one cell smaller.

Repeat for every row until you have no cells left.

How would you do this?

Quite confusing.. sorry.

For this one I would like to ask for capx or at least clear answer. I hope it is not too much.
B
60
S
18
G
13
Posts: 449
Reputation: 10,811

### » Sun Feb 08, 2015 9:02 am

Let's start smaller?

array:

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

Do you want the next stage to be:
1 2 3 4
0 2 3 4
0 1 2 3

but the final result to be

[ ]
[ ]
[ ]?
B
11
S
4
Posts: 152
Reputation: 1,236

### » Sun Feb 08, 2015 9:43 am

helena wrote:Since you can't have a XY array of irregular width.

You said it. So at no point will you have a row smaller than another row. The best you could do is:

1. Choose your random column (cell)
2. Re-order that row so that cell's value is at the end of the row
3. Repeat for each row
4. Finally, set the array width to it's current width -1

Now you have an array with width 1 less than before

Repeat the above steps until you have no more columns (cells).

Hopefully you will do something meaningful in between the above steps!

So this is not possible, because it goes against your original assertion. (Although conceptually, it could be thought of this way).
Then a loop for every horizontal row, you pick one cell at random, and then delete it. Making the width of THAT row one cell smaller.

Is this close to what you're asking?

edit: added a capx, hope it helps (it's 10x10 but it's dynamically set, just change it).

The array is represented on-screen. Tap on the layout to process each column and observe.
You do not have the required permissions to view the files attached to this post.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

### » Mon Feb 09, 2015 8:08 am

Thank you for this!
B
60
S
18
G
13
Posts: 449
Reputation: 10,811

### » Mon Feb 09, 2015 5:28 pm

You could create multiple arrays and think of each array as a row. Then it can be irregular.
You do not have the required permissions to view the files attached to this post.
B
100
S
38
G
134
Posts: 5,555
Reputation: 85,323

### » Tue Feb 10, 2015 2:52 am

Oh different instances! Yes. Thanks.
B
60
S
18
G
13
Posts: 449
Reputation: 10,811