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

docs(rust piscine): Add invert_sentence optional exercise subject #2221

Merged
Merged
Changes from 1 commit
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
36 changes: 36 additions & 0 deletions subjects/invert_sentence/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## invert_sentence

### Instructions

Write a function called `invert_sentence` that takes a string as input and returns the words in the string in reverse order.
In other words, the function should take a sentence as input and return a new sentence with the words reversed.

```rust
pub fn invert_string(string: &str) -> String {
// Your code goes here
}
```

### Usage

Here is a possible runner to test your function :

```rust
use invert_sentence::invert_sentence;

fn main() {
println!("{}", invert_sentence("Rust is Awesome"));
println!("{}", invert_sentence(" word1 word2 "));
mikysett marked this conversation as resolved.
Show resolved Hide resolved
println!("{}", invert_sentence("Hello, World!"));
}
```

And its output:

```console
$ cargo run | cat -e
Awesome is Rust$
word2 word1$
World! Hello,$
$
```