slices exercise solution

This commit is contained in:
Aliberk Sandıkçı 2023-07-12 16:45:14 +03:00
parent 53104e83c2
commit db81bd6a9e
1 changed files with 24 additions and 0 deletions

24
exercises/slices.go Normal file
View File

@ -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)
}