From b499b84ce3cbd175936df9e01608bbe83a7585e0 Mon Sep 17 00:00:00 2001 From: jrosendo Date: Tue, 6 Dec 2022 16:18:31 +0000 Subject: [PATCH] fix(getascii): replaced wrong exercise --- subjects/count-character/README.md | 43 ------------------------------ subjects/get-ascii/README.md | 35 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 43 deletions(-) delete mode 100644 subjects/count-character/README.md create mode 100644 subjects/get-ascii/README.md diff --git a/subjects/count-character/README.md b/subjects/count-character/README.md deleted file mode 100644 index ebe4d5bad..000000000 --- a/subjects/count-character/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# count-character - -### Instructions -write a function that takes a string and a character as arguments and returns 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 - -```go -package main - -import ( - "fmt" - "piscine" -) - -func main() { - fmt.Println(piscine.CountChar("Hello World", 'l')) - fmt.Println(piscine.CountChar("5 balloons",5)) - fmt.Println(piscine.CountChar(" ", ' ')) - fmt.Println(piscine.CountChar("The 7 deadly sins", '7')) -} -``` - -And its output : - -```console -$ go run . -3 -0 -1 -1 -``` - diff --git a/subjects/get-ascii/README.md b/subjects/get-ascii/README.md new file mode 100644 index 000000000..0e04afbbb --- /dev/null +++ b/subjects/get-ascii/README.md @@ -0,0 +1,35 @@ +# getascii + +### Instructions + +Write a program that takes a character as an argument, and displays the correspondent ASCII code followed by a newline. + +- If the input is more than one character, return a newline `\n`. +- If the number of arguments is less than 1, return a newline `\n`. +- If the number of arguments is more than 1, return a newline `\n`. +- If the the input is a non ascii character, return a newline `\n`. + +### Usage + +```console +console +$ go run . "W" | cat -e +87$ +$ +$ go run . "W" "Q" "T" | cat -e +$ +$ +$ go run . "^" | cat -e +94$ +$ +$ go run . 7 | cat -e +55$ +$ +$ go run . a | cat -e +97$ +$ +$ go run . "Stay Home" | cat -e +$ +$ go run . +$ +```