回答編集履歴
2
edit
test
CHANGED
@@ -19,3 +19,65 @@
|
|
19
19
|
https://stackoverflow.com/questions/23412146/create-cartesian-product-in-go
|
20
20
|
|
21
21
|
それと同等なgolangの実装。
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
---
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
私もそのロジックは理解できませんでしたが、正しそうな結果は得られました。
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
```go
|
34
|
+
|
35
|
+
package main
|
36
|
+
|
37
|
+
import "fmt"
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
func get_strings(ss []string, count int) []string {
|
42
|
+
|
43
|
+
searched := len(ss[len(ss)-1])
|
44
|
+
|
45
|
+
char := "abcde"
|
46
|
+
|
47
|
+
if searched < count-1 {
|
48
|
+
|
49
|
+
ss = get_strings(ss, count-1)
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
for _, s := range ss {
|
54
|
+
|
55
|
+
for _, c := range char {
|
56
|
+
|
57
|
+
ss = append(ss, s + string(c))
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
if count == 1 {
|
64
|
+
|
65
|
+
ss = ss[1:]
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
return ss
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
func main() {
|
76
|
+
|
77
|
+
ans := []string{""}
|
78
|
+
|
79
|
+
fmt.Println(get_strings(ans, 3))
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
```
|
1
edit
test
CHANGED
@@ -3,3 +3,19 @@
|
|
3
3
|
|
4
4
|
|
5
5
|
公開されているライブラリでは参考になりませんでしたか?
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
---
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
https://docs.python.jp/3/library/itertools.html#itertools.product
|
14
|
+
|
15
|
+
pythonでの実装。
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
https://stackoverflow.com/questions/23412146/create-cartesian-product-in-go
|
20
|
+
|
21
|
+
それと同等なgolangの実装。
|