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-#### Revert Rust Quest-03 Removed Subjects #2862

Merged
merged 1 commit into from
Jan 30, 2025
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
43 changes: 43 additions & 0 deletions subjects/is_anagram/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## is_anagram

### Instructions

Write a function called `is_anagram` that checks if one string is an anagram of another string. An anagram is a word or phrase formed by rearranging the letters of another, such as "listen" and "silent."

```rust
pub fn is_anagram(s1: &str, s2: &str) -> bool {
// Your code goes here
}
```

- `s1: &str`: The first input string.
- `s2: &str`: The second input string.

The function should return `true` if `s1` is an anagram of `s2`, and `false` otherwise.
Your task is to implement the `is_anagram` function to determine whether the two input strings are anagrams of each other.

### Usage

Here is a possible runner to test your function:

```rust
use is_anagram::is_anagram;

fn main() {
let s1 = "listen";
let s2 = "silent";

if is_anagram(s1, s2) {
println!("{} and {} are anagrams!", s1, s2);
} else {
println!("{} and {} are not anagrams.", s1, s2);
}
}
```

And its output:

```console
$ cargo run
listen and silent are anagrams!
```
38 changes: 38 additions & 0 deletions subjects/strings/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## strings

### Instructions

Create a **function** which receives a string slice and returns the number of characters in that string.

### Expected Function

```rust
pub fn char_length(s: &str) -> usize {
}
```

### Usage

Here is a program to test your function.

```rust
use strings::*;

fn main() {
println!("length of {} = {}", "❤", char_length("❤"));
println!("length of {} = {}", "形声字", char_length("形聲字"));
println!("length of {} = {}", "change", char_length("change"));
println!("length of {} = {}", "😍", char_length("😍"));
}
```

And its output

```console
$ cargo run
length of ❤ = 1
length of 形声字 = 3
length of change = 6
length of 😍 = 1
$
```
Loading