From 65a0fd7f41d65aeee6051416cf6862f0e5d76679 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 10 Feb 2021 05:15:46 +0000 Subject: [PATCH] formatting and fixing of examples --- subjects/bigger/README.md | 8 +++++++- subjects/collect/README.md | 8 +++++--- subjects/simple_hash/README.md | 14 +++++++------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/subjects/bigger/README.md b/subjects/bigger/README.md index fbd38a80..9687e5b0 100644 --- a/subjects/bigger/README.md +++ b/subjects/bigger/README.md @@ -4,6 +4,10 @@ Create the function `bigger` that gets the biggest positive number in the `HashMap`. +### Notions + +[hash maps](https://doc.rust-lang.org/book/ch08-03-hash-maps.html) + ### Expected Function ```rust @@ -16,9 +20,11 @@ pub fn bigger(h: HashMap<&str, i32>) -> i32 { Here is a program to test your function. ```rust +use std::collections::HashMap; use bigger::bigger; + fn main() { - + let mut hash = HashMap::new(); hash.insert("Daniel", 122); hash.insert("Ashley", 333); diff --git a/subjects/collect/README.md b/subjects/collect/README.md index 89c372d9..443d37cb 100644 --- a/subjects/collect/README.md +++ b/subjects/collect/README.md @@ -2,12 +2,12 @@ ### Instructions -Implement the function bubble_sort which receives a vector Vec and return the same vector but in increasing order using the bubble sort algorithm +Implement the **function** `bubble_sort` which receives a vector Vec and returns the same vector but in increasing order using the bubble sort algorithm. ### Expected Function ```rust -fn bubble_sort(vec: &mut Vec) { +pub fn bubble_sort(vec: &mut Vec) { } ``` @@ -16,6 +16,8 @@ fn bubble_sort(vec: &mut Vec) { Here is a program to test your function. ```rust +use collect::*; + fn main() { let ref mut v = vec![3, 2, 4, 5, 1, 7]; let mut b = v.clone(); @@ -27,7 +29,7 @@ fn main() { } ``` -And its output +And its output: ```console student@ubuntu:~/[[ROOT]]/test$ cargo run diff --git a/subjects/simple_hash/README.md b/subjects/simple_hash/README.md index a90c4c1f..6af5e31b 100644 --- a/subjects/simple_hash/README.md +++ b/subjects/simple_hash/README.md @@ -2,9 +2,9 @@ ### Instructions -Create the function `contain` that checks a `HashMap` to see if it contains the given key. +Create a **function** `contain` that checks a `HashMap` to see if it contains a given key. -Create the function `remove` that removes a given key from the `HashMap`. +Create a **function** `remove` that removes a given key from the `HashMap`. ### Notions @@ -23,7 +23,7 @@ pub fn remove(h: &mut HashMap<&str, i32>, s: &str) {} Here is a program to test your function. ```rust -use simple_hash::simple_hash; +use simple_hash::*; use std::collections::HashMap; fn main() { @@ -35,16 +35,16 @@ fn main() { println!( "Does the HashMap contains the name Roman? => {}", - contain(&hash, "Roman") + contain(hash.clone(), "Roman") ); println!( "Does the HashMap contains the name Katie? => {}", - contain(&hash, "Katie") + contain(hash.clone(), "Katie") ); - println!("Removing Robert {:?}", remove(&mut hash, "Robert")); + println!("Removing Robert {:?}", remove(hash.clone(), "Robert")); println!( "Does the HashMap contains the name Robert? => {}", - contain(&hash, "Robert") + contain(hash.clone(), "Robert") ); println!("Hash {:?}", hash); }