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 9574425 commit 5f1d563Copy full SHA for 5f1d563
1 file changed
exercises/projecteuler/problem0024.go
@@ -22,7 +22,7 @@ func factorial(n int) int {
22
23
func permute(symbols string, target int) string {
24
choices := strings.Split(symbols, "")
25
- answer := ""
+ var answer strings.Builder
26
minimum := 0
27
28
for len(choices) > 0 {
@@ -33,14 +33,14 @@ func permute(symbols string, target int) string {
33
index += 1
34
minimum += combos
35
}
36
- answer += choices[index]
+ answer.WriteString(choices[index])
37
copy(choices[index:], choices[index+1:])
38
choices[len(choices)-1] = ""
39
choices = choices[:len(choices)-1]
40
minimum -= combos
41
42
43
- return answer
+ return answer.String()
44
45
46
func Problem0024(inputElements string, inputPermutationToFind int) string {
0 commit comments