Question:

Suppose the board comes in the form of a 3x3 array, in which the value is 0 if the box is empty, 1 if it is an X and 2 if it is an O, such like this:

[[0,0,1], [0,1,2], [2,1,0]]

What we want is for our function to return -1 if the board is not resolved, 1 if X have won, 2 if O have won and 0 if tie.

We will assume that the board passed as input is always valid, given that we are within the context of our game. * / function boardState (array $ board): int {

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!