Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CON-2672 [CHECKPOINT-RESTRUCTURE] Update repeatalpha subject to ask for a function instead of a program #2587

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions subjects/repeatalpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,44 @@

### Instructions

Write a program called `repeat_alpha` that takes a `string` and displays it repeating each alphabetical character as many times as its alphabetical index.

The result must be followed by a newline (`'\n'`).
Write a function called `RepeatAlpha` that takes a `string` and displays it repeating each alphabetical character as many times as its alphabetical index.

`'a'` becomes `'a'`, `'b'` becomes `'bb'`, `'e'` becomes `'eeeee'`, etc...

If the number of arguments is different from 1, the program displays nothing.
### Expected Function

```go
func RepeatAlpha(s string) string {
}
```

### Usage

Here is a possible program to test your function:

```go
package main

import (
"fmt"
"piscine"
)

func main() {
fmt.Println(piscine.RepeatAlpha("abc"))
fmt.Println(piscine.RepeatAlpha("Choumi."))
fmt.Println(piscine.RepeatAlpha(""))
fmt.Println(piscine.RepeatAlpha("abacadaba 01!"))
}
```

And its output:

```console
$ go run . abc | cat -e
abbccc
$ go run . Choumi. | cat -e
$ go run . | cat -e
abbccc$
CCChhhhhhhhooooooooooooooouuuuuuuuuuuuuuuuuuuuummmmmmmmmmmmmiiiiiiiii.$
$ go run . "abacadaba 01!" | cat -e
abbacccaddddabba 01!$
$ go run .
$ go run . "" | cat -e
$
abbacccaddddabba 01!$
$
```
13 changes: 13 additions & 0 deletions subjects/repeatalpha/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package main

import (
MSilva95 marked this conversation as resolved.
Show resolved Hide resolved
"fmt"
"piscine"
)

func main() {
fmt.Println(piscine.RepeatAlpha("abc"))
fmt.Println(piscine.RepeatAlpha("Choumi."))
fmt.Println(piscine.RepeatAlpha(""))
fmt.Println(piscine.RepeatAlpha("abacadaba 01!"))
}
Loading