Browse Source

update exam exercises

pull/1099/head
davidrobert99 2 years ago committed by davhojt
parent
commit
167027b977
  1. 5
      subjects/blood_types_s/README.md
  2. 33
      subjects/brackets_matching/README.md
  3. 10
      subjects/brain_fuck/README.md
  4. 6
      subjects/display_table/README.md
  5. 16
      subjects/filter_table/README.md
  6. 2
      subjects/flat_tree/README.md
  7. BIN
      subjects/matrix_determinant/determinant-of-a-3x3-matrix-formula-3.png

5
subjects/blood_types_s/README.md

@ -33,12 +33,12 @@ pub enum Antigen {
}
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
enum RhFactor {
pub enum RhFactor {
Positive,
Negative,
}
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone)]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
pub struct BloodType {
pub antigen: Antigen,
pub rh_factor: RhFactor,
@ -52,6 +52,7 @@ impl BloodType {
}
pub fn recipients(&self) -> Vec<Self> {
}
}
```

33
subjects/brackets_matching/README.md

@ -2,24 +2,35 @@
### Instructions
Write a program that takes an undefined number of `string` in arguments. For each argument, if the expression is correctly bracketed, the program prints on the standard output `OK` followed by a newline (`'\n'`), otherwise it prints `Error` followed by a newline.
Write a `program` that takes an undefined number of `string` in arguments. For each argument, if the expression is correctly bracketed, the program prints on the standard output `OK` followed by a newline (`'\n'`), otherwise it prints `Error` followed by a newline.
Symbols considered as brackets are parentheses `(` and `)`, square brackets `[` and `]` and curly braces `{` and `}`. Every other symbols are simply ignored.
An opening bracket must always be closed by the good closing bracket in the correct order. A `string` which does not contain any bracket is considered as a correctly bracketed `string`.
An opening bracket must always be closed by the good closing bracket in the correct order. A `string` which does not contain any bracket is considered as a correctly bracketed.
If there is no argument, the program must print nothing.
For receiving arguments from the command line you should use something like:
```rust
fn main() {
let args: Vec<String> = std::env::args().collect();
//...
}
```
### Usage
```console
$ go run . '(johndoe)' | cat -e
OK$
$ go run . '([)]' | cat -e
Error$
$ go run . '' '{[(0 + 0)(1 + 1)](3*(-1)){()}}' | cat -e
OK$
OK$
$ go run .
$
$ cargo run '(johndoe)' | cat -e
OK
$ cargo run '([)]' | cat -e
Error
$ cargo run
$ cargo run '' '{[(0 + 0)(1 + 1)](3*(-1)){()}}' | cat -e
OK
OK
```

10
subjects/brain_fuck/README.md

@ -5,7 +5,7 @@
Write a `Brainfuck` interpreter program.
The source code will be given as first parameter.
The code will always be valid, with less than 4096 operations.
`Brainfuck` is a minimalist language. It consists of an array of bytes (in this exercice 2048 bytes) all initialized with zero, and with a pointer to its first byte.
`Brainfuck` is a minimalist language. It consists of an array of bytes (in this exercise 2048 bytes) all initialized with zero, and with a pointer to its first byte.
Every operator consists of a single character :
@ -22,11 +22,11 @@ Any other character is a comment.
For receiving arguments from the command line you should use something like:
```rust
fn main() {
let args: Vec<String> = std::env::args().collect();
fn main() {
let args: Vec<String> = std::env::args().collect();
brain_fuck(&args[1]);
}
brain_fuck(&args[1]);
}
```

6
subjects/display_table/README.md

@ -2,9 +2,9 @@
### Instructions
- Implement the `std::fmt::Display` trait for the structure table so that the table is printed like in the **[Usage](#usage)**. The length of each column must adjust to the longest element of the column and the element must be centered in the "cell" when possible. If the length of the element doees not allow to center exactly, it must descend slightly to the right.
- Implement the `std::fmt::Display` trait for the structure table so that the table is printed like in the **[Usage](#usage)**. The length of each column must adjust to the longest element of the column and the element must be centered in the "cell" when possible. If the length of the element does not allow to center exactly, it must be offset slightly to the left.
- Note: If the table is empty `println!` must not print anything.
- Note: If the table is empty (does not have a header), `println!` must not print anything.
- Define the associated function `new` which creates a new empty table.
@ -22,7 +22,7 @@ pub struct Table {
impl fmt::Display for Table {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
}
}
impl Table {

16
subjects/filter_table/README.md

@ -4,17 +4,13 @@
- Define the **functions**:
- new: which creates a new empty table.
- `new`: which creates a new empty table.
- add_rows: which adds a new row to the table from a slice of strings.
- `add_rows`: which adds a new row to the table from a slice of strings.
- filter_cols: which receives a closure which receives a `&str` and returns a `bool` value:
- `filter_cols`: which receives a closure and returns a table with all the columns that yielded true when applying that closure. The closure will receive a `&str` and return a `bool` value.
- filter_cols returns a table with all the columns that yielded true when applied to the header.
- filter_rows: which receives a closure that receives a `&str` and returns a `bool` value
- filter_rows returns a table with all the columns that yielded true when applied to the elements of the selected column.
- `filter_rows`: which receives a closure and returns a table with all the rows that yielded true when applied to the elements of the selected column. The closure will receive a `&str` and return a `bool` value.
### Expected functions and Structures
@ -34,11 +30,11 @@ impl Table {
}
pub fn filter_col(&self, filter: ) -> Option<Self> {
pub fn filter_col(&self, filter: T) -> Option<Self> {
}
pub fn filter_row(&self, col_name: &str, filter: ) -> Option<Self> {
pub fn filter_row(&self, col_name: &str, filter: T) -> Option<Self> {
}
}

2
subjects/flat_tree/README.md

@ -1,4 +1,4 @@
## flat_rust
## flat_tree
### Instructions

BIN
subjects/matrix_determinant/determinant-of-a-3x3-matrix-formula-3.png

diff.bin_not_shown

After

Width:  |  Height:  |  Size: 14 KiB

Loading…
Cancel
Save