Skip to content

Instantly share code, notes, and snippets.

@rprtr258
Last active October 12, 2022 11:36
Show Gist options
  • Save rprtr258/ae549c12fbcbb7c70542ec3a8d4072a8 to your computer and use it in GitHub Desktop.
Save rprtr258/ae549c12fbcbb7c70542ec3a8d4072a8 to your computer and use it in GitHub Desktop.
holes count program
package main
import (
"fmt"
"os"
)
var _table = map[rune]int{
// Numbers
'0': 1,
'4': 1,
'6': 1,
'8': 2,
'9': 1,
// Latin alphabet
'A': 1,
'B': 2,
'D': 1,
'O': 1,
'P': 1,
'Q': 1,
'R': 1,
'a': 1,
'b': 1,
'd': 1,
'e': 1,
'g': 1,
'o': 1,
'p': 1,
'q': 1,
// Cyrillic alphabet
'А': 1,
'Б': 1,
'В': 2,
'Д': 1,
'О': 1,
'Р': 1,
'Ф': 2,
'Ъ': 1,
'Ы': 1,
'Ь': 1,
'Ю': 1,
'Я': 1,
'а': 1,
'б': 1,
'в': 2,
'д': 1,
'е': 1,
'о': 1,
'р': 1,
'ф': 2,
'ъ': 1,
'ы': 1,
'ь': 1,
'ю': 1,
'я': 1,
// Auxiliary symbols
'#': 1,
'$': 2,
'%': 2,
'&': 2,
'@': 1,
}
func CountHoles(s string) (totalHoles int) {
for _, c := range s {
totalHoles += _table[c]
}
return
}
func main() {
if len(os.Args) != 2 {
fmt.Println("Usage: go run main.go 'your text goes here'")
os.Exit(1)
}
fmt.Printf("Дырочек: %d", CountHoles(os.Args[1]))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment