Skip to content

Commit 6972e6e

Browse files
committed
refactor(1b): sort once
1 parent 99e08ae commit 6972e6e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

1/main.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ var caloriesPerElf []int = make([]int, 0)
1414
func appendSetMax(sum int) {
1515
// store sum
1616
caloriesPerElf = append(caloriesPerElf, sum)
17-
sort.Ints(caloriesPerElf)
1817
}
1918

2019
func main() {
@@ -36,6 +35,9 @@ func main() {
3635
}
3736
appendSetMax(sum)
3837

38+
// Only sort once
39+
sort.Ints(caloriesPerElf)
40+
3941
elves := len(caloriesPerElf)
4042
fmt.Printf("there are a total of %d elves\n", elves)
4143

0 commit comments

Comments
 (0)