Skip to content

Commit

Permalink
Update LightBoard.java
Browse files Browse the repository at this point in the history
  • Loading branch information
sketchysoymilk authored Apr 30, 2024
1 parent e4972e0 commit 2647c09
Showing 1 changed file with 19 additions and 27 deletions.
46 changes: 19 additions & 27 deletions src/main/java/LightBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,25 @@ public LightBoard(int numRows, int numCols)
*/
public boolean evaluateLight(int row, int col)
{
int numOn = 0;
for (int r = 0; r < lights.length; r++)
{

if (lights[r][col])
{

numOn++;

}
}

if (lights[row][col] && numOn % 2 == 0)
{

return false;

}
if (!lights[row][col] && numOn % 3 == 0)
{

return true;

}
return lights[row][col];


int sum = 0;
if(lights[row][col] == true){
for(int r = 0; r<lights.length;r++){
if(lights[r][col] == true)
sum++;
}
if(sum%2 == 0)
return false;
return true;
}
if(lights[row][col] == false){
for(int r = 0; r<lights.length;r++){
if(lights[r][col] == true)
sum++;
}
if(sum%3 == 0)
return true;
return false;
}

}
public boolean[][] getLights()
Expand Down

0 comments on commit 2647c09

Please sign in to comment.