k.go 272 B

12345678910111213141516171819
  1. package kata
  2. import "unicode"
  3. func duplicate_count(s1 string) int {
  4. hits := make(map[rune]int)
  5. for _, r := range s1 {
  6. l := unicode.ToLower(r)
  7. n, _ := hits[l]
  8. hits[l] = n + 1
  9. }
  10. count := 0
  11. for _, n := range hits {
  12. if n > 1 {
  13. count++
  14. }
  15. }
  16. return count
  17. }