Browse Source

correction of typos, some small corrections

pull/997/head
davidrobert99 2 years ago
parent
commit
639680a498
  1. 6
      subjects/generics/README.md
  2. 16
      subjects/highest/README.md
  3. 8
      subjects/matrix/README.md
  4. 6
      subjects/matrix_mult/README.md
  5. 30
      subjects/sales/README.md
  6. 2
      subjects/slices_to_map/README.md
  7. 3
      subjects/spelling/README.md
  8. 2
      subjects/talking/README.md
  9. 14
      subjects/traits/README.md
  10. 6
      subjects/unwrap_or_expect/README.md

6
subjects/generics/README.md

@ -4,6 +4,12 @@
Write a **function** called `identity` which calculates the identity of a value (receives any data type and returns the same value).
### Notions
- [Generics](https://doc.rust-lang.org/book/ch10-01-syntax.html)
### Expected Function (signature to be completed)
```rust

16
subjects/highest/README.md

@ -21,13 +21,13 @@ These methods have to be written:
```rust
pub fn new(&[u32]) -> Self {}
pub fn List(&self) -> &[u32] {}
pub fn list(&self) -> &[u32] {}
pub fn Latest(&self) -> Option<u32> {}
pub fn latest(&self) -> Option<u32> {}
pub fn Highest(&self) -> Option<u32> {}
pub fn highest(&self) -> Option<u32> {}
pub fn Highest_Three(&self) -> Vec<u32> {}
pub fn highest_three(&self) -> Vec<u32> {}
```
### Usage
@ -45,10 +45,10 @@ struct Numbers<'a> {
fn main() {
let expected = [30, 500, 20, 70];
let n = Numbers::new(&expected);
println!("{:?}", n.List());
println!("{:?}", n.Highest());
println!("{:?}", n.Latest());
println!("{:?}", n.Highest_Three());
println!("{:?}", n.list());
println!("{:?}", n.highest());
println!("{:?}", n.latest());
println!("{:?}", n.highest_three());
}
```

8
subjects/matrix/README.md

@ -8,13 +8,15 @@ Define a data structure to represent a matrix of any size and implement the basi
- You have to use the definition of scalars done in the exercise: `lalgebra_scalar`
- Then define the associated function `identity` that returns the identity matrix of size n
- Define `new` that returns a matrix of size `1 x 1`
- Finally, define the associated function `zero` that returns a matrix of size `row x col` with all the positions filled by zeroes
- Then define the associated function `identity` that returns the identity matrix of size n
- Finally, define the associated function `zero` that returns a matrix of size `row x col` with all the positions filled by zeros
### Notions
[Traits](https://doc.rust-lang.org/book/ch19-03-advanced-traits.html)
- [Traits](https://doc.rust-lang.org/book/ch19-03-advanced-traits.html)
### Expected Functions and Structure

6
subjects/matrix_mult/README.md

@ -17,14 +17,14 @@ Define the matrix multiplication by implementing the std::ops::Mul for the type
### Expected Functions
```rust
impl Matrix<T> {
impl Matrix<T> {Esta errado o public, as funçoes row e col estao baralhadas com number of rows e number of colmns
pub fn number_of_cols(&self) -> usize {
}
pub fn rows(&self) -> usize {
pub fn number_of_row(&self, n: usize) -> usize {
}
pub fn number_of_row(&self, n: usize) -> Vec<T> {
pub fn rows(&self) -> Vec<T> {
}
pub fn col(&self, n: usize) -> Vec<T> {

30
subjects/sales/README.md

@ -5,11 +5,19 @@
In this exercise a shopping system will have to be created. There will be :
- A store that will save all the products in it
- A cart that will have `items`, that the client will buy, and a `receipt`
- A cart that will have `items` that the client will buy, and a `receipt`
This store is having a promotion, "Buy three and get one for free" (the free item must be the cheapest). The receipt must not present
any value as 0, so the promotion must be a reduction to be applied to all items instead.(see the example)
You will have to implement for the Cart structure the following **functions**:
- `new`, that will initialize the cart
- `insert_item`, that will receive a reference to `Store` and a `String`. Just like the name says you will
have to insert the item to the cart
- `generate_receipt`, that returns a vector of sorted floats. This function must generate the receipt just
like the example above, using the promotion. Also saving the result in the filed `receipt`.
### Notions
- [closures](https://doc.rust-lang.org/rust-by-example/fn/closures.html)
@ -17,8 +25,7 @@ any value as 0, so the promotion must be a reduction to be applied to all items
### Expected Function
```rust
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct Store {
pub products: Vec<(String, f32)>,
}
@ -28,43 +35,34 @@ impl Store {
}
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq)]
pub struct Cart {
// expected public fields
}
impl Cart {
pub fn new() -> Cart {}
pub fn insert_item(&mut self, s: &Store, ele: String) {}
pub fn get_prices(&self) -> Vec<f32> {}
pub fn generate_receipt(&mut self) -> Vec<f32> {}
}
```
### Example
`[1.23, 3.12, 23.1]` -> the receipt will be `[1.17, 2.98, 22.07]`
So `1.17 + 2.98 + 22.07 == 3.12 + 23.1 + 0`
Because `1.17 + 2.98 + 22.07 == 0 + 3.12 + 23.1`
This is a percentage calculation, and it can be applied to a set of three items.
If the client purchase 9 items, the promotion will be applied, three for free, to all items
|--------------| |---------------| |---------------|
`[1.23, 23.1, 3.12, 9.75, 1.75, 23.75, 2.75, 1.64, 15.23]` -> the receipt will be `[1.16, 1.55, 1.65, 2.6, 2.94, 9.2, 14.38, 21.8, 22.42]`
|--------| |--------| |--------|
`[3.12, 9.75, 1.75, 23.75, 2.75, 1.64, 15.23]` -> the receipt will be `[1.54, 1.65, 2.59, 2.94, 9.18, 14.34, 22.36]`
and so on... (hint: Closures is the way)
You will have to implement for the Cart structure the following **functions**:
- `new`, that will initialize the cart
- `insert_item`, that will receive a reference to `Store` and a `String`. Just like the name says you will
have to insert the item to the cart
- `generate_receipt`, that returns a vector of sorted floats. This function must generate the receipt just
like the example above, using the promotion. Also saving the result in the filed `receipt`.
### Usage

2
subjects/slices_to_map/README.md

@ -2,7 +2,9 @@
### Instructions:
Create a function that borrows two slices and returns a hashmap where the first slice represents the keys and the second represents the values.
- If the slices have different sizes, the function should return the hashmap with the size of the smallest list.
### Expected Function

3
subjects/spelling/README.md

@ -22,9 +22,6 @@ Only positive numbers will be tested. (Up to a million).
- [patterns](https://doc.rust-lang.org/book/ch18-00-patterns.html)
### Dependencies
rand = "0.7"
### Expected function

2
subjects/talking/README.md

@ -8,7 +8,7 @@ His answers will be created by you following the rules below.
- He answers "There is no need to yell, calm down!" if you yell at him, for example "LEAVE ME ALONE!"
(it is considered yelling when the sentence is all written in capital letters).
- He answers "Sure" if you ask him something without yelling, for example "Is everything ok with you?"
- He answers "Sure." if you ask him something without yelling, for example "Is everything ok with you?"
- He answers "Quiet, I am thinking!" if you yell a question at him. "HOW ARE YOU?"
- He says "Just say something!" if you address him without actually saying anything.
- He answers "Interesting" to anything else.

14
subjects/traits/README.md

@ -6,10 +6,10 @@ Imagine you are designing a new video game and you have to create food that the
There are two types of food for now:
- Fruit: increase the strength by 4 unit per each kilogram of fruit consumed.
- Meat: has the weight in kilograms -> `weight_in_kg` (which is the weight of the whole piece) and the fat_content which corresponds to the percentage of the weight which is pure fat (the rest is consider protein) each kilogram of protein gives 4 units of `strenght` and each kilogram of fat gives 9 units of `strength`.
- Fruit: increase the strength by 4 units per each kilogram of fruit consumed.
- Meat: has the weight in kilograms `weight_in_kg` (which is the weight of the whole piece) and the `fat_content` which corresponds to the percentage of the weight which is pure fat (the rest is considered protein) each kilogram of protein gives 4 units of `strength` and each kilogram of fat gives 9 units of `strength`.
Define the `Food` trait for `Fruit` and `Meat`. The method require method `gives()` represents the energy that the food provides.
Define the `Food` trait for `Fruit` and `Meat`. The required method `gives()` represents the energy that the food provides.
Implement the `std::fmt::Display` trait for `Player` structure in a way that when using the template `{}` inside a println! macro it will print:
@ -17,6 +17,12 @@ Implement the `std::fmt::Display` trait for `Player` structure in a way that whe
- In the second line the strength, score and the money
- In the third line the weapons
### Notions
- [Traits](https://doc.rust-lang.org/book/ch10-02-traits.html)
### Expected Functions and Structures
```rust
@ -45,7 +51,7 @@ impl Player {
}
pub trait Food {
fn gives(&self) -> u32;
fn gives(&self) -> f64;
}
impl Food for Fruit {

6
subjects/unwrap_or_expect/README.md

@ -8,11 +8,11 @@ return a tuple with a string, stating the error, and a vector with the elements
The objective is to execute the `odd_to_even` function and handle the error returned by it.
Create the following functions which receives a vector :
Create the following functions which receive a vector:
- `expect` which returns the error adding the string "ERROR"
- `expect` which returns the error adding the string "ERROR "
- `unwrap_or` which in case of error returns an empty vector
- `unwrap_err` which returns error if its `Ok` and returns the
- `unwrap_err` which panics if the value is `Ok` and returns the
string containing the error in case of `Err`
- `unwrap` which unwraps the `Result`
- `unwrap_or_else` which in case of error returns the vector of elements that caused the error

Loading…
Cancel
Save