Skip to content

Commit 0935296

Browse files
committed
ninja-level6 solutions
1 parent 240007b commit 0935296

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func main() {
6+
solution3()
7+
}
8+
9+
func solution3() {
10+
11+
y := []int{10, 200, 30}
12+
z := []int{10, 200, 300}
13+
14+
15+
defer fmt.Println(foo(y...))
16+
fmt.Println(bar(z))
17+
}
18+
19+
func foo(x ...int) int {
20+
21+
sum := 0
22+
for _, num := range x {
23+
sum += num
24+
}
25+
return sum
26+
}
27+
28+
func bar(x []int) int {
29+
sum := 0
30+
for _, num := range x {
31+
sum += num
32+
}
33+
return sum
34+
}

0 commit comments

Comments
 (0)