You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
535 B
33 lines
535 B
package raindrops
|
|
|
|
import "strconv"
|
|
|
|
const testVersion = 2
|
|
|
|
func Convert(i int) string {
|
|
var s string
|
|
switch {
|
|
case i%3+i%5+i%7 == 0:
|
|
s = "PlingPlangPlong"
|
|
case i%3+i%5 == 0:
|
|
s = "PlingPlang"
|
|
case i%3+i%7 == 0:
|
|
s = "PlingPlong"
|
|
case i%3 == 0:
|
|
s = "Pling"
|
|
case i%5+i%7 == 0:
|
|
s = "PlangPlong"
|
|
case i%5 == 0:
|
|
s = "Plang"
|
|
case i%7 == 0:
|
|
s = "Plong"
|
|
default:
|
|
s = strconv.Itoa(i)
|
|
}
|
|
return s
|
|
}
|
|
|
|
// Iteration 2 Benchmark
|
|
// PASS
|
|
// BenchmarkConvert-12 5000000 309 ns/op
|
|
// ok exercism/go/raindrops 1.869s
|