From f6251d8dfef4158121d4229c587a29c40332e65f Mon Sep 17 00:00:00 2001 From: eslopfer Date: Wed, 9 Nov 2022 21:05:59 +0000 Subject: [PATCH] docs(smallest): add readme with description of subject --- subjects/smallest/README.md | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 subjects/smallest/README.md diff --git a/subjects/smallest/README.md b/subjects/smallest/README.md new file mode 100644 index 00000000..1b861084 --- /dev/null +++ b/subjects/smallest/README.md @@ -0,0 +1,44 @@ +## smallest + +### Instructions + +Create a function named `smallest` that gets the smallest positive number in the `HashMap`. + +### Expected Function + +```rust +pub fn smallest(h: HashMap<&str, i32>) -> i32 { +} +``` + +### Usage + +Here is a program to test your function. + +```rust +use std::collections::HashMap; +use smallest::smallest; + +fn main() { + + let mut hash = HashMap::new(); + hash.insert("Cat", 122); + hash.insert("Dog", 333); + hash.insert("Elephant", 334); + hash.insert("Gorilla", 14); + + println!("The smallest of the elements in the HashMap is {}", smallest(hash)); +} +``` + +And its output + +```console +$ cargo run +The smallest of the elements in the HashMap is 14 +$ +``` + +### Notions + +- [hash maps](https://doc.rust-lang.org/book/ch08-03-hash-maps.html)