From b406be797473e942c85bdd37dd4bb0cff5e27f5c Mon Sep 17 00:00:00 2001 From: Michael Manring Date: Mon, 12 Aug 2024 21:50:58 +1000 Subject: pwc282 solution in go - fix ch-2 --- challenge-282/pokgopun/go/ch-2.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'challenge-282') diff --git a/challenge-282/pokgopun/go/ch-2.go b/challenge-282/pokgopun/go/ch-2.go index 4d11b56d8b..9ab40fe4d4 100644 --- a/challenge-282/pokgopun/go/ch-2.go +++ b/challenge-282/pokgopun/go/ch-2.go @@ -58,14 +58,13 @@ func ck(str string) int { var a, b byte c := -1 for i := range len(str) { - if str[i] < 97 { - a = str[i] + 32 + b = a + a = str[i] + if a < 97 { + a += 32 } - if i > 0 { - if a != b { - c++ - } - b = a + if a != b { + c++ } } return c @@ -79,6 +78,8 @@ func main() { {"pPeERrLl", 3}, {"rRr", 0}, {"GoO", 1}, + {"oOlong", 4}, + {"ToOlong", 5}, } { io.WriteString(os.Stdout, cmp.Diff(ck(data.input), data.output)) // blank if ok, otherwise show the differece } -- cgit