Browse Source

exam 2 first ex first pass

content-update
Chris 3 years ago
parent
commit
9432273786
  1. 2
      subjects/nextprime/README.md
  2. 19
      subjects/order_books/README.md
  3. 4
      subjects/previousprime/README.md
  4. 12
      subjects/rot21/README.md

2
subjects/nextprime/README.md

@ -2,7 +2,7 @@
### Instructions
Write a function that returns the first prime number that is equal or superior to the `int` passed as parameter.
Write a **function** which returns the first prime number which is equal or superior to the `u64` passed as parameter.
The function must be optimized in order to avoid time-outs with the tester.

19
subjects/order_books/README.md

@ -2,29 +2,31 @@
### Instructions
Build a module called `library` with two sub-modules inside it:
Build a module called `library` with two sub-modules inside of it:
- `writers` which contains a structure called `Writer` that has a first_name (String), last_name (String) and a set of books (Vec\<Book\>).
- `books` which contains a structure called `Book` that has a title (String) and a year of publish (u64).
- `writers` which contains a structure called `Writer` which has a first_name (String),a last_name (String) and a set of books (Vec\<Book\>).
- `books` which contains a structure called `Book` which has a title (String) and a year of publication (u64).
You will also have to create (outside the previous modules) a function `order_books` that receives a writer (Writer) and orders the set of books alphabetically.
A function `order_books` also has to be created (outside the previous modules which receives a writer (Writer) and orders the set of books alphabetically.
### Expected Functions and Structs
#### (The structs declarations need to be filled and added in the appropriate submodules)
```rs
pub fn order_books(writer: &mut Writer) {
pub struct Writer {
}
```
```rs
struct Writer {
pub struct Book {
}
```
```rs
struct Book {
pub fn order_books(writer: &mut Writer) {
}
```
@ -34,6 +36,9 @@ struct Book {
Here is a program to test your function and structs:
```rs
pub use library::writers::Writer;
pub use library::books::Book;
fn main() {
let mut writer_a = Writer {
first_name: "William".to_string(),

4
subjects/previousprime/README.md

@ -2,9 +2,9 @@
### Instructions
Write a function that returns the first prime number that is equal or inferior to the `int` passed as parameter.
Write a **function** which returns the first prime number which is equal or inferior to the `u64` passed as parameter.
If there are no primes inferior to the `int` passed as parameter the function should return 0.
If there are no primes inferior to the `u64` passed as parameter the function should return `0`.
### Expected function

12
subjects/rot21/README.md

@ -2,17 +2,19 @@
### Instructions
Your purpose in this exercise is to create a `rot21` function that works like the ROT13 cipher.
The purpose of this exercise is to create a `rot21` function that works like the ROT13 cipher.
Your function will receive a string and it will rotate each letter of that string 21 times to the right.
This function will receive a `string` and it will rotate each letter of that `string` 21 times to the right.
Your function should only change letters. If the string includes punctuation, symbols and numbers
The function should only rotate letters. If the string includes punctuation, symbols and/or numbers
they will remain the same.
### Expected functions
```rust
pub fn rot21(input: &str) -> String {}
pub fn rot21(input: &str) -> String {
}
```
### Usage
@ -32,7 +34,7 @@ fn main() {
```
And its output
And its output:
```console
student@ubuntu:~/[[ROOT]]/test$ cargo run

Loading…
Cancel
Save