Compare commits

..

3 Commits

Author SHA1 Message Date
davidrobert99 c827abed4c update blood_types 2 years ago
davidrobert99 4fcef1eed3 update notions 2 years ago
davidrobert99 8a8cb9e482 update lalgebra_vector 2 years ago
  1. 2
      README.md
  2. 28
      docs/pc-requirements.md
  3. 73
      docs/server-installation.md
  4. 29
      docs/server-requirements.md
  5. 2
      js/tests/get-some-time_test.js
  6. 11
      js/tests/test.mjs
  7. 1
      js/tests/valid-ip_test.js
  8. 16
      subjects/abs/README.md
  9. 43
      subjects/addifpositive/README.md
  10. 4
      subjects/adding/README.md
  11. 13
      subjects/adding_twice/README.md
  12. 15
      subjects/all/README.md
  13. 46
      subjects/alphaposition/README.md
  14. 16
      subjects/anything-to-declare/README.md
  15. 19
      subjects/arrange_it/README.md
  16. 17
      subjects/arrays/README.md
  17. 43
      subjects/arraysum/README.md
  18. 4
      subjects/ascii-art-web/dockerize/audit.md
  19. 18
      subjects/ascii-art/README.md
  20. 24
      subjects/ascii-art/audit/README.md
  21. 38
      subjects/ascii/README.md
  22. 18
      subjects/atm-management-system/README.md
  23. 36
      subjects/banner/README.md
  24. 46
      subjects/betweenus/README.md
  25. 10
      subjects/bigger/README.md
  26. 9
      subjects/biggie-smalls/README.md
  27. 47
      subjects/binaryaddition/README.md
  28. 22
      subjects/block-chain/README.md
  29. 36
      subjects/blood_types/README.md
  30. 13
      subjects/blood_types_s/README.md
  31. 12
      subjects/bloody-sunday/README.md
  32. 6
      subjects/border_cross/README.md
  33. 15
      subjects/borrow/README.md
  34. 23
      subjects/borrow_box/README.md
  35. 24
      subjects/borrow_me_the_reference/README.md
  36. 15
      subjects/box_it/README.md
  37. 24
      subjects/box_recursion/README.md
  38. 59
      subjects/boxing_todo/README.md
  39. 42
      subjects/brackets_matching/README.md
  40. 10
      subjects/brain_fuck/README.md
  41. 28
      subjects/brainfuck/README.md
  42. 4
      subjects/btreetransplant/README.md
  43. 44
      subjects/build-brick-and-break/README.md
  44. 6
      subjects/capitalizing/README.md
  45. 34
      subjects/card_deck/README.md
  46. 29
      subjects/chaikin/README.md
  47. 44
      subjects/chaikin/audit/README.md
  48. 17
      subjects/change/README.md
  49. 16
      subjects/changes/README.md
  50. 7
      subjects/chunky/README.md
  51. 13
      subjects/cipher/README.md
  52. 30
      subjects/circle/README.md
  53. 9
      subjects/circular/README.md
  54. 4
      subjects/cl-camp3/README.md
  55. 27
      subjects/clonernews/README.md
  56. 18
      subjects/clonernews/audit/README.md
  57. 11
      subjects/closures/README.md
  58. 2
      subjects/collect/README.md
  59. 39
      subjects/collections/README.md
  60. 26
      subjects/commits_stats/README.md
  61. 6
      subjects/concat-str/README.md
  62. 31
      subjects/copy/README.md
  63. 3
      subjects/count-leap-years/README.md
  64. 20
      subjects/counting_words/README.md
  65. 40
      subjects/countnegative/README.md
  66. 48
      subjects/curry-entries/README.md
  67. 21
      subjects/cut-corners/README.md
  68. 20
      subjects/date-is/README.md
  69. 3
      subjects/day-of-the-year/README.md
  70. 10
      subjects/debounce/README.md
  71. 29
      subjects/declarations/README.md
  72. 2
      subjects/deep-copy/README.md
  73. 2
      subjects/delete_prefix/README.md
  74. 20
      subjects/diamond_creation/README.md
  75. 12
      subjects/display_table/README.md
  76. 21
      subjects/division_and_remainder/README.md
  77. 41
      subjects/divisors/README.md
  78. 56
      subjects/does_it_fit/README.md
  79. 23
      subjects/dog-years/README.md
  80. 15
      subjects/doubtful/README.md
  81. 40
      subjects/dr-strange/README.md
  82. 53
      subjects/drawing/README.md
  83. 13
      subjects/drawing/audit/README.md
  84. BIN
      subjects/drawing/image.png
  85. 58
      subjects/drop_the_thread/README.md
  86. 8
      subjects/easy_traits/README.md
  87. 10
      subjects/edit_distance/README.md
  88. 12
      subjects/elementary/README.md
  89. 61
      subjects/error_types/README.md
  90. 89
      subjects/events/README.md
  91. 20
      subjects/expected_variable/README.md
  92. 25
      subjects/fibonacci2/README.md
  93. 31
      subjects/fifty-shades-of-cold/README.md
  94. 2
      subjects/fikbuk/README.md
  95. 22
      subjects/filter/README.md
  96. 22
      subjects/filter_table/README.md
  97. 19
      subjects/find-expression/README.md
  98. 16
      subjects/find_factorial/README.md
  99. 7
      subjects/flagger/README.md
  100. 6
      subjects/flat/README.md
  101. Some files were not shown because too many files changed in this diff diff.show_more

2
README.md

@ -1,4 +1,4 @@
### Welcome to the Public Repository of the 01 Edu System
### Welcome to the Public Repository of 01 Edu System
Our courses are meticulously studied in order to provide you with quality projects.
Please take into account our approach before making **Issues**

28
docs/pc-requirements.md

@ -1,28 +1,12 @@
# PC requirements (Minimum)
# PC requirements
Features required:
- **Compatibility with Linux (Ubuntu/Debian x64)**
- Linux compatible
| Component | Specifications |
| Component | Minimum specifications |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Processor | 4 threads x86-64 (64 bits), [2200 single thread performance](https://www.cpubenchmark.net/singleThread.html) / [1000 single-core score](https://browser.geekbench.com/processor-benchmarks) |
| Memory | 8 GB DDR4 |
| Storage | 120 GB SSD |
| Display | 14" Full HD (flicker-free) |
# PC requirements (Recommended)
Features required:
- **Compatibility with Linux (Ubuntu/Debian x64)**
| Component | Specifications |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Processor | 6 threads x86-64 (64 bits), [2600 single thread performance](https://www.cpubenchmark.net/singleThread.html) / [1200 single-core score](https://browser.geekbench.com/processor-benchmarks) |
| Memory | 16 GB DDR4 |
| Storage | 120 GB SSD |
| Display | 17" Full HD (flicker-free) |
|**For comfort:**| An additional display : 24" Full HD (flicker-free). Pivotable to 90 degrees.|
**Important**: Please note that the above requirements do not cover the Game Engine specific branches.
| Memory | 8 GB |
| Disk | 120 GB SSD |
| Monitor | 14" Full HD flicker-free |

73
docs/server-installation.md

@ -1,62 +1,47 @@
# Server installation
## 🌐 DNS Configuration
## DNS configuration
The following DNS records should be configured in your domain's [zone file](https://en.wikipedia.org/wiki/Zone_file) or through the web interface of your dns provider/domain registrar.
- A _domain/subdomain_ pointing to the public IP address (using `A Record`) of your [dedicated server](server-requirements.md).
- A _subdomain_ called `git` pointing to the above mentioned *domain/subdomain* (using `CNAME Record`) or it's IP address (using `A Record`).
One domain and one subdomain must point to the IP address of a [dedicated server](server-requirements.md).
Your newly configured DNS records should look like this:
| FQDN | Record type | Address |
| -------------- | ----------- | ------- |
| ((DOMAIN)) | A | X.X.X.X |
| git.((DOMAIN)) | A | X.X.X.X |
| FQDN | Record type | Target |
| -------------- | ----------- | ------------- |
| ((DOMAIN)) | A | X.X.X.X |
| git.((DOMAIN)) | CNAME | ((DOMAIN)) |
## Network configuration
Here is an _example_ of the DNS records for the domain `example.org` with the public IP address of `93.184.216.34`:
### Inbound
| FQDN | Record type | Target |
| -------------- | ----------- | ------------- |
| example.org | A | 93.184.216.34 |
| git.example.org | CNAME | example.org |
| Port | Transport | Application |
| ---- | --------- | ---------------- |
| 80 | TCP, UDP | HTTP/(1.1, 2, 3) |
| 443 | TCP, UDP | HTTP/(1.1, 2, 3) |
| 521 | TCP | SSH |
### Outbound
## 🛠 Network Configuration
| Port | Transport | Application |
| ---- | --------- | ----------- |
| 587 | TCP | SMTP |
### ➡ Inbound
### OS installation
| Port | Protocol(s) | Service/Application |
| ----------- | ----------- | ------------------- |
| 80 | TCP | HTTP/(1.1, 2, 3) |
| 443 | TCP | HTTP(S)/(1.1, 2, 3) |
| 521 | TCP | SSH |
| 8080 - 8090 | TCP | HTTP/(1.1, 2, 3) |
Download and boot the ISO image `amd64` of [Debian](https://www.debian.org/distrib/netinst)
### ⬅ Outbound
Select :
| Port | Protocol(s) | Service/Application |
| ----------- | ----------- | -------------------- |
| 587 | TCP | SMTP |
| 8080 - 8090 | TCP | HTTP/(1.1, 2, 3) |
- "Advanced options ..."
- "... Automated install"
## 💿 OS installation
The network is automatically configured with DHCP, you can also configure it manually.
1. Download and boot the `amd64` variant of the [Debian](https://www.debian.org/distrib/netinst) ISO image.
At the prompt "Location of initial preconfiguration file:", enter the URL :
2. Select :
- "**Advanced options ...**"
- "**... Automated install**"
```
raw.githubusercontent.com/01-edu/public/master/sh/debian/preseed.cfg
```
3. The network is automatically configured using your DHCP server. Additionally, you can also configure it manually to suit your preference.
and select "Continue".
4. At the prompt "Location of initial preconfiguration file:", please enter the following URL :
```console
raw.githubusercontent.com/01-edu/public/master/sh/debian/preseed.cfg
```
5. Then select "**Continue**" and follow the on-screen instructions.
## 🏁 Finishing up
Once the server is ready to be accessed remotely, please let us know via approriate communication channels and we will proceed with configuring the server.
--> Please let us know when the server's remote access is ready and we will configure it.

29
docs/server-requirements.md

@ -1,25 +1,12 @@
# Server requirements (Minimum)
# Server requirements
Features required:
- Dedicated hardware components (kept in **data centre** conditions)
- Compatibility with **Linux (Debian x64)**
- Dedicated hardware
- Linux compatible
| Component | Specification |
| --------- | ---------------------------------------------------------------------------------- |
| Processor | 8 threads x86-64 (64 bits), [2200 single thread performance](https://www.cpubenchmark.net/singleThread.html) / [1000 single-core score](https://browser.geekbench.com/processor-benchmarks) |
| Memory | 16 GB DDR4 |
| Storage | 2 x 500 GB SSD (`RAID 1` for _redundancy_ or `RAID 0` for _performance/capacity_) |
# Server requirements (Recommended)
Features required:
- Dedicated hardware components (kept in **data centre** environment)
- Compatibility with **Linux (Debian x64)**
| Component | Specification |
| --------- | ---------------------------------------------------------------------------------- |
| Processor | 10 threads x86-64 (64 bits), [2600 single thread performance](https://www.cpubenchmark.net/singleThread.html) / [1200 single-core score](https://browser.geekbench.com/processor-benchmarks) |
| Memory | 32 GB ECC DDR4 |
| Storage | 2 x 500 GB SSD (`RAID 1` for _redundancy_ or `RAID 0` for _performance/capacity_) |
| Component | Minimum specifications |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Processor | 8 threads x86-64 (64 bits), [2200 single thread performance](https://www.cpubenchmark.net/singleThread.html) / [1000 single-core score](https://browser.geekbench.com/processor-benchmarks) |
| Memory | 16 GB DDR4 |
| Disk | 2 \* 500 GB SSD |

2
js/tests/get-some-time_test.js

@ -11,6 +11,4 @@ t(({ eq }) => eq(firstDayWeek(43, '1983'), '17-10-1983'))
t(({ eq }) => eq(firstDayWeek(23, '0091'), '04-06-0091'))
t(({ eq }) => eq(firstDayWeek(2, '2017'), '02-01-2017'))
Object.freeze(tests)

11
js/tests/test.mjs

@ -163,23 +163,14 @@ const runTests = async ({ url, path, code }) => {
const tools = { eq, fail, wait, code, path, randStr, between, upperFirst }
tools.ctx = (await (setup && setup(tools))) || {}
let timeout
for (const [i, t] of tests.entries()) {
try {
const waitWithTimeout = Promise.race([
t(tools),
new Promise((s, f) => {
timeout = setTimeout(f, 60000, Error('Time limit reached (1min)'))
}),
])
if (!(await waitWithTimeout)) {
if (!(await t(tools))) {
throw Error('Test failed')
}
} catch (err) {
console.log(`test #${i+1} failed:\n${t.toString()}\n\nError:`)
fatal(stackFmt(err, url))
} finally {
clearTimeout(timeout)
}
}
console.log(`${name} passed (${tests.length} tests)`)

1
js/tests/valid-ip_test.js

@ -21,6 +21,7 @@ const $findIP = [
'192.169.1.23',
'10.1.23.7',
'0.0.0.0:22',
'0.0.0.0:68768',
'255.253.123.2:8000',
'192.168.1.123',
'0.0.0.0',

16
subjects/abs/README.md

@ -2,19 +2,23 @@
### Instructions
Create a function named `isPositive` that takes a number as a argument, returning `true` if the number is strictly positive, and `false` otherwise.
Create a `isPositive` function that takes a number as
parameter and return true if the given number is
stricly positive, or false otherwise
Create a function named `abs` that takes a number as an argument and returns its absolute value. You must make your own implementation. You **must not** use `Math.abs()`.
Create the `abs` function that takes one number argument
and returns its absolute value.
You are not allowed to use `Math.abs`, make your own.
### Notions
- [Functions](https://nan-academy.github.io/js-training/examples/functions.js)
- [Ternary](https://nan-academy.github.io/js-training/examples/ternary.js)
- [Math.abs](https://devdocs.io/javascript/global_objects/math/abs)
- [nan-academy.github.io/js-training/examples/functions.js](https://nan-academy.github.io/js-training/examples/functions.js)
- [nan-academy.github.io/js-training/examples/ternary.js](https://nan-academy.github.io/js-training/examples/ternary.js)
- [devdocs.io/javascript/global_objects/math/abs](https://devdocs.io/javascript/global_objects/math/abs)
### Code provided
> The provided code will be added to your solution, and does not need to be submitted.
> all code provided will be added to your solution and does not need to be submited.
```js
Math.abs = undefined

43
subjects/addifpositive/README.md

@ -1,43 +0,0 @@
## add-if-positive
### Instructions
Write a function that takes two numbers and adds them together if they are both positive.
- If either number is negative or one of them is negative and the other is positive return `0`.
### Expected function
```go
func AddIfPositive(a int, b int) int {
// your code here
}
```
### Usage
Here is a possible program to test your function:
```go
package main
import "fmt"
func main() {
fmt.Println(AddIfPositive(1, 2))
fmt.Println(AddIfPositive(1, -2))
fmt.Println(AddIfPositive(-1, 2))
fmt.Println(AddIfPositive(-1, -2))
fmt.Println(AddIfPositive(10,20))
fmt.Println(AddIfPositive(0,20))
}
```
and the output should be:
```console
$ go run .
3
0
0
0
30
20
```

4
subjects/adding/README.md

@ -2,8 +2,8 @@
### Instructions
Create the function `add_curry`, which returns a closure.
The purpose is to 'curry' the add method to create more variations.
Create the function `add_curry` that returns a closure.
The purpose is to curry the add method to create more variations.
### Usage

13
subjects/adding_twice/README.md

@ -2,11 +2,14 @@
### Instructions
You'll need to reuse your `add_curry` function. Copy and paste it directly into your `lib.rs` file.
In this exercise you will have to reuse your `add_curry` function (copy and paste it directly in your lib.rs file).
Then you have to create the function `twice` using closures, this function will
take a function f(x) as parameter and return a function f(f(x)).
So, the purpose of this function is to add two times the value in `add_curry` to the original value.
Now create a function named `twice` using closures. This function will take a function `f(x)` as parameter, and return a function `f(f(x))`.
### Notions
So, the purpose of this function is to add two times the value in `add_curry` to the original value.
- [higher order function](https://doc.rust-lang.org/rust-by-example/fn/hof.html#higher-order-functions)
### Expected functions
@ -54,7 +57,3 @@ The value is 67
The value is -57
$
```
### Notions
- [higher order function](https://doc.rust-lang.org/rust-by-example/fn/hof.html#higher-order-functions)

15
subjects/all/README.md

@ -2,17 +2,18 @@
### Instructions
Create a function named `all` that works like `Promise.all` but with objects (instead of arrays).
Create a function `all` that works like `Promise.all` but with objects.
(instead of arrays)
### Notions
- [nan-academy.github.io/js-training/examples/promise.js](https://nan-academy.github.io/js-training/examples/promise.js)
- [devdocs.io/javascript/global_objects/promise/all](https://devdocs.io/javascript/global_objects/promise/all)
### Code provided
> The provided code will be added to your solution, and does not need to be submitted.
> all code provided will be added to your solution and doesn't need to be submited.
```js
Promise.all = undefined
```
### Notions
- [Promise.js](https://nan-academy.github.io/js-training/examples/promise.js)
- [Promise.all](https://devdocs.io/javascript/global_objects/promise/all)

46
subjects/alphaposition/README.md

@ -1,46 +0,0 @@
## alpha-position
### Instructions
Write a function named `AlphaPosition` that takes an alphabetical character as a parameter and returns the position of the letter in the alphabet.
- If the character is not in the alphabet, return -1
- If the character is in the alphabet, return the position of the letter in the alphabet
### Expected function
```go
func AlphaPosition(c rune) int {
// your code goes here
}
```
### Usage
Here is a possible program to test your function:
```go
package main
import "fmt"
func main(){
fmt.Println(AlphaPosition('a'))
fmt.Println(AlphaPosition('z'))
fmt.Println(AlphaPosition('B'))
fmt.Println(AlphaPosition('Z'))
fmt.Println(AlphaPosition('0'))
fmt.Println(AlphaPosition(' '))
}
```
And its output :
```console
$ go run . | cat -e
1$
26$
2$
26$
-1$
-1$
```

16
subjects/anything-to-declare/README.md

@ -110,16 +110,14 @@ console.log(cashPayment)
### Instructions
All right, before we can embark on this adventure, you are going to tell us
more about yourself using **variables**.
All right, before we can embark into this adventure, you are going to tell us
more about yourself using **variables** !
Declare three variables:
- Declare a variable _identified_ `age` of a `Number` value of your age
- `age`: your age as a `number`
- Declare a variable _identified_ `name` of a `String` value of your name
- `name`: your name as a `string`
- Declare a variable _identified_ `secureLuggage` of a `Boolean` saying if your
luggage contain dangerous things or not. _(for obvious security reasons)_
- `secureLuggage`: which will be a `boolean` stating whether or not your
luggage contains dangerous materials. _(for obvious security reasons)_
> PS: Remember you are trying to board a plane, so use reasonable values.
> PS: And please, use reasonable values, or the tests might reject you !

19
subjects/arrange_it/README.md

@ -2,17 +2,23 @@
### Instructions
Create a **function** named `arrange_phrase`, that takes a string literal, _sorts_ the words and returns it. Each word will contain a number that indicates the position of that word.
Create a **function** called `arrange_phrase` that takes a string literal as a phrase and returns it organized
Each word will have a number that indicates the position of that word.
> This exercise will test how many times the **heap is going to be allocated**!\
> So try your best to allocate the minimum data on the heap!
### Expected Function
### Expected Functions
```rust
pub fn arrange_phrase(phrase: &str) -> String {
}
```
> Your heap allocations will be monitored to ensure that you do not make too many allocations, and that your allocations are reasonably sized.
### Notions
- [stack and heap](https://doc.rust-lang.org/1.22.0/book/first-edition/the-stack-and-the-heap.html)
- [str](https://doc.rust-lang.org/std/primitive.str.html)
### Usage
@ -33,8 +39,3 @@ $ cargo run
"This is a Test"
$
```
### Notions
- [stack and heap](https://doc.rust-lang.org/1.22.0/book/first-edition/the-stack-and-the-heap.html)
- [str](https://doc.rust-lang.org/std/primitive.str.html)

17
subjects/arrays/README.md

@ -2,9 +2,16 @@
### Instructions
Define a **function** named `thirtytwo_tens` that returns an array with 32 positions filled with only the value `10`, so that `[10, 10, 10, ... 10].len()` is equal to 32.
Define a **function** called `thirtytwo_tens` that returns an array with 32 positions filled with only the value `10`:
Write a **function** that takes an array of `i32` and returns the sum of the elements (make it work with the main).
- [10, 10, 10, ... 10].len()
= 32
Write a **function** that takes an array of i32 and returns the sum of the elements (make it work with the main).
### Notions
- [arrays](https://doc.rust-lang.org/std/primitive.array.html)
### Expected functions
@ -23,7 +30,7 @@ pub fn thirtytwo_tens() -> [i32; 32] {
Here is a program to test your function.
> It's incomplete. Use the output and the other available information to figure out what is missing.
There are things missing in this program. Use the output and the other information that you have available to retrieve what is missing.
```rust
use arrays::{sum, thirtytwo_tens};
@ -54,7 +61,3 @@ The Sum of the elements in [5, 5, 5, 5, 5, 5, 5, 5, 5, 5] = 50
Array size 32 with only 10's in it [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
$
```
### Notions
- [arrays](https://doc.rust-lang.org/std/primitive.array.html)

43
subjects/arraysum/README.md

@ -1,43 +0,0 @@
## array-sum
### Instructions
Write a function that takes an array of numbers and returns the sum of all the numbers in the array.
- If the array is empty, the function should return 0.
### Expected function
```go
func SumArray(numbers []int) int {
// your code here
}
```
### Usage
Here is a possible program to test your function:
```go
package main
import (
"fmt"
)
func main(){
fmt.Println(SumArray([]int{1,2,3,4,5}))
fmt.Println(SumArray([]int{}))
fmt.Println(SumArray([]int{-1,-2,-3,-4,-5}))
fmt.Println(SumArray([]int{-1,2,3,4,-5}))
}
```
and the output should be:
```console
$ go run .
15
0
-15
3
```

4
subjects/ascii-art-web/dockerize/audit.md

@ -39,8 +39,12 @@ exit
student$
```
###### Is the file system of the containers well organized?
###### Does the DockerFile contain some [metadata](https://docs.docker.com/config/labels-custom-metadata/) applied to the docker object?
###### Does the project present no [unused object](https://docs.docker.com/config/pruning/)?
###### As an auditor, is this project up to every standard? If not, why are you failing the project?(Empty Work, Incomplete Work, Invalid compilation, Cheating, Crashing, Leaks)
#### General

18
subjects/ascii-art/README.md

@ -156,24 +156,6 @@ student$ go run . "Hello\nThere" | cat -e
|_| |_| |_| \___| |_| \___| $
$
$
student$ go run . "Hello\n\nThere" | cat -e
_ _ _ _ $
| | | | | | | | $
| |__| | ___ | | | | ___ $
| __ | / _ \ | | | | / _ \ $
| | | | | __/ | | | | | (_) | $
|_| |_| \___| |_| |_| \___/ $
$
$
$
_______ _ $
|__ __| | | $
| | | |__ ___ _ __ ___ $
| | | _ \ / _ \ | '__| / _ \ $
| | | | | | | __/ | | | __/ $
|_| |_| |_| \___| |_| \___| $
$
$
student$
```

24
subjects/ascii-art/audit/README.md

@ -85,30 +85,6 @@
###### Does it display the right graphical representation in ASCII as above?
##### Try passing `"Hello\n\nThere"` as an argument.
```
_ _ _ _ $
| | | | | | | | $
| |__| | ___ | | | | ___ $
| __ | / _ \ | | | | / _ \ $
| | | | | __/ | | | | | (_) | $
|_| |_| \___| |_| |_| \___/ $
$
$
$
_______ _ $
|__ __| | | $
| | | |__ ___ _ __ ___ $
| | | _ \ / _ \ | '__| / _ \ $
| | | | | | | __/ | | | __/ $
|_| |_| |_| \___| |_| \___| $
$
$
```
###### Does it display the right graphical representation in ASCII as above?
##### Try passing `"{Hello & There #}"` as an argument.
```

38
subjects/ascii/README.md

@ -1,38 +0,0 @@
## ascii
### Instructions
Write a function that receives a string and returns a slice with the ASCII values of its characters. If the string is empty it should return an empty slice.
### Expected function
```go
func Ascii(str string) []byte {
}
```
### Usage
Here is a possible program to test your function:
```go
package main
import (
"piscine"
"fmt"
)
func main() {
l := piscine.Ascii("Hello")
fmt.Println(l)
}
```
And its output:
```console
$ go run .
[104 101 108 108 111]
```

18
subjects/atm-management-system/README.md

@ -4,7 +4,7 @@
The objective of this project is to show that you have acquired programming logic and that you are able to adapt to new languages.
The programming language you are about to use is [C](https://en.wikipedia.org/wiki/C_%28programming_language%29). You will not be asked to create
The programming language you are about to use is [C](https://en.wikipedia.org/wiki/C_%28programming_language%29). It will not be asked to create
a project from scratch, instead you will have **to add features or fix the code of a given application**.
### Instructions
@ -42,10 +42,10 @@ A folder which you can find [here](https://assets.01-edu.org/atm-system/atm-syst
The `data` folder presented above will contain information about the users and their accounts:
- `users.txt` will be the file that stores all information about each user
- `records.txt` will be the file that stores all information relevant to the accounts for each user
- `users.txt` will be the a file that stores all information about each user
- `records.txt` will be the a file that stores all information relevant to the accounts for each user
The format of the content saved in the file will be displayed like this :
The format for the content saved in the file will be displayed like this :
`users.txt` (id, name, password):
@ -78,7 +78,7 @@ The following features must be implemented by yourself.
3. The **Checking the details of existing accounts** feature, users must be able to check just one account at a time.
3.1. For this they must be asked to input the account id they want to see
3.1. For this it must be asked to input the account id they want to see
3.2. If the account is either `savings`, `fixed01`, `fixed02` and `fixed03` the system will display
the information of that account and the interest you will acquire depending on the account:
@ -102,9 +102,9 @@ The following features must be implemented by yourself.
### Bonus
As a bonus you can add a verification to the field **Transfer owner**. Every time a user transfers ownership of an account the other user who received the account
As bonus you can add a verification to the field **Transfer owner**. Every time a user transfers ownership of an account the other user who received the account
can be alerted that he or she received an account from someone instantly.
Example: if you have two terminals opened logged in with two different users, and one sends the account to the other user,
Example: if you have two terminals opened logged with two different users, and one send the account to the other user,
the user who received the account should be instantly notified.
One of the ways of doing this is by using pipes and child processes (communication between processes).
@ -114,12 +114,12 @@ You can also do more bonus features or update the terminal interface:
- Encryption of passwords
- Adding your own Makefile
A relational database can also be added as a bonus. You can use the database of your choice, but we recommend you use SQLite.
A relational database can also be added as a bonus. You can use the database at your choice, but we recommend you do use SQLite
To know more about SQLite you can check the [SQLite page](https://www.sqlite.org/index.html).
### Example
You can find an example of the final application [here](https://www.youtube.com/watch?v=xVtikDcGG2E). Don't forget that you are free to
You can find an example of the final application [here](https://www.youtube.com/watch?v=xVtikDcGG2E). Do not forget that you are free to
implement whichever kind of interface you desire. It just needs to obey the instructions given above so it can pass the audit.
This project will help you learn about:

36
subjects/banner/README.md

@ -2,16 +2,16 @@
### Instructions
"`Result` is a better version of the `Option` type that describes a possible `error` instead of possible `absence`".
"`Result` is a better version of the `Option` type that describes possible `error` instead of possible `absence`".
Create a structure called `Flag` which has the following elements:
- `short_hand`: `String`
- `long_hand`: `String`
- `desc`: `String`
- short_hand: `String`
- long_hand: `String`
- desc: `String`
This structure must have a **function** called `opt_flag` which initializes the structure.
This **function** receives two string references and returns a structure `Flag`. Here is an example of its usage:
This **function** receives two strings references and returns a structure `Flag`. Here is an example of its usage:
```rust
let d = Flag::opt_flag("diff", "gives the difference between two numbers");
@ -20,17 +20,24 @@ This **function** receives two string references and returns a structure `Flag`.
// output: "short hand: -d, long hand: --diff, description: gives the difference between two numbers"
```
A second structure named `FlagsHandler` will be given which just has one element: `flags: HashMap<(String, String), Callback>`. You'll need to implement the following **associated functions**" (methods) associated with `FlagsHandler` are for you to complete:"
A second structure called `FlagsHandler` will be given which just has one element: `flags: HashMap<(String, String), Callback>`
The following **functions** (methods) associated with `FlagsHandler` are for you to complete :
- `add_flag`, which adds the flag and callback function to the HashMap.
- `exec_func`, which executes the function using the flag provided and returns the result. The result will be either a string with the value from the callback or an error.
- `add_flag`, which adds to the HashMap the flag and the Callback function.
- `exec_func`, which executes the function using the flag provided and returns the result, which can be either a string with the value from the callback or an error.
A `type` called `Callback` will also be provided. It is a function which is going to be used in the structure and functions above. This function will be the callback for the flag associated to it.
A `type` called `Callback` will also be provided. It is a function which is going to be used in the structure
and functions above. This function will be the callback for the flag associated to it.
You will have to create the following callback functions:
You will have to create the following callback functions :
- `div`: which converts the reference strings to `float`s and returns the `Result`, as the division of the `float`s or the standard (std) error: `ParseFloatError`.
- `rem`: which converts the reference strings to `float`s and returns the `Result`, as the remainder of the division of the `float`s or the standard (std) error `ParseFloatError`.
- `div` which converts the reference strings to `float`s and returns the `Result`, being the division of the `float`s or the standard (std) error: `ParseFloatError`.
- `rem` which converts the reference strings to `float`s and returns the `Result`, being the remainder of the division of the `float`s or the standard (std) error `ParseFloatError`.
### Notions
- [Result](https://doc.rust-lang.org/rust-by-example/error/result.html)
- [Method optflag](https://docs.rs/getopts/0.2.18/getopts/struct.Options.html#method.optflag)
### Expected Function
@ -111,8 +118,3 @@ $ cargo run
"invalid float literal"
$
```
### Notions
- [Result](https://doc.rust-lang.org/rust-by-example/error/result.html)
- [Method optflag](https://docs.rs/getopts/0.2.18/getopts/struct.Options.html#method.optflag)

46
subjects/betweenus/README.md

@ -1,46 +0,0 @@
## between-us
### Instructions
Write a function named `BetweenUs` that takes 3 paramters and return :
- If the first paramter is between the second and third paramters, return **true** else return **false**
- If the second parameter is bigger than the third return **false**
### Expected function
```go
func BetweenUs(num, min, max int) bool {
// Your code here
}
```
### Usage
Here is a possible program to test your function:
```go
package main
import "fmt"
func main(){
fmt.Println(BetweenUs(1, 2, 3))
fmt.Println(BetweenUs(1, 1, 3))
fmt.Println(BetweenUs(1, 3, 3))
fmt.Println(BetweenUs(1, 1, 1))
fmt.Println(BetweenUs(1, 2, 1))
fmt.Println(BetweenUs(-1, -10, 0))
}
```
and the output should be:
```console
$ go run .
false
true
false
true
false
true
```

10
subjects/bigger/README.md

@ -2,7 +2,11 @@
### Instructions
Create a function named `bigger` that gets the biggest positive number in the `HashMap`.
Create the function `bigger` that gets the biggest positive number in the `HashMap`.
### Notions
- [hash maps](https://doc.rust-lang.org/book/ch08-03-hash-maps.html)
### Expected Function
@ -38,7 +42,3 @@ $ cargo run
The biggest of the elements in the HashMap is 334
$
```
### Notions
- [hash maps](https://doc.rust-lang.org/book/ch08-03-hash-maps.html)

9
subjects/biggie-smalls/README.md

@ -2,10 +2,11 @@
### Instructions
Create 2 variables:
- `smalls` with the smallest possible `number` value.
- `biggie` with the greatest possible `number` value.
Create 2 variables
- `smalls` with the smallest possible `number` value
- `biggie` with the greatest possible `number` value
### Notions
- [Number](https://devdocs.io/javascript-number/)
- [devdocs.io/javascript-number](https://devdocs.io/javascript-number/)

47
subjects/binaryaddition/README.md

@ -1,47 +0,0 @@
## binary-addition
### Instructions
Write a function named `BinaryAddition(int,int)` that takes two integers and returns the sum of the two in binary in an array of `int`.
- If one of the integers is negative return `nil`
- Convert the argument to binary then add the two binary numbers together
### Expected function
```go
func BinaryAddition(a int, b int) []int {
// your code here
}
```
### Usage
Here is a possible program to test your function:
```go
package main
import "fmt"
func main(){
fmt.Println(BinaryAddition(1, 1))
fmt.Println(BinaryAddition(1, 2))
fmt.Println(BinaryAddition(1, 3))
fmt.Println(BinaryAddition(2, 1))
fmt.Println(BinaryAddition(2, 2))
fmt.Println(BinaryAddition(1, 16))
}
```
and the output should be:
```console
$ go run .
[1 0]
[1 1]
[1 0 0]
[1 1]
[1 0 0]
[1 0 1]
[1 0 0 0 1]
```

22
subjects/block-chain/README.md

@ -2,18 +2,22 @@
### Instructions
Create a function named `blockChain` that creates a block in your very own block chain. It takes 2 arguments:
Create a `blockChain` that create a block in your very own block chain.
- `data`: any valid JSON data.
- `prev`: the previous block, if no block are given it should use the genesis block: `{ index: 0, hash: '0' }`.
the function takes 2 arguments:
- `data` any valid JSON data
- `prev` the previous block, if no block are given it should use the
genesis block: `{ index: 0, hash: '0' }`
A block must have the following properties:
- `index`
- `hash`: a computed hash using the `hashCode` function provided. You will need to pass it a concatenation of the block's `index`, the previous block's `hash` and the block's stringified `data`.
- `data`: any valid object.
- `prev`: the previous block.
- `chain`: a function that accepts `data` as an argument, and creates the next block with it.
- `hash` a computed hash using the concatenation of the `index`, `hash`
and stringified `data` and hashing all of it using the provided `hashCode`.
- `data` the data (not encoded in JSON)
- `prev` the previous block
- `chain` a function that takes a new `data` and create the next block with it.
### Examples
@ -47,11 +51,11 @@ console.log(fork.index) // -> 5
### Notions
- [JSON.stringify](https://devdocs.io/javascript/global_objects/json/stringify)
- [devdocs.io/javascript/global_objects/json/stringify](https://devdocs.io/javascript/global_objects/json/stringify)
### Code provided
> The provided code will be added to your solution, and does not need to be submitted.
> all code provided will be added to your solution and doesn't need to be submited.
```js
const hashCode = str =>

36
subjects/blood_types/README.md

@ -4,33 +4,27 @@
In this exercise you will create a data model of blood types and an API to deal with them.
First, we'll implement the data representation of the blood types.
Start by copying the data representation of the blood types:
Take a look at the `BloodType` struct below. It contains two enums which enable us to describe a blood type (e.g. "A-").
- Create the enum `Antigen` that has 4 possibilities: A, B, O and AB And the enum `RhFactor` that has two possible values: Positive and Negative
- `Antigen`: which can be one of:
- `A`
- `B`
- `AB`
- `O`
- `RhFactor`: which can be one of:
- `Positive`
- `Negative`
- After, create the struct `BloodType` that contains two fields with the names antigen and rh_factor
To provide a simple way to create blood types, implement the trait `FromStr` for `BloodType`. This will allow us to use the `parse` method and `from_str`, so we can do:
- To provide a simple way to create blood types implement the trait FromStr for BloodType (which will allow us to use the `parse` method and the associated function from_str, so we can do:
```rust
let a_neg: BloodType = "A-".parse();
```
Implement the following Traits:
- `std::cmp::Ord`: to make possible to sort a vector or array of `BloodType`.
- `std::Debug`: for `BloodType`, allowing us print a vector such as `[BloodType { antigen: A, rh_factor: Positive}, BloodType{ antigen: B, rh_factor: Negative}]` as `"[ A+, A-]"` when using format strings `{:?}`.
- Implement the std::cmp::Ord trait to make possible to sort a vector or array of BloodType's
Create three methods for BloodType:
- `can_receive_from`: which returns `true` if `self` can receive blood from `other` blood type.
- `donors`: which returns all the blood types that can give blood to `self`.
- `recipients`: which returns all the blood types that can receive blood from `self`.
- Implement the trait std::Debug for BloodType allowing to print a vector such as [BloodType { antigen: A, rh_factor: Positive}, BloodType{ antigen: B, rh_factor: Negative}] as [ A+, A-] using the formatting {:?}
- Lastly, write three methods for BloodType:
- `can_receive_from`: which returns true if `self` can receive blood from `other` blood type
- `donors`: which returns all the blood types that can give blood to `self`
- `recipients`: which returns all the blood types that can receive blood from `self`
### Expected Functions and Structures
@ -59,12 +53,6 @@ use std::cmp::{Ord, Ordering};
use std::str::FromStr;
impl FromStr for Antigen {
}
impl FromStr for RhFactor {
}
impl Ord for BloodType {
}

13
subjects/blood_types_s/README.md

@ -15,11 +15,11 @@ Use the following table to define the methods asked:
| B- | B+, B-, AB+, AB- | B-, O- |
| AB- | AB+, AB- | AB-, A-, B-, O- |
Implement three methods for `BloodType`:
Write three methods for BloodType:
- `can_receive_from`: returns `true` if `self` **can** receive blood from `other` blood type.
- `donors`: which returns all the blood types that can give blood to `self`.
- `recipients`: which returns all the blood types that can receive blood from `self`.
- `can_receive_from`: which returns true if `self` can receive blood from `other` blood type
- `donors`: which returns all the blood types that can give blood to `self`
- `recipients`: which returns all the blood types that can receive blood from `self`
### Expected Functions and Structures
@ -33,12 +33,12 @@ pub enum Antigen {
}
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
pub enum RhFactor {
enum RhFactor {
Positive,
Negative,
}
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone)]
pub struct BloodType {
pub antigen: Antigen,
pub rh_factor: RhFactor,
@ -52,7 +52,6 @@ impl BloodType {
}
pub fn recipients(&self) -> Vec<Self> {
}
}
```

12
subjects/bloody-sunday/README.md

@ -1,8 +1,14 @@
## Bloody Sunday
### Instructions
Let's get rid of Sundays, by removing them from the calendar. So now a week is only 6 days in length, from `"Monday"` to `"Saturday"`.
Create a function named `bloodySunday` which accepts a `Date`, and returns teh weekday as a `string`.
You were missioned to make the world more productive.
Your solution ? no more sundays,
you are ask to remove them from the existing calendar.
> 01/01/0001 is a Monday.
So now, a week is 6 days from monday to saturday.
To prove your point, create a `bloodySunday` function
that return what week day the given date is.
> note that the 01/01/0001 is still a monday.

6
subjects/border_cross/README.md

@ -2,9 +2,11 @@
### Instructions
At a border crossing, you want to keep a list of all the vehicles that are waiting to enter the country. You intend to keep a waiting list of the vehicles, but the vehicles can be one of two types: `Car` or `Truck`.
- Create the trait Vehicle with the model and year
Create a function that receives a vector of structures that implements the `Vehicle` trait, and returns all the models.
- In a border cross you want to keep a list of all the vehicles that are waiting to enter the country. You want to keep a waiting list of the vehicle but the vehicles can be of two types: Car or Truck
- Create a function that receives a vector of structures that implements the Vehicle trait and returns all the models.
With the following structure:

15
subjects/borrow/README.md

@ -2,17 +2,22 @@
### Instructions
Create a **function** named `str_len`, you'll need to complete the function signature. Your function should accept a string or a string literal, and return its length without taking ownership of the value (i.e, borrowing the value).
Complete the signature and the body of the `str_len` **function** that receives a string or a string literal and returns its length without taking ownership of the value (i.e, borrowing the value).
### Expected Function (The signature needs to be completed)
### Expected functions
```rust
pub fn str_len(s: ) -> usize {
}
```
### Notions
- [Primitive Type str](https://doc.rust-lang.org/std/primitive.str.html)
### Usage
Here is a possible program to test your function:
Here is a possible program to test your function :
```rust
use borrow::*;
@ -34,7 +39,3 @@ str_len("hello") = 5
str_len("camelCase") = 9
$
```
### Notions
- [Primitive Type str](https://doc.rust-lang.org/std/primitive.str.html)

23
subjects/borrow_box/README.md

@ -2,19 +2,24 @@
### Instructions
Game time.
In this exercise, a **CRUD** functionality will have to be created. Therefore the following functions will have to be defined :
You will implement some **CRUD** functionality for a game. You will need to implement the `Game` structure with the following associated functions:
- `new`, which receives two players and initializes them with a name and a score. This function should
return the structure wrapped in a Box.
- `new`: which initializes a game state with player names and some other information. This function returns the structure wrapped in a `Box`.
- `read_winner`, which returns a tuple with the name and the score of the player who is winning.
In case none of the players are winning, it should return the same tuple with the string "Same score! tied" and the tied score.
- `read_winner`: which returns a tuple with the name and score of the player who is currently winning. In the case that no player is winning, it should return the same tuple with the string `"Same score! tied"` and the tied score.
- `update_score`, which receives the name of a player.
This function should increment the score of the player. The score should only be increased if it does not pass the `nbr_of_games`.
Example: if the nbr_of_games is 3 then the winner of the game should be the one who is the best out of three games. So if one play has 2 wins then
he is the winner and the function should not increase the score anymore for either player.
- `update_score`: which receives the name of a player, and increments their score. The `nbr_of_games` should also be incremented. This function should **do nothing** if the the game is already finished.
- `delete`, which takes the ownership of the boxed game and returns a string: "game deleted: id -> 0".
- `delete`: which takes ownership of the boxed game and returns a string: `"game deleted: id -> 0"`.
### Notions
> If `nbr_of_games` is 5, then it is "best out of 5", and no more than 5 games can be played. If some player has a score of 3, then the game is also finished. This is because there is an insufficient number of remaining games for the trailing player to catch up.
- [Box Pointers](https://doc.rust-lang.org/book/ch15-01-box.html)
### Expected Functions
@ -88,7 +93,3 @@ $ cargo run
"game deleted: id -> 0"
$
```
### Notions
- [Box Pointers](https://doc.rust-lang.org/book/ch15-01-box.html)

24
subjects/borrow_me_the_reference/README.md

@ -2,15 +2,22 @@
### Instructions
Ownership is Rust's most unique feature. It enables Rust to make memory safety guarantees without needing a garbage collector. You must have a good understanding of ownership in rust.
Ownership is Rust's most unique feature, and it enables Rust to make memory safety guarantees without
needing garbage collector. Therefore you must understand ownership in rust.
Create the following functions:
Create the following functions :
- `delete_and_backspace`: which receives a borrowed string, and processes it. `-` represents the backspace key and `+` represents the delete key, so that `"helll-o"` and `"he+lllo"` are both converted to `"hello"`. The `-` and `+` characters should be removed from the string.
- `delete_and_backspace`, imagine that the `-` represents the `backspace key` and the `+` represents the `delete key`, this function must receive a borrowed string and turn this string into the string that applies the `backspaces` and the `deletes`.
- For example:
- `is_correct`: which borrows a Vector of string literals representing simple addition and subtraction equations. The function should replace the correct equations with `✔`, and the wrong ones with `✘`. It should return a `usize` with the percentage of correct equations.
- "helll-o" turns into "hello"
- "he+lllo" turns into "hello"
- `is_correct` that borrows a Vector of string literals with some correct and incorrect math equations and replaces the correct equations with `✔` and the wrong with `✘` and returns a `usize` with the percentage of correct equations.
### Expected Functions
```rust
pub fn delete_and_backspace(s: &mut String) {
}
@ -19,6 +26,10 @@ pub fn is_correct(v: &mut Vec<&str>) -> usize {
}
```
### Notions
- [ownership](https://doc.rust-lang.org/book/ch04-00-understanding-ownership.html)
- [meval](https://docs.rs/meval/0.2.0/meval/)
### Dependencies
@ -52,8 +63,3 @@ $ cargo run
("borrow", ["✔", "✔", "✘", "✔"], 75)
$
```
### Notions
- [ownership](https://doc.rust-lang.org/book/ch04-00-understanding-ownership.html)
- [meval](https://docs.rs/meval/0.2.0/meval/)

15
subjects/box_it/README.md

@ -4,9 +4,15 @@
Create the following **functions**:
- `transform_and_save_on_heap`: which accepts a string of numbers separated by spaces. Each number may or may not have a `'k'` as a suffix which represents kilograms. The function transforms those numbers into a vector of `u32`, and saves them in the heap using `Box`.
- `transform_and_save_on_heap`, which receives a string with a number (that can or not have a k (kilo) suffix)
and transforms those numbers into `u32` and inserts them into a vector which must be saved in the heap using **Box**.
- `take_value_ownership`: which accepts the return value from `transform_and_save_on_heap`, unboxes the value, and returns it.
- `take_value_ownership`, which takes the value (unboxed value) from the box and returns it
### Notions
- [smart pointers](https://doc.rust-lang.org/book/ch15-00-smart-pointers.html)
- [using box](https://doc.rust-lang.org/book/ch15-01-box.html)
### Expected Functions
@ -51,8 +57,3 @@ value : [5500, 8900, 32]
size occupied in the stack : 24 bytes
$
```
### Notions
- [smart pointers](https://doc.rust-lang.org/book/ch15-00-smart-pointers.html)
- [using box](https://doc.rust-lang.org/book/ch15-01-box.html)

24
subjects/box_recursion/README.md

@ -2,14 +2,21 @@
### Instructions
Using the given code, create the following **associated functions**:
Using the given code create the following **functions**:
- `new`: which will initialize the `WorkEnvironment` with `grade` set to `None`.
- `add_worker`: which receives two strings, one being the type of worker and the other the name of the worker.
- `remove_worker`: which removes the last worker that was placed in the `WorkEnvironment`, this function returns an `Option` with the name of the worker.
- `search_worker`: which returns a tuple with the name and type of worker.
- `new` which will initialize the `WorkEnvironment` as `None`
- `add_worker`, which receives two strings, one being the type of worker and the other the name of the worker.
- `remove_worker`, which removes the last worker that was placed in the `WorkEnvironment`, this function should
returns an `Option` with the name of the worker.
- `search_worker`, which returns a tuple with the name and type of worker.
You must also create a type named `Link`. This will be the connection between the `WorkEnvironment` and `Worker` structures. This will be a recursion type, and it must point to `None` if there is no `Worker` to point to.
You must also create a type called `Link`. This will be the connection of the structures `WorkEnvironment` and `Worker`.
Do not forget that this will be a recursion type and it must point to `None` if there is no workers.
### Notions
- [boc](https://doc.rust-lang.org/book/ch15-01-box.html)
- [Module std::option](https://doc.rust-lang.org/std/option/)
### Expected Functions and structures
@ -70,8 +77,3 @@ Some(("Alice", "Normal Worker"))
WorkEnvironment { grade: None }
$
```
### Notions
- [boc](https://doc.rust-lang.org/book/ch15-01-box.html)
- [Module std::option](https://doc.rust-lang.org/std/option/)

59
subjects/boxing_todo/README.md

@ -2,7 +2,8 @@
### Instructions
The objective is to create an API to parse a list of _todos_ that are organized in a JSON file. You must handle all possible errors in a multiple error system.
The objective is to create an api to parse a list of _todos_ that is organized in a JSON file,
handling all possible errors in a multiple error system.
Organization of the JSON file:
@ -18,30 +19,39 @@ Organization of the JSON file:
#### err.rs
Create a module in a file named **err.rs** which handles the boxing of errors.
Create a module in another file called **err.rs** which handles the boxing of errors.
This module must implement an `enum` called `ParseErr` which will take care of the
parsing errors. It must have the following elements:
This module must implement an `enum` called `ParseErr` which will take care of the parsing errors. It must have the following elements:
- Empty
- Malformed, which has a dynamic boxed error as element
- `Empty`
- `Malformed`: which has a dynamic boxed error as element
A structure called `ReadErr` which will take care of the reading errors, having just an element called `child_err` of type `Box<dyn Error>`.
A structure called `ReadErr` which will take care of the reading errors, with an element called `child_err` of type `Box<dyn Error>`.
For each data structure, you will have to implement a function called `fmt` for the `Display` trait. It should write the message **"Fail to parse todo"** in the case of any parsing error. Otherwise, it should write the message **"Fail to read todo file"**.
For the `Error` trait, the following functions (methods) have to be implemented:
For each data structure you will have to implement a function called `fmt` for the trait `Display` which writes
out the message **"Fail to parse todo"** in case it is a parsing error. Otherwise, it should write the message
**"Fail to read todo file"**.
For the `Error` trait the following functions (methods) have to be implemented:
- `source` which returns an `Option` with the error:
- For the `ReadErr`, it must return the option with the error.
- For the `ParseErr`, it will return an option which is `None` if the tasks are **empty**, and the error if the parsing is **malformed**.
- For the `ReadErr` it must just return the option with the error
- For the `ParseErr` it will return an option which can be `None` if the tasks are **empty** otherwise the error, if
the parsing is **malformed**.
#### lib.rs
In the **lib** file you will have to implement a **function** called `get_todo` which receives a string and returns a `Result` which can be the structure `TodoList` or a boxing error. This **function** must be able to deserialize the json file.
In the **lib** file you will have to implement a **function** called `get_todo` which receives a string and returns a Result
which can be the structure `TodoList` or a boxing error. This **function** must be able to deserialize the json file.
Basically it must parse and read the JSON file and return the `TodoList` if everything is fine, otherwise it returns the error.
### Notions
- [Module std::fmt](https://doc.rust-lang.org/std/fmt/)
- [JSON](https://docs.rs/json/0.12.4/json/)
- [Boxing errors](https://doc.rust-lang.org/stable/rust-by-example/error/multiple_error_types/boxing_errors.html)
- [Returning Traits wirh dyn](https://doc.rust-lang.org/stable/rust-by-example/trait/dyn.html)
### Expected Functions
For **err.rs**
@ -118,11 +128,13 @@ impl TodoList {
### Usage
Here is a program to test your function.
You can create some _todos_ yourself, inside the boxing_todo file in order to test it. The JSON structure can be found above.
Note that you can create some todo list your self to test it, but you can find the JSON files that
are being tested [here](https://github.com/01-edu/public/blob/master/subjects/boxing_todo)
```rust
use boxing_todo::TodoList;
mod lib;
use lib::{ TodoList };
fn main() {
let todos = TodoList::get_todo("todo.json");
match todos {
@ -131,13 +143,15 @@ fn main() {
println!("{}{:?}", e.to_string(), e.source());
}
}
let todos = TodoList::get_todo("todo_empty.json");
let todos = TodoList::get_todo("no_todo_list.json");
match todos {
Ok(list) => println!("{:?}", list),
Err(e) => {
println!("{}{:?}", e.to_string(), e.source());
}
}
let todos = TodoList::get_todo("malformed_object.json");
match todos {
Ok(list) => println!("{:?}", list),
@ -153,14 +167,7 @@ And its output:
```console
$ cargo run
TodoList { title: "TODO LIST FOR PISCINE RUST", tasks: [Task { id: 0, description: "do this", level: 0 }, Task { id: 1, description: "do that", level: 5 }] }
Fail to parses todoNone
Todo List parse failed: None
Fail to parse todo Some(Malformed(UnexpectedCharacter { ch: ',', line: 2, column: 18 }))
$
```
### Notions
- [Module std::fmt](https://doc.rust-lang.org/std/fmt/)
- [JSON](https://docs.rs/json/0.12.4/json/)
- [Boxing errors](https://doc.rust-lang.org/stable/rust-by-example/error/multiple_error_types/boxing_errors.html)
- [Returning Traits with dyn](https://doc.rust-lang.org/stable/rust-by-example/trait/dyn.html)

42
subjects/brackets_matching/README.md

@ -2,40 +2,24 @@
### Instructions
Create a **program** that takes an undefined number of command-line arguments. For each argument, if the expression is correctly bracketed, the program prints `OK` to the standard output 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.
All characters are ignored except for the following brackets:
- parentheses `(` and `)`.
- square brackets `[` and `]`.
- curly braces `{` and `}`.
Symbols considered as brackets are parentheses `(` and `)`, square brackets `[` and `]` and curly braces `{` and `}`. Every other symbols are simply ignored.
Opening brackets must only be closed by the corresponding closing bracket. For example, a curly brace cannot close a square bracket.
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`.
A `String` which does not contain any brackets is considered to be correctly bracketed.
If there are no arguments, the program must print nothing.
You'll need to get the command line arguments somehow, and this will get you started:
```rust
fn main() {
let args: Vec<String> = std::env::args().collect();
//...
}
```
If there is no argument, the program must print nothing.
### Usage
```console
$ 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
$ 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 .
$
```

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 exercise 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 exercice 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]);
}
```

28
subjects/brainfuck/README.md

@ -1,23 +1,21 @@
## brainfuck
> Esoteric programming languages (esolang) are designed to test the boundaries of computer programming design, as proofs of concept, as software art, as a hacking interface or simply as a joke. One such esoteric language is `Brainfuck`. It was created by Urban Müller in 1993. It is a minimalist language consisting of 8 simple commands. It is Turing complete, but is not intended for practical use. It exists to amuse and challenge programmers.
### Instructions
Write a `Brainfuck` interpreter program.
The source code will be given as the first parameter, and will always be valid with fewer than 4096 operations.
Your `Brainfuck` interpreter will consist of an array of 2048 bytes, all initialized to 0, with a pointer to the first byte.
Every operator consists of a single character:
- `>`: increment the pointer.
- `<`: decrement the pointer.
- `+`: increment the pointed byte.
- `-`: decrement the pointed byte.
- `.`: print the pointed byte to the standard output.
- `[`: if the pointed byte is 0, then instead of moving onto the next command, skip to the command after the matching `]`.
- `]`: if the pointed byte is **not** 0, then instead of moving onto the next command, move back to the command after the matching `[`.
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.
Every operator consists of a single character :
- '>' increment the pointer
- '<' decrement the pointer
- '+' increment the pointed byte
- '-' decrement the pointed byte
- '.' print the pointed byte on standard output
- '[' go to the matching ']' if the pointed byte is 0 (loop start)
- ']' go to the matching '[' if the pointed byte is not 0 (loop end)
Any other character is a comment.

4
subjects/btreetransplant/README.md

@ -30,8 +30,8 @@ func main() {
piscine.BTreeInsertData(root, "7")
piscine.BTreeInsertData(root, "5")
node := piscine.BTreeSearchItem(root, "1")
rplc := &piscine.TreeNode{Data: "3"}
root = piscine.BTreeTransplant(root, node, rplc)
replacement := &piscine.TreeNode{Data: "3"}
root = piscine.BTreeTransplant(root, node, replacement)
piscine.BTreeApplyInorder(root, fmt.Println)
}
```

44
subjects/build-brick-and-break/README.md

@ -2,41 +2,43 @@
### Instructions
Today, your mission is to build a 3-column brick tower, maintain it and finally break it.
Today, your mission is to build a 3-column brick tower, maintain it and finally break it!
- Create a function `build` which will create and display the amount of bricks passed as argument:
- Create a function `build` which will create and display the given amount of bricks passed as argument:
- each brick has to be created as a `div` and added to the page at a regular interval of 100ms.
- each brick will receive a unique `id` property, like the following:
- each brick has to be created as a `div` and added to the page at a regular interval of 100ms,
- each brick will receive a unique `id` property, like following:
```html
<div id="brick-1"></div>
```
- each brick in the middle column has to be set with the custom data attribute `foundation`, receiving the value `true`.
- each brick in the middle column has to be set with the custom data attribute `foundation` receiving the value `true`
- Each one of the two emojis in the top-right corner fires a function on click:
- 🔨: triggers the function `repair`. Write the body of that function. It receives any number of `ids`. For each `id`, it retrieves the HTML element, and sets the `repaired` custom attribute to `in progress` if it is a brick situated in the middle column, and `true` if not.
- 🧨: triggers the `destroy` function. Erite the body of that function. It removes the current last brick in the tower.
- 🔨 triggers the function `repair`: write the body of that function, which receives any number of `ids`, and for each `id`, retrieves the HTML element and set a custom attribute `repaired` set to `in progress` if it is a brick situated in the middle column, and `true` if not
- 🧨 triggers the function `destroy`: write the body of that function, which removes the current last brick in the tower
### Notions
- [`createElement()`](https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement)
- [`append()`](https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/append)
- [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)
- [`setInterval()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval) / [`clearInterval()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/clearInterval)
- [`hasAttribute()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttribute)
- [dataset](https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/dataset) / [`data-*`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/data-*)
- [`remove()`](https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove)
### Files
You only need to create & submit the JS file `build-brick-and-break.js`, We're providing you the following file to download and test locally:
You only need to create & submit the JS file `build-brick-and-break.js` ; we're providing you the following file to download (click right and save link) & test locally:
- the HTML file [build-brick-and-break.html](./build-brick-and-break.html) can be opened in the browser, which includes:
- the JS script running some code, and which will enable you to run your code.
- some CSS pre-styled classes: feel free to use those as they are, or modify them.
- the HTML file [build-brick-and-break.html](./build-brick-and-break.html) to open in the browser, which includes:
- the JS script running some code, and which will also allow to run yours
- some CSS pre-styled classes: feel free to use those as they are, or modify them
### Expected result
You can see an example of the expected result [here](https://youtu.be/OjSP_7u9CZ4)
### Notions
- [createElement](https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement)
- [append](https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/append)
- [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)
- [setInterval](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval) / [clearInterval](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/clearInterval)
- [hasAttribute](https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttribute)
- [dataset](https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/dataset) / [data-*](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/data-*)
- [remove](https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove)

6
subjects/capitalizing/README.md

@ -2,11 +2,11 @@
### Instructions
Complete the `capitalize_first` **function** which converts the first letter of the string to uppercase.
Complete the `capitalize_first` **function** which turns the first letter of a string to uppercase.
Complete the `title_case` **function** which converts the first letter of each word in a string to uppercase.
Complete the `title_case` **function** which turns the first letter of each word in a string to uppercase.
Complete the `change_case` **function** which converts the uppercase letters of a string into lowercase, and the lowercase to uppercase.
Complete the `change_case` **function** which turns the uppercase letters of a string into lowercase and the lowercase letters into uppercase.
### Expected Functions

34
subjects/card_deck/README.md

@ -2,22 +2,31 @@
### Instructions
A standard deck of cards has 52 cards: 4 suits with 13 cards per suit.
A standard deck of cards has 52 cards: 4 suits and 13 cards per suit.
Represent the cards from a deck:
- Create an `enum` to represent the `Suit`.
- Implement the associated **function** `random`, which returns a random `Suit` (`Heart`, `Diamond`, `Spade` or `Club`).
- Create a `Rank` enum. For ace and face cards, it can be one of `Ace`, `King`, `Queen` or `Jack`. For the values from 2 to 10, it can have a `Number` value associated to a `u8`.
- Create an associated **function** to `Rank` called `Random` that returns a random `Rank`.
- Create a structure name `Card` which has the fields `suit` and `rank`.
- Start by creating the `Suit` enum
- implement the associated **function** `random` which returns a random `Suit` (`Heart`, `Diamond`, `Spade` or `Club`)
- Then create the `Rank` enum that can have the value
`Ace`, `King`, `Queen`, `Jack`, and `Number` associated to an `u8`
value to represent the ranks 2 through 10
- After create an associated **function** to `Rank` called `Random` that
returns a random `Rank`
- Finally create a structure name `Card` which has the fields `suit`
and `rank`
Define:
- The associated **function** `translate` for `Rank` and `Suit`:
- For `Suit`, `translate` converts an integer value (`u8`) to a suit (1 -> Heart, 2 -> Diamonds, 3 -> Spade, 4 -> Club).
- For `Rank`, `translate` converts an integer value (`u8`) to a rank ( 1 -> Ace, 2 -> 2, .., 10 -> 10, 11 -> Jack, 12 -> Queen, 13 -> King).
- The associated **function** `random` for `Rank` and `Suit` returns a random `Rank` and `Suit` respectively.
- Finally define the **function** `winner_card` which returns `true` if the card passed as an argument is an ace of spades.
- For `Suit`, `translate` makes the translation between an integer value (u8) and the suit of a card (1 -> Heart, 2 -> Diamonds, 3 -> Spade, 4 -> Club)
- For `Rank`, `translate` makes the translation between an integer value (u8) and the rank ( 1 -> Ace, 2 -> 2, .., 10 -> 10, 11 -> Jack, 12 -> Queen, 13 -> King)
- The associated **function** `random` for `Rank` and `Suit` which returns a random `Rank` and `Suit` respectively
- Finally define the **function** `winner_card` which returns `true` if the card passed as an argument is an Ace of spades
### Notions
- [Crate rand](https://docs.rs/rand/0.3.14/rand/)
- [Enums](https://doc.rust-lang.org/book/ch06-00-enums.html)
### Dependencies
@ -84,8 +93,3 @@ $ cargo run
Your card is Card { suit: Club, rank: Ace }
$
```
### Notions
- [Crate rand](https://docs.rs/rand/0.3.14/rand/)
- [Enums](https://doc.rust-lang.org/book/ch06-00-enums.html)

29
subjects/chaikin/README.md

@ -2,33 +2,24 @@
### Instructions
Implement [Chaikin's](http://graphics.cs.ucdavis.edu/education/CAGDNotes/Chaikins-Algorithm/Chaikins-Algorithm.html) algorithm as a step by step animation.
Implement the [Chaikin's](http://graphics.cs.ucdavis.edu/education/CAGDNotes/Chaikins-Algorithm/Chaikins-Algorithm.html) algorithm step by step in an animation.
You will create a canvas to enable the user to draw 1 or more points. The screen will then animate each step that is taken to obtain the final result of a drawn curve. The animation must play for 7 steps and then it must restart.
The objective is to create a canvas where the user will draw 1 or more points, and then the screen will play an animation of each step to get to the final result of a curve drawn using the `Chaikin's` algorithm. You can see [here](https://youtu.be/PbB2eKnA2QI) a demo of how the application should work.
You can see how the application should work [here](https://youtu.be/PbB2eKnA2QI).
- Functionality:
> Usage of Chaikin's algorithm is mandatory.
- The canvas should receive input from the mouse: the user of the program should be able to use the left button to select the control point for the `Chaikin's` algorithm
#### Functionality
- After pressing `Return` should start the animation of the steps until reaching the 7th step of the `Chaikin's` algorithm.
- The canvas must receive input from the mouse. The user must be able to use the left button to place control points for Chaikin's algorithm.
- The selected points must be visible on the canvas. You will need to draw a **small** circle surrounding each point.
- Pressing `Escape` should quit the window.
- If the canvas has control points drawn on it, then pressing `Enter` should start the animation. It should cycle through the steps until reaching the 7th step of `Chaikin's` algorithm. The animation should then restart.
### Note
- If the user presses `Enter` before any points have been drawn, then nothing should happen. It should still be possible to draw points. You may optionally choose to display a message to inform the user that they forgot to draw points.
- If the canvas only has only one control point, the program must only present that point and not cycle through the steps.
- If the canvas has only two control points, the program must draw a straight line.
- Pressing `Escape` should quit the window.
> You are free to use any library to create and handle windows, rendering, keyboard and mouse events.
You are free to use any library for creating and handling window creation, rendering, keyboard and mouse events.
### Bonus
- Make it possible to clear the screen, so that the user can select new control points.
- Add the ability to clear the screen and add new control points.
- Make it possible to drag the control points in real time.

44
subjects/chaikin/audit/README.md

@ -1,49 +1,29 @@
#### Functional
##### Run the program using `cargo run`.
##### Run the program using `cargo run`
###### Does it compile and run without warnings?
###### Does it compile and run without any warnings?
##### Left click on the canvas to set one or more control points.
##### Left click in three different positions in the canvas
###### Does the program allow you to mark these control points?
###### Does the program draw a small circle surrounding the area where you clicked?
###### Can you confirm that the program draws a small circle around the control points in order to identify them?
##### Press `Return`
##### Left click on the canvas to set three or more control points and press `Enter`.
###### Does the animation of the Chaikin's algorithm starts?
###### Does the animation of the Chaikin's algorithm start?
###### Does the animations the animation completes 7 steps before starting again?
##### Press `Escape` to exit the program.
##### Press `Escape`
###### Does the program exit without errors?
##### Start the program and left click on the canvas to set just one control point and press `Enter`.
##### Run the program again and this time press `Return` without selecting any points
###### Can you confirm that only the control point is shown and nothing changes?
##### Restart the program and left click on the canvas to set just two control points and press `Enter`.
###### Can you confirm that only a straight line was drawn?
##### Restart the program and left click on the canvas to set three or more control points and press `Enter`.
###### Does the animation complete 7 steps before restarting?
##### Restart the program and left click on the canvas to set three or more control points and press `Enter`. Then press `Escape` to exit the program.
###### Does the program exit without errors?
##### Start the program and press `Enter` without selecting any points.
###### Does the program continue without errors?
###### After you pressed `Enter` before selecting points, is it possible to place points without needing to kill the program?
###### Is the program still running?
##### Bonus
###### +When you pressed `Enter` without drawing any points, was a message displayed to inform you that you forgot to draw any points?
###### +Is it possible to clear the screen and add new control points without killing and relaunching the program?
###### +Are you able to clear the screen and add new control points without killing and relaunching the program?
###### +Is it possible to drag the control points in real time and get a new curve?
###### +Are you able to drag the control points in real time and get a new curve?

17
subjects/change/README.md

@ -4,20 +4,23 @@
Create 2 functions:
- `get`: a function that takes a key and returns the corresponding value from the `sourceObject`.
- `get`: a function that takes a key and return the corresponding
value from the sourceObject
- `set`: a function that takes a key and a value. Update the value for the corresponding property of the `sourceObject` and return the value.
- `set`: a function that takes a key and a value update the
value for the corresponding property of the sourceObject
and return the set value
### Notions
- [Functions](https://nan-academy.github.io/js-training/examples/functions.js)
- [Data Structures](https://nan-academy.github.io/js-training/examples/data-structures.js)
- [Get](https://nan-academy.github.io/js-training/examples/get.js)
- [Set](https://nan-academy.github.io/js-training/examples/set.js)
- [nan-academy.github.io/js-training/examples/functions.js](https://nan-academy.github.io/js-training/examples/functions.js)
- [nan-academy.github.io/js-training/examples/data-structures.js](https://nan-academy.github.io/js-training/examples/data-structures.js)
- [nan-academy.github.io/js-training/examples/get.js](https://nan-academy.github.io/js-training/examples/get.js)
- [nan-academy.github.io/js-training/examples/set.js](https://nan-academy.github.io/js-training/examples/set.js)
### Code provided
> The provided code will be added to your solution, and does not need to be submitted.
> all code provided will be added to your solution and doesn't need to be submited.
```js
const sourceObject = {

16
subjects/changes/README.md

@ -2,11 +2,16 @@
### Instructions
Imagine you are working on some software to control smart lights in a house. You have access to an array of all the lights in that house.
Imagine you are working on a software to control smart lights in a house. You have access to an array of all the lights in a house.
Define the associated **function** `new`, and add it to the data structure `Light`. It should create a new light with the alias passed as an argument, with a brightness of 0.
Define the associated **function** `new` to the data structure `Light` which creates a new light with the alias passed in the arguments and a brightness of 0.
Define the **function** `change_brightness`, which receives a `Vec` of lights, an `alias` and a `u8`value. It should find the light in the `Vec` by its alias, and set the value of the brightness.
Define the **function** `change_brightness` that receives a `Vec` of lights, an `alias` and a `u8`value. The **function** then sets the `u8` value as the new brightness of the light identified by the alias in the Vec of lights.
### Notions
- [Example of Structs](https://doc.rust-lang.org/book/ch05-02-example-structs.html)
- [Keyword Self](https://doc.rust-lang.org/std/keyword.Self.html)
### Expected Functions and Structure
@ -54,8 +59,3 @@ brightness = 0
new brightness = 200
$
```
### Notions
- [Example of Structs](https://doc.rust-lang.org/book/ch05-02-example-structs.html)
- [Keyword Self](https://doc.rust-lang.org/std/keyword.self.html)

7
subjects/chunky/README.md

@ -2,8 +2,7 @@
### Instructions
Create a function named `chunk` which accepts an array and an integer representing a size.
Create the `chunk` function which has as parameters an `array` that will be split and an `integer` which is the size that the array should be split.
Your function will chunk the array into sub-arrays, and return an array with each sub-array as its elements. The length of each sub-array is denoted by the size argument.
If the array cannot be split evenly, the last sub-array will contain the remaining elements.
The function will return an array of elements divided into groups of the length of the given size.
If the array cannot be split evenly, the final part will be the remaining elements.

13
subjects/cipher/README.md

@ -4,9 +4,14 @@
The Atbash cipher is an encryption method in which each letter of a word is replaced by its mirror letter in the alphabet.
Your objective is to create a **function** named `cipher` which must return a `Result` wrapped in an `Option`. The `Result` should contain either a `boolean` or and `Error` based on the `CipherError` structure. This structure should be the error type for the **function** `cipher`.
Your objective is to create a **function** called `cipher` which must return a `Result` wrapped in an `Option`, this result should return either a `boolean`
or an `Error` based on the structure `CipherError`. This structure should be the error type for the **function** `cipher`.
`cipher` should compare the original `String` with the ciphered `String`. It should return `true` if the cipher is correct. If the cipher is incorrect it should return the error type `CipherErr` with a `boolean` and the expected atbash cipher `String`.
This function should compare the original `String` with the ciphered `String`. It should return `true` if the cipher is correct. If the cipher is incorrect it should return the error type `CipherErr` with a `boolean` and the expected atbash cipher `String`.
### Notions
- [Module std::fmt](https://doc.rust-lang.org/std/fmt/index.html)
### Expected Function and structure
@ -49,7 +54,3 @@ Some(Err(CipherError { validation: false, expected: "1Svool 2dliow!" }))
None
$
```
### Notions
- [Module std::fmt](https://doc.rust-lang.org/std/fmt/index.html)

30
subjects/circle/README.md

@ -2,25 +2,30 @@
### Instructions
Create the structures `Circle` and `Point`. You'll need to create the necessary methods for the code in the [usage](#usage) to compile, and give the expected output.
Create the structures `Circle` and `Point` (which will be made of two coordinates) and the methods necessary for the code in [usage](#usage) to compile and run giving the expected output.
#### Methods:
- `Point`:
- `distance()` -> returns the distance between two coordinates.
- `Circle`:
- `diameter()` -> returns the diameter of the circle.
- `area()` -> returns the area of the circle.
- `intersect()` -> which returns `true`, if 2 circles intersect.
- Point:
distance() -> returns the distance between two coordinates.
- Circle:
- diameter() -> returns the diameter of the circle.
- area() -> returns the area of the circle.
- intersect() -> which returns true, if 2 circles intersect.
#### Associated Functions
- `Circle`:
- `new()` -> receives three 64bit floating point numbers in the following order: x, y and radius (x and y are the coordinates of the center of the new circle). The function returns a new circle.
- Circle:
- new() -> receives three 64 bits floating point numbers in the following order: x, y and radius (x and y are the coordinates of the center of the new circle). The function returns a new circle
### Notions
- [Using Structs](https://doc.rust-lang.org/book/ch05-00-structs.html)
- [f64 constants](https://doc.rust-lang.org/std/f64/consts/index.html)
### Expected Functions and Structures
This snippets are incomplete, you'll need to complete them. You'll find some useful information in the [usage](#usage).
This snippets are incomplete and it is part of the exercise to discover how to complete them. In the [usage](#usage) you will find all the information that you need.
```rust
pub struct Circle {
@ -96,8 +101,3 @@ circle and circle1 intersect = false
distance between Point { x: 1.0, y: 1.0 } and Point { x: 0.0, y: 0.0 } is 1.4142135623730951
$
```
### Notions
- [Using Structs](https://doc.rust-lang.org/book/ch05-00-structs.html)
- [f64 constants](https://doc.rust-lang.org/std/f64/consts/index.html)

9
subjects/circular/README.md

@ -2,10 +2,11 @@
### Instructions
Create an object named `circular` that has a property named `circular` with itself as the value.
Create an object named `circular` that has a property named `circular` with
itself as the value
### Notions
- [Data Structures](https://nan-academy.github.io/js-training/examples/data-structures.js)
- [Get](https://nan-academy.github.io/js-training/examples/get.js)
- [Sets](https://nan-academy.github.io/js-training/examples/set.js)
- [nan-academy.github.io/js-training/examples/data-structures.js](https://nan-academy.github.io/js-training/examples/data-structures.js)
- [nan-academy.github.io/js-training/examples/get.js](https://nan-academy.github.io/js-training/examples/get.js)
- [nan-academy.github.io/js-training/examples/set.js](https://nan-academy.github.io/js-training/examples/set.js)

4
subjects/cl-camp3/README.md

@ -4,9 +4,9 @@
"start looking ..."
Create a file `look`, which will look for and show, in the current directory and its sub-folders:
Create a file `look`, which will look for and show, in the current directory and its sub-folders all the files :
- everything that starts with an `a` or,
- starting with an `a` or,
- all the files ending with a `z` or,
- all files starting with `z` and ending with `a!`.

27
subjects/clonernews/README.md

@ -1,30 +1,35 @@
## clonernews
### Objectives
Technology is a rapidly evolving sector. As a programmer, it is not always easy to keep up to date with every new advancement.
Tech news (like Hacker News) is a really great way to keep up to date with the exponential evolution of technology, as well as tech jobs and much more. Some websites do not offer very appealing propositions to consume their media.
Technology nowadays continue to evolve. As a programmer or developer you must be updated with this exponential evolution of technology.
So your objective for this raid is to create an UI for the [HackerNews API](https://github.com/HackerNews/API).
This is where tech news shines, just like Hacker News where you can see all about new technology, jobs and much more, but some websites do not perform very well or their are not so appealing.
So your objective for this raid is to create an UI for [`HackerNewsAPI`](https://github.com/HackerNews/API).
You must handle at least:
- Posts: including:
- Posts, this includes :
- [stories](https://github.com/HackerNews/API#ask-show-and-job-stories)
- [jobs](https://github.com/HackerNews/API#ask-show-and-job-stories)
- [polls](https://github.com/HackerNews/API#items)
- [comments](https://github.com/HackerNews/API#items): each comment must have the proper post parent.
- [comments](https://github.com/HackerNews/API#items), each comment must have the proper post parent.
Post and comments must be ordered by newest post to oldest.
You must not load all posts at once, so that you only load posts once the users need to see more posts. This can be done with the help of [events](https://developer.mozilla.org/en-US/docs/Web/Events).
You must not load all posts at once. You must be able to load posts when ever the users need to see more posts. This can be done with the help of [event](https://developer.mozilla.org/en-US/docs/Web/Events).
[Live Data](https://github.com/HackerNews/API#live-data) : is one of the features from this Hacker News API, you can handle requests so that the news you provide are updated.
- You must have a section that present the newest information. You will have to notify the user at least every 5 seconds, whenever the live data is updated. In other words, after every 5 seconds if a change was made in the live data, you have to notify the user.
The point of the project is to keep users updated, so we'll need to inform our users of changes to the data using [Live Data](https://github.com/HackerNews/API#live-data). Create a section that presents the newest information. You'll need to notify the user at least every 5 seconds, whenever the live data is updated.
Currently this API does not present [rate limit](https://en.wikipedia.org/wiki/Rate_limiting). But that does not mean you should abuse/overload the API!!!
Currently this API does not present a [rate limit](https://en.wikipedia.org/wiki/Rate_limiting), but that does not mean that you should abuse or overload the API.
Best ways you can avoid rate limiting :
Best ways you can avoid rate limiting:
- optimize your code to eliminate any unnecessary requests
- usage of a throttling/debouncing function to regulate the number of requests,
- usage of throttling/debouncing function to regulates the amount of requests
### Optional
You can handle sub-comments for stories, jobs and polls, by implementing nested comments.
You can handle sub-comments for each stories, jobs and polls this meaning nested comments

18
subjects/clonernews/audit/README.md

@ -1,20 +1,20 @@
#### Functional
#### Functionals
##### Try to open a story post
###### Does this post open without any errors?
###### Does this post open without problems?
##### Try to open a job post
###### Does this post open without any errors?
###### Does this post open without problems?
##### Try to open a poll post
###### Does this post open without any errors?
###### Does this post open without problems?
##### Try to load more posts
###### Did the posts load without error and without spamming the user?
###### Did the posts loaded without error or without spamming the user?
##### Try to open a post with comments
@ -24,16 +24,16 @@
###### Does the UI have at least stories, jobs and polls?
###### Are the posts displayed in the correct order (from newest to oldest)?
###### Are the posts displayed in the correct order(from newest to oldest)?
###### Does each comment present the right parent post?
###### Does the UI notify the user when a certain post is updated?
###### Is the UI notifying the user that there is a new update on a certain post?
###### Is the project using throttling to regulate the number of requests (every 5 seconds)?
###### Is the project using Throttle to regulate the amount of request (every 5 seconds)?
#### Bonus
###### +Does the UI have more types of posts than stories, jobs and polls?
###### +Have sub-comments (nested comments) been implemented?
###### +Are there sub-comments(nested comments) on the UI?

11
subjects/closures/README.md

@ -2,7 +2,12 @@
### Instructions
Using closures and iterators create a **function**, that returns the first 50 even numbers squared in a `Vec<i32>`.
Using closures and iterators create a **function**, `first_fifty_even_square` that returns the first 50 even numbers squared.
in a `Vec<i32>`.
### Notions
[Iterators and Closures](https://doc.rust-lang.org/book/ch13-00-functional-features.html)
### Expected Functions
@ -34,7 +39,3 @@ $ cargo run
All elements in [4, 16, 36, ..., 10000], len = 50
$
```
### Notions
[Iterators and Closures](https://doc.rust-lang.org/book/ch13-00-functional-features.html)

2
subjects/collect/README.md

@ -2,7 +2,7 @@
### Instructions
Implement the **function** `bubble_sort`, which receives a `Vec<i32>` and returns the same vector but in increasing order using the bubble sort algorithm.
Implement the **function** `bubble_sort` which receives a vector Vec<i32> and returns the same vector but in increasing order using the bubble sort algorithm.
### Expected Function

39
subjects/collections/README.md

@ -2,21 +2,22 @@
### Instructions
Write a bunch of functions which converts data from one type to another:
Write a bunch of function to move from one type to another
- `arrToSet`: from `Array` to `Set`.
- `arrToStr`: from `Array` to `string`.
- `setToArr`: from `Set` to `Array`.
- `setToStr`: from `Set` to `string`.
- `strToArr`: from `string` to `Array`.
- `strToSet`: from `string` to `Set`.
- `mapToObj`: from `Map` to `Object`.
- `objToArr`: from `Object` to `Array`.
- `objToMap`: from `Object` to `Map`.
- `arrToObj`: from `Array` to `Object`.
- `strToObj`: from `string` to `Object`.
- `arrToSet` from `Array` to `Set`
- `arrToStr` from `Array` to `String`
- `setToArr` from `Set` to `Array`
- `setToStr` from `Set` to `String`
- `strToArr` from `String` to `Array`
- `strToSet` from `String` to `Set`
- `mapToObj` from `Map` to `Object`
- `objToArr` from `Object` to `Array`
- `objToMap` from `Object` to `Map`
- `arrToObj` from `Array` to `Object`
- `strToObj` from `String` to `Object`
Finally, write a function named `superTypeOf` that unlike `typeof` returns a specific values for advanced types like `Map` and `Set`.
and finally write a function `superTypeOf` that unlike `typeof` return
a different value for advanced types like `Map` and `Set`
### Examples
@ -61,9 +62,9 @@ superTypeOf(superTypeOf) // -> 'Function'
### Notions
- [typeof](https://devdocs.io/javascript/operators/typeof)
- [Spread syntax](https://devdocs.io/javascript/operators/spread_syntax)
- [Map](https://devdocs.io/javascript/global_objects/map)
- [Set](https://devdocs.io/javascript/global_objects/set)
- [Object.fromEntries](https://devdocs.io/javascript/global_objects/object/fromentries)
- [Object.entries](https://devdocs.io/javascript/global_objects/object/entries)
- [devdocs.io/javascript/operators/typeof](https://devdocs.io/javascript/operators/typeof)
- [devdocs.io/javascript/operators/spread_syntax](https://devdocs.io/javascript/operators/spread_syntax)
- [devdocs.io/javascript/global_objects/map](https://devdocs.io/javascript/global_objects/map)
- [devdocs.io/javascript/global_objects/set](https://devdocs.io/javascript/global_objects/set)
- [devdocs.io/javascript/global_objects/object/fromentries](https://devdocs.io/javascript/global_objects/object/fromentries)
- [devdocs.io/javascript/global_objects/object/entries](https://devdocs.io/javascript/global_objects/object/entries)

26
subjects/commits_stats/README.md

@ -2,13 +2,26 @@
### Instructions:
In this exercise, you will be provided with a json file `commits.json` with data corresponding to git commits in GitHub (extracted using the GitHub rest API). Your objective is to extract the relevant data and place it in a struct called `CommitData`.
In this exercise you will be provided with a json file `commits.json` with data corresponding to git commits in GitHub (extracted using the GitHub rest API). Your objective is to extract the relevant data and place it in a struct called `CommitData` to get the following information:
1. Number of commits per author (identified by the GitHub login).
2. The number of commits per author.
Create two functions:
- `commits_per_author`: which returns a hash map with the number of commits per author. The auditors will be identified by their GitHub login.
- `commits_per_week`: which returns a hash map with the number of commits per week.
> A week is represented by the a year followed by the number of the week. For example, January 1, 2020 is in week 1 of 2020 and will be represented by a `String` with the form `"2020-W1"`.
- `commits_per_author`: which returns a hash map with the number of commits per author.
- `commits_per_date`: which returns a hash map with the number of commits per week.
- Note: A week is represented by the a year followed by the number of the
week. For example, January 1, 2020 is in week 1 of 2020 and will be
represented by a String with the form "2020-W1".
### Notions:
- [chrono](https://docs.rs/chrono/0.4.19/chrono)
- [json](https://docs.rs/json/0.12.4/json/index.html)
### Expected functions
@ -43,8 +56,3 @@ $ cargo run
{"homembaixinho": 2, "mwenzkowski": 3, ... ,"tamirzb": 1, "paul-ri": 2, "RPigott": 1}
$
```
### Notions:
- [chrono](https://docs.rs/chrono/0.4.19/chrono)
- [json](https://docs.rs/json/0.12.4/json/index.html)

6
subjects/concat-str/README.md

@ -2,9 +2,9 @@
### Instructions
Create a function named `concatStr` which takes 2 arguments and concatenates them.
Create a `concatStr` function that takes 2 arguments and concatenate them
### Notions
- [Functions.js](https://nan-academy.github.io/js-training/examples/functions.js)
- [Primitive and Operators.js](https://nan-academy.github.io/js-training/examples/primitive-and-operators.js)
- [nan-academy.github.io/js-training/examples/functions.js](https://nan-academy.github.io/js-training/examples/functions.js)
- [nan-academy.github.io/js-training/examples/primitive-and-operators.js](https://nan-academy.github.io/js-training/examples/primitive-and-operators.js)

31
subjects/copy/README.md

@ -2,20 +2,28 @@
### Instructions
Create the following **functions**. The objective is to know how ownership works with different types.
Your objective is to fix the **functions** work so that the program works.
- `nbr_function` returns a tuple:
- with the `original` value.
- the `exponential function` of the value.
- and the `natural logarithm` of the `absolute` value.
- with the `original` value
- the `exponential function` of the value
- and the `natural logarithm` of this `absolute` value
- `str_function` returns a tuple:
- with the `original` value.
- and the `exponential function` of each value as a string (see the example).
- with the `original` value
- and the `exponential function` each value as a string (see the example)
- `vec_function` returns a tuple:
- with the `original` value.
- and the `natural logarithm` of each `absolute` value.
- with the `original` value
- and the `natural logarithm` of each `absolute` value
The objective is to know how ownership works with different types.
### Notions
- [scope](https://doc.rust-lang.org/rust-by-example/scope/move.html)
- [Primitive Type f64](https://doc.rust-lang.org/std/primitive.f64.html)
### Expected Functions
### Expected functions
```rust
pub fn nbr_function(c: i32) -> (i32, f64, f64) {
}
@ -58,8 +66,3 @@ $ cargo run
([1, 2, 4, 5], [0.0, 0.6931471805599453, 1.3862943611198906, 1.6094379124341003])
$
```
### Notions
- [scope](https://doc.rust-lang.org/rust-by-example/scope/move.html)
- [Primitive Type f64](https://doc.rust-lang.org/std/primitive.f64.html)

3
subjects/count-leap-years/README.md

@ -2,4 +2,5 @@
### Instructions
Create a function named `countLeapYears` which accepts a `Date`. Your function should return the number of leap years to have taken place since the year 1.
Make a `countLeapYears` functions that takes a date
and returns the number of leap years since year 1

20
subjects/counting_words/README.md

@ -2,25 +2,25 @@
### Instructions
Create a function named `counting_words`, that receives a `&str`. It should return each word and the number of times it appears on the string.
In this program you will have to create a function `counting_words` that
receives a `&str` and returns each word and the number of times it appears on the string.
Each of the following will count as **1** word:
The program will count as a word the following:
- A number like "0" or "1234".
- A word or letter like "a" or "they".
- Two words joined by a single apostrophe like "it's" or "they're").
- A number like ("0" or "1234") will count as 1.
- A simple word or letter like ("a" or "they") will count as 1.
- Two simple words joined by a single apostrophe ("it's" or "they're") will count as 1.
The function must respect the following rules:
The program must respect the following rules:
- The count is case insensitive, so that "HELLO", "Hello", and "hello" are 3 uses of the same word.
- All forms of punctuation are to be ignored, except for the apostrophe if used like the example above.
- The count is case insensitive ("HELLO", "Hello", and "hello") are 3 uses of the same word.
- All forms of punctuation have to be ignored except for the apostrophe if used like the example above.
- The words can be separated by any form of whitespace (ie "\t", "\n", " ").
### Expected Function
```rust
fn counting_words(words: &str) -> HashMap<String, u32> {
}
fn counting_words(words: &str) -> HashMap<String, u32> {}
```
### Usage

40
subjects/countnegative/README.md

@ -1,40 +0,0 @@
## count-negative
### Instructions
Write a function that takes an array of integers and returns the number of negative numbers in the array.
- If the array is empty, the function should return `0`.
### Expected function
```go
func CountNegative(numbers []int) int {
// your code here
}
```
### Usage
Here is a possible program to test your function:
```go
package main
import "fmt"
func main(){
fmt.Println(CountNegative([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}))
fmt.Println(CountNegative([]int{-1, -2, -3, -4, -5, -6, -7, -8, -9, -10}))
fmt.Println(CountNegative([]int{}))
fmt.Println(CountNegative([]int{-1,2,0,-3}))
}
```
and the output should be:
```console
$ go run .
0
10
0
2
```

48
subjects/curry-entries/README.md

@ -2,20 +2,18 @@
### Instructions
You're going to create some curry functions, to apply to the object's entries.
This exercise consists in creating curry functions to apply in the object's entries.
You will have to create the following curry functions:
Create `defaultCurry`, which curries two objects. It mergers the objects together. If the key exists in both objects, the value from the second object override the value from the first object.
- `defaultCurry` curries two objects in which the second object overrides the values of the first. If the key is not present then add it with the corresponding value.
```js
defaultCurry({
http: 403,
connection: 'close',
contentType: 'multipart/form-data',
})({
http: 200,
connection: 'open',
requestMethod: 'GET'
})
})({ http: 200, connection: 'open', requestMethod: 'GET' })
// output
{
http: 200,
@ -26,7 +24,7 @@ defaultCurry({
```
Create `mapCurry`, which replicates function `.map` (but for an object). The first entry is the function, and the second entry is the object.
- `mapCurry` replicates function `.map`, where first entry is a function, second is an object.
```js
mapCurry(([k, v]) => [`${k}_force`, v])(personnel)
@ -40,7 +38,7 @@ mapCurry(([k, v]) => [`${k}_force`, v])(personnel)
}
```
Create `reduceCurry`, which replicates the `.reduce` method (but fro an object). The first entry is the function, and the second is the object and initial value).
- `reduceCurry` replicates function `.reduce`, where first entry is function, second is (object, initial value).
```js
reduceCurry((acc, [k, v]) => (acc += v))({ a: 1, b: 2, c: 3 }, 0)
@ -48,7 +46,7 @@ reduceCurry((acc, [k, v]) => (acc += v))({ a: 1, b: 2, c: 3 }, 0)
6
```
Create `filterCurry` which replicates the `.filter` method (but for an object). The first entry is the function, and the second is an object.
- `filterCurry` replicates function `.filter`, where first entry is function, second is object.
```js
filterCurry(([k, v]) => typeof v === 'string' || k === 'arr')({
@ -62,14 +60,25 @@ filterCurry(([k, v]) => typeof v === 'string' || k === 'arr')({
Using each curry function create the following functions with a parameter `personnel`:
- `reduceScore`: that will return the total value of the scores
of the people who use the force. (this function can have one additional parameter).
- `filterForce`: that will return the force users with `shootingScores` equal to or higher than 80.
- `mapAverage`: that will return a new object with the property `averageScore`, that is the average of the scores for each person.
- `reduceScore` that will return the total value of the scores
of the persons who use the force (this function can have one additional parameter)
- `filterForce` that will return the force users with `shootingScores`
equal or higher than 80
- `mapAverage` that will return a new object with the propriety `averageScore`
that is the average of the scores for each person
### Notions
- [devdocs.io/javascript/global_objects/array/filter](https://devdocs.io/javascript/global_objects/array/filter)
- [devdocs.io/javascript/global_objects/array/map](https://devdocs.io/javascript/global_objects/array/map)
- [devdocs.io/javascript/global_objects/array/reduce](https://devdocs.io/javascript/global_objects/array/reduce)
- [devdocs.io/javascript/global_objects/object/entries](https://devdocs.io/javascript/global_objects/object/entries)
- [devdocs.io/javascript/global_objects/object/fromentries](https://devdocs.io/javascript/global_objects/object/fromentries)
- [stackoverflow.com/questions/36314/what-is-currying](https://stackoverflow.com/questions/36314/what-is-currying)
### Code provided
> The provided code will be added to your solution, and does not need to be submitted.
> all code provided will be added to your solution and doesn't need to be submited.
```js
// prettier-ignore
@ -81,12 +90,3 @@ const personnel = {
calebDume: { id: 11, pilotingScore: 71, shootingScore: 85, isForceUser: true },
}
```
### Notions
- [filter](https://devdocs.io/javascript/global_objects/array/filter)
- [map](https://devdocs.io/javascript/global_objects/array/map)
- [reduce](https://devdocs.io/javascript/global_objects/array/reduce)
- [entries](https://devdocs.io/javascript/global_objects/object/entries)
- [fromentries](https://devdocs.io/javascript/global_objects/object/fromentries)
- [stackoverflow what-is-currying?](https://stackoverflow.com/questions/36314/what-is-currying)

21
subjects/cut-corners/README.md

@ -2,24 +2,25 @@
### Instructions
Create some functions which behave like JavaScript's `Math` rounding functions:
Create a function for each rounding math functions:
- `round`: which behaves similar to `Math.round()`.
- `ceil`: which behaves similar to `Math.ceil()`.
- `floor`: which behaves similar to `Math.floor()`.
- `trunc`: which behaves similar to `Math.trunc()`.
- round (like `Math.round`)
- ceil (like `Math.ceil`)
- floor (like `Math.floor`)
- trunc (like `Math.trunc`)
> Some restrictions apply:
> - You may not use strings conversion to do it
> - No bitwise operator
Some restrictions apply:
- You may not use strings conversion to do it
- No bitwise operator
### Notions
- [Math](https://devdocs.io/javascript/global_objects/math)
- [devdocs.io/javascript/global_objects/math](https://devdocs.io/javascript/global_objects/math)
### Code provided
> The provided code will be added to your solution, and does not need to be submitted.
> all code provided will be added to your solution and doesn't need to be submited.
```js
Math.round = Math.ceil = Math.floor = Math.trunc = undefined

20
subjects/date-is/README.md

@ -4,16 +4,16 @@
Create the following functions:
- `isValid`: accepts a `Date`, and returns `false` if the `Date` is invalid.
- `isAfter`: accepts two `Date` arguments, and returns `true` if the first is greater then the second.
- `isBefore`: accepts two `Date` arguments, and returns `true` if the second is greater than the first.
- `isFuture`: accepts a `Date`, and returns `true` if the `Date` is valid, and is after than the present date.
- `isPast`: accepts a `Date`, and returns `true` if the `Date` is valid, and is before the present date.
- `isValid`, this function must return false if it's an Invalid Date
- `isAfter`, this function will receive two valid dates and return true if the first date is bigger then the second date
- `isBefore`, this function will receive two valid dates and return true if the first date is lesser then the second date
- `isFuture`, will return true if the date given as parameter is valid and higher than the present date
- `isPast`, will return true if the date given as parameter is valid and less than the present date
### Notions
- [date-fns: isValid](https://date-fns.org/v2.14.0/docs/isValid)
- [date-fns: isAfter](https://date-fns.org/v2.14.0/docs/isAfter)
- [date-fns: isBefore](https://date-fns.org/v2.14.0/docs/isBefore)
- [date-fns: isFuture](https://date-fns.org/v2.14.0/docs/isFuture)
- [date-fns: isPast](https://date-fns.org/v2.14.0/docs/isPast)
- [date-fns.org/v2.14.0/docs/isValid](https://date-fns.org/v2.14.0/docs/isValid)
- [date-fns.org/v2.14.0/docs/isAfter](https://date-fns.org/v2.14.0/docs/isAfter)
- [date-fns.org/v2.14.0/docs/isBefore](https://date-fns.org/v2.14.0/docs/isBefore)
- [date-fns.org/v2.14.0/docs/isFuture](https://date-fns.org/v2.14.0/docs/isFuture)
- [date-fns.org/v2.14.0/docs/isPast](https://date-fns.org/v2.14.0/docs/isPast)

3
subjects/day-of-the-year/README.md

@ -2,4 +2,5 @@
### Instructions
Create a function named `dayOfTheYear` which accepts a `Date`. Your function should return the number of days since the first day of that year.
Make a `dayOfTheYear` functions that takes a date
and returns the number of days since the first day of that year

10
subjects/debounce/README.md

@ -2,12 +2,12 @@
### Instructions
Create two functions that will work like `_.debounce` from lodash.
Create two functions that will work like `_.debounce` from lodash
- `debounce`: don't worry about the options.
- `opDebounce`: implement the `leading` options.
- `debounce`, this function doesn't need to take care of the options
- `opDebounce`, this function will take care of the `leading` options
### Notions
- [lodash debounce](https://lodash.com/docs/4.17.15#debounce)
- [css-tricks.com debounce](https://css-tricks.com/debouncing-throttling-explained-examples/#debounce)
- [lodash.com/docs/4.17.15#debounce](https://lodash.com/docs/4.17.15#debounce)
- [https://css-tricks.com/debouncing-throttling-explained-examples/#debounce](https://css-tricks.com/debouncing-throttling-explained-examples/#debounce)

29
subjects/declarations/README.md

@ -4,25 +4,22 @@
Create the following constant variables:
- `escapeStr`: a `string` which contains the following special characters: `` ` ``, `\`, `/`, `"` and `'`.
- `arr`: an array containing the values `4` and `'2'`.
- `obj`: an object containing primitive values:
- `str`: with a `string` value.
- `num`: with a `number` value.
- `bool`: with a `boolean` value.
- `undef`: with a `undefined` value.
- `nested`: an object containing:
- `arr`: an array of 3 values: `4`, `undefined` and `'2'`.
- `obj`: an object with 3 properties
- `str` with a `string` value.
- `num` with a `number` value.
- `bool` with a `boolean` value.
- `escapeStr`, that contains the following specials characters: `` ` ``, `\`, `/`, `"`, `'`
- `arr` that is an array containing the values 4 and '2'
- `obj` that is an object containing a property for each primitives:
- `str` for `String`
- `num` for `Number`
- `bool` for `Boolean`
- `undef` for `undefined`
- A `nested` object that contains
- arr: an array of the 3 values: 4, undefined, '2'
- obj: an object with 3 property (str, num & bool)
`nested`, `arr` and `obj` must be frozen, so that their elements or properties cannot be changed.
`nested`, `arr` and `obj` must be frozen to prevent changes from them.
### Notions
- Primitive and Operators
- Variables
- [Data Structures](https://nan-academy.github.io/js-training/examples/data-structures.js)
- [Freeze](https://devdocs.io/javascript/global_objects/object/freeze)
- [nan-academy.github.io/js-training/examples/data-structures.js](https://nan-academy.github.io/js-training/examples/data-structures.js)
- [devdocs.io/javascript/global_objects/object/freeze](https://devdocs.io/javascript/global_objects/object/freeze)

2
subjects/deep-copy/README.md

@ -2,7 +2,7 @@
### Instructions
Create a function named `deepCopy` that copies objects and arrays recursively.
Create a function called `deepCopy` that copy objects and arrays recursively.
### Notions

2
subjects/delete_prefix/README.md

@ -2,7 +2,7 @@
### Instructions
Define the function `delete_prefix` which returns the string slice `s` with the `prefix` removed. It should be wrapped in `Some`. If `prefix` is not a prefix of `s`, then `delete_prefix` returns `None`.
Define the function `delete_prefix(prefix, s)` which returns the string slice `s` with the `prefix` removed wrapped in `Some`. If `prefix ` is not a prefix of `s` it returns `None`.
### Expected Function

20
subjects/diamond_creation/README.md

@ -2,18 +2,22 @@
### Instructions
Build the **function** `make_diamond` which takes a letter as an input, and returns a diamond.
Build the **function** `make_diamond` which takes a letter as input, and outputs it in a diamond shape.
Rules:
- The first and last row contain one 'A'.
- The given letter has to be at the widest point.
- All rows, except the first and last, have exactly two identical letters.
- All rows have as many trailing spaces as leading spaces. This may be 0.
- The diamond is vertically symmetrical, and horizontally symmetrical.
- The width of the diamond equals its height.
- The top half has letters in ascending order (abcd).
- The bottom half has letters in descending order (dcba).
- All rows have as many trailing spaces as leading spaces. (This might be 0).
- The diamond is vertically and horizontally symmetric.
- The diamond width equals the height.
- The top half has the letters in ascending order. (abcd)
- The bottom half has the letters in descending order. (dcba)
### Notions
- [pattern syntax](https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html)
### Expected functions
@ -44,7 +48,3 @@ $ cargo run
[" A ", " B B ", "C C", " B B ", " A "]
$
```
### Notions
- [pattern syntax](https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html)

12
subjects/display_table/README.md

@ -1,12 +1,14 @@
## display_table
### Instructions
### Instructions
Define the `Table` struct below, and implement the associated functions `new` and `add_row`. You can see how they should work from the usage.
- 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 `Table` structure so that the table is printed like in the 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 element cannot be centred exactly, it must be positioned slightly to the left.
- Note: If the table is empty `println!` must not print anything.
If the table is empty `println!` must not print anything.
- Define the associated function `new` which creates a new empty table.
- Define the method function `add_row` which adds a new row to the table created from a slice of strings.
### Expected functions and Structures
@ -20,7 +22,7 @@ pub struct Table {
impl fmt::Display for Table {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
}
}
impl Table {

21
subjects/division_and_remainder/README.md

@ -2,10 +2,21 @@
### Instructions
Create a **function** named `divide` that receives two `i32` and returns a `tuple`. The first element is the result of the integer division between the two numbers, and the second is the remainder of the division.
Create a **function** `divide` that receives two i32 and returns a tuple in which the first element is the result of the integer division between the two numbers and the second is the remainder of the division.
### Notions
- [The Tuple Type](https://doc.rust-lang.org/stable/book/ch03-02-data-types.html?highlight=accessing%20a%20tuple#compound-types)
- [Tuples](https://doc.rust-lang.org/rust-by-example/primitives/tuples.html)
- [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)
### Expected Function
```rust
pub fn divide(x: i32, y: i32) -> (i32, i32) {
}
```
@ -34,11 +45,3 @@ $ cargo run
9/4: division = 2, remainder = 1
$
```
### Notions
- [The Tuple Type](https://doc.rust-lang.org/stable/book/ch03-02-data-types.html?highlight=accessing%20a%20tuple#compound-types)
- [Tuples](https://doc.rust-lang.org/rust-by-example/primitives/tuples.html)
- [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)

41
subjects/divisors/README.md

@ -1,41 +0,0 @@
## Devisor
### Instructions
Write a function that takes a positive integer and returns the number of it's devisors.
- If the the number a is negative return 0.
- Test numbers from 0 to 99999999 .
### Expected function
```go
func Divisors(n int) int {
...
}
```
### Usage
Here is a possible program to test your function:
```go
package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(piscine.Divisors(4))// 4 can be divided by 1 and 2 and 4
fmt.Println(piscine.Divisors(5))//5 can be divided by 1 and 5
}
```
And its output :
```console
$ go run .
3
2
```

56
subjects/does_it_fit/README.md

@ -2,42 +2,32 @@
### Instructions
Use the `areas_volumes` module provided to create two **functions**.
Create `area_fit`. It should return `true` if the geometric shape can fit inside the rectangular area as many times as is indicated by `times`.
- `x` and `y`: length and width of the rectangular area.
- `objects`: the type of geometric shape.
- `times`: the number of geometric shapes to fit inside the rectangular area.
- `a`: size of dimension for:
- `side` of a `Square`
- `base` of a `Triangle`
- `radius` of a `Circle`
- `side_a` of a `Rectangle`
- `b`: size of dimension for:
- `height` of a `Triangle`
- `side_b` of a `Rectangle`
Create `volume_fit`. It should return `true` if the geometric volume can fit inside the box as many times as is indicated by `times`.
- `x`, `y` and `z`: length, width and depth of the box.
- `objects`: the type of geometric volume.
- `times`: the number of geometric volumes to fit inside the box.
- `a`: size of dimension for:
- `side` of a `Cube`
- `radius` of a `Sphere`
- `base_area` of a triangular `Pyramid`
- `side_a` of a `Parallelepiped`
- `base_radius` of a `Cone`
- `b`: size dimension for:
- `height` of the triangular `Pyramid`
- `side_b` of a `Parallelepiped`
- `height` of the `Cone`
- `c`: size dimension for:
- `side_c` of a `Parallelepiped`
Using the `areas_volumes` module provided, create two **functions**:
- `area_fit` which receives 6 arguments and returns a boolean:
- `x` and `y`, length and width of the Rectangle in which it is going to be tried to fit the geometrical shapes (both usize)
- `objects`, the type of geometrical shape(s) which are going to be tried to be fitted in the square (areas_volumes::GeometricalShapes)
- `times`, the number of geometrical shapes which are going to be tried to be fitted in the square (usize)
- `a` and `b`, the dimensions which the plane(s) shape(s) passed will have (both usize)
- `a` will refer to the side of the Square, the radius of the Circle, the side_a of the Rectangle or the base of the Triangle
- `b` will refer to the side_b of the Rectangle or the height of the Triangle
- `area_fit` should return `true` if the geometrical shape(s) fit inside of the square.
- `volume_fit` which receives 8 arguments and returns a boolean:
- `x`, `y` and `z`, length, width and depth of the box in which it is going to be tried to fit the geometrical volumes (both usize)
- `objects`, the type of geometrical volume(s) which are going to be tried to be fitted in the box (areas_volumes::GeometricalVolumes)
- `times`, the number of geometrical volumes which are going to be tried to be fitted in the box (usize)
- `a`, `b` and `c`, the dimensions which the geometrical volume(s) passed will have (all of them usize)
- `a` will refer to the side of the Cube, the radius of the Sphere, the side_a of the Parallelepiped, the area of the base of the Triangular Pyramid or the base radius of the Cone
- `b` will refer to the side_b of the Parallelepiped, the height of the Triangular Pyramid or the height of the Cone
- `c` will refer to the side_c of the Parallelepiped
- `volume_fit` should return `true` if the geometrical volume(s) fit inside of the box.
### Expected Functions
```rust
```rs
pub fn area_fit(
x: usize,
y: usize,

23
subjects/dog-years/README.md

@ -2,19 +2,20 @@
### Instructions
Someone once said that a human year is equal to 7 dog years.
Someone once said that a dog makes 7 years for each human year.
Create a function named `dogYears`, that accepts the name of a planet, and the age of the dog in seconds. Your function should return the age of the dog on that planet in dog years.
Create a `dogYears` function that if given a planet name and an age in seconds,
calculates how old a dog would be on the given planet.
- `earth`: orbital period 1.0 Earth years, 365.25 Earth days, or 31,557,600 seconds.
- `mercury`: orbital period 0.2408467 Earth years.
- `venus`: orbital period 0.61519726 Earth years.
- `mars`: orbital period 1.8808158 Earth years.
- `jupiter`: orbital period 11.862615 Earth years.
- `saturn`: orbital period 29.447498 Earth years.
- `uranus`: orbital period 84.016846 Earth years.
- `neptune`: orbital period 164.79132 Earth years.
- `earth` : orbital period 1.0 Earth years, 365.25 Earth days, or 31,557,600 seconds
- `mercury` : orbital period 0.2408467 Earth years
- `venus` : orbital period 0.61519726 Earth years
- `mars` : orbital period 1.8808158 Earth years
- `jupiter` : orbital period 11.862615 Earth years
- `saturn` : orbital period 29.447498 Earth years
- `uranus` : orbital period 84.016846 Earth years
- `neptune` : orbital period 164.79132 Earth years
If you were told that a dog was 1,000,000,000 seconds old, you should calculate that the dog would be 221.82 Earth-years old.
So if you were told someone that their dog were 1,000,000,000 seconds old, you should be able to say that the dog is 221.82 Earth-years old.
You will have to format the number so that the result is rounded like the example above.

15
subjects/doubtful/README.md

@ -2,16 +2,23 @@
### Instructions
Create a function named `doubtful` which appends a question mark to every string passed to it. It must not return a value.
Write a function called `doubtful` that adds to every string passed to it a question mark (?).
You have to complete the signature the functions to make it fit the usage and you also have to modify the usage to be able to do what is expected.
- Restrictions:
- `doubtful` cannot return any value.
- And in the example of the usage you can only modify the argument of the function
### Expected
### Expected functions
```rust
pub fn doubtful(s: /*give the correct type*/ ) {
}
```
You'll need to complete the function signature, so that it works properly with the usage example. You'll also need to complete the usage if you plan to use it.
### Usage
Here is a program to test your function

40
subjects/dr-strange/README.md

@ -2,23 +2,37 @@
### Instructions
You will create two functions: `addWeek` and `timeTravel`.
You have been given the mission to create a new sense of time! Normally a week has 7 days right? Well, that is about to change!
You have been given a mission to create a new sense of time. Normally a week has 7 days right? Well, that is about to change.
Instead of a normal week having only 7 days, it will have 14 days.
Let me explain, this new week will have 14 days, from `Monday` to `Sunday` then `secondMonday` to `secondSunday`.
Your purpose is to create a new function `addWeek`, that takes as parameter a `Date` and that will return what week day the given date is, according to your new week format.
Week number should be count from `0001-01-01`.
Weeks will instead have **14** days.
Let me explain; this new week will have 14 days, from `Monday` to `Sunday`, then `secondMonday` to `secondSunday`.
Your purpose is to create a new function named `addWeek`, that takes a `Date` as an argument. Your function should return the weekday as a string, according to our new 14-day week format.
The **epoch** of our new 14-day week is `0001-01-01`, and that was a `Monday`.
> What is an epoch?
Now imagine you have an appointment with your doctor, and you have to wait for some hours, but you do not want to wait. So you decide that you need to create a new function named `timeTravel`, that allows you to change the **time** according to your needs.
```
new week format:
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
secondMonday
secondTuesday
secondWednesday
secondThursday
secondFriday
secondSaturday
secondSunday
```
Your function will take an `object` as an argument, and return a `Date`. You can see the `timeTravel` example below to understand the structure of the `object` argument.
Now imagine you have a doctor appointment and you have to wait some hours, but you do not want to wait, so you decided that you need to create a
function `timeTravel` that allows you to change the time according to your needs.
This function will give you the power to go backwards or forwards in time.
Your objective is to use the information from the `object` to modify the **time** of the `Date` before returning it.
So, you will have a function that takes an object with the following `{date, hour, minute, second}`. This object will be responsible for changing the `hour`, `minute` and `second` of the given `date`.
### Example

53
subjects/drawing/README.md

@ -2,41 +2,44 @@
### Instructions
The purpose of this exercise is to create an image like the example bellow:
- Copy the code in [usage](#usage) to your main.rs
![example](image.png)
- Create a module called geometrical_shapes in another file.
You will need to do the following:
- This module will keeps all the logic for creating and operating with the different geometrical shapes and define two traits `Displayable` and `Drawable`.
- Copy the code in the [usage](#usage) to your `main.rs`.
- `Drawable` contains the methods `draw` and `color`
- Create a module called `geometrical_shapes` in another file.
- `Displayable` contains the method `display`.
You'll define the logic for creating and working with shapes in `geometrical_shapes`. Create the following traits:
- Define them in correspondence with the way they're called in the main function
- `Drawable` which contains the methods `draw` and `color`.
- You have to define the structures for Point, Circle, Line, Rectangle and Triangle and make the code in `main.rs` compile and run.
- `Displayable` which contains the method `display`.
- You are free to implement all the shapes with the internal structure that you find more adequate, but you have to provide for all the shapes an associated function `new` which will be described next:
Define them according to the way they are called in the `main.rs` function.
- Point: a new point should be created from two i32 values
- Line: a new line should be created from references to two points also define an associated function called `random` that receives two argument the first is the maximum x value a point can have and the
second the maximum y value that a point can have
- Triangle: a new triangle should be created from references to three points
- Rectangle: a new rectangle should be created from two references to points
- Circle: a new circle should be created from a point representing the center and an i32 value representing the radius
In order to compile and run `main.rs`, you'll need to define some structures. You are free to implement all the shapes with whatever internal structure you see fit, but you must provide an associated function `new` for all the shapes, which will be described below:
- The main function also requires a definition of an associated function called `random` for the types Line, Point and Circle. You should derive their signature from the usage.
- `Point`: a new point should be created from two `i32` values.
- `Line`: a new line should be created from references to two different points.
- `Triangle`: a new triangle should be created from references to three different points.
- `Rectangle`: a new rectangle should be created from references to two different points.
- `Circle`: a new circle should be created from a reference to a point representing the center, and an `i32` value representing the circle's radius.
Don't forget to add the dependencies in your Cargo.toml.
You'll also need to create the associated function `random` for `Line`, `Point` and `Circle`. You should derive their signatures from the usage.
#### Bonus
> Don't forget to add the dependencies in your Cargo.toml.
- Implement drawing a pentagon (implement the structure Pentagon, and the trait needed to draw in the image)
### Bonus
- Implement drawing a cube (implement the structure Cube, and the trait needed to draw in the image)
You may optionally implement the following shapes, including the structures and traits needed to draw them:
- `Pentagon`
- `Cube`
### Notions
- [Image processing library](https://docs.rs/raster/0.2.0/raster/)
- [Traits](https://doc.rust-lang.org/stable/book/ch10-02-traits.html)
### Usage
@ -80,10 +83,4 @@ impl Displayable for Image {
}
```
> The expected output is a png file: `image.png`
### Notions
- [Image processing library](https://docs.rs/raster/0.2.0/raster/)
- [Traits](https://doc.rust-lang.org/stable/book/ch10-02-traits.html)
### And the expected output is a png file: `image.png`

13
subjects/drawing/audit/README.md

@ -1,18 +1,10 @@
#### Functional
###### Can you confirm that the module `geometrical_shapes` was created?
##### Try to run the command `cargo run`.
##### Run the command `cargo run`
###### Does the program compile and run without any error or warning?
###### Does the program produce a `png` file called `image.png`?
##### Open the module `geometrical_shapes`.
###### Can you confirm that the traits `Displayable` and `Drawable` where created?
##### Try to open the `image.png`.
###### Does the program produces a png file called image.png?
###### Does the image contain lines, circles, rectangles and triangles?
@ -23,3 +15,4 @@
###### +Can you draw a pentagon?
###### +Can you draw a cube?

BIN
subjects/drawing/image.png

diff.bin_not_shown

Before

Width:  |  Height:  |  Size: 146 KiB

58
subjects/drop_the_thread/README.md

@ -2,35 +2,45 @@
### Instructions
> Interior mutability is a design pattern in Rust that allows you to mutate data even when there are immutable references to that data.
"Interior mutability is a design pattern in Rust that allows you to mutate data even when there are immutable references to that data"
In this exercise, you will create a Drop Checker API.
in this exercise a Drop checker API has to be created. For this you must define:
Define the following structures:
- Two structures:
- `Workers` that will have two fields:
- `drops` that will save the number of dropped threads.
- `states` that will save a state of multiple threads.
If the thread is not dropped, the state will be false otherwise true.
- `Thread` that will have the following fields:
- `pid`, the id of the thread.
- `cmd`, the name of the thread.
- `parent`, that will be the link to the structure `Workers` (Tip: this must be a reference to the structure Workers)
- `Workers`: containing:
- `drops`: that will save the number of dropped threads.
- `states`: that will save the state of multiple threads. If the thread is not dropped, the state will be `false`, and will be `true` otherwise.
- `Thread`: containing:
- `pid`: the id of the thread.
- `cmd`: the name of the thread.
- `parent`: a link to the structure `Workers`. (Tip: this should be a reference).
- Implementation of each structure:state
You'll need to also add the following associated functions to the structures:
- `Workers` :
- `Workers` :
- `new`: that creates a default worker.
- `new_worker`: that returns a tuple with the `pid` and a new `Thread`. This function must receive a `String` representing the `cmd`.
- `is_dropped`: that receives a `pid` and returns a `bool` that indicates the state of the thread.
- `track_worker`: which returns a `usize` representing the length of the `states` vector. (The index of the next new thread).
- `add_drop`: which is **called by the `Drop` trait**. It will receive a `pid` that will be used to change the state of the thread. If the state of that thread is `true` then it will panic with the message `"X is already dropped"`, where `X` represents the `pid`). Otherwise it should change the state to `true` and increment the `drops` field by 1.
- `new`, that creates a default worker
- `new_worker`, that returns a tuple with the `pid` and a new `Thread`,
this function must receive a `String` being the `cmd`
- `is_dropped`, that receives a `pid` and returns a `bool` that indicates the state of the thread by using the `pid`
- `track_worker`, it should return a `usize`, that will be the last available index of the `states` vector, being the new next thread
- `add_drop`, this function must be **called by the `Drop` trait**. It will receive a `pid` that will be used to change the
state of the thread. If the state of that thread is `true` then it will panic with the message ("Cannot drop {}, because its already dropped", pid).
Otherwise it should change the state to true and increment the `drops` field by one.
- `Thread`:
- `new_thread`: that initializes a new thread.
- `skill`: that drops the thread.
- `Thread`:
- `new_thread`, that initializes a new thread
- `skill`, that drops the thread
- You must implement the `Drop` trait for the `Thread` structure. In this trait you must call the function `add_drop` so that the state of the thread changes.
- You must implement for the structure `Thread` the `Drop` trait. In this trait you must call the function `add_drop` so that the state of the thread changes
### Notions
- [Trait std::ops::Drop](https://doc.bccnsoft.com/docs/rust-1.36.0-docs-html/std/ops/trait.Drop.html)
- [Struct std::cell::RefCell](https://doc.rust-lang.org/std/cell/struct.RefCell.html)
- [Interior Mutability](https://doc.rust-lang.org/book/ch15-05-interior-mutability.html)
### Expected Functions
@ -101,9 +111,3 @@ $ cargo run
(false, 2, Cell { value: 2 }, 1)
$
```
### Notions
- [Trait std::ops::Drop](https://doc.bccnsoft.com/docs/rust-1.36.0-docs-html/std/ops/trait.Drop.html)
- [Struct std::cell::RefCell](https://doc.rust-lang.org/std/cell/struct.RefCell.html)
- [Interior Mutability](https://doc.rust-lang.org/book/ch15-05-interior-mutability.html)

8
subjects/easy_traits/README.md

@ -2,13 +2,13 @@
### Instructions
Your task is to implement the trait `AppendStr` for the type `StringValue`.
Your task is to implement the trait `AppendStr` for the type StringValue.
The trait `AppendStr` has the following functions:
- `append_str`: that appends to the string to the `value`.
- `append_number`: that appends the number to the `value`.
- `remove_punctuation_marks`: that removes punctuation from the `value` (`.`, `,`, `?` and `!`).
- `append_str`, that appends to the value of the structure a new_str of type String
- `append_number`, that appends to the value of the structure a new_number of type f64
- `remove_punctuation_marks`, that removes from the value of the structure the following punctuation marks: `. , ? !`
### Expected Function

10
subjects/edit_distance/README.md

@ -2,7 +2,7 @@
### Instructions
Create a **function** named `edit_distance`, which calculates the minimum number of changes (insertions, deletions and/or substitutions) which are needed to transform the `source` string to the `target` string.
Create a **function** called `edit_distance` which calculates the minimum number of changes (insertions, deletions and/or substitutions) which need to be made to a string `source` to transform to another string `target`.
### Expected Function
@ -11,6 +11,10 @@ pub fn edit_distance(source: &str, target: &str) -> usize {
}
```
### Notions
For more information and examples go to this [link](https://en.wikipedia.org/wiki/Edit_distance)
### Usage
Here is a program to test your function.
@ -37,7 +41,3 @@ $ cargo run
It's necessary to make 2 change(s) to alignment, to get assignment
$
```
### Notions
[Edit Distance (Wikipedia)](https://en.wikipedia.org/wiki/Edit_distance)

12
subjects/elementary/README.md

@ -2,15 +2,17 @@
### Instructions
Create 3 functions which each take `(a, b)` as arguments:
Create 3 functions:
- `multiply` that acts like the `*` operator, without using it.
- `divide` that acts like the integer division operator `/`, without using it.
- `modulo` that acts like the `%` operator, without using it.
- `multiply` that act like the `*` operator without using it
- `divide` that do an integer division without using `/`
- `modulo` that act like the `%` operator without using it
> functions should have (a, b) as arguments
### Code provided
> The provided code will be added to your solution, and does not need to be submitted.
> all code provided will be added to your solution and doesn't need to be submited.
```js
Math.imul = undefined

61
subjects/error_types/README.md

@ -2,37 +2,47 @@
### Instructions
For this exercise, you will have to implement an **error type** for a form validator. This must validate the password and the first name.
For this exercise, you will have to implement an **error type**.
The first name must not be empty and the password must have **at least 8 characters**, and a combination of **alphabetic**, **numeric** and **none-alphanumeric** (`<`, `&`, `/` ...).
The main objective is to create a form validator, where you must implement an
error type. This must validate the password and the first name. The
first name must not be empty and the password must have **at least 8 char**, a **combination of alphanumeric**, **none-alphanumeric** (ex: <, & or /, ...)
examples
- `"asDd123=%"`: **good**.
- `"asgfD"`: **error** as it only contains alphabetic characters.
- `"asdsdf2"`: **error** as it is missing none-alphanumeric characters.
- `"sad\_#$"`: **error** as it is missing numeric characters.
ex: "asDd123=%" => good (as 8 char, alphanumeric and non-alphanumeric)\
"asgfD" => error (does only have alphabetic letters)\
"asdsdf2" => error (missing none-alphanumeric)\
"sad\_#$" => error (does not have a combination of alphanumeric)
Create a structure named `Form` that will have the following fields:
Create a structure called `Form` that will have the following fields:
- `first_name`: `String`
- `last_name`: `String`
- `birth`: `NaiveDate` that will convert a string `"2015-09-05"` to a date of that format.
- `fav_colour`: of type `Color` that must be an `enum` with the fields `Red`, `Blue` and `Green`
- `birth_location`: `String`
- `password`: `String`
- `first_name`, that will be a string
- `last_name`, that will be a string
- `birth`, of type `NaiveDate` that will convert a string "2015-09-05" to a date of that format
- `fav_colour`, of type Color that must be a `enum` with the fields `Red`, `Blue` and `Green`
- `birth_location`, that will be a string
- `password`, that will be a string
You must implement the **associated functions** `new` and
`validate` that will validate the form.
You must also implement for this structure a function to initialize the structure, `new` and a function called
`validate` that will validate the form
For the error type you must create a `struct` named `FErr`. It must have the fields:
For the error type you must create a type struct called `FErr`, that will be the type for the error
It must have the fields:
- `form_values`: this will be a tuple of strings representing the invalid input. For example: `("password", "asdaSD\_")` or `("first_name", "someone")`
- `form_values`, this will be a tuple of strings that will save the value that the user inserted into the form
- `date`: that will have the date that the error occurred in the format `"2020-12-14 09:33:41"`
- `err`: the error description:
- `"No user name"`
- `"At least 8 characters"`
- `"Combination of different ASCII character types (numbers, letters and none alphanumeric characters)"`
ex: ("password", "asdaSD\_")
("first_name", "someone")
- `date`, that will have the date that the error occurred in the format "2020-12-14 09:33:41"
- `err`, that will have the error description:
- "No user name"
- "At least 8 characters"
- "Combination of different ASCII character types (numbers, letters and none alphanumeric characters)"
### Notions
- [Error types](https://doc.rust-lang.org/rust-by-example/error/multiple_error_types/define_error_type.html)
- [Struct NaiveDate](https://docs.rs/chrono/0.4.19/chrono/naive/struct.NaiveDate.html)
### Dependencies
@ -124,8 +134,3 @@ FErr { form_values: ("password", "asdasASd(_"), date: "2022-04-21 09:18:12", err
FErr { form_values: ("password", "asdasASd123SA"), date: "2022-04-21 09:18:12", err: "Combination of different ASCII character types (numbers, letters and none alphanumeric characters)" }
$
```
### Notions
- [Error types](https://doc.rust-lang.org/rust-by-example/error/multiple_error_types/define_error_type.html)
- [Struct NaiveDate](https://docs.rs/chrono/0.4.19/chrono/naive/struct.NaiveDate.html)

89
subjects/events/README.md

@ -4,41 +4,51 @@
You have to design a notification system for a platform.
Depending on the type of event, your event handler will control the size, color and position of the notification.
Create a method named `notify` which returns a `Notification` with the following characteristics for each of:
- `Remainder(text)`:
- `size`: `50`
- `color`: `(50, 50, 50)`
- `position`: `Bottom`
- `content`: the `text` associated to the enum variant
- `Registration(chrono::Duration)`:
- `size`: `30`
- `color`: `(255, 2, 22)`
- `position`: `Top`
- `content`: `"You have {duration} left before the registration ends"`
- `Appointment(text)`:
- `size`: `100`
- `color`: `(200, 200, 3)`
- `position`: `Center`
- `content`: `text associated to the value`
- `Holiday`:
- `size`: `25`
- `color`: `(0, 255, 0)`
- `position`: `Top`
- `content`: `"Enjoy your holiday"`
`duration` must be displayed in the form of `{hours}H:{minutes}M:{seconds}S`. The time will represent the remaining time before the event starts. For example, if there are 13 hours, 38 minutes and 14 seconds left, then the content will be `"You have 13H:38M:14S left before the registration ends"`
Implement the `std::fmt::Display` trait so the text of the notifications are printed in the right color in the command line.
These events can be: Remainders, Registrations, Appointments or Holidays.
- Create an event handler that, depending on the type of event, creates different notifications with different colors, different sizes and different positions
- The possible positions are Top, Bottom and Center: Create and Enum `Position` with those values
- Create a method called `notify` which returns a notification with the following caracteristics for each
- Remainder:
size= 50,
color= (50, 50, 50),
position= Bottom,
content= the slice associated to the enum value
- Registration(chrono::Duration),
size = 30,
color = (255, 2, 22),
position = Top,
content = "You have `duration` left before the registration ends",
`durations` must be displayed in the form of {hours}:{minutes}:{seconds} left for the beginning of the event for example if there is two hours 32 minutes and 3 seconds left before the registration then the content will be `You have 2:32:2 left before the registration ends`
- Appointment(text)
size: 100
color: (200, 200, 3)
position: Center
content: text associated to the value
- Holiday
size: 25
color: (0, 255, 0)
position: Top
content: "Enjoy your holiday"
- Implement the std::fmt::Display trait so the text of the notification is printed in the right color in the command line
### Notions
- [colored crate](https://docs.rs/colored/2.0.0/colored/)
- [chrono crate](https://crates.io/crates/chrono)
### Dependencies
chrono = "0.4"
colored = "2.0.0"
### Expected Functions and Data Structures
```rust
@ -46,22 +56,22 @@ use chrono::Duration;
use colored::*;
#[derive(Debug, Eq, PartialEq)]
pub enum Position {
enum Position {
Top,
Bottom,
Center,
}
#[derive(Debug, Eq, PartialEq)]
pub struct Notification {
pub size: u32,
pub color: (u8, u8, u8),
pub position: Position,
pub content: String,
struct Notification {
size: u32,
color: (u8, u8, u8),
position: Position,
content: String,
}
#[derive(Debug)]
pub enum Event<'a> {
enum Event<'a> {
Remainder(&'a str),
Registration(Duration),
Appointment(&'a str),
@ -76,7 +86,7 @@ impl fmt::Display for Notification {
use Event::*;
impl Event {
pub fn notify(&self) -> Notification {
fn notify(&self) -> Notification {
}
}
```
@ -111,8 +121,3 @@ $ cargo run
(Top, 25, Enjoy your holiday)
$
```
### Notions
- [colored crate](https://docs.rs/colored/2.0.0/colored/)
- [chrono crate](https://crates.io/crates/chrono)

20
subjects/expected_variable/README.md

@ -2,15 +2,22 @@
### Instructions
Create a **function** named `expected_variable` that receives a string to compare and an expected string. It should return an `Option`. Every comparison should be case insensitive.
Create a **function** `expected_variable` that receives two strings: one to be evaluated and the other to be compared to (expected) and returns an Option. Every comparison should be case insensitive.
If the compared string is **not** in camel case or snake case, `expected_variable` returns `None`. You can use the `case` crate to figure that out. Otherwise, the compared string should be compared to the expected string using the `edit_distance` **function** that you have already created.
If the evaluated string is not in camel case or in snake case (use the `case` crate for this evaluation) `expected_variable` returns `None`.
Otherwise the evaluated string should be compared to the expected string using the `edit_distance` **function** that you did in one of the previous quests.
If the result of `edit_distance` has more than 50% alikeness to the expected string, considering the length of the expected string and the result of `edit_distance`, the function should return that value with a `'%'` symbol after the number.
If the result of `edit_distance` has more than 50% of 'alikeness' to the expected string, considering the length of the expected string and the result of `edit_distance`, the function should return that same percentage with a '%' symbol in front of the number.
Otherwise `expected_value` should return `None`.
### Notions
- [Crate case](https://crates.io/crates/case)
- [Specifying Dependencies](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html)
### Expected Function
> You'll need to work out the function signature for yourself.
#### For this exercise the signature of the function has to be found out.
### Usage
@ -49,8 +56,3 @@ None
67% close to it
$
```
### Notions
- [Crate case](https://crates.io/crates/case)
- [Specifying Dependencies](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html)

25
subjects/fibonacci2/README.md

@ -4,15 +4,27 @@
Complete the body of the **function** `fibonacci`.
This function receives a number `n` and returns the `n`th number in the fibonacci series.
The Fibonacci Series starts like this: 0, 1, 1, 2, 3, 5, 8, 13 etc...
### Recommendation
Videos designed to give **hints** are assigned to each quest. It is strongly suggested to watch them as you go.
### 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)
### Expected function
```rust
pub fn fibonacci(n: u32) -> u32 {
}
```
This function receives a number `n` and returns the `n`th number in the fibonacci series.
The Fibonacci Series starts like this: 0, 1, 1, 2, 3, 5, 8, 13 etc...
### Usage
Here is a possible test for your function:
@ -38,8 +50,3 @@ The element in the position 22 in fibonacci series is 17711
The element in the position 20 in fibonacci series is 6765
$
```
### 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)

31
subjects/fifty-shades-of-cold/README.md

@ -2,11 +2,11 @@
### Instructions
You've been asked to freshen up a webpage, by displaying shades of cold colors.
You've been asked to freshen a webpage atmosphere by displaying shades of cold colors.
Check the `colors` array provided in the data file below.
Write the `generateClasses` function. It creates a `<style>` tag inside the `<head>`. It should generate one class for each color in the `colors` array, which sets the `background` attribute like so:
- Write the `generateClasses` function which creates a `<style>` tag in the `<head>` tag and generates, for each color of `colors`, a class setting the `background` attribute and taking the color as value, like following:
```css
.blue {
@ -14,32 +14,33 @@ Write the `generateClasses` function. It creates a `<style>` tag inside the `<he
}
```
Write the `generateColdShades` function which creates a `<div>` for each color of the `colors` array, whose name contains `aqua`, `blue`, `turquoise`, `green`, `cyan`, `navy` or `purple`. Each `<div>` must have the corresponding generated class and display the name of the color, like following:
- Write the `generateColdShades` function which creates a `<div>` for each color of the `colors` array whose name contains `aqua`, `blue`, `turquoise`, `green`, `cyan`, `navy` or `purple`.\
Each `<div>` must have the corresponding generated class and display the name of the color, like following:
```html
<div class="blue">blue</div>
```
The function `choseShade` is triggered when clicking on a `div`. Write the body of this function. It accepts the shade of the clicked element as an argument, and replaces all the classes of all the other elements by the chosen shade.
- The function `choseShade` is triggered when clicking on a `div`.\
Write the body of this function, which receives the shade of the clicked element as argument, and replaces all the other elements class by the chosen shade.
### Notions
- [`head`](https://developer.mozilla.org/en-US/docs/Web/API/Document/head) / [style tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style)
- [`className`](https://developer.mozilla.org/en-US/docs/Web/API/Element/className)
- [`classList`](https://developer.mozilla.org/en-US/docs/Web/API/Element/classList): `contains()`, `replace()`
### Files
You only need to create & submit the JS file `fifty-shades-of-cold.js`, we're providing you the following files to download and test locally:
You only need to create & submit the JS file `fifty-shades-of-cold.js` ; we're providing you the following files to download (click right and save link) & test locally:
- the HTML file [fifty-shades-of-cold.html](./fifty-shades-of-cold.html) to open in the browser, which includes:
- the JS script running some code, and which will enable you to run yours
- some CSS pre-styled classes: feel free to use those as they are, or modify them.
- the JS script running some code, and which will also allow to run yours
- some CSS pre-styled classes: feel free to use those as they are, or modify them
- the data file [fifty-shades-of-cold.data.js](./fifty-shades-of-cold.data.js) from which you can import `colors`.
- the data file [fifty-shades-of-cold.data.js](./fifty-shades-of-cold.data.js) from which you can import `colors`
### Expected result
You can see an example of the expected result [here](https://youtu.be/a-3JDEvW-Qg)
### Notions
- [head tag](https://developer.mozilla.org/en-US/docs/Web/API/Document/head)
- [style tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style)
- [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className)
- [classList](https://developer.mozilla.org/en-US/docs/Web/API/Element/classList): `contains()`, `replace()`

2
subjects/fikbuk/README.md

@ -5,7 +5,7 @@
Create a `fikBuk` function that takes a number `n` and will start counting from
`1` to `n`.
You will return an array from those values
You will return create an array from those values
for each numbers in between `1` and `n` you must do the following:

22
subjects/filter/README.md

@ -2,25 +2,25 @@
### Instructions
- Create a `filter` function that takes an array as first argument, a function as second,
and that works like the method [].filter
Create the following functions, which each take an array as the first argument, and a function as the second argument.
- Create a `reject` function that takes an array as first argument, a function as second,
and that works like the reject function from lodash.
- `filter`: that works like the `[].filter` method.
- Create a `partition` function that takes an array as first argument, a function as second,
and that works like the partition function from lodash.
- `reject`: that works like the `reject` function from lodash.
### Notions
- `partition`: that works like the `partition` function from lodash.
- [devdocs.io/javascript/global_objects/array/filter](https://devdocs.io/javascript/global_objects/array/filter)
- [lodash.com/docs/4.17.15#reject](https://lodash.com/docs/4.17.15#reject)
- [lodash.com/docs/4.17.15#partition](https://lodash.com/docs/4.17.15#partition)
### Code provided
> The provided code will be added to your solution, and does not need to be submitted.
> all code provided will be added to your solution and doesn't need to be submited.
```js
Array.prototype.filter = undefined
```
### Notions
- [devdocs.io/javascript/global_objects/array/filter](https://devdocs.io/javascript/global_objects/array/filter)
- [lodash.com/docs/4.17.15#reject](https://lodash.com/docs/4.17.15#reject)
- [lodash.com/docs/4.17.15#partition](https://lodash.com/docs/4.17.15#partition)

22
subjects/filter_table/README.md

@ -2,11 +2,19 @@
### Instructions
- Define the associated functions for the `Table` struct:
- `new`: which creates a new empty table.
- `add_rows`: which adds a new row to the table from a slice of strings.
- `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_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.
- Define the **functions**:
- new: which creates a new empty table.
- 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 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.
### Expected functions and Structures
@ -26,11 +34,11 @@ impl Table {
}
pub fn filter_col(&self, filter: T) -> Option<Self> {
pub fn filter_col(&self, filter: ) -> Option<Self> {
}
pub fn filter_row(&self, col_name: &str, filter: T) -> Option<Self> {
pub fn filter_row(&self, col_name: &str, filter: ) -> Option<Self> {
}
}

19
subjects/find-expression/README.md

@ -2,22 +2,25 @@
### Instructions
Create a function named `findExpression` that takes a `number` as parameter and returns a `string`.
Create a function called `findExpression` that takes a number as parameter and returns a string
- 2 constant variables will be made available to your function: `add4` and `mul2`.
- Your goal is to try to find a sequence, starting from the number 1, and repeatedly either adding 4 or multiplying by 2, to produce the number given as a parameter.
- If the number can not be reached you should return `undefined`
- It will be given two constant variable `add4` and `mul2`
- Your goal is to try to find a sequence, starting from the number 1, and repeatedly either adding 4 or multiplying 2
that produces the number given has parameter.
For example, the number 8 you must first multiplying by 2 twice and then add 4.
It will look something like this `1 *2 *2 +4`
For example, for the number `8`, you must first multiply by 2 twice, and then add 4. Your function should return something like: `1 *2 *2 +4`.
- If the number can not be reached you should return `undefined`
### Notions
- [Loops](https://nan-academy.github.io/js-training/examples/loops.js)
- [Recursion](https://nan-academy.github.io/js-training/examples/recursion.js)
- [nan-academy.github.io/js-training/examples/loops.js](https://nan-academy.github.io/js-training/examples/loops.js)
- [nan-academy.github.io/js-training/examples/recursion.js](https://nan-academy.github.io/js-training/examples/recursion.js)
### Code provided
> The provided code will be added to your solution, and does not need to be submitted.
> all code provided will be added to your solution and doesn't need to be submited.
```js
const add4 = '+4'

16
subjects/find_factorial/README.md

@ -2,19 +2,21 @@
### Instructions
Create a **function** named `factorial` which returns 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
```rust
pub fn factorial(num: u64) -> u64 {
}
```
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.
### Usage
Here is a possible program to test your function :

7
subjects/flagger/README.md

@ -2,13 +2,14 @@
### Instructions
Create a function named `flags` that receives an object and returns the specific aliases and descriptions from the properties of that object.
Create a function called `flags` that receives an object and returns
the specific aliases and descriptions from the properties of that object.
The `help` flag:
- Must be present in the **output** by default.
- Should be present in the output by default.
- When not present in the input, it should return the description of all flags.
- When present in the input, it specifies the descriptions of the flags that are passed to `help`. (ex: `help: ['divide']`)
But when present it specifies the descriptions of the flags that are passed to help. (ex: `help: ['divide']`)
#### Example:

6
subjects/flat/README.md

@ -2,15 +2,15 @@
### Instructions
Create a function named `flat` that works like `Array.flat()`, except its first argument is the array.
Create the `flat` functions that works like the `.flat` array method
### Notions
- [Flat](https://devdocs.io/javascript/global_objects/array/flat)
- [devdocs.io/javascript/global_objects/array/flat](https://devdocs.io/javascript/global_objects/array/flat)
### Code provided
> The provided code will be added to your solution, and does not need to be submitted.
> all code provided will be added to your solution and doesn't need to be submited.
```js
Array.prototype.flat = undefined

Some files were not shown because too many files changed in this diff diff.show_more

Loading…
Cancel
Save