Shazer2 problems thread.

This thread will be the one thread that I will post all my problems on instead of creating several threads every time I have something wrong that I can’t solve.

Right now I’m trying to make a console based Connect 4, and I need to check in the 2D array if 4 of the same types are in a row. I’m not sure how to do this. If anyone can link me to some resources or give me some hints I’d be more than appreciative.

Shannon :slight_smile:

I think the most straight forward way would be to scan the array. I would start at the bottom, (since the Connect 4 has the markers drop to the bottom).

  1. pick a bottom corner to start (say left).
  2. if it has a marker, check if the space above, above to the right (and left) and right are the same type of marker.
  3. if there is a match, continue in that direction, counting the matches, until you run out of matches are you reach four.
  4. If no four in a row, move to the right and repeat from step 2.

Thinking about the forum in a whole, more people would benefit from your several (?) questions if you created a separate thread for each one of them with a meaningful subject line.

Furthermore, I highly doubt people will check you thread to see if you have fresh new questions they might know the answer . Most people will only click a topic if the subject line is something they are instersted in.

As a personal advice, I would try thinking a bit more about the problems I have before posting them and waiting people to solve it . As I could see, you’re hoping to have lots of problems ahead but you’re not very willing to think about their solutions . If you don’t try a little hard before giving up and waiting for other people’s answer, you’ll not improve your skills very much .
For example, based on your other threads in this forums, I’m 100% sure that you could solve this problem by yourself (given that you wrote the code you posted here in your past threads) .

I’ve tried figuring it out and I can’t. Seems nobody has belief in me.

Shannon :slight_smile: