public/subjects/scores/README.md

53 lines
1.0 KiB
Markdown
Raw Permalink Normal View History

2020-12-29 10:40:42 +00:00
## score
### Instructions
2022-05-30 11:13:44 +00:00
Lets play a little.
2020-12-29 10:40:42 +00:00
2022-05-30 11:13:44 +00:00
Create a function named `score` that given a string, computes the score for that given string as a `u64`.
Each letter has a value, you just have to sum the values of the letters in the given string.
2020-12-29 10:40:42 +00:00
2021-03-16 01:56:54 +00:00
You will need these:
2020-12-29 10:40:42 +00:00
| Letter | Value |
| ---------------------------- | :---: |
| A, E, I, O, U, L, N, R, S, T | 1 |
| D, G | 2 |
| B, C, M, P | 3 |
| F, H, V, W, Y | 4 |
| K | 5 |
| J, X | 8 |
| Q, Z | 10 |
### Expected functions
2022-05-30 11:13:44 +00:00
> You'll need to work out the function signature for yourself.
2020-12-29 10:40:42 +00:00
### Usage
Here is a program to test your function.
```rust
2021-03-16 01:56:54 +00:00
use scores::*;
2020-12-29 14:38:26 +00:00
2020-12-29 10:40:42 +00:00
fn main() {
println!("{}", score("a"));
println!("{}", score("ã ê Á?"));
println!("{}", score("ThiS is A Test"));
}
```
And its output
```console
$ cargo run
2020-12-29 10:40:42 +00:00
1
0
14
$
2020-12-29 10:40:42 +00:00
```
2022-05-30 11:13:44 +00:00
### Notions
- [patterns](https://doc.rust-lang.org/book/ch18-00-patterns.html)