Skip to content

Commit

Permalink
Update instructions append for anagram (#1848)
Browse files Browse the repository at this point in the history
- Remove some performance considerations. These are basically giving
away the implementation. Also, not every student might want to focus on
performance. Such considerations may be better suited for approaches
articles.

- Remove non-Rust-related hints. These are pretty much covered by the
instructions. I guess these were lacking at some point, but updated in
the meantime.

- Move the most important hint about lifetimes to the top.
  • Loading branch information
senekor authored Jan 10, 2024
1 parent f3eb863 commit c5fc8e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
4 changes: 4 additions & 0 deletions exercises/practice/anagram/.docs/hints.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## General

The solution is case insensitive, which means `"WOrd"` is the same as `"word"` or `"woRd"`.
It may help to take a peek at the [std library](https://doc.rust-lang.org/std/primitive.char.html) for functions that can convert between them.
13 changes: 3 additions & 10 deletions exercises/practice/anagram/.docs/instructions.append.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
# Hints
# Instructions append

The solution is case insensitive, which means `"WOrd"` is the same as `"word"` or `"woRd"`. It may help to take a peek at the [std library](https://doc.rust-lang.org/std/primitive.char.html) for functions that can convert between them.

The solution cannot contain the input word. A word is always an anagram of itself, which means it is not an interesting result. Given `"hello"` and the list `["hello", "olleh"]` the answer is `["olleh"]`.

You are going to have to adjust the function signature provided in the stub in order for the lifetimes to work out properly. This is intentional: what's there demonstrates the basics of lifetime syntax, and what's missing teaches how to interpret lifetime-related compiler errors.

Try to limit case changes. Case changes are expensive in terms of time, so it's faster to minimize them.

If sorting, consider [sort_unstable](https://doc.rust-lang.org/std/primitive.slice.html#method.sort_unstable) which is typically faster than stable sorting. When applicable, unstable sorting is preferred because it is generally faster than stable sorting and it doesn't allocate auxiliary memory.
You are going to have to adjust the function signature provided in the stub in order for the lifetimes to work out properly.
This is intentional: what's there demonstrates the basics of lifetime syntax, and what's missing teaches how to interpret lifetime-related compiler errors.

0 comments on commit c5fc8e1

Please sign in to comment.