Skip to content

Instantly share code, notes, and snippets.

@alexUXUI
Last active July 9, 2019 15:25
Show Gist options
  • Save alexUXUI/0654d637618910de7b541399f72b6b71 to your computer and use it in GitHub Desktop.
Save alexUXUI/0654d637618910de7b541399f72b6b71 to your computer and use it in GitHub Desktop.
Code Challenge
package main
import (
"fmt"
"strings"
)
func ErrorPrinter(label string) string {
const alphabetSection = "abcdefghijklm"
var errorCounter = 0
for _, char := range label {
if (!strings.Contains(alphabetSection, string(char)) {
errorCounter += 1
}
}
return fmt.Sprintf("%d/%d", errorCounter, len(label))
}
func main() {
fmt.Println(ErrorPrinter("aaabbbbhaijjjm")) // 0/14
fmt.Println(ErrorPrinter("aaaxbbbbyyhwawiwjjjwwm")) // 8/22
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment