-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(repeatalpha): udpate test according to new subject
- Loading branch information
1 parent
d344053
commit 0c11292
Showing
3 changed files
with
35 additions
and
42 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package solutions | ||
|
||
import "unicode" | ||
|
||
func RepeatAlpha(s string) string { | ||
res := "" | ||
for _, r := range s { | ||
if unicode.IsLetter(r) { | ||
rep := unicode.ToLower(r) - 'a' + 1 | ||
for i := 0; i < int(rep); i++ { | ||
res += string(r) | ||
} | ||
} else { | ||
res += string(r) | ||
} | ||
} | ||
return res | ||
} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,26 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/01-edu/go-tests/lib/challenge" | ||
"github.com/01-edu/go-tests/lib/chars" | ||
"github.com/01-edu/go-tests/lib/random" | ||
"fmt" | ||
"os" | ||
student "student" | ||
) | ||
|
||
func main() { | ||
args := []string{ | ||
"", | ||
"Hello", | ||
"World", | ||
"Home", | ||
"Theorem", | ||
"Choumi is the best cat", | ||
"abracadaba 01!", | ||
"abc", | ||
"MaTheMatiCs", | ||
testCases := []struct { | ||
in string | ||
want string | ||
}{ | ||
{"abc", "abbccc"}, | ||
{"Choumi.", "CCChhhhhhhhooooooooooooooouuuuuuuuuuuuuuuuuuuuummmmmmmmmmmmmiiiiiiiii."}, | ||
{"", ""}, | ||
{"abacadaba 01!", "abbacccaddddabba 01!"}, | ||
} | ||
|
||
args = append(args, random.StrSlice(chars.Alnum)...) | ||
|
||
for _, v := range args { | ||
challenge.Program("repeatalpha", v) | ||
for _, tc := range testCases { | ||
got := student.RepeatAlpha(tc.in) | ||
if got != tc.want { | ||
fmt.Printf("RepeatAlpha(%q) = %q instead of %q\n", tc.in, got, tc.want) | ||
os.Exit(1) | ||
} | ||
} | ||
challenge.Program("repeatalpha") | ||
challenge.Program("repeatalpha", "", "") | ||
} |