Problem 45354. Connect Four - 01
Connect four is a two player board game.
https://en.wikipedia.org/wiki/Connect_Four
Given a complete connect-four board, determine who is the winner.
User-1 is represented by 1
User-2 is represented by 2
Winner is the one with the highest number of sets of 4 consecutive numbers. A set can be comprised of same numbers on row, column, diagonal or anti-diagonal basis.
x=[2 2 1 1 2 1 2; 1 2 2 1 1 1 1; 1 2 1 1 2 2 2; 2 1 2 2 2 1 1; 1 1 2 1 2 1 1; 2 1 1 2 2 2 1]
here in the 5th column, we've a set of 2;
in the 2nd row, we've a set of 1;
in the 2nd anti-diagonal, we've a set of 1;
so, 1 is the winner.
A tie is represented by 0.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers12
Suggested Problems
-
Flip the main diagonal of a matrix
780 Solvers
-
Duplicate each element of a vector.
596 Solvers
-
07 - Common functions and indexing 4
403 Solvers
-
120 Solvers
-
ベクトル [1 2 3 4 5 6 7 8 9 10] の作成
524 Solvers
More from this Author165
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!