Browse Source

fixing errors from augusto pr

pull/694/head
MSilva95 3 years ago
parent
commit
cfd12734d3
  1. 4
      subjects/bigger/README.md
  2. 6
      subjects/division_and_remainder/README.md
  3. 29
      subjects/simple_hash/README.md

4
subjects/bigger/README.md

@ -7,7 +7,7 @@ Create the function `bigger` that gets the biggest positive number in the `HashM
### Expected Function
```rust
fn bigger(h: HashMap<&str, i32>) -> i32 {
pub fn bigger(h: HashMap<&str, i32>) -> i32 {
}
```
@ -33,6 +33,6 @@ And its output
```console
student@ubuntu:~/[[ROOT]]/test$ cargo run
Is `thought` a permutation of `thougth`? = true
The biggest of the elements in the HashMap is 334
student@ubuntu:~/[[ROOT]]/test$
```

6
subjects/division_and_remainder/README.md

@ -7,7 +7,7 @@ Create a function divide that receives two i32 and returns a tuple in which the
### Expected Function
```rust
fn divide(x: i32, y: i32) -> (i32, i32) {
pub fn divide(x: i32, y: i32) -> (i32, i32) {
}
```
@ -17,12 +17,14 @@ fn divide(x: i32, y: i32) -> (i32, i32) {
Here is a program to test you're function
```rust
use division_and_remainder::division_and_remainder;
fn main() {
let x = 9;
let y = 4;
let (division, remainder) = divide(x, y);
println!(
"\t{}/{}: division = {}, remainder = {}",
"{}/{}: division = {}, remainder = {}",
x, y, division, remainder
);
}

29
subjects/simple_hash/README.md

@ -2,18 +2,20 @@
### Instructions
- Create the function `contain` that checks a `HashMap` to see if it contains the given key.
Create the function `contain` that checks a `HashMap` to see if it contains the given key.
- Create the function `remove` that removes a given key from the `HashMap`.
Create the function `remove` that removes a given key from the `HashMap`.
### Expected Functions
### Notions
- https://doc.rust-lang.org/rust-by-example/std/hash.html
### Expected functions
```rust
fn contain(h: HashMap<&str, i32>, s: &str) -> bool {
}
pub fn contain(h: &HashMap<&str, i32>, s: &str) -> bool {}
fn remove(mut h: HashMap<&str, i32>, s: &str) {
}
pub fn remove(h: &mut HashMap<&str, i32>, s: &str) {}
```
### Usage
@ -32,13 +34,17 @@ fn main() {
println!(
"Does the HashMap contains the name Roman? => {}",
contain(hash.clone(), "Roman")
contain(&hash, "Roman")
);
println!(
"Does the HashMap contains the name Katie? => {}",
contain(hash.clone(), "Katie")
contain(&hash, "Katie")
);
println!("Removing Robert {:?}", remove(&mut hash, "Robert"));
println!(
"Does the HashMap contains the name Robert? => {}",
contain(&hash, "Robert")
);
println!("Removing Robert {:?}", remove(hash.clone(), "Robert"));
println!("Hash {:?}", hash);
}
```
@ -50,6 +56,7 @@ student@ubuntu:~/[[ROOT]]/test$ cargo run
Does the HashMap contains the name Roman? => false
Does the HashMap contains the name Katie? => true
Removing Robert ()
Hash {"Daniel": 122, "Ashley": 333, "Robert": 14, "Katie": 334}
Does the HashMap contains the name Robert? => false
Hash {"Katie": 334, "Daniel": 122, "Ashley": 333}
student@ubuntu:~/[[ROOT]]/test$
```

Loading…
Cancel
Save