func (m *symbol) penalty1() int {
	penalty := 0
	for x := 0; x < m.symbolSize; x++ {
		lastValue := m.get(x, 0)
		count := 1
		for y := 1; y < m.symbolSize; y++ {
			v := m.get(x, y)
			if v != lastValue {
				count = 1
				lastValue = v
			} else {
				count++
				if count == 6 {
					penalty += penaltyWeight1 + 1
				} else if count > 6 {
					penalty++
				}
			}
		}
	}
	for y := 0; y < m.symbolSize; y++ {
		lastValue := m.get(0, y)
		count := 1
		for x := 1; x < m.symbolSize; x++ {
			v := m.get(x, y)
			if v != lastValue {
				count = 1
				lastValue = v
			} else {
				count++
				if count == 6 {
					penalty += penaltyWeight1 + 1
				} else if count > 6 {
					penalty++
				}
			}
		}
	}
	return penalty
}
penalty1 returns the penalty score for "adjacent modules in row/column with
same colour".

The numbers of adjacent matching modules and scores are:
0-5: score = 0
6+ : score = penaltyWeight1 + (numAdjacentModules - 5)
package qrcode
type symbol struct {
	module [][]bool
	isUsed [][]bool
	size int
	symbolSize int
	quietZoneSize int
}
func newSymbol(size int, quietZoneSize int) *symbol {
	var m symbol
	m.module = make([][]bool, size+2*quietZoneSize)
	m.isUsed = make([][]bool, size+2*quietZoneSize)
	for i := range m.module {
		m.module[i] = make([]bool, size+2*quietZoneSize)
		m.isUsed[i] = make([]bool, size+2*quietZoneSize)
	}
	m.size = size + 2*quietZoneSize
	m.symbolSize = size
	m.quietZoneSize = quietZoneSize
	return &m
}
func (m *symbol) get(x int, y int) (v bool) {
	v = m.module[y+m.quietZoneSize][x+m.quietZoneSize]
	return
}
func (m *symbol) empty(x int, y int) bool {
	return !m.isUsed[y+m.quietZoneSize][x+m.quietZoneSize]
}
func (m *symbol) numEmptyModules() int {
	var count int
	for y := 0; y < m.symbolSize; y++ {
		for x := 0; x < m.symbolSize; x++ {
			if !m.isUsed[y+m.quietZoneSize][x+m.quietZoneSize] {
				count++
			}
		}
	}
	return count
}
func (m *symbol) set(x int, y int, v bool) {
	m.module[y+m.quietZoneSize][x+m.quietZoneSize] = v
	m.isUsed[y+m.quietZoneSize][x+m.quietZoneSize] = true
}
func (m *symbol) set2dPattern(x int, y int, v [][]bool) {
	for j, row := range v {
		for i, value := range row {
			m.set(x+i, y+j, value)
		}
	}
}
func (m *symbol) bitmap() [][]bool {
	module := make([][]bool, len(m.module))
	for i := range m.module {
		module[i] = m.module[i][:]
	}
	return module
}
func (m *symbol) string() string {
	var result string
	for _, row := range m.module {
		for _, value := range row {
			switch value {
			case true:
				result += "  "
			case false:
				result += "██"
			}
		}
		result += "\n"
	}
	return result
}
const (
	penaltyWeight1 = 3
	penaltyWeight2 = 3
	penaltyWeight3 = 40
	penaltyWeight4 = 10
)
func (m *symbol) penaltyScore() int {
	return m.penalty1() + m.penalty2() + m.penalty3() + m.penalty4()
}