diff --git a/exercises/slices.go b/exercises/slices.go new file mode 100644 index 0000000..7900ed5 --- /dev/null +++ b/exercises/slices.go @@ -0,0 +1,24 @@ +package main + +// exercise link: https://go.dev/tour/moretypes/18 + +import ( +// "golang.org/x/tour/pic" // not valid on local! +) + +func Pic(dx, dy int) [][]uint8 { + mypic := make([][]uint8, dx) + for i := range mypic { + mypic[i] = make([]uint8, dy) + } + for i, _ := range mypic { + for j, _ := range mypic[i] { + mypic[i][j] = uint8((i*dy + j*3) % 256) + } + } + return mypic +} + +func main() { + // pic.Show(Pic) +}