package main import "fmt" type img struct { raw []string } func newImg(sz int) img { return img{raw: make([]string, sz)} } // transposed rotates an image rightwards ninety degrees func (i img) transposed() []string { transposed := []string{} for x := 0; x < len(i.raw[0]); x++ { buf := "" for j := len(i.raw) - 1; j >= 0; j-- { buf += string(i.raw[j][x]) } transposed = append(transposed, buf) } return transposed } // String implements the fmt.Stringer interface func (i img) String() string { out := "" for _, line := range i.raw { out += fmt.Sprintf("%s\n", line) } return out }