We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e3447b6 commit 45ff9e1Copy full SHA for 45ff9e1
StringCombinations.go
@@ -0,0 +1,32 @@
1
+/*
2
+ String combinations in Go
3
+*/
4
+package main
5
+
6
+import "fmt"
7
8
+type Combinations struct {
9
+ out []rune
10
+ in []rune
11
+}
12
13
+func startCombinations(input string) {
14
+ c := &Combinations{
15
+ in: []rune(input),
16
+ }
17
18
+ c.Combine(0)
19
20
21
+func (c *Combinations) Combine(seed int) {
22
+ inLen := len(c.in)
23
+ for i := seed; i < inLen-1; i++ {
24
+ c.out = append(c.out, c.in[i])
25
+ fmt.Println(string(c.out))
26
+ c.Combine(i + 1)
27
+ c.out = c.out[:len(c.out)-1]
28
29
+ c.out = append(c.out, c.in[inLen-1])
30
31
32
0 commit comments