aoc2023/day-14/image.go

36 lines
608 B
Go
Raw Normal View History

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