You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
963 B

## string_permutation
### Instructions
4 years ago
Define the **function** `is_permutation` that returns true if:
- the string `s1` is a permutation of `s2`, otherwise it returns false.
- `s1` is a permutation of `s2` if all the elements in `s1` appear the same number of times in `s2` and all the characters in `s1` appear in `s2` even if they are in different order.
### Notions
[hash maps](https://doc.rust-lang.org/book/ch08-03-hash-maps.html)
### Expected Function
```rust
4 years ago
pub fn is_permutation(s1: &str, s2: &str) -> bool {
}
```
### Usage
Here is a program to test your function.
```rust
4 years ago
use string_permutation::*;
fn main() {
let word = "thought";
let word1 = "thougth";
println!(
"Is `{}` a permutation of `{}`? = {}",
word,
word1,
is_permutation(word, word1)
);
}
```
And its output
```console
student@ubuntu:~/string_permutation/test$ cargo run
Is `thought` a permutation of `thougth`? = true
student@ubuntu:~/string_permutation/test$
```