# Thread: computing points depending from values of vector

1. ## computing points depending from values of vector

Hello,
I am pretty new to the c++ language I am doing a coding challenge regarding checking the values of a vector.

I have been stuck on this challenge for hours and I can't think of a proper solution.

I have a vector which is called values that looks like this :

Code:
```std::vector <char > values {a,b,a,b,b,b,a,a,a,a,b,b,a};
```
Then after three values a column is started , so at the end this is how the values should be looked at
Code:
```abaaa
bbab
abab```
Player 1 has the letter a and player 2 the letter b.
If player one has orthogonally connecting a's (exluding diagonal a's) he get's points at the end of the iteration.
If one a is not connected to any other a player 1 get's one point. Two a's are worth 2 points and for 3 a's 5 points. Always excluding diagonal a's.
If there are more than 3 connected a's player 1 gets 2 points extra. for example 4 a's 7 points and 5' as 9 points.
This applies for player 2 as well.
The tricky part is that a player can get points for more than one group of orthogonally connects a's or b's.
So for example if player 1 has a group of 3 'as he gets 5 points. If he also has a single a he get's a point.
So at the end he get's 6 points altogether.

in this case:
Code:
```abaaa
bbab
abab```
Player 1 gets : 9+1+1
Player 2 gets: 7+2

I hope my question is clear.
I would be thankful for any hint.

2. You say "C language", but you mean "C++ language". Although they are related, they are radically different.

In player 1's score, I see where the 9 and the two 1's come from, but where does the 2 come from? I feel I don't understand your explanation of the "tricky" part: "a player can get points for more than one group of orthogonally connects a's or b's."

3. sorry I made a mistake the two points are wrong . i will remove it.
The tricky part in my opinion is how to determine that player 1 get's 9+1+1 points by checking if the letters are connected orthogonally and ignoring the other letter b and also excluding diagonal letters for each player

4. Okay, that makes sense now.

I think you will need a kind of "floodfill" algorithm.
(Hopefully someone else will suggest a simpler solution if it exists.)
The floodfill function is recursive.
Do you know anything about recursion?

BTW, what is the maximum size of the values vector?

5. Thanks for the suggestion.
No I don't really know much about recursions.
But I will check out the floodfill algorithm
The maximum size of values can be anything. I just tried it with these values.

6. So the size of the value array could be trillions of characters?
Are you sure your computer has enough memory?
Maybe you should look at the problem description again.
Usually there are constraints to these kinds of problems.
If you have a link to the problem description, post it.

7. the maximum size could can be 24 so space for a maximum amount of 23 letters