From 38fe54f3de645fee4c5f6985021e78be75f7cd99 Mon Sep 17 00:00:00 2001 From: raul Date: Thu, 29 Feb 2024 06:50:39 +0100 Subject: [PATCH] Added guessing coordinates to matrix exercise --- matrix/main.go | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/matrix/main.go b/matrix/main.go index b008b98..41c6c5b 100644 --- a/matrix/main.go +++ b/matrix/main.go @@ -4,17 +4,32 @@ import ( "fmt" ) +var cell string = "x" +var x int +var y int + func main() { - a := [][]int{ - {0, 1, 2}, - {3, 4, 5}, - {6, 7, 8}, + a := [][]string{ + {cell, cell, cell}, + {cell, "1", cell}, + {cell, cell, cell}, } for i := 0; i < len(a); i++ { for _, v := range a[i] { - fmt.Printf("%v", v) + fmt.Printf("%v ", v) } fmt.Println() } + + fmt.Printf("Where's the one?\n") + fmt.Printf("X coordinate: ") + fmt.Scanln(&x) + fmt.Printf("Y coordinate: ") + fmt.Scanln(&y) + x++ + y++ + + fmt.Println(a[x][y]) + }