From 79427641194115f5f4c4f62c832c8a9b14a238fe Mon Sep 17 00:00:00 2001 From: jotapero Date: Thu, 20 Oct 2022 16:29:54 +0100 Subject: [PATCH] fix(getAlpha): fix removed file - readded removed file to renew branch --- subjects/count-character/README.md | 42 ++++++++++++++++++++++++++++++ subjects/get-alpha/README.md | 23 ++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 subjects/count-character/README.md create mode 100644 subjects/get-alpha/README.md diff --git a/subjects/count-character/README.md b/subjects/count-character/README.md new file mode 100644 index 00000000..71b8b3ff --- /dev/null +++ b/subjects/count-character/README.md @@ -0,0 +1,42 @@ +## Count-Characters + +### Instructions + +Write a function that, given a string and a character as arguments, returns an int representing the number of times the character appears in the string. + +- if the character is not in the string return 0 +- if the string is empty return 0 + +### Expected Function + +```go +func CountChar(str string, c rune) int { +} +``` + +### Usage + +Here is a possible program to test your function: + +```go +package main + +import "fmt" + +func main() { + fmt.Println(CountChar("Hello World", 'l')) + fmt.Println(CountChar("5 balloons",5)) + fmt.Println(CountChar(" ", ' ')) //The first argument contains space and tabulation. + fmt.Println(CountChar("The 7 deadly sins", '7')) +} +``` + +And its output : + +```console +$ go run . +3 +0 +1 +1 +``` \ No newline at end of file diff --git a/subjects/get-alpha/README.md b/subjects/get-alpha/README.md new file mode 100644 index 00000000..c81d7d9e --- /dev/null +++ b/subjects/get-alpha/README.md @@ -0,0 +1,23 @@ +# getalpha + +### Instructions + +write a program that takes an integer [0-127] in parameter and returns the char that match the index of the integer in the ASCII table follwed by newline, follwed by newline. + +- If the integer above 127 or less than 0 returns newline. +- If it's not a number returns newline. +- If tge number of arguments above 1 return newline. + +### Usage + + +```go +$ go run . | cat -e +$ +$ go run . "98" | cat -e +a +$ go run . "95" | cat -e +; +$ go run . "95" "102" | cat -e +$ +``` \ No newline at end of file