1 Star 0 Fork 0

jimgo/Three Plus One Game

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
tpo.go 744 Bytes
一键复制 编辑 原始数据 按行查看 历史
jimgo 提交于 2021-10-25 01:19 . Use golang to varify.
package home
import "fmt"
func sc(p int8, n int8) int8 {
var r int8 = 0
switch p {
case 0, 1, 2:
switch n {
case 0, 3:
r = 0
case 2, 5:
r = 1
case 1, 4:
r = 3
case 6:
r = 6
}
case 3, 4, 5:
switch n {
case 0, 3:
r = 4
case 2, 5:
r = 5
case 1, 4, 6:
r = 2
}
case 6:
r = n
}
return r
}
func next(num []int8) []int8 {
num = append([]int8{0}, append(num, 6)...)
var num2 []int8
for i := 0; i < len(num)-1; i++ {
num2 = append(num2, sc(num[i], num[i+1]))
}
if num2[0] == 0 {
num2 = num2[1:]
}
e := len(num2) - 1
if num2[e] == 6 {
num2 = num2[:e]
}
return num2
}
func path(num []int8) {
for true {
if len(num) <= 1 {
break
}
fmt.Println(num)
num = next(num)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/jimgo/ThreePlusOneGame.git
git@gitee.com:jimgo/ThreePlusOneGame.git
jimgo
ThreePlusOneGame
Three Plus One Game
master

搜索帮助