From 606cb972c3505ba69bc622caed2c75bf9fb9643a Mon Sep 17 00:00:00 2001 From: Tiago Collot Date: Wed, 24 Aug 2022 20:13:59 +0100 Subject: [PATCH] feat: add new README.md for loafofbread exercise --- subjects/loafofbread/README.md | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 subjects/loafofbread/README.md diff --git a/subjects/loafofbread/README.md b/subjects/loafofbread/README.md new file mode 100644 index 00000000..39ad4e09 --- /dev/null +++ b/subjects/loafofbread/README.md @@ -0,0 +1,44 @@ +# loafofbread + +### Instructions + +Write a function `LoafOfBread()` that takes a string and returns another one with words of 5 characters and skips the next character followed by newline `\n`. + +- If there is a space in the middle of a word it should ignore it and get the first character until getting to a length of 5. +- If the string less than 5 characters returns "Invalid Output\n" +- +### Expected function + +```go +func LoafOfBread(str string) string { +} +``` + +### Usage + +Here is a possible program to test your function : + +```go +package main + +import "fmt" + +func main() { + LoafOfBread("deliciousbread") + LoafOfBread("This is a loaf of bread") + LoafOfBread("Bread crumbles") + fmt.Print(LoafOfBread("deliciousbread")) + fmt.Print(LoafOfBread("This is a loaf of bread")) + fmt.Print(LoafOfBread("loaf")) +} +``` + +And its output : + +```go +$ go run . | cat -e +delic ousbr ad$ +Thisi ashor sente ce$ +This s a l af of bread$ +Invalid Output$ +```