How do I count selected in rows and columns?

If I click on a black box (sprite), it turns yellow. How do I count how many I have selected in a row/coloumn vertical or horizontal?

Lets say from top left coriander to the right like this:
Yellow, Blue Yellow Yellow
Largest count is 2 for Yellow and one for Blue

If first column looks like this
Blue, Blue, Blue, Yellow
Largest count is 3 for Blue and one for Yellow.

I’am thinking of adding new objects group for each row and colour and loop them to see if a variable in the group is larger than a specifik number.


LMB to create stones and RMB to remove them
In upper left you have count of how many of stones exist
But i limit it to check only stones on SOME Y position in this case 384

And that is exactly this row

So you can delete or create stones in this row to see how number change while it won’t change if you create them in different row (different Y pos)

I assume you have your squares same object with different animation
So you have animation 0 gray 1 yellow 2 blue
You could add condition next to Y position
Animation of object is 0 or 1 or 2
To count how many colors are in that row

IDK how you gonna manage multiple rows (for columns you check X pos)
I mean do you gonna have separate text object for each row for yellow and blue squares and then double on that to cover columns for blue and yellow?

Well your choice but now you have idea how to count them
Or you could do this to count blue squares assuming you have there condition to check animation of square is blue or whatever
Instead of like i have change text of score text to ToString(PickedInstancesCount(Stone))
You would remove this action and put there
Change scene number variable Row1Blue to PickedInstancesCount(Stone)

Now you would copy and paste this event and do same for yellow where variable name would be Row1Yellow

And now in separate event you would do this
Change text of YOUR TEXT OBjECT to "Row 1 Blue “+ToString(SceneVariable(Row1Blue))+” Yellow "+ToString(SceneVariable(Row1Yellow))

And it would look print text like

Row1 Blue 15 Yellow 20

OR if you wanna new line then here where i put XXX

Change text of YOUR TEXT OBjECT to "Row 1XXXBlue "+ToString(SceneVariable(Row1Blue))+"XXXYellow "+ToString(SceneVariable(Row1Yellow))
You hold left shift and hit enter to start a new line and text would look like

Blue 15
Yellow 20
This way as you see you can print as much stuff with one text object as you want