Browse Source

multi_if solution and benchmark

master
Jim Infield 9 years ago
committed by jimi
parent
commit
6018555af2
  1. 3
      multi_if.bench
  2. 19
      raindrops.go

3
multi_if.bench

@ -0,0 +1,3 @@
PASS
BenchmarkConvert-8 2000000 741 ns/op
ok exercism/go/raindrops 2.253s

19
raindrops.go

@ -2,8 +2,25 @@
package raindrops
import "strconv"
const testVersion = 2
func Convert(int) string
func Convert(i int) string {
var s string
if i%3 == 0 {
s += "Pling"
}
if i%5 == 0 {
s += "Plang"
}
if i%7 == 0 {
s += "Plong"
}
if s == "" {
s = strconv.Itoa(i)
}
return s
}
// The test program has a benchmark too. How fast does your Convert convert?
Loading…
Cancel
Save