public/subjects/bigger/README.md

45 lines
756 B
Markdown
Raw Permalink Normal View History

## bigger
### Instructions
2022-05-24 14:42:02 +00:00
Create a function named `bigger` that gets the biggest positive number in the `HashMap`.
### Expected Function
```rust
2020-12-29 12:53:44 +00:00
pub fn bigger(h: HashMap<&str, i32>) -> i32 {
}
```
### Usage
Here is a program to test your function.
```rust
2021-02-10 05:15:46 +00:00
use std::collections::HashMap;
use bigger::bigger;
2021-02-10 05:15:46 +00:00
fn main() {
2021-02-10 05:15:46 +00:00
let mut hash = HashMap::new();
hash.insert("Daniel", 122);
hash.insert("Ashley", 333);
hash.insert("Katie", 334);
hash.insert("Robert", 14);
println!("The biggest of the elements in the HashMap is {}", bigger(hash));
}
```
And its output
```console
$ cargo run
2020-12-29 12:53:44 +00:00
The biggest of the elements in the HashMap is 334
$
```
2022-05-24 14:42:02 +00:00
### Notions
- [hash maps](https://doc.rust-lang.org/book/ch08-03-hash-maps.html)