Skip to content

Instantly share code, notes, and snippets.

View GlenDC's full-sized avatar
🚀

Glen De Cauwsemaecker GlenDC

🚀
View GitHub Profile
@GlenDC
GlenDC / permutations.go
Last active August 29, 2015 14:01
Permations of an array in Go
func Pow(x, n int) int {
return int(math.Pow(float64(x), float64(n)))
}
func Permutations(array []int) [][]int {
size := len(array)
total := Pow(2, size)
permutations := make([][]int, 0, total)
for i := 0; i < total; i++ {
package main
import "code.google.com/p/go-tour/pic"
func Pic(dx, dy int) [][]uint8 {
pic := make([][]uint8, dy)
for y := range pic {
pic[y] = make([]uint8, dx)
for x := range pic[y] {
pic[y][x] = uint8(x*y)