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.

53 lines
903 B

## spelling
### Instructions
In this exercise, you'll create the function `spell` that will spell a generated number.
Here are some examples of what your function should return:
- `1` -> `"one"`
- `14` -> `"fourteen".`
- `96` -> `"ninety-six"`
- `100` -> `"one hundred".`
- `101` -> `"one hundred one"`
- `348` -> `"one hundred twenty-three"`
- `1002` -> `"one thousand two".`
- `1000000` -> `"one million"`
> Only positive numbers will be tested, up to `"one million"`.
4 years ago
### Expected function
```rust
4 years ago
pub fn spell(n: u64) -> String {
}
```
### Usage
Here is a program to test your function.
```rust
4 years ago
use spelling::*;
fn main() {
println!("{}", spell(348));
println!("{}", spell(9996));
}
```
4 years ago
And its output:
```console
$ cargo run
three hundred forty-eight
nine thousand nine hundred ninety-six
$
```
### Notions
- [patterns](https://doc.rust-lang.org/book/ch18-00-patterns.html)