2023-12-14 22:22:41 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2023-12-17 20:49:11 +00:00
|
|
|
// String implements the fmt.Stringer interface
|
2023-12-14 22:22:41 +00:00
|
|
|
func (i img) String() string {
|
|
|
|
out := ""
|
|
|
|
for _, line := range i.raw {
|
|
|
|
out += fmt.Sprintf("%s\n", line)
|
|
|
|
}
|
|
|
|
return out
|
|
|
|
}
|