Last active
July 9, 2019 15:25
-
-
Save alexUXUI/0654d637618910de7b541399f72b6b71 to your computer and use it in GitHub Desktop.
Code Challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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