1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-25 16:58:06 +08:00
This commit is contained in:
harveyshao 2023-02-20 20:38:11 +08:00
parent b19fc4fc58
commit 7ff38a4575
2 changed files with 29 additions and 0 deletions

4
src/hi/sku.go Normal file
View File

@ -0,0 +1,4 @@
package hi
func init() {
}

25
src/sku.go Normal file
View File

@ -0,0 +1,25 @@
package main
import "fmt"
func helper(chunks [][]string, chunkIndex int, prev []string, res [][]string) [][]string {
chunk := chunks[chunkIndex]
isLast := chunkIndex == len(chunks)-1
for _, val := range chunk {
if cur := append(prev, val); isLast {
res = append(res, cur)
} else {
res = helper(chunks, chunkIndex+1, cur, res)
}
}
return res
}
func combine(chunks ...[]string) (res [][]string) {
return helper(chunks, 0, []string{}, res)
}
func main() {
names := []string{"iPhone X", "iPhone XS"}
colors := []string{"黑色", "白色"}
storage := []string{"64g", "256g"}
fmt.Println(combine(names, colors, storage))
}