Created
July 10, 2018 07:39
-
-
Save szalai1/8cb985422287c26133f13b962b050d2d 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
package main | |
import ( | |
"fmt" | |
) | |
const ( | |
ENCODED_T = 0 | |
ENCODED_X = 1 | |
ENCODED_O = 2 | |
ENCODED_DOT = 4 | |
) | |
func checkRow(table [4][4]int) (bool, int) { | |
resultRow := 0 | |
resultCol := 0 | |
resultDiag := 0 | |
resultDiagSub := 0 | |
for i := 0; i < 4; i++ { | |
for j := 0; j < 4; j++ { | |
resultRow |= table[i][j] | |
resultCol |= table[j][i] | |
} | |
if resultCol == ENCODED_X || resultCol == ENCODED_O { | |
return true, resultCol | |
} | |
if resultRow == ENCODED_X || resultRow == ENCODED_O { | |
return true, resultRow | |
} | |
} | |
return false, ENCODED_T | |
} | |
func checkRow(table [4][4]int) (bool, int) { | |
result := 0 | |
for i := 0; i < 4; i++ { | |
for j := 0; j < 4; j++ { | |
result |= table[i][j] | |
} | |
if result == ENCODED_X || result == ENCODED_O { | |
return true, result | |
} | |
} | |
return false, result | |
} | |
func main() { | |
fmt.Println(ENCODED_DOT, ENCODED_O, ENCODED_X, ENCODED_T) | |
mapping := map[byte]int{ | |
'X': 1, | |
'O': 2, | |
'.': 4, | |
'T': 0, | |
} | |
var T int | |
fmt.Scanf("%d", &T) | |
for t := 0; t < T; t++ { | |
var table [4][4]int | |
for r := 0; r < 4; r++ { | |
for c := 0; c < 4; c++ { | |
var b byte | |
fmt.Scanf("%c", &b) | |
table[r][c] = mapping[b] | |
} | |
} | |
fmt.Println(table) | |
break | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment