Skip to content

Instantly share code, notes, and snippets.

@brianjester
Created August 12, 2017 04:10
Show Gist options
  • Save brianjester/2bd84c828f3f4aed9723f8d5450be260 to your computer and use it in GitHub Desktop.
Save brianjester/2bd84c828f3f4aed9723f8d5450be260 to your computer and use it in GitHub Desktop.
A Tour of Go - Exercise: Slices
package main
import "golang.org/x/tour/pic"
func Pic(dx, dy int) [][]uint8 {
mypic := make([][]uint8, dy)
for i := 0; i < dy; i++ {
mypic[i] = make([]uint8, dx)
for j := 0; j < dx; j++ {
mypic[i][j] = uint8((i*j)^i-j)
}
}
return mypic
}
func main() {
pic.Show(Pic)
}
@brianjester
Copy link
Author

image

@brianjester
Copy link
Author

mypic[i][j] = uint8((i-j)^i-j)
image

@brianjester
Copy link
Author

mypic[i][j] = uint8(((1/2)*i-j)^i-j)
image

@brianjester
Copy link
Author

mypic[i][j] = uint8(((1/2)*j-i)^i-j)
image

@brianjester
Copy link
Author

mypic[i][j] = uint8((j-i)^i-j)
image

@brianjester
Copy link
Author

mypic[i][j] = uint8((2*j-3*i)^2*i-3*j)
image

@brianjester
Copy link
Author

mypic[i][j] = uint8((i^j-j^i)^((i^j)-(j^i)))
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment