Created
May 26, 2019 06:09
-
-
Save lasagnaphil/70f6cd21d14f6963011c98d75fc930f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
bool[,] board = new bool[5, 5] | |
{ | |
{ true, false, false, true, false }, | |
{ true, true, true, true, true }, | |
{ false, true, true, true, true }, | |
{ false, true, true, true, true }, | |
{ true, true, true, true, true } | |
}; | |
int bingos = 0; | |
bool lineTrue = true; | |
for (int i = 0; i < 5; i++) { | |
lineTrue = true; | |
for (int j = 0; j < 5; j++) { | |
lineTrue &= board[i,j]; | |
} | |
if (lineTrue) { | |
bingos++; | |
} | |
} | |
for (int i = 0; i < 5; i++) { | |
lineTrue = true; | |
for (int j = 0; j < 5; j++) { | |
lineTrue &= board[j,i]; | |
} | |
if (lineTrue) { | |
bingos++; | |
} | |
} | |
lineTrue = true; | |
for (int i = 0; i < 5; i++) { | |
lineTrue &= board[i,i]; | |
} | |
if (lineTrue) { | |
bingos++; | |
} | |
lineTrue = true; | |
for (int i = 0; i < 5; i++) { | |
lineTrue &= board[i,4-i]; | |
} | |
if (lineTrue) { | |
bingos++; | |
} | |
Console.WriteLine(bingos); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment