我将尝试编写一个算法,返回长度为n时值为0、1和2的所有可能组合的数组。
例如当n = 2时:
00
01
02
10
11
12
20
21
22
我已经开始写的代码还远远不够正确或完整:
func main() {
var results []string
matches := rangeSlice(2)
for a := 0; a < len(matches); a++ {
for b := 0; b < 3; b++ {
matches[(len(matches) - a) - 1] = b
results = append(results, strings.Join(convertValuesToString(matches), ""))
}
}
printResults(results)
}
非常感谢您的帮助!