From ee5349a851e0e7f5975c494b040823bee72c8939 Mon Sep 17 00:00:00 2001 From: hamza Date: Tue, 14 Jun 2022 10:59:01 +0100 Subject: [PATCH] subject(camelTosnackCase): add readme --- subjects/cameltosnakecase/README.md | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 subjects/cameltosnakecase/README.md diff --git a/subjects/cameltosnakecase/README.md b/subjects/cameltosnakecase/README.md new file mode 100644 index 00000000..ac9c1ed5 --- /dev/null +++ b/subjects/cameltosnakecase/README.md @@ -0,0 +1,43 @@ +## Camel-to-snake-case + +### Instructions + +Write a function that converts a string from a camel case to a snake case. +- If the string is empty, return an empty string. +- If the string is not a camel case, return the string unchanged. +- If the string is a camel case, return the snake case version of the string. + +### Expected function +```go +func CamelToSnakeCase(s string) string{ + //Your code here +} +``` + +### Usage + +```go +package main + +import "fmt" + +func main() { + fmt.Println(CamelToSnakeCase("HelloWorld")) + fmt.Println(CamelToSnakeCase("heloWorld")) + fmt.Println(CamelToSnakeCase("CamelToSnakeCase")) + fmt.Println(CamelToSnakeCase("132322")) + fmt.Println(CamelToSnakeCase("")) +} +``` + +and the output should be: + +```console +$ go run . | cat -e +Hello_World$ +helo_World$ +Camel_To_Snake_Case$ +132322$ +$ +``` +