Browse Source

formatting and fixing of examples

content-update
Chris 3 years ago
parent
commit
65a0fd7f41
  1. 8
      subjects/bigger/README.md
  2. 8
      subjects/collect/README.md
  3. 14
      subjects/simple_hash/README.md

8
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);

8
subjects/collect/README.md

@ -2,12 +2,12 @@
### Instructions
Implement the function bubble_sort which receives a vector Vec<i32> and return the same vector but in increasing order using the bubble sort algorithm
Implement the **function** `bubble_sort` which receives a vector Vec<i32> and returns the same vector but in increasing order using the bubble sort algorithm.
### Expected Function
```rust
fn bubble_sort(vec: &mut Vec<i32>) {
pub fn bubble_sort(vec: &mut Vec<i32>) {
}
```
@ -16,6 +16,8 @@ fn bubble_sort(vec: &mut Vec<i32>) {
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

14
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);
}

Loading…
Cancel
Save