Last active
November 21, 2020 05:41
-
-
Save sithumonline/133a27b67431c1a19e23abc61f589ac7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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" | |
| "math/rand" | |
| ) | |
| func main() { | |
| var matrix = make(map[int][]string) | |
| var luckyNumber int | |
| status := "Win" | |
| for i := 0; i < 3; i++ { | |
| matrix[i] = append([]string{"O", "O", "O"}) | |
| } | |
| for _, value := range matrix { | |
| fmt.Println(value) | |
| } | |
| fmt.Print("\nEnter Your Lucy Number : ") | |
| fmt.Scanln(&luckyNumber) | |
| for i := 0; i < len(matrix); i++ { | |
| for KEY := range matrix[i] { | |
| if rand.Intn(luckyNumber)%2 == 0 { | |
| matrix[i][KEY] = "X" | |
| } | |
| } | |
| } | |
| for _, value := range matrix { | |
| fmt.Println(value) | |
| } | |
| for i := 0; i < len(matrix); i++ { | |
| if (matrix[i][0] == matrix[i][1] && matrix[i][1] == matrix[i][2]) || (matrix[0][i] == matrix[1][i] && matrix[1][i] == matrix[2][i]) { | |
| status = "Lose" | |
| } | |
| } | |
| fmt.Printf("\nYour %s the game...!! ", status) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment