diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2024-08-12 12:54:19 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-12 12:54:19 +0100 |
| commit | 06d85752a276e45b5d4fa48366da43d17a244210 (patch) | |
| tree | 9702536c9b21303e89f28b4def26055d1b9fb358 | |
| parent | 9b340b42cd2122c2a74bac19ae7f6c0e2df30603 (diff) | |
| parent | b406be797473e942c85bdd37dd4bb0cff5e27f5c (diff) | |
| download | perlweeklychallenge-club-06d85752a276e45b5d4fa48366da43d17a244210.tar.gz perlweeklychallenge-club-06d85752a276e45b5d4fa48366da43d17a244210.tar.bz2 perlweeklychallenge-club-06d85752a276e45b5d4fa48366da43d17a244210.zip | |
Merge pull request #10592 from pokgopun/pwc282
pwc282 solution in go - fix ch-2
| -rw-r--r-- | challenge-282/pokgopun/go/ch-2.go | 15 |
1 files changed, 8 insertions, 7 deletions
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 } |
