Tic Tac Tree Winner
Written by a community member · · 2 attempts · 0% pass
Given an N x N board represented as a list of lists of booleans, determine the winner of the game Tic Tac Tree.
In this game, True represents a red piece and False represents a black piece. A player earns 1 point for every sequence of exactly three consecutive cells of their color in a straight line: horizontally, vertically, or diagonally down-right (top-left to bottom-right) or diagonally down-left (top-right to bottom-left). Overlapping sequences both count.
Return the string "Red" if red has more points, "Black" if black has more points, and "Tie" if the scores are equal.
Examples:
Input: [[True, True, True, False], [True, False, True, False], [True, False, True, False], [False, False, False, False]]
Output: "Black"
Explanation: Red scores 3 points, Black scores 5 points.
Input: [[True, True, True, True], [True, True, True, True], [True, True, True, True], [True, True, True, True]]
Output: "Red"
Explanation: Red scores more because every length-3 line on the board is red.