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.

53 lines
1.4 KiB

3 years ago
package main
import (
"fmt"
"strings"
)
/*
50Matthew,Sarah,Augustus,Heidi,Emilie,Peter,Giana,Adriano,Aaron,Elizabeth
a. 1'e''E'1
b. 1'i''I'2
c. 1'o''O'3
d: 1'u''U'4
dispatchCoin
*/
var (
coins = 50
users = []string{
"Matthew", "Sarah", "Augustus", "Heidi", "Emilie", "Peter", "Giana", "Adriano", "Aaron", "Elizabeth",
}
distribution = make(map[string]int, len(users))
)
func main() {
left := dispatchCoin()
fmt.Println("剩下:", left)
}
func dispatchCoin() interface{} {
for _, v := range users {
distribution[v] = 0
}
for k := range distribution {
distribution[k] += strings.Count(k, "e")
distribution[k] += strings.Count(k, "E")
distribution[k] += strings.Count(k, "i") * 2
distribution[k] += strings.Count(k, "I") * 2
distribution[k] += strings.Count(k, "o") * 3
distribution[k] += strings.Count(k, "O") * 3
distribution[k] += strings.Count(k, "u") * 4
distribution[k] += strings.Count(k, "U") * 4
//fmt.Println(k, distribution[k])
}
sum := 0
for _, v := range distribution {
sum += v
}
return coins - sum
}