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.

54 lines
1.2 KiB

## spelling
### Instructions
In this exercise a number between 0 and 1000000 will be generated.
Your purpose is to create the function `spell` that will spell the numbers generated.
So, if the program generates the number:
- 1 your function will return the string "one"
- 14 your function will return the string "fourteen".
- 96 your function will return the string "ninety-six"
- 100 your function will return the string "one hundred".
- 101 your function will return the string "one hundred one"
- 348 your function will return the string "one hundred twenty-three"
- 1002 your function will return the string "one thousand two".
- 1000000 your function will return the string "one million"
4 years ago
Only positive numbers will be tested. (Up to a million).
### Notions
4 years ago
- [patterns](https://doc.rust-lang.org/book/ch18-00-patterns.html)
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
student@ubuntu:~/[[ROOT]]/test$ cargo run
three hundred forty-eight
nine thousand nine hundred ninety-six
student@ubuntu:~/[[ROOT]]/test$
```