Browse Source

DEV-3175-new-go-exercise-printfirsthalf (#1348)

* add subject for localhost

* fix the name

* add hints && add conditions

* Update README.md

* add cgi condition

* add condition of http code and redirections

* Update README.md

* Localhost Subject

* feat: Update the audir

* feat: Update the audit

* Add bonus part

* Update README.md

* add condition in bonus part

* Update README.md

* Update README.md

* feat: subject

* feat: subject

* feat: subject of Printfirsthalf

* feat: subject of Printfirsthalf

* Update README.md

* feat: subject of Printfirsthalf

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Correct  a Typo

* Update README.md

* docs(printfirsthalf): fix subject

- fix exercise header
- upgrade instructions
- add missig import 'fmt'/'piscine'
- fix console
- fix white-spaces and indentation

* docs(printfirsthalf): instructions upgrade

* feat(go-checkpoints): add new exercise retainfirsthalf

the exercise has been renamed from printfirsthalf to retain first half

* docs(retainfirsthalf): directory name changed accordingly to new name

---------

Co-authored-by: hamza <hamzaelkhatri@gmail.com>
Co-authored-by: Hamza elkhatri <40549481+Hamzaelkhatri@users.noreply.github.com>
Co-authored-by: Tiago Collot <collot.tiago1@gmail.com>
Co-authored-by: Michele Sessa <mikysett@gmail.com>
pull/2069/head
Zainab Dnaya 11 months ago committed by GitHub
parent
commit
8210a25c27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 47
      subjects/retainfirsthalf/README.md

47
subjects/retainfirsthalf/README.md

@ -0,0 +1,47 @@
## retainfirsthalf
### Instructions
Write a function called `RetainFirstHalf()` that takes a `string` as an argument and returns the first half of this `string`.
- If the length of the `string` is odd, round it down.
- If the `string` is empty, return an empty string.
- If the `string` length is equal to one, return the string.
### Expected function
```go
func RetainFirstHalf(str string) string {
}
```
### Usage
Here is a possible program to test your function:
```go
package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(solutions.RetainFirstHalf("This is the 1st halfThis is the 2nd half"))
fmt.Println(solutions.RetainFirstHalf("A"))
fmt.Println(solutions.RetainFirstHalf(""))
fmt.Println(solutions.RetainFirstHalf("Hello World"))
}
```
And its output:
```console
$ go run . | cat -e
This is the 1st half$
A$
$
Hello$
```
Loading…
Cancel
Save