Browse Source

various clarifications and reformating

content-update
Chris 3 years ago
parent
commit
10abb32eee
  1. 8
      subjects/fibonacci2/README.md
  2. 8
      subjects/find_factorial/README.md
  3. 11
      subjects/groceries/README.md
  4. 6
      subjects/looping/README.md
  5. 22
      subjects/matrix_transposition/README.md
  6. 11
      subjects/reverse_string/README.md
  7. 25
      subjects/scalar/README.md
  8. 5
      subjects/speed_transformation/README.md
  9. 21
      subjects/temperature_conv/README.md

8
subjects/fibonacci2/README.md

@ -11,12 +11,10 @@ Each number in the series is calculated by the summing of the two previous ones
- so fibonacci(2) = 1 (1 + 1)
- and fibonnacci(4) = 3 (1 + 2)
### TNotions
### Notions
#### Primitives
- https://doc.rust-lang.org/stable/rust-by-example/primitives.html
#### Functions
- https://doc.rust-lang.org/stable/rust-by-example/fn.html
- [Primitives](https://doc.rust-lang.org/stable/rust-by-example/primitives.html)
- [Functions](https://doc.rust-lang.org/stable/rust-by-example/fn.html)
### Expected function

8
subjects/find_factorial/README.md

@ -2,7 +2,13 @@
### Instruccions
Complete the function `factorial` to return the factorial of a given number
Complete the **function** `factorial` to return the factorial of a given number.
As a reminder the factorial of a number is the product of all the integers from 1 to that number.
Example: the factorial of 6 (written 6!) is 1*2*3*4*5*6 = 720.
Do not forget the rules for 0 and 1.
### Expected Function

11
subjects/groceries/README.md

@ -2,13 +2,14 @@
### Instructions
Create a function called `insert` that inserts a new element at the end of the Vec
Create a **function** called `insert` that inserts a new element at the end of the `Vec`.
And another function `at_index` that returns the value found at the index passed as an argument
And another **function** `at_index` that returns the value found at the index passed as an argument.
### Notions
[Common Collections]( https://doc.rust-lang.org/stable/book/ch08-00-common-collections.html)
- [Common Collections](https://doc.rust-lang.org/stable/book/ch08-00-common-collections.html)
- [Vectors]https://doc.rust-lang.org/stable/book/ch08-01-vectors.html)
### Expected Functions
@ -16,7 +17,7 @@ And another function `at_index` that returns the value found at the index passed
pub fn insert(vec: &mut Vec<String>, val: String) {
}
pub fn at_index(vec: &Vec<String>, index: ) -> String {
pub fn at_index(vec: &Vec<String>, index: usize) -> String {
}
```
@ -25,7 +26,7 @@ pub fn at_index(vec: &Vec<String>, index: ) -> String {
Here is a possible program to test your function:
```rust
use groceries::{insert, at_index}
use groceries::{insert, at_index};
fn main() {
let mut groceries = vec![

6
subjects/looping/README.md

@ -2,11 +2,11 @@
### Instructions
Write a program that prints a riddle, receives input from the user and checks that the answer is correct
Write a **program** that prints a riddle, receives input from the user and checks that the answer is correct.
The program must allow indefinite number of trials and only quit after the correct answer is given
The program must allow indefinite number of trials and only quit after the correct answer is given.
Every time the user introduces an incorrect answer the program must print the riddle again and after the user gives the correct answer the program must print the number of tries that took to get the correct answer
Every time the user introduces an incorrect answer the program must print the riddle again and after the user gives the correct answer the program must print the number of tries that took to get the correct answer.
Riddle: I am the beginning of the end, and the end of time and space. I am essential to creation, and I surround every place. What am I?

22
subjects/matrix_transposition/README.md

@ -2,9 +2,9 @@
### Instructions
- Define the structure matrix as a tuple of tuples of `i32`'s
- Define the structure matrix as a tuple of 2 tuples of 2 `i32`'s.
- Define a function that calculate the transpose matrix of a 2x2 matrix.
- Define a function that calculates the transpose matrix of a 2x2 matrix.
- Note:
@ -17,13 +17,21 @@ Example:
( c d ) ( b d )
```
- Matrix must implement Debug, PartialEq and Eq. You can use derive
- Matrix must implement Debug, PartialEq and Eq. You can use derive.
- Remember that you're defining a library so you have to make public the elements that are going to be called from an external crate.
- Remember that you are defining a library so you have to make public the elements that are going to be called from an external crate.
### Notions
[Chapter 7]( https://doc.rust-lang.org/stable/book/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html )
- [Defining a struct](https://doc.rust-lang.org/stable/book/ch05-01-defining-structs.html)
- [The Tuple Type](https://doc.rust-lang.org/stable/book/ch03-02-data-types.html?highlight=accessing%20a%20tuple#compound-types)
- [Tuple Structs without Named Fields](https://doc.rust-lang.org/stable/book/ch05-01-defining-structs.html?highlight=tuple#using-tuple-structs-without-named-fields-to-create-different-types)
- [Adding Useful Functionality with Derived Traits](https://doc.rust-lang.org/stable/book/ch05-02-example-structs.html?highlight=debug%20deriv#adding-useful-functionality-with-derived-traits)
- [Chapter 7](https://doc.rust-lang.org/stable/book/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html)
### Expected Function
@ -37,6 +45,8 @@ pub fn transpose(m: Matrix) -> Matrix {
Here is a posible program to test your function
```rust
use matrix_transposition::transpose;
fn main() {
let matrix = Matrix((1, 3), (4, 5));
println!("Original matrix {:?}", matrix);
@ -44,7 +54,7 @@ fn main() {
}
```
And it's output:
And its output:
```console
student@ubuntu:~/[[ROOT]]/test$ cargo run

11
subjects/reverse_string/README.md

@ -2,7 +2,14 @@
### Instructions
Write a function `rev_str` that takes a `&str` as a parameter, and returns a string with its words reversed.
Write a **function** `rev_str` that takes a `&str` as a parameter, and returns a `String` with its letters reversed.
### Notions
- [Strings](https://doc.rust-lang.org/rust-by-example/std/str.html)
- [Primitive Type str](https://doc.rust-lang.org/std/primitive.str.html)
- [Primtive Type char](https://doc.rust-lang.org/std/primitive.char.html)
- [Module std::string](https://doc.rust-lang.org/std/string/index.html)
### Expected Functions
@ -27,7 +34,7 @@ fn main() {
}
```
And it's output:
And its output:
```console
student@ubuntu:~/[[ROOT]]/test$ cargo run

25
subjects/scalar/README.md

@ -11,7 +11,7 @@ Create the following **functions**, which each receives two parameters:
You **must** complete the Expected functions parameters data type accordingly (Replace the Xs)!
### Notions
- https://doc.rust-lang.org/book/ch03-02-data-types.html
- [Data Types](https://doc.rust-lang.org/book/ch03-02-data-types.html)
### Expected functions (Incomplete, you must precise the Data Types)
@ -38,30 +38,27 @@ pub fn rem(a: X, b: X) -> X {
}
```
### Usage (do not forget to comment the ERROR test if you want to use all the tests):
### Usage :
#### Note that There is no output for this test for you to train to comment accordingly.
```rust
use scalar::sum;
use scalar::diff;
use scalar::pro;
use scalar::quo;
use scalar::rem;
use scalar::*;
fn main() {
// sum
println!("sum : {}", sum(234, 2));
println!("sum : {}", sum(234, 2)); // 'sum : 236'
println!("sum : {}", sum(1, 255)); // 'ERROR: attempt to add with overflow'
// diff
println!("diff : {}", diff(234, 2));
println!("diff : {}", diff(234, 2)); // 'diff : 232'
println!("diff : {}", diff(-32768, 32766)); // 'ERROR: attempt to subtract with overflow'
// product
println!("pro : {}", pro(23, 2));
println!("pro : {}", pro(23, 2)); // 'pro : 46'
println!("pro : {}", pro(-128, 2)); // 'ERROR: attempt to multiply with overflow'
// quotient
println!("quo : {}", quo(22.0, 2.0));
println!("quo : {}", quo(-128.23, 2.0));
println!("quo : {}", quo(22.0, 2.0));// 'quo : 11'
println!("quo : {}", quo(-128.23, 2.0));// 'quo : -64.115'
// remainder
println!("rem : {}", rem(22.0, 2.0));
println!("rem : {}", rem(-128.23, 2.0));
println!("rem : {}", rem(22.0, 2.0));// 'rem : 0'
println!("rem : {}", rem(-128.23, 2.0));// 'rem : -0.22999573'
}
```

5
subjects/speed_transformation/README.md

@ -2,19 +2,20 @@
### Instructions
Create a function that receives the speed in km/h (kilometers per hour) and returns the equivalent in m/s (meters per second)
Create a **function** that receives the speed in km/h (kilometers per hour) and returns the equivalent in m/s (meters per second).
### Expected Function
```rust
pub fn km_per_hour_to_meters_per_second(km_h: f64) -> f64 {
(10.0 / 36.0) * km_h
}
```
### Usage
```rust
use speed_transformation::km_per_hour_to_meters_per_second;
fn main() {
let km_h = 100.0;
let m_s = km_per_hour_to_meters_per_second(km_h);

21
subjects/temperature_conv/README.md

@ -2,15 +2,17 @@
### Instructions
Write two functions to transform values of temperatures from celcius to fahrenheit and the other way arraound:
Write two functions which convert values of temperatures from `fahrenheit` to `celcius` and the other way around.
### Expected funcions
To pass this exercise you must use (9/5) in **both** functions.
### Expected functions
```rust
fn fahrenheit_to_celsius(f: f64) -> f64 {
pub fn fahrenheit_to_celsius(f: f64) -> f64 {
}
fn celsius_to_fahrenheit(c: f64) -> f64 {
pub fn celsius_to_fahrenheit(c: f64) -> f64 {
}
```
@ -19,9 +21,18 @@ fn celsius_to_fahrenheit(c: f64) -> f64 {
```rust
use temperature_conv::*;
fn main() {
println!("{} F = {} C", -459.67, fahrenheit_to_celsius(-459.67));
println!("{} C = {} F", 0.0, celsius_to_fahrenheit(0.0));
}
```
And its output:
```console
student@ubuntu:~/[[ROOT]]/test$ cargo run
-459.67 F = -273.15 C
0 C = 32 F
student@ubuntu:~/[[ROOT]]/test$
```

Loading…
Cancel
Save