If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Finish the solution so that it returns the sum of all the multiples of 3 or 5 below the number passed in.
Note: If the number is a multiple of both 3 and 5, only count it once.
package kata
func Multiple3And5(number int) int {
}
package kata_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "codewarrior/kata"
)
var _ = Describe("Multiples of 3 and 5", func() {
It("should handle basic cases", func() {
Expect(Multiple3And5(10)).To(Equal(23))
Expect(Multiple3And5(20)).To(Equal(78))
})
It("should handle zeroes", func() {
Expect(Multiple3And5(0)).To(Equal(0))
Expect(Multiple3And5(1)).To(Equal(0))
})
It("should handle large numbers", func() {
Expect(Multiple3And5(200)).To(Equal(9168))
})
})
Count the number of occurrences of each character and return it as a list of tuples in order of appearance. For empty output return an empty list.
Example:
'''
OrderedCount("abracadabra") == []Tuple{Tuple{'a', 5}, Tuple{'b', 2}, Tuple{'r', 2}, Tuple{'c', 1}, Tuple{'d', 1}}
// Where
type Tuple struct {
Char rune
Count int
}
'''
package orderedcount
// Use the preloaded Tuple struct as return type
// type Tuple struct {
// Char rune
// Count int
// }
func OrderedCount(text string) []Tuple {
// to implement
}
package orderedcount_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "codewarrior/orderedcount"
)
var _ = Describe("Test Suite", func() {
It("Sample Tests", func() {
Expect(OrderedCount("abracadabra")).Should(Equal([]Tuple{Tuple{'a', 5}, Tuple{'b', 2}, Tuple{'r', 2}, Tuple{'c', 1}, Tuple{'d', 1}}))
Expect(OrderedCount("Code Wars")).Should(Equal([]Tuple{Tuple{'C', 1}, Tuple{'o', 1}, Tuple{'d', 1}, Tuple{'e', 1}, Tuple{' ', 1}, Tuple{'W', 1}, Tuple{'a', 1}, Tuple{'r', 1}, Tuple{'s', 1}}))
Expect(OrderedCount("")).Should(Equal([]Tuple{}))
})
})