Skip to content

Commit 5f1d563

Browse files
author
Gonzalo Diaz
committed
LINT fix (modernize): using string += string in a loop is inefficient
1 parent 9574425 commit 5f1d563

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

exercises/projecteuler/problem0024.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func factorial(n int) int {
2222

2323
func permute(symbols string, target int) string {
2424
choices := strings.Split(symbols, "")
25-
answer := ""
25+
var answer strings.Builder
2626
minimum := 0
2727

2828
for len(choices) > 0 {
@@ -33,14 +33,14 @@ func permute(symbols string, target int) string {
3333
index += 1
3434
minimum += combos
3535
}
36-
answer += choices[index]
36+
answer.WriteString(choices[index])
3737
copy(choices[index:], choices[index+1:])
3838
choices[len(choices)-1] = ""
3939
choices = choices[:len(choices)-1]
4040
minimum -= combos
4141
}
4242

43-
return answer
43+
return answer.String()
4444
}
4545

4646
func Problem0024(inputElements string, inputPermutationToFind int) string {

0 commit comments

Comments
 (0)