Introduction
Connect Four is a game where you attempt to get four in a row: horizontally, vertically, or diagonally. In this code golf, we will be trying to find who won, given a game board. There will always be one winner, and only one winner.
Task
Given a Connect Four board, figure out who the winner is: X
or Y
. There will always be one winner, and only one winner. The board size will always be 6 by 7 like how the game board is in the in picture.
Given a board the following board, in this instance, X
is red and Y
is blue:
Your input would be:
OOOOOOO
OOOOOOO
OOOOOOO
OOOOXOO
OOOXXOO
OOXYYYY
You can separate rows of the game by newline character (like above), no dividing character, divide the rows into an array or list, or you can input a matrix of characters.
Correct output for this example:
Y
Y has four in a row; so, Y is the winner. So, we output Y.
Test cases
Input:
OOOOOOO
OOOOOOO
OOOOOOO
OOOOOOO
OOYYOOO
OYXXXXO
Output:
X
Input:
OOOOOOO
OOOOOOO
OOOOOOO
XXXXOOO
YXYYOOO
YXYYXYX
Output:
X
Input:
YXYYXOO
XYXXYOO
XXXYYOO
YYYXXOO
XXYYYYO
XXYYXXO
Output:
Y
Input:
OOOOOOO
OOOOOOO
OYOOOOO
OOYOOOO
OOOYOOO
OOOOYOO
Output:
Y
Input:
OOOOOOO
OOOOOOO
OYOOOOX
OOYOOOX
OOOXOOX
OXOXYOX
Output:
X
Scoring
Least number of bytes wins!