Compare commits

...

179 Commits

Author SHA1 Message Date
MSilva95 eb95584405 small fix 2 years ago
Hamza elkhatri 3bdf80b9c6 Update README.md 2 years ago
Hamza elkhatri 216b1a9efa rewrite description 2 years ago
hamza e0693e278a add(subject):getarea 2 years ago
davhojt 25400daa15 docs(ultimatedivmod): correct grammar 2 years ago
estlop 7e4af38af0 chore: Format with prettier 2 years ago
estlop 7c304d8b30 docs: Update audit file to include example with contiguous new line characters 2 years ago
estlop f740ba0a03 docs: Update description to include example with contiguous new line characters 2 years ago
estlop 3097cd47f3 docs: Add what to do when string is empty as per review 2 years ago
estlop f5679a6ca6 docs: Add readme for ascii subject 2 years ago
Dav Hojt fcc042a38e
Update README.md 2 years ago
davhojt c84959b8ba docs(manipulate-values): fix typo 2 years ago
Hamza elkhatri 5cbf005b3b Update README.md 2 years ago
Hamza elkhatri fbb90f82d2 Update README.md 2 years ago
hamza 66624b671d add(subject): print-ascii 2 years ago
Hamza elkhatri 69b19b2269 Update README.md 2 years ago
hamza 69245b40ba fix name of file 2 years ago
hamza 016714770e fix output 2 years ago
hamza 3266406fb2 subject(communmultiple):add readme 2 years ago
Hamza elkhatri 54c5214072 Update README.md 2 years ago
hamza 1d8cacc5c6 subject(Count-Negative):add readme 2 years ago
davhojt 9fd8117c3b docs(clonernews): correct audit grammar 2 years ago
davhojt 36a9dc25e2 docs(clonernews): correct subject grammar 2 years ago
davhojt 9e13f453a6 docs(race): correct grammar 2 years ago
davhojt 8e1024a6a3 docs(series): correct grammar 2 years ago
davhojt 0eb520dad0 docs(all): correct grammar 2 years ago
davhojt 44cfb248db docs(gougle-search): correct grammar 2 years ago
davhojt 5e8ef51a75 docs(is-winner): correct grammar 2 years ago
hamza f8a9d72f0a Subject(rot-arg-n):add README 2 years ago
Hamza elkhatri abbfbd4031 Update README.md 2 years ago
Hamza elkhatri ad23781b3b Update README.md 2 years ago
hamza 1fb9df9b5b add(subject):leap year 2 years ago
Hamza elkhatri 2e04c1e2ba Update README.md 2 years ago
Hamza elkhatri e8a3809405 Update README.md 2 years ago
Hamza elkhatri 6f590b8f6e Update README.md 2 years ago
Hamza elkhatri 2f7f49f495 Update README.md 2 years ago
hamza 6b4208a56e add usage 2 years ago
hamza 89394634fd subject(binaryaddition):add readmed 2 years ago
zainabdnaya 241dcf3b70 Devisors 2 years ago
zainabdnaya c7e4e42d0a devisors 2 years ago
zainabdnaya 310d16d23d feat:Add test cases 2 years ago
zainabdnaya 294315a72b feat : Add devisors subject 2 years ago
Hamza elkhatri fbb007535d Update README.md 2 years ago
Hamza elkhatri 745609bf47 Update README.md 2 years ago
Hamza elkhatri d6544fb2db Update README.md 2 years ago
hamza 9fc547d843 subject(param_range):add Readme 2 years ago
Hamza elkhatri 4ed04e41ec Update README.md 2 years ago
Hamza elkhatri c8f6198854 Update README.md 2 years ago
hamza ba97b8f27b subject(SumArray):add readme 2 years ago
Hamza elkhatri 084e1decc3 Update README.md 2 years ago
Hamza elkhatri 0344c096fd Update README.md 2 years ago
hamza bedf3d69ff subject(Add-if-positive):add readme 2 years ago
Hamza elkhatri 3130318a76 Update README.md 2 years ago
Hamza elkhatri d66915e3b0 Update README.md 2 years ago
Hamza elkhatri 1727ae0d86 Update README.md 2 years ago
hamza 270e1f370b add(subject): add subject betweenus 2 years ago
Hamza elkhatri 9fed0ac66a Update README.md 2 years ago
Hamza elkhatri d119045dc5 Update README.md 2 years ago
hamza 97464fd121 add(subject): alphaPostion 2 years ago
zoevig 2cc51d266a
Small typo correction 2 years ago
davidrobert99 3d7ff3c1d3 update ref_cell 2 years ago
davhojt bf06961810 docs(get-json): correct grammar 2 years ago
davhojt a55dccefd6 docs(keep-trying-or-giveup): correct grammar 2 years ago
davhojt 6327a1e6bb docs(interpolation): correct grammar 2 years ago
davhojt 1ec58a46e4 docs(throttle): correct grammar 2 years ago
davhojt d043c1544d docs(debounce): correct grammar 2 years ago
davhojt 3b53b3dfca docs(events): make small changes to @Zewasik #1225 2 years ago
Zewasik e7dde746f6 updated description to fit the task 2 years ago
Maxim Mihajlov 7a0e6fcdc0 Update README.md for roman_numbers_iter 2 years ago
davhojt 0218f8e8b3 docs(flagger): correct grammar 2 years ago
davhojt c370eb398e docs(neuron): correct grammar 2 years ago
davhojt 6d7155a2e0 docs(pronoun): correct grammar 2 years ago
davhojt 23d3613428 docs(replica): correct grammar 2 years ago
davhojt 1102140338 docs(deep-copy): correct grammar 2 years ago
davhojt 0625ba5470 docs(curry-entries): correct grammar 2 years ago
davhojt 744fb88684 docs(manipulate-entries): correct grammar 2 years ago
davhojt 51a14fcbba docs(manipulate-keys): correct grammar 2 years ago
davhojt 8eea553805 docs(manipulate-values): correct grammar 2 years ago
davhojt 6c6b48236b docs(fusion): correct grammar 2 years ago
davhojt 7dcebe0873 docs(pick-omit): correct grammar 2 years ago
davhojt e27fbf1abd docs(invert): correct grammar 2 years ago
davhojt c668fc6351 docs(gossip-grid): correct grammar 2 years ago
davhojt 22e7c768a1 docs(pick-and-click): correct grammar 2 years ago
davhojt a912624feb docs(mouse-trap): correct grammar 2 years ago
davhojt 4cdc68b6e2 docs(keycodes-symphony): correct grammar 2 years ago
davhojt 6ee0e87482
docs(where-do-we-go): correct grammar 2 years ago
davhojt 37eafe4b72 docs(sortable): correct audit grammar 2 years ago
davhojt fbe11323a4 docs(sortable): correc subject grammar 2 years ago
davhojt 2ee3bfeb0a docs(fifty-shades-of-cold): correct grammar 2 years ago
davhojt dd454651c9 docs(pimp-my-style): correct grammar 2 years ago
davhojt 6a48d49b45 docs(harder-bigger-bolder-stronger): correct grammar 2 years ago
davhojt bc932456d7 docs(build-brick-and-break): correct grammar 2 years ago
davhojt 8bb87517e2 docs(get-them-all): remove code-quotes from links 2 years ago
davhojt 8e214c5f26 docs(get-them-all): correct grammar 2 years ago
davhojt 428ad8da08 feat(sales): fix bad result in output 2 years ago
davhojt bb81c93c2b docs(filter): correct grammar 2 years ago
davhojt 9d7f5e2abe docs(sweet-curry): correct grammar 2 years ago
davhojt 885ce248a6 docs(quantifiers): correct grammar 2 years ago
davhojt a55edd12c8 docs(mapper): correct grammar 2 years ago
davhojt 75b096e5e7 docs(flow): correct grammar 2 years ago
davhojt d6b8797947 docs(for-each): correct grammar 2 years ago
davhojt cbcbdb1324 docs(for-each): correct grammar 2 years ago
davhojt f2b943adbd docs(long-words): correct grammar 2 years ago
davhojt 61ab6ec47b docs(using-reduce): correct grammar 2 years ago
davhojt 23c5329e73 docs(using-map): add 'prototype' to Array.map link 2 years ago
davhojt 98af0a4bee docs(using-filter): correct grammar 2 years ago
davhojt 65b8b5df02 docs(using-map): correct grammar 2 years ago
davhojt 92befee220 docs(highest): correct grammar 2 years ago
davhojt 1b6b6bee61 docs(get_produects): correct grammar 2 years ago
davhojt b0c3496062 docs(adding_twice): correct grammar 2 years ago
davhojt 57ef30f7ba docs(adding): correct grammar 2 years ago
davhojt b04109caf1 docs(sales): correct grammar 2 years ago
davhojt 4da7643244 docs(closures): correct grammar 2 years ago
David Mata 10e93ebfa5
Merge pull request #1119 from 01-edu/review-the-project-c-578 2 years ago
davhojt d556894a35 docs(events): correct grammar 2 years ago
davhojt 4e9d32395c docs(matrix_ops): fix import typo 2 years ago
Mihkel Gering 8a76352968 fix typo in matrix_mult 2 years ago
Harry d6f4632bc9
Update pc-requirements.md 2 years ago
Harry 6e31185fdb
Update server-requirements.md 2 years ago
Harry 7d4314ee18
Update server-installation.md 2 years ago
davhojt 39ef371506 fix(get-some-time): add missing test case 2 years ago
davhojt 827f7c4d11 docs(commits_per_week) correct typo 2 years ago
davhojt 0bac09d1b4 docs(border_crosss) correct grammar 2 years ago
davhojt bfe28c091b docs(delete_prefix) correct grammar 2 years ago
davhojt 3cd40e5cc3 docs(lifetimes) correct grammar 2 years ago
davhojt 8c900df0f2 docs(matrix_mult) correct grammar 2 years ago
davhojt 2bd91fd9f5 docs(matrix_ops) correct grammar 2 years ago
davhojt 2ea9e5a782 docs(matrix) correct grammar 2 years ago
davhojt c7b763ebdb docs(road_intersection) add compas directions to graphic 2 years ago
davhojt 654aa9087e docs(road_intersection) improve grammar of spawn positions 2 years ago
davhojt c083a56617 docs(road_intersection) correct audit grammar 2 years ago
davhojt 85e2be688e docs(road_intersection) correct subject grammar 2 years ago
davhojt 84db0132be docs(chaikin) add small correction to @uristdwarf proposed changes 2 years ago
Urmas Rist 3b0928ce7c Leave it up to the student on how it should exit 2 years ago
Urmas Rist 065eb91bcf change a few more one's to three's 2 years ago
Urmas Rist cc2323fab5 chaikin audit fix 2 years ago
davhojt 026d7e673d fix(lunch_queue) correct Person structure 2 years ago
davhojt 7350a3b4d6 fix(valid-ip) remove faulty expected result 2 years ago
davhojt 5fb783a173 docs(valid-ip) update description to add information about max IP ports 2 years ago
davhojt b916bf35cc docs(tron) correct audit grammar 2 years ago
davhojt 779e60adca docs(tron) correct subject grammar 2 years ago
davhojt df7eed8272 docs(tron) change URLs 2 years ago
davidrobert99 a91a88aa89 update tron 2 years ago
Harry 7b0d53dd3b
Updated PC Requirements 2 years ago
zoevig 915a934454
Update pc-requirements.md 2 years ago
Christopher Fremond 39f8e26926
Update pc-requirements.md 2 years ago
Christopher Fremond d649562591
Update pc-requirements.md 2 years ago
davhojt 2972b88be3 docs(lunch_queue) improve grammar about Link pointing to None 2 years ago
davhojt 4a2c962331 docs(lunch_queue) correct grammar 2 years ago
David Mata 30f3ae23c5
Merge pull request #1120 from 01-edu/check-shopping_mall-c-574 2 years ago
davhojt ebab4a3f8c docs(brainfuck) correct grammar 2 years ago
davhojt 49bbf8a874 docs(brackets_matching) correct grammar 2 years ago
davhojt d801a4a7f1 docs(flat_tree) correct grammar 2 years ago
davhojt ef9cee5a31 docs(filter_table) correct grammar 2 years ago
davhojt cd1c3fd113 docs(display_table) correct grammar 2 years ago
davhojt f760682f53 docs(blood_types_s) correct grammar 2 years ago
davhojt b09478556e docs(matrix_display) correct grammar 2 years ago
Zewasik 3726c9a3b0 update wrong instruction 2 years ago
davhojt 3388d2ff97 docs(chaikin) correct audit grammar 2 years ago
davhojt 825b613895 docs(chaikin) add info to subject about handling no points. 2 years ago
davhojt be51c5e8b6 docs(chaikin) correct raid subject grammar 2 years ago
davhojt 1321ad02d8 docs(lalgebra_svalar) add trait sized to notions 2 years ago
davhojt 168a3c495f docs(lalgebra_vector) switch addition to var + var, instead of var plus dereferenced ptr 2 years ago
davhojt 4aebc1576c docs(commits_stats) correct grammar 2 years ago
davhojt f4b37fde93 docs(lalgebra_vector) correct grammar 2 years ago
davhojt 342528c2cd docs(lalgebra_scaler) correct grammar 2 years ago
davhojt 3c6542f6b0 docs(roman_numbers) correct grammar 2 years ago
davhojt b1fd04446b docs(vector_operations) correct grammar 2 years ago
davhojt 5b8025182a docs(blood_types) correct grammar 2 years ago
davhojt ee14e69c39 docs(easy_traits) correct grammar 2 years ago
davhojt 2bd1d77a5e docs(traits) correct grammar 2 years ago
davhojt 604911375d docs(generics_list) correct grammar 2 years ago
davhojt 23a0633ab4 docs(generics) correct grammar 2 years ago
davhojt d36e462f3b docs(drop_the_thread) correct grammar 2 years ago
davhojt fc4288ccc4 docs(ref_cell) correct grammar 2 years ago
davidrobert99 55a72a0d32 update description shopping mall 2 years ago
davidrobert99 b38b7f33d9 update rt 2 years ago
davidrobert99 245e7c32a1 update smart-road 2 years ago
davidrobert99 e21db80a69 update rt 2 years ago
  1. 2
      README.md
  2. 28
      docs/pc-requirements.md
  3. 75
      docs/server-installation.md
  4. 29
      docs/server-requirements.md
  5. 2
      js/tests/get-some-time_test.js
  6. 1
      js/tests/valid-ip_test.js
  7. 43
      subjects/addifpositive/README.md
  8. 4
      subjects/adding/README.md
  9. 13
      subjects/adding_twice/README.md
  10. 15
      subjects/all/README.md
  11. 46
      subjects/alphaposition/README.md
  12. 43
      subjects/arraysum/README.md
  13. 18
      subjects/ascii-art/README.md
  14. 24
      subjects/ascii-art/audit/README.md
  15. 38
      subjects/ascii/README.md
  16. 46
      subjects/betweenus/README.md
  17. 47
      subjects/binaryaddition/README.md
  18. 30
      subjects/blood_types/README.md
  19. 8
      subjects/blood_types_s/README.md
  20. 6
      subjects/border_cross/README.md
  21. 15
      subjects/brackets_matching/README.md
  22. 28
      subjects/brainfuck/README.md
  23. 44
      subjects/build-brick-and-break/README.md
  24. 32
      subjects/chaikin/README.md
  25. 32
      subjects/chaikin/audit/README.md
  26. 27
      subjects/clonernews/README.md
  27. 18
      subjects/clonernews/audit/README.md
  28. 11
      subjects/closures/README.md
  29. 26
      subjects/commits_stats/README.md
  30. 40
      subjects/countnegative/README.md
  31. 48
      subjects/curry-entries/README.md
  32. 10
      subjects/debounce/README.md
  33. 2
      subjects/deep-copy/README.md
  34. 2
      subjects/delete_prefix/README.md
  35. 10
      subjects/display_table/README.md
  36. 41
      subjects/divisors/README.md
  37. 58
      subjects/drop_the_thread/README.md
  38. 8
      subjects/easy_traits/README.md
  39. 89
      subjects/events/README.md
  40. 31
      subjects/fifty-shades-of-cold/README.md
  41. 22
      subjects/filter/README.md
  42. 6
      subjects/filter_table/README.md
  43. 7
      subjects/flagger/README.md
  44. 2
      subjects/flat_tree/README.md
  45. 3
      subjects/flow/README.md
  46. 8
      subjects/for-each/README.md
  47. 14
      subjects/fusion/README.md
  48. 10
      subjects/generics/README.md
  49. 13
      subjects/generics_list/README.md
  50. 27
      subjects/get-json/README.md
  51. 69
      subjects/get-them-all/README.md
  52. 20
      subjects/get_products/README.md
  53. 25
      subjects/getarea/README.md
  54. 36
      subjects/gossip-grid/README.md
  55. 36
      subjects/gougle-search/README.md
  56. 25
      subjects/harder-bigger-bolder-stronger/README.md
  57. 23
      subjects/highest/README.md
  58. 17
      subjects/interpolation/README.md
  59. 4
      subjects/invert/README.md
  60. 22
      subjects/is-winner/README.md
  61. 45
      subjects/ismultiple/README.md
  62. 32
      subjects/keep-trying-or-giveup/README.md
  63. 25
      subjects/keycodes-symphony/README.md
  64. 17
      subjects/lalgebra_scalar/README.md
  65. 14
      subjects/lalgebra_vector/README.md
  66. 41
      subjects/leapyear/README.md
  67. 17
      subjects/lifetimes/README.md
  68. 15
      subjects/long-words/README.md
  69. 22
      subjects/lunch_queue/README.md
  70. 40
      subjects/manipulate-entries/README.md
  71. 37
      subjects/manipulate-keys/README.md
  72. 44
      subjects/manipulate-values/README.md
  73. 18
      subjects/mapper/README.md
  74. 23
      subjects/matrix/README.md
  75. 6
      subjects/matrix_display/README.md
  76. 15
      subjects/matrix_mult/README.md
  77. 8
      subjects/matrix_ops/README.md
  78. 35
      subjects/mouse-trap/README.md
  79. 3
      subjects/neuron/README.md
  80. 20
      subjects/paramrange/README.md
  81. 54
      subjects/pick-and-click/README.md
  82. 10
      subjects/pick-omit/README.md
  83. 31
      subjects/pimp-my-style/README.md
  84. 23
      subjects/printascii/README.md
  85. 17
      subjects/pronoun/README.md
  86. 24
      subjects/quantifiers/README.md
  87. 20
      subjects/race/README.md
  88. 62
      subjects/ref_cell/README.md
  89. 7
      subjects/replica/README.md
  90. 121
      subjects/road_intersection/README.md
  91. 58
      subjects/road_intersection/audit/README.md
  92. 6
      subjects/roman_numbers/README.md
  93. 2
      subjects/roman_numbers_iter/README.md
  94. 27
      subjects/rotargn/README.md
  95. 18
      subjects/rt/README.md
  96. 2
      subjects/rt/audit/README.md
  97. 48
      subjects/sales/README.md
  98. 5
      subjects/series/README.md
  99. 54
      subjects/shopping_mall/README.md
  100. 38
      subjects/smart-road/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 01 Edu System
### Welcome to the Public Repository of the 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,12 +1,28 @@
# PC requirements
# PC requirements (Minimum)
Features required:
- Linux compatible
- **Compatibility with Linux (Ubuntu/Debian x64)**
| Component | Minimum specifications |
| Component | 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 |
| Disk | 120 GB SSD |
| Monitor | 14" Full HD flicker-free |
| 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.

75
docs/server-installation.md

@ -1,49 +1,62 @@
# Server installation
## DNS configuration
## 🌐 DNS Configuration
One domain and one subdomain must point to the IP address of a [dedicated server](server-requirements.md).
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`).
| FQDN | Record type | Address |
| -------------- | ----------- | ------- |
| ((DOMAIN)) | A | X.X.X.X |
| git.((DOMAIN)) | A | X.X.X.X |
Your newly configured DNS records should look like this:
## Network configuration
| FQDN | Record type | Target |
| -------------- | ----------- | ------------- |
| ((DOMAIN)) | A | X.X.X.X |
| git.((DOMAIN)) | CNAME | ((DOMAIN)) |
### Inbound
Here is an _example_ of the DNS records for the domain `example.org` with the public IP address of `93.184.216.34`:
| Port | Transport | Application |
| ----------- | --------- | ---------------- |
| 80 | TCP, UDP | HTTP/(1.1, 2, 3) |
| 443 | TCP, UDP | HTTP/(1.1, 2, 3) |
| 521 | TCP | SSH |
| 8080 - 8090 | TCP, UDP | HTTP/(1.1, 2, 3) |
| FQDN | Record type | Target |
| -------------- | ----------- | ------------- |
| example.org | A | 93.184.216.34 |
| git.example.org | CNAME | example.org |
### Outbound
| Port | Transport | Application |
| ----------- | --------- | ---------------- |
| 587 | TCP | SMTP |
| 8080 - 8090 | TCP, UDP | HTTP/(1.1, 2, 3) |
## 🛠 Network Configuration
### OS installation
### ➡ Inbound
Download and boot the ISO image `amd64` of [Debian](https://www.debian.org/distrib/netinst)
| 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) |
Select :
### ⬅ Outbound
- "Advanced options ..."
- "... Automated install"
| Port | Protocol(s) | Service/Application |
| ----------- | ----------- | -------------------- |
| 587 | TCP | SMTP |
| 8080 - 8090 | TCP | HTTP/(1.1, 2, 3) |
The network is automatically configured with DHCP, you can also configure it manually.
## 💿 OS installation
At the prompt "Location of initial preconfiguration file:", enter the URL :
1. Download and boot the `amd64` variant of the [Debian](https://www.debian.org/distrib/netinst) ISO image.
```
raw.githubusercontent.com/01-edu/public/master/sh/debian/preseed.cfg
```
2. Select :
- "**Advanced options ...**"
- "**... Automated install**"
and select "Continue".
3. The network is automatically configured using your DHCP server. Additionally, you can also configure it manually to suit your preference.
--> Please let us know when the server's remote access is ready and we will configure it.
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.

29
docs/server-requirements.md

@ -1,12 +1,25 @@
# Server requirements
# Server requirements (Minimum)
Features required:
- Dedicated hardware
- Linux compatible
- Dedicated hardware components (kept in **data centre** conditions)
- Compatibility with **Linux (Debian x64)**
| 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 |
| 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_) |

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

@ -11,4 +11,6 @@ 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)

1
js/tests/valid-ip_test.js

@ -21,7 +21,6 @@ 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',

43
subjects/addifpositive/README.md

@ -0,0 +1,43 @@
## 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` that returns a closure.
The purpose is to curry the add method to create more variations.
Create the function `add_curry`, which returns a closure.
The purpose is to 'curry' the add method to create more variations.
### Usage

13
subjects/adding_twice/README.md

@ -2,14 +2,11 @@
### Instructions
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.
You'll need to reuse your `add_curry` function. Copy and paste it directly into your `lib.rs` file.
### Notions
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))`.
- [higher order function](https://doc.rust-lang.org/rust-by-example/fn/hof.html#higher-order-functions)
So, the purpose of this function is to add two times the value in `add_curry` to the original value.
### Expected functions
@ -57,3 +54,7 @@ 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,18 +2,17 @@
### Instructions
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)
Create a function named `all` that works like `Promise.all` but with objects (instead of arrays).
### Code provided
> all code provided will be added to your solution and doesn't need to be submited.
> The provided code will be added to your solution, and does not need to be submitted.
```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

@ -0,0 +1,46 @@
## 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$
```

43
subjects/arraysum/README.md

@ -0,0 +1,43 @@
## 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
```

18
subjects/ascii-art/README.md

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

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

@ -85,6 +85,30 @@
###### 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

@ -0,0 +1,38 @@
## 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]
```

46
subjects/betweenus/README.md

@ -0,0 +1,46 @@
## 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
```

47
subjects/binaryaddition/README.md

@ -0,0 +1,47 @@
## 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]
```

30
subjects/blood_types/README.md

@ -4,27 +4,33 @@
In this exercise you will create a data model of blood types and an API to deal with them.
Start by copying the data representation of the blood types:
First, we'll implement the data representation of the blood types.
- 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
Take a look at the `BloodType` struct below. It contains two enums which enable us to describe a blood type (e.g. "A-").
- After, copy the struct `BloodType` that contains two fields with the names antigen and rh_factor
- `Antigen`: which can be one of:
- `A`
- `B`
- `AB`
- `O`
- `RhFactor`: which can be one of:
- `Positive`
- `Negative`
- 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:
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:
```rust
let a_neg: BloodType = "A-".parse();
```
- Implement the std::cmp::Ord trait to make possible to sort a vector or array of BloodType's
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 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`
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`.
### Expected Functions and Structures

8
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- |
Write three methods for BloodType:
Implement 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`
- `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`.
### Expected Functions and Structures

6
subjects/border_cross/README.md

@ -2,11 +2,9 @@
### Instructions
- Create the trait Vehicle with the model and year
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`.
- 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.
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/brackets_matching/README.md

@ -2,15 +2,20 @@
### Instructions
Write a `program` that takes an undefined number of `string` in arguments. For each argument, if the expression is correctly bracketed, the program prints on the standard output `OK` followed by a newline (`'\n'`), otherwise it prints `Error` followed by a newline.
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.
Symbols considered as brackets are parentheses `(` and `)`, square brackets `[` and `]` and curly braces `{` and `}`. Every other symbols are simply ignored.
All characters are ignored except for the following brackets:
- parentheses `(` and `)`.
- square brackets `[` and `]`.
- curly braces `{` and `}`.
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.
Opening brackets must only be closed by the corresponding closing bracket. For example, a curly brace cannot close a square bracket.
If there is no argument, the program must print nothing.
A `String` which does not contain any brackets is considered to be correctly bracketed.
For receiving arguments from the command line you should use something like:
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() {

28
subjects/brainfuck/README.md

@ -1,21 +1,23 @@
## 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 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)
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 `[`.
Any other character is a comment.

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

@ -2,43 +2,41 @@
### 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 given amount of bricks passed as argument:
- Create a function `build` which will create and display the 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 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 the 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, 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)
- 🔨: 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.
### Files
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:
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:
- 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
- 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.
### 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)

32
subjects/chaikin/README.md

@ -2,35 +2,33 @@
### Instructions
Implement the [Chaikin's](http://graphics.cs.ucdavis.edu/education/CAGDNotes/Chaikins-Algorithm/Chaikins-Algorithm.html) algorithm step by step in an animation.
Implement [Chaikin's](http://graphics.cs.ucdavis.edu/education/CAGDNotes/Chaikins-Algorithm/Chaikins-Algorithm.html) algorithm as a step by step animation.
The objective is to create a canvas where the user will be able to draw 1 or more points on it, and then the screen will play an animation of 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.
It is mandatory to use the `Chaikin's` algorithm.
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.
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.
- The selected points must be visible in the canvas, so you will have to draw a small circle surrounding the selected points.
#### Functionality
- After pressing `Enter` the program should start the animation of the steps until reaching the 7th step of the `Chaikin's` algorithm. After the 7th step the program must restart.
- 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.
- If the canvas only has only one control point, the program must only present that point and do no change at all.
- 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.
- If the canvas has only two control points, the program must draw a straight line.
- 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.
- Pressing `Escape` should quit the window.
- If the canvas only has only one control point, the program must only present that point and not cycle through the steps.
### Note
- If the canvas has only two control points, the program must draw a straight line.
You are free to use any library to create and handle windows, rendering, keyboard and mouse events.
- Pressing `Escape` should quit the window.
### Bonus
> You are free to use any library to create and handle windows, rendering, keyboard and mouse events.
- Add the ability to clear the screen and add new control points.
### Bonus
- Make it possible to clear the screen, so that the user can select new control points.
- Make it possible to drag the control points in real time.

32
subjects/chaikin/audit/README.md

@ -2,40 +2,48 @@
##### Run the program using `cargo run`.
###### Does it compile and run without any warnings?
###### Does it compile and run without warnings?
##### Left click in the canvas to set one or more control points.
##### Left click on the canvas to set one or more control points.
###### Does the program allow you to mark these control points?
###### Can You confirm that the program draws a small circle around the control points, in order to identify them?
###### Can you confirm that the program draws a small circle around the control points in order to identify them?
##### Left click in the canvas to set one or more control points and press `Enter`.
##### 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?
##### Left click in the canvas to set just one control point and press `Enter`.
##### Press `Escape` to exit the program.
###### Does the program exit without errors?
##### Start the program and left click on the canvas to set just one control point and press `Enter`.
###### Can you confirm that only the control point is shown and nothing changes?
##### Left click in the canvas to set just two control points and press `Enter`.
##### 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?
##### Left click in the canvas to set one or more control points and press `Enter`.
##### 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 starting again?
###### Does the animation complete 7 steps before restarting?
##### Left click in the canvas to set one or more control points and press `Enter` then press `Escape`.
##### 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?
##### Press `Enter` without selecting any points.
##### Start the program and press `Enter` without selecting any points.
###### Does the program returns an error?
###### 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?
##### 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?
###### +Is it possible to drag the control points in real time and get a new curve?

27
subjects/clonernews/README.md

@ -1,35 +1,30 @@
## 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.
Technology nowadays continue to evolve. As a programmer or developer you must be updated with this exponential evolution of technology.
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.
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).
So your objective for this raid is to create an UI for the [HackerNews API](https://github.com/HackerNews/API).
You must handle at least:
- Posts, this includes :
- Posts: including:
- [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. 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.
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).
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!!!
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.
Best ways you can avoid rate limiting :
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:
- optimize your code to eliminate any unnecessary requests
- usage of throttling/debouncing function to regulates the amount of requests
- usage of a throttling/debouncing function to regulate the number of requests,
### Optional
You can handle sub-comments for each stories, jobs and polls this meaning nested comments
You can handle sub-comments for stories, jobs and polls, by implementing nested comments.

18
subjects/clonernews/audit/README.md

@ -1,20 +1,20 @@
#### Functionals
#### Functional
##### Try to open a story post
###### Does this post open without problems?
###### Does this post open without any errors?
##### Try to open a job post
###### Does this post open without problems?
###### Does this post open without any errors?
##### Try to open a poll post
###### Does this post open without problems?
###### Does this post open without any errors?
##### Try to load more posts
###### Did the posts loaded without error or without spamming the user?
###### Did the posts load without error and 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?
###### Is the UI notifying the user that there is a new update on a certain post?
###### Does the UI notify the user when a certain post is updated?
###### Is the project using Throttle to regulate the amount of request (every 5 seconds)?
###### Is the project using throttling to regulate the number of requests (every 5 seconds)?
#### Bonus
###### +Does the UI have more types of posts than stories, jobs and polls?
###### +Are there sub-comments(nested comments) on the UI?
###### +Have sub-comments (nested comments) been implemented?

11
subjects/closures/README.md

@ -2,12 +2,7 @@
### Instructions
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)
Using closures and iterators create a **function**, that returns the first 50 even numbers squared in a `Vec<i32>`.
### Expected Functions
@ -39,3 +34,7 @@ $ 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)

26
subjects/commits_stats/README.md

@ -2,26 +2,13 @@
### 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` to get the following information:
1. Number of commits per author (identified by the GitHub login).
2. The number of commits per author.
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`.
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.
- `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)
> 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"`.
### Expected functions
@ -56,3 +43,8 @@ $ 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)

40
subjects/countnegative/README.md

@ -0,0 +1,40 @@
## 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,18 +2,20 @@
### Instructions
This exercise consists in creating curry functions to apply in the object's entries.
You will have to create the following curry functions:
You're going to create some curry functions, to apply to the object's entries.
- `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.
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.
```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,
@ -24,7 +26,7 @@ defaultCurry({
```
- `mapCurry` replicates function `.map`, where first entry is a function, second is an object.
Create `mapCurry`, which replicates function `.map` (but for an object). The first entry is the function, and the second entry is the object.
```js
mapCurry(([k, v]) => [`${k}_force`, v])(personnel)
@ -38,7 +40,7 @@ mapCurry(([k, v]) => [`${k}_force`, v])(personnel)
}
```
- `reduceCurry` replicates function `.reduce`, where first entry is function, second is (object, initial value).
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).
```js
reduceCurry((acc, [k, v]) => (acc += v))({ a: 1, b: 2, c: 3 }, 0)
@ -46,7 +48,7 @@ reduceCurry((acc, [k, v]) => (acc += v))({ a: 1, b: 2, c: 3 }, 0)
6
```
- `filterCurry` replicates function `.filter`, where first entry is function, second is object.
Create `filterCurry` which replicates the `.filter` method (but for an object). The first entry is the function, and the second is an object.
```js
filterCurry(([k, v]) => typeof v === 'string' || k === 'arr')({
@ -60,25 +62,14 @@ 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 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)
- `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.
### Code provided
> all code provided will be added to your solution and doesn't need to be submited.
> The provided code will be added to your solution, and does not need to be submitted.
```js
// prettier-ignore
@ -90,3 +81,12 @@ 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)

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`, this function doesn't need to take care of the options
- `opDebounce`, this function will take care of the `leading` options
- `debounce`: don't worry about the options.
- `opDebounce`: implement the `leading` options.
### Notions
- [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)
- [lodash debounce](https://lodash.com/docs/4.17.15#debounce)
- [css-tricks.com debounce](https://css-tricks.com/debouncing-throttling-explained-examples/#debounce)

2
subjects/deep-copy/README.md

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

2
subjects/delete_prefix/README.md

@ -2,7 +2,7 @@
### Instructions
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`.
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`.
### Expected Function

10
subjects/display_table/README.md

@ -1,14 +1,12 @@
## display_table
### Instructions
### Instructions
- Implement the `std::fmt::Display` trait for the structure table so that the table is printed like in the **[Usage](#usage)**. The length of each column must adjust to the longest element of the column and the element must be centered in the "cell" when possible. If the length of the element does not allow to center exactly, it must be offset slightly to the left.
Define the `Table` struct below, and implement the associated functions `new` and `add_row`. You can see how they should work from the usage.
- Note: If the table is empty (does not have a header), `println!` must not print anything.
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.
- 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.
If the table is empty `println!` must not print anything.
### Expected functions and Structures

41
subjects/divisors/README.md

@ -0,0 +1,41 @@
## 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
```

58
subjects/drop_the_thread/README.md

@ -2,45 +2,35 @@
### 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 a Drop checker API has to be created. For this you must define:
In this exercise, you will create a Drop Checker API.
- Two structures:
Define the following 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)
- Implementation of each structure:state
- `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).
- `Workers` :
You'll need to also add the following associated functions to the structures:
- `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.
- `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.
- `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 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)
- 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.
### Expected Functions
@ -111,3 +101,9 @@ $ 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 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: `. , ? !`
- `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 `!`).
### Expected Function

89
subjects/events/README.md

@ -4,51 +4,41 @@
You have to design a notification system for a platform.
These events can be: Remainders, Registrations, Appointments or Holidays.
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.
- 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
@ -56,22 +46,22 @@ use chrono::Duration;
use colored::*;
#[derive(Debug, Eq, PartialEq)]
enum Position {
pub enum Position {
Top,
Bottom,
Center,
}
#[derive(Debug, Eq, PartialEq)]
struct Notification {
size: u32,
color: (u8, u8, u8),
position: Position,
content: String,
pub struct Notification {
pub size: u32,
pub color: (u8, u8, u8),
pub position: Position,
pub content: String,
}
#[derive(Debug)]
enum Event<'a> {
pub enum Event<'a> {
Remainder(&'a str),
Registration(Duration),
Appointment(&'a str),
@ -86,7 +76,7 @@ impl fmt::Display for Notification {
use Event::*;
impl Event {
fn notify(&self) -> Notification {
pub fn notify(&self) -> Notification {
}
}
```
@ -121,3 +111,8 @@ $ 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)

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

@ -2,11 +2,11 @@
### Instructions
You've been asked to freshen a webpage atmosphere by displaying shades of cold colors.
You've been asked to freshen up a webpage, by displaying shades of cold colors.
Check the `colors` array provided in the data file below.
- 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:
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:
```css
.blue {
@ -14,33 +14,32 @@ Check the `colors` array provided in the data file below.
}
```
- 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, 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()`
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.
### Files
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:
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:
- 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 also allow 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 enable you 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()`

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 a `reject` function that takes an array as first argument, a function as second,
and that works like the reject function from lodash.
Create the following functions, which each take an array as the first argument, and a function as the second argument.
- Create a `partition` function that takes an array as first argument, a function as second,
and that works like the partition function from lodash.
- `filter`: that works like the `[].filter` method.
### Notions
- `reject`: that works like the `reject` 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)
- `partition`: that works like the `partition` function from lodash.
### Code provided
> all code provided will be added to your solution and doesn't need to be submited.
> The provided code will be added to your solution, and does not need to be submitted.
```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)

6
subjects/filter_table/README.md

@ -2,14 +2,10 @@
### Instructions
- Define the **functions**:
- 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.
### Expected functions and Structures

7
subjects/flagger/README.md

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

2
subjects/flat_tree/README.md

@ -2,7 +2,7 @@
### Instructions
- Define the functions `flatten_tree` which receives a `std::collections::BTreeSet` and returns a new `Vec` with the elements of the binary tree in order.
Create the `flatten_tree` **function** which receives a `std::collections::BTreeSet` and returns a new `Vec` with the elements of the binary tree in order.
### Expected function

3
subjects/flow/README.md

@ -2,8 +2,7 @@
### Instructions
Create the function `flow` that will works as the \_.flow([funcs])
from lodash.
Create the function named `flow` that will like the `_.flow([funcs])` from lodash.
### Example

8
subjects/for-each/README.md

@ -2,16 +2,16 @@
### Instructions
Create a `forEach` function that takes an array as first argument, a function as second,
and that works like the method .forEach
Create a function named `forEach` which takes an array as the first argument, a function as the second argument,
and that works like the `Array.prototype.forEach` method.
### Notions
- [devdocs.io/javascript/global_objects/array/foreach](https://devdocs.io/javascript/global_objects/array/foreach)
- [Array.prototype.forEach](https://devdocs.io/javascript/global_objects/array/foreach)
### Code provided
> all code provided will be added to your solution and doesn't need to be submited.
> The provided code will be added to your solution, and does not need to be submitted.
```js
Array.prototype.forEach = undefined

14
subjects/fusion/README.md

@ -2,38 +2,38 @@
### Instructions
The objective of this exercise is to merge objects into a new object depending on the values type
The objective of this exercise is to merge objects into a new object depending on the values type.
With this, create a function called `fusion` that:
Create a function named `fusion` that:
- If the type is an array you must concatenate it
- For array types, you will concatenate them.
```js
fusion({ arr: [1, "2"] }, { arr: [2] }); // -> { arr: [ 1, '2', 2 ] }
fusion({ arr: [], arr1: [5] },{ arr: [10, 3], arr1: [15, 3], arr2: ["7", "1"] }); // ->{ arr: [ 10, 3 ], arr1: [ 5, 15, 3 ], arr2: [ '7', '1' ] }
```
- If it is a string you must concatenate it with a space
- For strings, you must concatenate them with a space.
```js
fusion({ str: "salem" }, { str: "alem" }); // -> { str: 'salem alem' }
fusion({ str: "salem" }, { str: "" }); // -> { str: 'salem ' }
```
- If they are numbers, you must add them
- If they are numbers, you must add them.
```js
fusion({ a: 10, b: 8, c: 1 }, { a: 10, b: 2 }); // -> { a: 20, b: 10, c: 1 }
```
- If it is an object, you must join them recursively
- If it is an object, you must join them recursively.
```js
fusion({ a: 1, b: { c: "Salem" } }, { a: 10, x: [], b: { c: "alem" } }); // -> { a: 11, x: [], b: { c: 'Salem alem' } }
fusion( { a: { b: [3, 2], c: { d: 8 } } },{ a: { b: [0, 3, 1], c: { d: 3 } } }); // -> { a: { b: [ 3, 2, 0, 3, 1 ], c: { d: 11 } } }
```
- In case of type mismatch you must replace it with the value of the second object
- In case of type mismatch you must replace it with the value of the second object (if it exists).
```js
fusion({ a: "hello", b: [] }, { a: 4 }); // -> { a: 4, b: [] }

10
subjects/generics/README.md

@ -2,13 +2,9 @@
### Instructions
Write a **function** called `identity` which calculates the identity of a value (receives any data type and returns the same value).
Create a **function** named `identity` which calculates the identity of a value (receives any data type and returns the same value).
### Notions
- [Generics](https://doc.rust-lang.org/book/ch10-01-syntax.html)
### Expected Function (signature to be completed)
@ -38,3 +34,7 @@ Hello, world!
3
$
```
### Notions
- [Generics](https://doc.rust-lang.org/book/ch10-01-syntax.html)

13
subjects/generics_list/README.md

@ -4,15 +4,10 @@
Create a linked list of generic values with the following methods.
- `new` which returns a new empty list.
- `push` which adds at the beginning of the list a new element.
- `pop` which deletes the last added element to the list.
- `len` which returns the size of the list.
- `new`: returns a new empty list.
- `push`: adds an element to the beginning of the list.
- `pop`: deletes an element from the list based on LIFO.
- `len`: returns the size of the list.
### Expected Functions

27
subjects/get-json/README.md

@ -4,26 +4,23 @@
In this exercise, we will focus on building complex async flows with promises.
Create a `getJSON` function that takes 2 parameters:
Create a function named `getJSON` with two parameters:
- `path`: a URL called by your function.
- `params`: optional query parameters that will be appended to the `path`.
- `path`, that will be the url called by your function
- `params` _optional_, that will be the search parameters appended to your url
`getJSON` must construct a valid url with the `path` and stringified `params`, and use `fetch` to fulfil the request.
`getJSON` must construct a valid url with the `path` and stringified `params`
and call `fetch` with it.
If the response is not ok, your function must throw an error using
the response status message.
If the response is not OK, `getJSON` must throw an error using the response _status text_.
The response body must then be read and parsed from json.
The response body must then be read and parsed from JSON.
The parsed object contains one of those 2 properties:
- `"data"` the actual data to return
- `"error"` the error message to throw
- `"data"`: the actual data to return.
- `"error"`: the error message to throw.
### Notions
- [nan-academy.github.io/js-training/examples/promise.js](https://nan-academy.github.io/js-training/examples/promise.js)
- [devdocs.io/dom/fetch_api/using_fetch](https://devdocs.io/dom/fetch_api/using_fetch)
- [devdocs.io/dom/urlsearchparams](https://devdocs.io/dom/urlsearchparams)
- [devdocs.io/javascript/global_objects/json](https://devdocs.io/javascript/global_objects/json)
- [Promise.js](https://nan-academy.github.io/js-training/examples/promise.js)
- [Using fetch](https://devdocs.io/dom/fetch_api/using_fetch)
- [URL search params](https://devdocs.io/dom/urlsearchparams)
- [JSON](https://devdocs.io/javascript/global_objects/json)

69
subjects/get-them-all/README.md

@ -2,52 +2,55 @@
### Instructions
You've been attributed the task to find the main architect of the Tower of Pisa before he achieves his plans, avoiding us nowadays all those lame pictures of people pretending to stop it from falling.
You've been given the task of finding the main architect of the Tower of Pisa before he achieves his plans; avoiding all those lame pictures of people pretending to stop it from falling.
You arrive at the architects' chamber to find him, but all you have in front of you is a bunch of unknown people.
Step by step, with the little information you have, gather information and figure out by elimination who he is.
You arrive at the architects' chamber, but all you have in front of you is a bunch of unknown people.
Launch the provided HTML file in the browser to begin your investigation.<br/>
On top of the webpage, each of the four buttons fires a function:
Step by step, gather information and figure out by elimination who he is.
- Write the body of the `getArchitects` function, which returns an array containing 2 arrays of HTML elements:
Launch the provided HTML file in the browser to begin your investigation.
- the first array contains the architects, all corresponding to a `<a>` tag
- the second array contains all the non-architects people
At the top of the webpage, each of the four buttons fires a function:
- Write the body of the `getClassical` function, which returns an array containing 2 arrays of HTML elements:
Complete the body of the following functions. The first three functions return an array containing two arrays of HTML elements:
- the first array contains the architects belonging to the `classical` class
- the second array contains the non-classical architects
- `getArchitects`:
- 1st array: the architects, all corresponding to a `<a>` tag.
- 2nd array: all the non-architects.
- Write the body of the `getActive` function, which returns an array containing 2 arrays of HTML elements:
- `getClassical`:
- 1st array: the architects belonging to the `classical` class.
- 2nd array: the non-classical architects.
- the first array contains the classical architects who are `active` in their class
- the second array contains the non-active classical architects
- `getActive`:
- 1st array: the classical architects who are `active` in their class.
- 2nd array: the non-active classical architects.
- Write the body of the `getBonannoPisano` function, which returns an array containing:
- the HTML element of the architect you're looking for, whose `id` is `BonannoPisano`
- an array which contains all the remaining HTML elements of active classical architects
> From now on, don't forget to [**export**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export) all the expected functions, so that they can be imported to be tested<br/> > `export const getArchitects = () => {...}`
### Notions
- [HTML Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)
- [`getElementsByTagName()`](https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByTagName)
- [`getElementsByClassName()`](https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName)
- [`getElementById()`](https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById)
- [`querySelectorAll()`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll) / [`querySelector()`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector)
- ...and bit of CSS that could help with the [`:not` pseudo class](https://developer.mozilla.org/en-US/docs/Web/CSS/:not)
The last function is `getBonannoPisano`. It returns an array containing:
- the HTML element of the architect you're looking for, whose `id` is `BonannoPisano`.
- an array containing all the remaining HTML elements of active classical architects.
> From now on, don't forget to [**export**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export) all the expected functions, so that they can be imported to be tested.
```js
export const getArchitects = () => {...}
```
### Files
You only need to create & submit the JS file `get-them-all.js` ; we're providing you the following files to download (click right and save link) & test locally:
You only need to create & submit the JS file `get-them-all.js`. We're providing you the following files to download. You may test them locally:
- the HTML file [get-them-all.html](./get-them-all.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
- the import of the data
- the JS script running some code, and which will allow you to run your code.
- some CSS pre-styled classes: feel free to use those as they are, or modify them.
- an import of the data.
- the data file [get-them-all.data.js](./get-them-all.data.js) used to generate content in the HTML
- the data file [get-them-all.data.js](./get-them-all.data.js) used to generate content in the HTML.
### Notions
- [HTML Element](https://developer.mozilla.org/en-US/docs/Web/API/Element)
- [getElementsByTagName](https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByTagName)
- [getElementsByClassName](https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName)
- [getElementById](https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById)
- [querySelectorAll](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll) / [querySelector`](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector)
- ...and bit of CSS that could help with the [`:not` pseudo class](https://developer.mozilla.org/en-US/docs/Web/CSS/:not)

20
subjects/get_products/README.md

@ -2,18 +2,16 @@
### Instructions
Create a function `get_products` that takes a vector of integers, and returns a vector of the products
of each index. For this exercise to be correct you will have to return the product of every index
except the current one.
Create a function named `get_products` that takes a vector of integers, and returns a vector of the products of each index.
Examples: [1,2,3,4]
You'll need to return the product of every index
except the current one.
- for the number `1` we get `2*3*4 = 24`
- for the number `3` we get `1*2*4 = 8`
### Example:
For `[1,2,3,4]`, we get:
### Notions
- [Trait iterator](https://doc.rust-lang.org/std/iter/trait.Iterator.html)
- for the number `1` we get `2*3*4 = 24`.
- for the number `3` we get `1*2*4 = 8`.
### Expected functions
@ -44,3 +42,7 @@ $ cargo run
[84, 12, 28, 21]
$
```
### Notions
- [Trait iterator](https://doc.rust-lang.org/std/iter/trait.Iterator.html)

25
subjects/getarea/README.md

@ -0,0 +1,25 @@
## get-area
### Instructions
Write a program that takes a positive number as radius and prints the area of a circle.
- The area of the circle is `3.14` times the radius squared.
- Only positive numbers will be accepted, otherwise print `Error` followed by (`'\n'`)
- If the number of arguments is not `1` print (`'\n'`)
- The output must be an integer.
### Usage
```console
$ go run . | cat -e
$
$ go run . 10 | cat -e
314$
$ go run . 4 | cat -e
50$
$ go run . -10 | cat -e
Error$
$ go run . "Hello World!" | cat -e
Error$
```

36
subjects/gossip-grid/README.md

@ -2,37 +2,37 @@
### Instructions
Good information is the pillar of society, that's why you've decided to dedicate your time to reveal the powerful truth to the world and deliver essential and strong news: you're launching a gossip grid.
Create the function `grid` which displays all the `gossips`, provided in the data file below, as cards on a grid (in the same order).
They must be `div` with the `gossip` class.
The first `gossip` card must be a `form` with a `textarea` and a submit button with the text `Share gossip!` that allows to add a new gossip to the list.
Create 3 `type="range"` inputs with the class `range`, all wrapped in a `div` with the class `ranges`:
They will each be represented as a `div` with the `gossip` class.
- one with `id="width"` that control the width of cards _(from 200 to 800 pixels)_
- one with `id="fontSize"` that control the font size _(from 20 to 40 pixels)_
- one with `id="background"` that control the background lightness _(from 20% to 75%)_
The first `gossip` card must be a `form`. It will need a `textarea`, and a submit button with the text `"Share gossip!"`. It will add new gossip to the list.
> _tips:_ use `hsl` for colors
### Notions
Create 3 `type="range"` inputs with the class `range`, all wrapped in a `div` with the class `ranges`.
- `id="width"`: that controls the width of cards from 200 to 800 pixels.
- `id="fontSize"`: that controls the font size from 20 to 40 pixels.
- `id="background"`: that control the background lightness from 20% to 75%.
- [`<form>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Form)
- [`<input>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input): [`text`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text), [`range`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range)
> Use `hsl` for colors
### Files
You only need to create & submit the JS file `gossip-grid.js` ; we're providing you the following files to download (click right and save link) & test locally:
You only need to create & submit the JS file `gossip-grid.js`; we're providing you the following files to download and test locally:
- the HTML file [gossip-grid.html](./gossip-grid.html) to open in the browser, which includes:
- the JS script which will allow to run your code
- some CSS pre-styled classes: feel free to use those as they are, or modify them
- the JS script 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 data file [gossip-grid.data.js](./gossip-grid.data.js) from which you can import `gossips`
- the data file [gossip-grid.data.js](./gossip-grid.data.js) from which you can import `gossips`.
### Expected result
You can see an example of the expected result [here](https://youtu.be/nbR2eHBqTxU)
### Notions
- [form](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Form)
- [input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input)
- [text](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text)
- [range](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range)

36
subjects/gougle-search/README.md

@ -2,16 +2,11 @@
### Instructions
Create the `queryServers` function, that takes 2 arguments:
- `serverName` a string of the name of the server
- `q` a string of the query given by the user
You have to construct 2 urls, using `q` as a search parameter,
prepending a `'/'` and for the 2nd appending `'_backup'`.
Then return the first value of those 2 calls
Create a function named `queryServers` that takes 2 arguments:
- `serverName`: a string of the name of the server.
- `q`: a string of the query given by the user.
You need to construct 2 urls which should work like this:
```js
queryServers('pouet', 'hello+world')
// return the fastest of those 2 calls:
@ -19,25 +14,26 @@ queryServers('pouet', 'hello+world')
// -> getJSON('/pouet_backup?q=hello+world')
```
Create a `gougleSearch` function that takes a single query argument.
It must call `queryServers` in concurrently on 3 servers:
`'web'`, `'image'` and `'video'`.
A timeout of 80milliseconds must be set for the whole operation.
Create a function named: `gougleSearch` that takes a single query argument (`q`). It must invoke `queryServers` concurrently on 3 servers:
- `"web"`
- `"image"`
- `"video"`
You must return the value from each server in an object
using the server name as key.
You must return the value from each server in an object using the server name as key.
### Notions
A timeout of 80milliseconds must be set for the whole operation, if it is not complete within 80 milliseconds, then you must return `Error('timeout')`.
- [devdocs.io/javascript/global_objects/promise/race](https://devdocs.io/javascript/global_objects/promise/race)
- [devdocs.io/javascript/global_objects/promise/all](https://devdocs.io/javascript/global_objects/promise/all)
### Code provided
> all code provided will be added to your solution and doesn't need to be submited.
> The provided code will be added to your solution, and does not need to be submitted.
```js
// fake `getJSON` function
let getJSON = async (url) => url
```
### Notions
- [Promise.race](https://devdocs.io/javascript/global_objects/promise/race)
- [Promise.all](https://devdocs.io/javascript/global_objects/promise/all)

25
subjects/harder-bigger-bolder-stronger/README.md

@ -2,27 +2,26 @@
### Instructions
Being stuck at home, bored, desperate and coming up with a lot of weird ideas, a friend asks you to develop a tool to measure his ocular skills: one of those [Monoyer charts](https://en.wikipedia.org/wiki/Monoyer_chart) that ophthalmologists use.
Being stuck at home, bored, desperate and coming up with a lot of weird ideas, a friend asks you to develop a tool to measure his ocular skills. One of those [Monoyer charts](https://en.wikipedia.org/wiki/Monoyer_chart) that ophthalmologists use.
Generate a board where each new letter is harder, bigger, bolder and stronger!
Generate a board where each new letter is harder, bigger, bolder and stronger.
Write the function `generateLetters` which creates 120 `div`, each containing a letter randomly picked through the **uppercase** alphabet, and whose style properties have to be increased:
- each letter `font-size` has to grow from `11` to `130` pixels
- `font-weight` has to be `300` for the first third of the letters, `400` for the second third, and `600` for the last third
Write the function `generateLetters` which creates 120 `div` elements, each containing a letter randomly picked through the **uppercase** alphabet, and whose style properties have to be increased:
- each letter's `font-size` has to grow from `11` to `130` pixels.
- `font-weight` has to be `300` for the first third of the letters, `400` for the second third, and `600` for the last third.
### Files
You only need to create & submit the JS file `harder-bigger-bolder-stronger.js` ; we're providing you the following file to download (click right and save link) & test locally:
You only need to create & submit the JS file `harder-bigger-bolder-stronger.js`. We're providing you the following file to download and test locally:
- the HTML file [harder-bigger-bolder-stronger.html](./harder-bigger-bolder-stronger.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
- 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.
### 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)
- [`style`](https://developer.mozilla.org/en-US/docs/Web/API/ElementCSSInlineStyle/style)
- [`textContent`](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent)
- [createElement](https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement)
- [append](https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/append)
- [style](https://developer.mozilla.org/en-US/docs/Web/API/ElementCSSInlineStyle/style)
- [textContent](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent)

23
subjects/highest/README.md

@ -2,19 +2,14 @@
### Instructions
In this exercise a `Numbers` struct will be given.
In this exercise, a `Numbers` struct will be given.
These methods have to be written:
- `new` create a new instance of Number.
- `List` that returns an `array` with every number in the struct.
- `Latest` that returns an `Option<u32>` with the last added number.
- `Highest` that return an `Option<u32>` with the highest number from the list.
- `Highest_Three` that returns a `Vec<u32>` with the three highest numbers.
### Notions
- [Trait iterator](https://doc.rust-lang.org/std/iter/trait.Iterator.html)
These methods have to be written for it:
- `new`: create a new instance of `Number`.
- `List`: which returns an `array` with every number in the struct.
- `Latest`: which returns an `Option<u32>` with the last added number.
- `Highest`: which returns an `Option<u32>` with the highest number from the list.
- `Highest_Three`: which returns a `Vec<u32>` with the three highest numbers.
### Expected functions
@ -62,3 +57,7 @@ Some(70)
[500, 70, 30]
$
```
### Notions
- [Trait iterator](https://doc.rust-lang.org/std/iter/trait.Iterator.html)

17
subjects/interpolation/README.md

@ -2,14 +2,15 @@
### Instructions
Create a function called `interpolation` that takes an object with 5 properties
`step`, `start`, `end`, `callback` and `duration`.
This function must calculate the interpolation points, (x, y),
from the `start` position to `end` position depending on the number of steps.
All the points must be calculated in the duration time.
Create a function named `interpolation` that takes an object with 5 properties: `step`, `start`, `end`, `callback` and `duration`.
For each interpolation point you must call `callback` function with parameter - interpolation point ([x, y]).
Each interpolation point should be calculated with interval of `duration / step`.
This function must interpolate points from the `start` position to the `end` position (not including the `end` position). The number of points depends on the number of steps.
For each interpolation point, you must call the `callback` function with an array of the two points `[x, y]`:
- `x`: distance
- `y`: point
There should be a delay between each `callback` invocation; of `duration / step`, so that the final call happens after `duration`.
### Example
@ -41,4 +42,4 @@ duration = 10
### Notions
- [javascript.info/settimeout-setinterval](https://javascript.info/settimeout-setinterval)
- [setTimeout & setInterval](https://javascript.info/settimeout-setinterval)

4
subjects/invert/README.md

@ -2,8 +2,8 @@
### Instructions
Create a function called `invert` that takes an object and returns it with its keys and values inverted.
Create a function named `invert` which takes an object and returns it with its keys and values inverted.
### Notions
- [devdocs.io/javascript/global_objects/object](https://devdocs.io/javascript/global_objects/object)
- [object](https://devdocs.io/javascript/global_objects/object)

22
subjects/is-winner/README.md

@ -2,27 +2,23 @@
### Instructions
Create a function `isWinner` that, by making use of `winners` "API", should
return a resolved Promise with the string:
Create a function named `isWinner` which accepts a string representing the name of a country. It should use the `winners` _"API"_ to return a resolved `Promise` with an appropriate string.
- `<country> + ' never was a winner'`, if the country passed in `isWinner` has never won the FIFA World Cup
The strings which can be returned are listed below. You'll need to replace `"Country"` with the country named which is passed to `isWinner`:
- `<country> + ' is not what we are looking for because of the continent'`,
if the country passed in `isWinner` is not from the european
continent
- `"Country never was a winner"`: The country has never won a FIFA world cup.
- `<country> + ' is not what we are looking for because of the number of times it was champion'`, if the country passed in `isWinner` was champion
less than 3 times
- `"Country is not what we are looking for because of the continent"`: The country is not from the european continent.
- `<country> + ' won the FIFA World Cup in ' + <year(s)> + 'winning by ' + <results>`, otherwise.
- `"Country is not what we are looking for because of the number of times it was champion"`: The country won the FIFA world cup fewer than 3 times.
The years and results should be displayed like bellow:
```<country> + ' won the FIFA World Cup in 1000, 1004, 1008 winning by 4-3, 5-2, 1-0```
- `"Country won the FIFA World Cup in <years> winning by <results>"`: with the following format:
- `<years>`: `"1000, 1004, 1008"`
- `<results>`: `"4-3, 5-2, 1-0"`
### Code provided
> all code provided will be added to your solution and doesn't need to be submitted.
> The provided code will be added to your solution, and does not need to be submitted.
```js
const db = (() => {

45
subjects/ismultiple/README.md

@ -0,0 +1,45 @@
## common-multiples
### Instructions
Write a function to check whether a given non-negative number is a multiple of 3 or 7.
- If the number is a multiple of 3 or 7, return `true`.
- If the number is not a multiple of 3 or 7, return `false`.
- If the number is less or equal to 0, return `false`.
### Expected function
```go
func IsMultiple(number int) bool {
// Your code here
}
```
### Usage
Here is a possible program to test your function:
```go
package main
import "fmt"
func main() {
fmt.Println(IsMultiple(3))
fmt.Println(IsMultiple(7))
fmt.Println(IsMultiple(8))
fmt.Println(IsMultiple(9))
fmt.Println(IsMultiple(-1))
}
```
and the output should be:
```console
$ go run .
true
true
false
true
false
```

32
subjects/keep-trying-or-giveup/README.md

@ -2,30 +2,26 @@
### Instructions
Create a `retry` function, that takes 2 arguments
Create a `retry` function, that takes 2 arguments:
- a `count` indicates maximum amount of retries
- an async `callback`, that will be called on every try
- `count`: indicates maximum number of retries.
- `callback`: an `async` function that will be invoked for every attempt.
`retry` returns a function that calls and returns value from `callback`
function passing its arguments and catches errors. If error is caught it
should return the `callback` function with catch. If number of errors
exceeds `count` then throw an `Error`.
`retry` returns a function that invokes the `callback` function. That function passes its arguments to `callback`, and returns the value from `callback`.
> for count of 3, the function will be called at most 4 times:
> the initial call + 3 retries.
The function returned by `retry` must `catch` errors from `callback`. After that function has caught `count` errors, it must `throw` an `Error`.
Create a `timeout` function, that takes 2 arguments
> if `count` is 3, `callback` will be invoked at most 4 times, the initial call plus 3 retries.
- a `delay` indicates maximum wait time
- an async `callback`, that will be called
Create function named `timeout`, that takes 2 arguments:
`timeout` returns a function either that calls and returns value from `callback`
function passing its arguments or returns `Error('timeout')` if `callback` didn't
resolve before `delay` time has reached.
- `delay`: indicates maximum wait time.
- `callback`: an asynchronous function that will be invoked.
`timeout` returns a function that invokes and returns the value from `callback`. The function must pass its arguments to `callback`. If `callback` does not resolve before `delay`, your function returns `Error('timeout')`.
### Notions
- [nan-academy.github.io/js-training/examples/promise.js](https://nan-academy.github.io/js-training/examples/promises.js)
- [devdocs.io/dom/settimeout]( https://devdocs.io/dom/settimeout)
- [devdocs.io/javascript/global_objects/promise/race](https://devdocs.io/javascript/global_objects/promise/race)
- [Promises](https://nan-academy.github.io/js-training/examples/promises.js)
- [setTimeout]( https://devdocs.io/dom/settimeout)
- [Promise.race](https://devdocs.io/javascript/global_objects/promise/race)

25
subjects/keycodes-symphony/README.md

@ -2,28 +2,27 @@
### Instructions
Like an inspired Beethoven who's going to write his Moonlight Sonata, you're about to compose a colourful symphony of letters with your keyboard.
Like an inspired Beethoven who's about to write his Moonlight Sonata, you're about to compose a colorful symphony of letters with your keyboard.
Write the function `compose`:
- Make it fire every time a key is pressed
- Create a new `div` with the class `note` when a letter of the lowercase alphabet is pressed, which has a unique background color generated using the `key` of the `event`, and displays the corresponding letter pressed
- If the pressed key is the `Backspace` one, delete the last note
- If the pressed key is the `Escape` one, clear all the notes
### Notions
- [Keyboard event](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent): [`keydown`](https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event), [`key`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)
- Make it fire every time a key is pressed.
- Create a new `div` with the class `note` when a letter of the lowercase alphabet is pressed. It should have a unique background color generated using the `key` of the `event`. It should also displays the corresponding pressed character.
- When `Backspace` is pressed, delete the last note.
- When `Escape` is pressed, clear all the notes.
### Files
You only need to create & submit the JS file `keycodes-symphony.js` ; we're providing you the following file to download (click right and save link) & test locally:
You only need to create & submit the JS file `keycodes-symphony.js`; we're providing you the following file to download to test locally:
- the HTML file [keycodes-symphony.html](./keycodes-symphony.html) to open in the browser, which includes:
- the JS script which will allow to run your code
- some CSS pre-styled classes: feel free to use those as they are, or modify them
- the JS script which will allow to run your code.
- 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/5DdijwBnpAk)
### Notions
- [Keyboard event](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent): [`keydown`](https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event), [`key`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key)

17
subjects/lalgebra_scalar/README.md

@ -2,19 +2,15 @@
### Instructions
Define a `Scalar` trait which must implement the operations Addition, Subtraction, Multiplication and Division (you might also have to use more restrictions). For this use a trait inheritance (supertraits)
Define a `Scalar` trait which implements the operations `Add`, `Sub`, `Mul`, `Div` and any other restrictions you may need. Use a trait inheritance (supertraits)
Another condition for a number to be a scalar is to have a zero (neutral element in the addition) and a one (neutral element in the multiplication). Therefore the `Scalar` trait will require 2 functions zero() and one() (as shown)
Another condition for a number to be a scalar is to have a `zero` (as the neutral element in the addition), and a `one` (as the neutral element in the multiplication). Therefore the `Scalar` trait will require these two functions (described below).
After finishing completing the declaration of the trait, implement the `Scalar` trait for u32, u64, i32, i64, f32 and f64.
### Notions
- [Module std::ops](https://doc.rust-lang.org/std/ops/index.html)
After finishing completing the declaration of the trait, implement the `Scalar` trait for `u32`, `u64`, `i32`, `i64`, `f32` and `f64`.
### Expected Function (The signature must be completed)
#### You need add the impl for each cases asked in the subject
> You need add the impl for each cases asked in the subject
```rust
pub trait Scalar: _ {
@ -49,3 +45,8 @@ $ cargo run
1
$
```
### Notions
- [Module std::ops](https://doc.rust-lang.org/std/ops/index.html)
[Module std::marker::Sized](https://doc.rust-lang.org/std/marker/trait.Sized.html)

14
subjects/lalgebra_vector/README.md

@ -2,17 +2,11 @@
### Instructions
A vector in linear algebra is defined as "anything that can be added and that can be multiplied by a scalar"
A vector in linear algebra is defined as "anything that can be added, and that can be multiplied by a scalar".
Define the associated function `dot` that calculates the dot product between two vectors
Define the associated function `dot`, that calculates the dot product between two vectors. If the vectors are of different lengths, return `None`.
The dot product between two vectors of different length it's not defined
Note: `Vector` must implement Debug, Clone, Eq, PartialEq.
#### Important
Note that in the addition of vector of the example the `Rhs` is not `Self`
Note: `Vector` must implement `Debug`, `Clone`, `Eq` and `PartialEq`.
### Expected Functions and Structure
@ -44,7 +38,7 @@ fn main() {
let vector_1: Vector<i64> = Vector(vec![1, 3, -5]);
let vector_2: Vector<i64> = Vector(vec![4, -2, -1]);
println!("{:?}", vector_1.dot(&vector_2));
println!("{:?}", vector_1 + &vector_2);
println!("{:?}", vector_1 + vector_2);
}
```

41
subjects/leapyear/README.md

@ -0,0 +1,41 @@
## leap-year
### Instructions
Write a function named `LeapYear(int)` that takes a year as a parameter and returns true if the year is a leap year and false otherwise.
- A leap year is a year divisible by 4, but not by 100.
- A leap year is also divisible by 400.
- If the number is not positive, return false
### Expected function
```go
func LeapYear(year int)bool{
// your code here
}
```
### Usage
Here is a possible program to test your function:
```go
package main
import "fmt"
func main(){
fmt.Println(LeapYear(2020))
fmt.Println(LeapYear(2021))
fmt.Println(LeapYear(2022))
fmt.Println(LeapYear(-10))
}
```
and the output should be:
``` console
$ go run . | cat -e
true$
false$
false$
false$
```

17
subjects/lifetimes/README.md

@ -2,18 +2,7 @@
### Instructions
Declare the struct called `Person` that has two fields:
- name of type string slice (&str)
- age of type u8
Additionaly, create the associated **function** `new` which creates a new person with age 0 and with the name given.
The expected Fucntions and Structures need to be completed.
### Notions
- [lifetimes](https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html)
Complete the `Person` struct with the fields and associated function described below. `new` should set the `age` to `0`.
### Expected Functions and Data Structures (Both need to be completed)
@ -51,3 +40,7 @@ $ cargo run
Person = Person { name: "Leo", age: 0 }
$
```
### Notions
- [lifetimes](https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html)

15
subjects/long-words/README.md

@ -2,18 +2,15 @@
### Instructions
Create three functions that take as argument an array each:
Create three functions, which each accept an array as an argument.
- `longWords` that returns true if every element of the array is a string of at
least 5 characters.
- `longWords`: returns `true` if every element of the array is a `string` with at least 5 characters.
- `oneLongWord` that returns true if at least one element of the array is a
string of at least 10 characters.
- `oneLongWord`: returns `true` if at least one element of the array is a `string` with 10 or more characters.
- `noLongWords` that returns true if there are no elements in the array that are
a string with at least 7 characters.
- `noLongWords`: returns `true` if there are no elements in the array which is a `string` with at least 7 characters.
### Notions
- [devdocs.io/javascript/global_objects/array/every](https://devdocs.io/javascript/global_objects/array/every)
- [devdocs.io/javascript/global_objects/array/some](https://devdocs.io/javascript/global_objects/array/some)
- [Array.prototype.every](https://devdocs.io/javascript/global_objects/array/every)
- [Array.prototype.some](https://devdocs.io/javascript/global_objects/array/some)

22
subjects/lunch_queue/README.md

@ -2,19 +2,17 @@
### Instructions
You will need to create an *API* which will organize a queue of people, so that a program can organize a queue of people.
You will need to create an *API*, so that a program can organize a queue of people.
The program requires the following functionsAdd the following associated functions to the `Queue` structure:
The program requires the following functions. Add them as associated functions to the `Queue` structure:
- `new`: which will initialize the `Queue`.
- `add`: which receives a person's information, to add them to the `Queue`.
- `add`: which adds a person to the queue.
- `invert_queue`: which reverses the queue.
- `rm`: which will remove the person who finished ordering their food. The removal should respect the FIFO method (first in first out. The function should return the removed person.
The removal should respect a FIFO system (first in first out). This function should return a tuple wrapped in an `Option` with the information of the removed person (check the usage)
- `search`: which returns a tuple with the information of a given person `id`
- `rm`: which removes the person who finished ordering their food. The removal should respect the FIFO method (first in first out). It should return the person's details.
- `search`: which returns the details for a given person's `name`.
You must also create a type called `Link`. This will be the connection of the structures `Queue` and `Person`.
Do not forget that this will be a recursion type and it must point to `None` if there is no persons.
You must also create a type named `Link`. This will be the connection of the structures `Queue` and `Person`. This will be a recursion type, and must point to `None` if there is no `Person` to point to.
### Expected Function and Structures
@ -26,7 +24,7 @@ pub struct Queue {
pub type Link =
pub struct Person {
pub id: i32,
pub discount: i32,
pub name: String,
}
@ -34,16 +32,16 @@ impl Queue {
pub fn new() -> Queue {
}
pub fn add(&mut self, t: String, name: String) {
pub fn add(&mut self, name: String, discount: i32) {
}
pub fn invert_queue(&mut self) {
}
pub fn rm(&mut self) -> Option<String> {
pub fn rm(&mut self) -> Option<(String, i32)> {
}
pub fn search(&mut self, ) -> Option<(String, String)> {
pub fn search(&self, name: &str) -> Option<(String, i32)> {
}
}

40
subjects/manipulate-entries/README.md

@ -2,35 +2,23 @@
### Instructions
Finish your groceries!!!
Create 3 functions which work like the `.filter`, `.map` and `.reduce` array methods, but for the **entries** in the grocery cart.
Create 3 functions that works like the `.filter`, `.map` and `.reduce` array method but for the entries of the grocery cart.
- `filterEntries`: filters using both key and value.
- `mapEntries`: changes the key, the value or both.
- `reduceEntries`: reduces the entries.
- `filterEntries` filters using both key and value.
- `mapEntries` changes either the key or the value or both.
- `reduceEntries` reduce over entries.
Create 3 additional functions that use your previously created functions:
Create 3 other functions that use your previously create functions:
- `totalCalories`: that will return the total calories of a cart.
- `lowCarbs`: that leaves only those items which are lower than 50grams.
- `cartTotal`: that will give you the right amount of calories, proteins... and **all the other** items in your grocery cart.
- `totalCalories` that will return the total calories of a cart
- `lowCarbs` that will leave only items that total carbs are lower than 50grams
- `cartTotal` that will give you the right amount of calories, proteins, ..., of all items in your grocery cart.
### Clarification
What the functions will take as argument is an object cart which contains the food rations. All the nutrition in the nutritionDB object are measured per 100 grams.
### 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)
> Think about the shape of `Object.entries()`
### Code provided
> all code provided will be added to your solution and doesn't need to be submited.
> The provided code will be added to your solution, and does not need to be submitted.
```js
// small database with nutrition facts, per 100 grams
@ -46,3 +34,11 @@ const nutritionDB = {
orange: { calories: 49, protein: 0.9, carbs: 13, sugar: 9, fiber: 0.2, fat: 0.1 },
}
```
### 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)

37
subjects/manipulate-keys/README.md

@ -2,40 +2,29 @@
### Instructions
I do not want onions. I want oranges!!!
I do not want onions. I want oranges.
Create 3 functions that works like the `.filter`, `.map` and `.reduce` array method but for the keys of your grocery cart.
- `filterKeys` filters the name of the items you have.
- `mapKeys` changes the name of the items you have.
- `reduceKeys` reducing you grocery cart.
Create 3 functions that works like the `.filter`, `.map` and `.reduce` array methods, but for the **keys** of your grocery cart. You can see their names and how they work in the examples.
### Examples
```js
const nutrients = { carbohydrates: 12, protein: 20, fat: 5 }
console.log(filterKeys(nutrients, (key) => /protein/.test(key)))
// output :
// { protein: 20 }
// output: { protein: 20 }
console.log(mapKeys(nutrients, (k) => `-${k}`))
// output :
// { -carbohydrates: 12, -protein: 20, -fat: 5 }
// output: { -carbohydrates: 12, -protein: 20, -fat: 5 }
console.log(reduceKeys(nutrients, (acc, cr) =>acc.concat(', ', cr)))
// output :
// carbohydrates, protein, fat
// output: carbohydrates, protein, fat
```
### 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)
### Code provided
> all code provided will be added to your solution and doesn't need to be submited.
> The provided code will be added to your solution, and does not need to be submitted.
```js
// small database with nutrition facts, per 100 grams
@ -51,3 +40,11 @@ const nutritionDB = {
orange: { calories: 49, protein: 0.9, carbs: 13, sugar: 12, fiber: 0.2, fat: 0.1 },
}
```
### 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)

44
subjects/manipulate-values/README.md

@ -2,48 +2,32 @@
### Instructions
Go buy groceries!!!
Let's buy groceries.
You have a grocery cart with some items you need.
The items will have a `key` being the name and a `value` that is the amount in grams.
You have a grocery cart with some items you need. The item's name is the `key`, and the `value` will represent nutrition facts per 100 grams.
Create 3 functions that works like the `.filter`, `.map` and `.reduce` array method but for the values of your grocery cart.
- `filterValues` filters the values of your grocery cart.
- `mapValues` changes the values of your grocery cart.
For the above function the callback function should accepts only the element in the arguments, this being the current element being processed.
- `reduceValues` that will reduce your grocery cart. The callback function should accepts only the **accumulated value** and the **current value**.
Create 3 functions that work like the `.filter`, `.map` and `.reduce` array methods, for the values in your grocery cart object. You can see their function names and how they work in the examples.
### Examples
```js
const nutrients = { carbohydrates: 12, protein: 20, fat: 5 }
console.log(filterValues(nutrients, (nutrient) => nutrient <= 12))
// output :
// { carbohydrates: 12, fat: 5 }
// output: { carbohydrates: 12, fat: 5 }
console.log(mapValues(nutrients, (v) => v+1))
// output :
// { carbohydrates: 13, protein: 21, fat: 6 }
// output: { carbohydrates: 13, protein: 21, fat: 6 }
console.log(reduceValues(nutrients, (acc, cr) => acc + cr))
// output :
// 37
// output: 37
```
You will have a small database to help you with the groceries.
### 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)
### Code provided
> all code provided will be added to your solution and doesn't need to be submitted.
> The provided code will be added to your solution, and does not need to be submitted.
```js
// small database with nutrition facts, per 100 grams
@ -60,3 +44,11 @@ const nutritionDB = {
orange: { calories: 49, protein: 0.9, carbs: 13, sugar: 9, fiber: 0.2, fat: 0.1 },
}
```
### 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)

18
subjects/mapper/README.md

@ -2,23 +2,21 @@
### Instructions
- Create a `map` function that takes an array as first argument, a function as second,
and that works like the method .map
- Create a `map` function that takes an array as the first argument, a function as second, and that works like the method `.map`
- Create a `flatMap` function that takes an array as first argument, a function as second,
and that works like the method .flatMap
### Notions
- [devdocs.io/javascript/global_objects/array/map](https://devdocs.io/javascript/global_objects/array/map)
- [devdocs.io/javascript/global_objects/array/flatmap](https://devdocs.io/javascript/global_objects/array/flatmap)
- Create a `flatMap` function that takes an array as the first argument, a function as second, and that works like the method `.flatMap`
### Code provided
> all code provided will be added to your solution and doesn't need to be submited.
> The provided code will be added to your solution, and does not need to be submitted.
```js
Array.prototype.map = undefined
Array.prototype.flatMap = undefined
Array.prototype.flat = undefined
```
### Notions
- [devdocs.io/javascript/global_objects/array/map](https://devdocs.io/javascript/global_objects/array/map)
- [devdocs.io/javascript/global_objects/array/flatmap](https://devdocs.io/javascript/global_objects/array/flatmap)

23
subjects/matrix/README.md

@ -2,22 +2,15 @@
### Instructions
Define a data structure to represent a matrix of any size and implement the basic operations for this. The next steps need to be followed:
Define a data structure to represent a matrix of any size and implement some basic operations.
- You can use a 2 dimensional Vec<T>'s. We will consider a matrix as a rectangular arrangements of scalars.
We will consider a matrix as a rectangular arrangements of scalars. You can represent this as a 2 dimensional vector`. You will use the definition of scalars from the [lalgebra_scalar](../lalgebra_scalar/README.md) exercise.
- You have to use the definition of scalars done in the exercise: `lalgebra_scalar`
- Define `new` that returns a matrix of size `1 x 1`
- Then define the associated function `identity` that returns the identity matrix of size n
- Finally, define the associated function `zero` that returns a matrix of size `row x col` with all the positions filled by zeros
Implement the following associated functions:
- `new`: which returns a matrix of size `1 x 1`.
- `identity`: which returns the identity matrix of size n.
- `zero`: which returns a matrix of size `row` x `col` with all the positions filled by zeros.
### Notions
- [Traits](https://doc.rust-lang.org/book/ch19-03-advanced-traits.html)
### Expected Functions and Structure
```rust
@ -59,3 +52,7 @@ Matrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]])
Matrix([[0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]])
$
```
### Notions
- [Traits](https://doc.rust-lang.org/book/ch19-03-advanced-traits.html)

6
subjects/matrix_display/README.md

@ -2,9 +2,11 @@
### Instructions
Use the Matrix struct given in the [expected struct](#expected-functions-and-struct) and implement the `std::fmt::Display` trait so it prints the matrix like in the [usage](#usage).
Complete the `Matrix` struct below.
The associated function `new` that creates a matrix from a slice of slices also has to be implemented.
You will need to create the `new` associated function which initializes the struct.
You will also need to implement the `std::fmt::Display` trait, so that it prints like the example in the usage.
### Expected Functions and Struct

15
subjects/matrix_mult/README.md

@ -4,15 +4,12 @@
Implement the methods:
- `number_of_cols` which returns the number of columns of the matrix.
- `number_of_cols`: which returns the number of columns in the matrix.
- `number_of_rows`: which returns the number of rows in the matrix.
- `row`: which returns the `n`th row in the matrix.
- `col`: which returns the `n`th column in the matrix.
- `number_of_rows` which returns the number of rows of the matrix.
- `row(n)` which returns the `n`th row in the matrix.
- `col(n)` which returns the `n`th column in the matrix.
Define the matrix multiplication by implementing the std::ops::Mul for the type matrix
Define the matrix multiplication by implementing the `std::ops::Mul` for the type matrix
### Expected Functions
@ -24,7 +21,7 @@ impl Matrix<T> {
pub fn number_of_rows(&self) -> usize {
}
pub fn rows(&self, n: usize) -> Vec<T> {
pub fn row(&self, n: usize) -> Vec<T> {
}
pub fn col(&self, n: usize) -> Vec<T> {

8
subjects/matrix_ops/README.md

@ -2,11 +2,11 @@
### Instructions
In this exercise you will define the basic operations with a matrix starting by implementing the `std::ops::Add` trait
In this exercise, you will define some basic matrix operations, Implement traits for `Add` and `Sub`
Define the operation + (by defining the trait std::ops::Add) for two matrices. Remember that two matrices can only be added if they have the same size. Therefore the add method must handle the possibility of failure by returning an Option<T>.
Remember that two matrices can only be added or subtracted if they have they have the same dimensions. Therefore, you must handle the possibility of failure by returning an `Option<T>`.
You will be using your own `Matrix` and `Scalar` defined in the `matrix` and the `lalgebra_scalar` exercises.
You will be reusing your `Matrix` and `Scalar` structures defined in the [matrix](../matrix/README.md) and [lalgebra_scalar](../lalgebra_scalar/README.md) exercises.
### Expected Function
@ -28,7 +28,7 @@ impl Sub for Matrix {
Here is a program to test your function
```rust
use matrix_ops::*;
use matrix::*;
fn main() {
let matrix = Matrix(vec![vec![8, 1], vec![9, 1]]);

35
subjects/mouse-trap/README.md

@ -2,34 +2,39 @@
### Instructions
Develop a trap to capture the elements when the mouse is getting too close to the center of the page!
Develop a trap to capture the elements when the mouse is getting too close to the center of the page.
- Create a function `createCircle`: make it fire on every click on the page, and create a `div` at the position of the mouse on the screen, setting its `background` to `white` and its class to `circle`
Create the following functions:
- `createCircle`: make it fire on every click on the page, and create a `div` at the position of the mouse on the screen, setting its `background` to `white` and its class to `circle`.
- Create a function `moveCircle`: make it fire when the mouse moves, and get the last circle created and makes it move along with the mouse
- `moveCircle`: make it fire when the mouse moves, and get the last circle created and makes it move along with the mouse.
- Create a function `setBox` which sets a box with the class `box` in the center of the page ; when a circle is inside that box, it has to be purple (use the CSS global variable `var(--purple)` as `background`) ; once a circle enters the box, it is trapped inside and cannot go out of it anymore.
- `setBox`: which creates a box with the class `box` in the center of the page. When a circle is inside that box, it has to be purple (use the CSS global variable `var(--purple)` as its `background`). Once a circle enters the box, it is trapped inside and cannot escape.
> Hint: Be careful, a circle cannot overlap the box which has walls of `1px`, it has to be trapped **strictly** inside.
### Notions
- [`addEventListener()`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener): `click`, `mousemove`
- [`removeEventListener()`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener)
- [Mouse event](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent): [`click`](https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event), [`mousemove`](https://developer.mozilla.org/en-US/docs/Web/API/Element/mousemove_event) / [`clientX`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/clientX), [`clientY`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/clientY)
- [`getBoundingClientRect()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect)
> Hint: Be careful, a circle cannot overlap the box which has walls of `1px`. It has to be trapped **strictly** inside.
### Provided files
### Files
You only need to create & submit the JS file `mouse-trap.js` ; we're providing you the following file to download (click right and save link) & test locally:
You only need to create & submit the JS file `mouse-trap.js`; we're providing you the following file to download and test locally:
- the HTML file [mouse-trap.html](./mouse-trap.html) to open in the browser, which includes:
- the JS script which will allow to run your code
- some CSS pre-styled classes: feel free to use those as they are, or modify them
- the JS script which will enable you to run your code.
- 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/qF843P-V2Yw)
### Notions
- [addEventListener](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener)
- [removeEventListener](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener)
- [Mouse event](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent)
- [click](https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event)
- [mousemove](https://developer.mozilla.org/en-US/docs/Web/API/Element/mousemove_event)
- [clientX](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/clientX)
- [clientY](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/clientY)
- [getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect)

3
subjects/neuron/README.md

@ -2,8 +2,7 @@
### Instructions
Create a function called `neuron` that allows your AI/bot to learn how to data shape a given
dataset into an object so that it can better navigate the data.
Create a function named `neuron`, that enables your AI/bot to learn to mutate data into a more usable shape. You can see how it works from the example.
### Example

20
subjects/paramrange/README.md

@ -0,0 +1,20 @@
## param-range
### instructions
Write a program that takes a number in the arguments and prints the max and min.
- If the number of arguments is less than 2 print (`'\n'`)
- If one of the arguments is not a number, print (`"Error\n"`)
- The output should be space-separated and (`'\n'`) at the end.
### Usage
```console
$ go run . | cat -e
$
$ go run . 1 2 3 4 5 6 7 8 9 | cat -e
1 9$
$ go run . "-1" "1" | cat -e
-1 1$
$ go run . 1 a 2 3 4 5 6 7 8 9 | cat -e
Error$
```

54
subjects/pick-and-click/README.md

@ -2,43 +2,47 @@
### Instructions
Today, you're gonna create your own color picker.
Today, you're going to create your own color picker.
Write the function `pick` which turns the screen into a `hsl` color picker, varying the `hue` and `luminosity` of according to the position of the mouse, which:
Write the function `pick` which turns the screen into a `hsl` color picker. It will vary the `hue` and `luminosity` according to the position of the mouse.
- changes the `background` color of the `body`, so the `hsl` value is different on each mouse position on the screen:
- on the axis X, the hue value has to vary between 0 and 360
- on the axis Y, the luminosity value has to vary between 0 and 100
- displays those 3 values using the `text` class:
- the full `hsl` value in a `div` with the class `hsl` in the middle of the screen
- the `hue` value in a `div` with the class `hue` in the top right corner of the screen
- the `luminosity` value in a `div` with the class `luminosity` in the bottom left corner of the screen
- copies that value in the clipboard on click
- displays two SVG lines, with respective ids `axisX` and `axisY`, following the cursor like so:
- the axisX has to set the attributes `x1` and `x2` to the mouse X position
- the axisY has to set the attributes `y1` and `y2` to the mouse Y position
The `background` color of the `body` will change based on the position of the mouse on the screen.
- The X axis will vary the hue value between 0 and 360.
- The Y axis will vary the luminosity value between 0 and 100.
> Here is how a hsl value is formatted: `hsl(45, 50%, 35%)`
You'll need to display these three values:
- The full `hsl` value in a `div`, which has the class `hsl` in the middle of the screen.
- The `hue` value in a `div` with the class `hue` in the top right corner of the screen.
- The `luminosity` value will be displayed in the bottom left corner of the screen, in a `div` with the class `luminosity`.
> Use `Math.round()` to round the values
When the mouse is clicked, the value of the `hsl` will need to copied to the clipboard.
### Notions
Two SVG lines with ids `axisX` and `axisY` will need to follow the cursor, like really long cross hairs.
- the `axisX` attributes `x1` and `x2` need to be set to the X position of the cursor.
- the `axisY` attributes `y1` and `y2` need to be set to the Y position of the cursor.
- [Copy event](https://developer.mozilla.org/en-US/docs/Web/API/Element/copy_event)
- [Mouse move event](https://developer.mozilla.org/en-US/docs/Web/API/Element/mousemove_event)
- [SVG](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/svg): [`createElementNS`](https://developer.mozilla.org/en-US/docs/Web/API/Document/createElementNS), [`setAttribute`](https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute)
- Take a look at the [HSL section](https://developer.mozilla.org/en-US/docs/Web/HTML/Applying_color)
> The formatting of a `hsl` value: `hsl(45, 50%, 35%)`.
> Use `Math.round()` to round the values.
### Files
You only need to create & submit the JS file `pick-and-click.js` ; we're providing you the following file to download (click right and save link) & test locally:
You only need to create & submit the JS file `pick-and-click.js`; we're providing you the following file to download and test locally:
- the HTML file [pick-and-click.html](./pick-and-click.html) to open in the browser, which includes:
- the JS script which will allow to run your code
- some CSS pre-styled classes: feel free to use those as they are, or modify them
- the JS script which will enable you to run your code.
- 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:
[![video](https://img.youtube.com/vi/eE4eE9_eKZI/0.jpg)](https://www.youtube.com/watch?v=eE4eE9_eKZI)
You can see an example of the expected result [here](https://www.youtube.com/watch?v=eE4eE9_eKZI)
### Notions
- [Copy event](https://developer.mozilla.org/en-US/docs/Web/API/Element/copy_event)
- [Mouse move event](https://developer.mozilla.org/en-US/docs/Web/API/Element/mousemove_event)
- [SVG](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/svg)
- [createElementNS](https://developer.mozilla.org/en-US/docs/Web/API/Document/createElementNS)
- [setAttribute](https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute)
- Take a look at the [HSL section](https://developer.mozilla.org/en-US/docs/Web/HTML/Applying_color)

10
subjects/pick-omit/README.md

@ -2,14 +2,12 @@
### Instructions
Create a `pick` function that takes an object and a string or array of strings.
This function returns a new object that contains only the key/value pairs, whose key matches with the string or a string in the array, from the object passed as an argument.
Create a `omit` function that takes an object and a string or array of strings.
This function returns a new object that contains only the key/value pairs, whose key doesn't match with the string or a single string in the array, from the object passed as an argument.
Create two functions which taken an object and a string or array of strings. They should return a new object which:
- `pick`: contains only those keys which appear in the string or array of strings.
- `omit`: contains only those keys which do not match the string, or do not appear in the array of strings.
> Those functions are pure and must not modify the given object
### Notions
- [devdocs.io/javascript/global_objects/object](https://devdocs.io/javascript/global_objects/object)
- [object](https://devdocs.io/javascript/global_objects/object)

31
subjects/pimp-my-style/README.md

@ -8,18 +8,22 @@ Check out that button on the HTML page:
<button class="button">pimp my style</div>
```
For now, it's only a lonely, basic and sad element ; let's pimp it up!
For now, it's only a lonely, basic and sad element. let's pimp it up.
On each click on the page, a function `pimp` is triggered.
Write the body of that function so that the button's class is altered:
- Add in order the next class of the `styles` array provided in the data file below
- When the end of the array is reached, remove backwards each class
- Toggle the class 'unpimp' when removing classes
- From the data file provided, add each of the `styles` array elements as classes, in order.
- When the end of the array is reached, remove the classes in a FIFO fashion.
- While removing classes, toggle the `unpimp` class on. And toggle it off again while adding classes.
```
Example for a `styles` array with only 3 classes:
```js
["one", "two", "three"]
```
```
Page load --> <button class="button"></div>
...adding
@ -35,21 +39,20 @@ Click 5 --> <button class="button one unpimp"></div>
Click 6 --> <button class="button"></div>
```
### Notions
- [`classList`](https://developer.mozilla.org/en-US/docs/Web/API/Element/classList): `add()`, `remove()`, `toggle()`
### Files
You only need to create & submit the JS file `pimp-my-style.js` ; we're providing you the following files to download (click right and save link) & test locally:
You only need to create & submit the JS file `pimp-my-style.js`. Ee're providing you the following files to download and test locally.:
- the HTML file [pimp-my-style.html](./pimp-my-style.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
- the data file [pimp-my-style.data.js](./pimp-my-style.data.js) from which you can import `styles`
- 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 data file [pimp-my-style.data.js](./pimp-my-style.data.js) from which you can import `styles`.
### Expected result
You can see an example of the expected result [here](https://youtu.be/VIRf3TBDTN4)
### Notions
- [classList](https://developer.mozilla.org/en-US/docs/Web/API/Element/classList): `add()`, `remove()`, `toggle()`

23
subjects/printascii/README.md

@ -0,0 +1,23 @@
## print-ascii
### Instructions
Write a program that prints the ASCII value of a letter passed in the command line
- If the argument is not a letter nothing will be printed
- if the number of arguments is not 1 then nothing will be printed
### Usage
```console
$ go run .
$ go run . a
97
$ go run . 'A'
65
$ go run . 'z'
122
$ go run . Z
90
$ go run . 1
$ go run . "Hello" "Word"
```

17
subjects/pronoun/README.md

@ -2,10 +2,19 @@
### Instructions
Create a function called `pronoun` that has a string as parameter. This function returns an object
that will have all the personal pronouns, present in the string, as keys. Each key will have a sub object with the
first word after each of the personal pronouns found in the string.
Also, a property `count` must be added, to the sub object, with the amount of occurrences of the pronoun.
Create a function named `pronoun` that accepts a string parameter.
This function returns an object that will have all the personal pronouns, present in the string, as keys. Each key will have a sub object with the first word after each of the personal pronouns found in the string.
You must also a `count` property to the sub object, with the amount of occurrences of the pronoun.
Pronouns:
- i
- you
- he
- she
- it
- they
- we
#### Example

24
subjects/quantifiers/README.md

@ -2,26 +2,22 @@
### Instructions
Create three functions that receive an array and a function each:
- `every` that returns true if every element of the array respects the
condition of the received function and false otherwise.
- `some` that returns true if at least one element of the array respects the
condition of the received function and false otherwise.
- `none` that returns true if none of the elements of the array respects the
condition of the received function and false otherwise.
Create these functions which receive an array and a function each. Each element will return `true` if
- `every`: every element in the array respects the condition of the function.
- `some`: that returns `true` if at least one element in the array respects the condition of the function.
- `none`: that returns `true` if **none** of the elements in the array respects the condition of the function.
The use of `[].every` and `[].some` is forbidden for this exercise.
### Notions
- [devdocs.io/javascript/global_objects/array/some](https://devdocs.io/javascript/global_objects/array/some)
- [devdocs.io/javascript/global_objects/array/every](https://devdocs.io/javascript/global_objects/array/every)
### Code provided
> all code provided will be added to your solution and doesn't need to be submited.
> The provided code will be added to your solution, and does not need to be submitted.
```js
Array.prototype.some = Array.prototype.every = undefined
```
### Notions
- [devdocs.io/javascript/global_objects/array/some](https://devdocs.io/javascript/global_objects/array/some)
- [devdocs.io/javascript/global_objects/array/every](https://devdocs.io/javascript/global_objects/array/every)

20
subjects/race/README.md

@ -2,22 +2,20 @@
### Instructions
Create a function `race` that works like `Promise.race`
Create two functions:
- `race`: that works like `Promise.race`.
- `some`: that takes an `array` of promises or values, and `count` number. It should return the first `count` resolved values. Empty arrays or a `count` of 0 return a promise resolving to `undefined`.
Create a function `some` that takes an `array` of promises or values
and `N` number. It should return the first `N` resolved values.
> Empty array or a count of 0 return a promise resolving to `undefined`
### Notions
- [nan-academy.github.io/js-training/examples/promise](https://nan-academy.github.io/js-training/examples/promise.js)
- [devdocs.io/javascript/global_objects/promise/race](https://devdocs.io/javascript/global_objects/promise/race)
### Code provided
> all code provided will be added to your solution and doesn't need to be submited.
> The provided code will be added to your solution, and does not need to be submitted.
```js
Promise.race = undefined
```
### Notions
- [Promise](https://nan-academy.github.io/js-training/examples/promise.js)
- [Promise.race](https://devdocs.io/javascript/global_objects/promise/race)

62
subjects/ref_cell/README.md

@ -4,48 +4,49 @@
#### First part (messenger.rs)
Create a module called `messenger`. This module will be able to inform a user of how many references of a given value he is using.
Create a module named `messenger`. This module will be able to inform a user of how many references of a given value they are using.
The main objective of this module is to limit how many times a value is referenced.
For this module the following must be created:
- A trait `Logger` which implements three functions: `warning`, `info`, `error`. All **functions** should receive a reference to themselves and a string literal.
Implement `Logger`: a trait which implements the following three functions:
```rust
fn warning(&self, msg: &str);
fn info(&self, msg: &str);
fn error(&self, msg: &str);
fn warning(&self, msg: &str);
fn info(&self, msg: &str);
fn error(&self, msg: &str);
```
- A structure called `Tracker`, which must have the fields: `logger` being a reference to the `Logger`, `value` being the count of how many times the value was referenced,
`max` being the max count of references the actual value can achieve.
Implement the `Tracker` structure with the following fields:
- An implementation of three functions that are associated to the `Tracker` structure:
- `new` that will initialize the structure
- `set_value` that sets the value to the `Tracker` structure and writes to the trait functions. This should be done comparing the **max** and the number of referenced of the actual value.
If the percentage is equal or greater to 100% of the limit usage, it should write **"Error: you are over your quota!"** to the `error` function
If the percentage is equal or greater to 70% of the limit usage, it should write **("Warning: you have used up over {}% of your quota! Proceeds with precaution", <calculated_percentage>)** to the `warning` function
- `peek` that will take a peek of how much usage the variable already has. It should write **("Info: you are using up too {}% of your quote", <calculated_percentage>)** to the `info` function
- `logger`: a reference to `Logger`.
- `value`: the count of how many times the value was referenced. It should not exceed `max`.
- `max`: the max count of references.
Add the following associated functions to `Tracker`:
- `new`: that initializes the structure.
- `set_value`: that sets the `value`. It should compare the number of references to `value` and `max` to work out the percentage used. It should write to the following traits if it exceeds the specified usage percentage:
- percentage >= 100%: `"Error: you are over your quota!"` should be written to `error`.
- percentage >= 70% and percentage < 100%: `"Warning: you have used up over X% of your quota! Proceeds with precaution"` should be written to `warning`, where `X` should be replaced with the calculated percentage.
- `peek`: that will take a peek at how much usage the variable already has. It should write `"Info: you are using up to X% of your quota"` to the `info` trait function. `X` should be replaced with the calculated percentage.
### Second part (lib.rs)
Afterwards you must use the module `messenger` and create the following:
Now that you've created `messenger`, you can now create the following:
- A structure `Worker` that has the fields:
- `track_value` this will be the value that will be tracked by the tracker.
- `mapped_messages` that will have the latest messages. This must be a HashMap with the key being the type of message
sent by the logger (info, error or warning) and the value being the message
- `all_messages` that will be a vector of all messages sent.
- A `new` function that initializes the structure `Worker`
- To use the trait `Logger` you must implement it for the Worker structure. Each function (warning, error and info) must insert the message to the
respective fields of the structure Worker.
Create the `Worker` structure with the following fields:
You must use **interior mutability**, this means it must be able to mutate data even when there are immutable references to that data. Consequently, the user will not need to use the keyword `mut` (tip: RefCell)
- `track_value`: which is the value that will be tracked by the tracker.
- `mapped_messages`: that will store the latest messages from the `Logger` trait functions. This will be a HashMap. The key will represent the type of message (`info`, `error` or `warning`), and the value will be the actual message.
- `all_messages`: that will be a vector of **all** messages sent.
### Notions
Create the following associated functions for `Worker`:
- [std::cell::RefCell](https://doc.rust-lang.org/std/cell/struct.RefCell.html)
- [Struct std::rc::Rc](https://doc.rust-lang.org/std/rc/struct.Rc.html)
- `new`: that initializes a `Worker` structure.
- `Logger`: to use the trait `Logger`, you must implement it for the `Worker` structure. Each function (`warning`, `error` and `info`) must insert the message to the respective field of the `Worker` structure.
You must use **interior mutability**, this means it must be possible to mutate data, even when there are immutable references to that data. Consequently, the user will not need to use the keyword `mut`. _tip:_ RefCell.
### Usage
@ -99,14 +100,19 @@ And its output:
```console
$ cargo run
("Info", "you are using up too 40% of your quote")
("Info", "you are using up to 40% of your quota")
("Warning", "you have used up over 90% of your quota! Proceeds with precaution")
("Error", "you are over your quota!")
[
"Info: you are using up too 40% of your quote",
"Info: you are using up to 40% of your quota",
"Warning: you have used up over 80% of your quota! Proceeds with precaution",
"Warning: you have used up over 90% of your quota! Proceeds with precaution",
"Error: you are over your quota!"
]
$
```
### Notions
- [std::cell::RefCell](https://doc.rust-lang.org/std/cell/struct.RefCell.html)
- [Struct std::rc::Rc](https://doc.rust-lang.org/std/rc/struct.Rc.html)

7
subjects/replica/README.md

@ -2,11 +2,10 @@
### Instructions
Create a function called `replica` that allows you to deep assign the values of all properties from one or more
objects to a target object.
Create a function named `replica` that allows you to deep assign the values of all properties from one or more objects to a target object.
Attention with the shallow copies.
> Watch out for shallow copies.
### Notions
- [nan-academy.github.io/js-training/examples/data-structures](https://nan-academy.github.io/js-training/examples/data-structures.js)
- [data-structures](https://nan-academy.github.io/js-training/examples/data-structures.js)

121
subjects/road_intersection/README.md

@ -2,62 +2,61 @@
### Objectives
The objective for this raid is to create a traffic control strategy and represent it with an interface/UI.
It's up to you to decide which library and file system you want to use in order to create this simulation, but we recommend you to use the library [sdl2](https://docs.rs/sdl2/0.34.3/sdl2/)
Traffic, traffic, traffic...
You will need to solve the traffic problem in your capital city. Your objective will be to create a traffic control strategy, and visualize it with a simulation.
It is up to you to decide which library and file system you want to use in order to create this simulation, but we recommend that you use the [sdl2](https://docs.rs/sdl2/0.34.3/sdl2/) library.
### Instructions
#### **Environment and Rules**
You must create an environment which contains all the objects described in this section. You can display the objects as you wish.
You must create an environment which contains all the objects described in this section. You can display the objects in any way you wish.
**1 Roads**
1. Roads
You will create two roads which cross each other to create an intersection. Each road will have **one lane** in each direction.
There are various forms of intersections, let's focus on the widely seen four-lane crossroad. For simplicity, each road will have two lanes with two different directions for the total of two roads and four lanes.
Traffic entering the intersection will be able to select a route by:
- turning left
- turning right
- continuing on straight
```console
lane1 lane2
| ↓ | ↑ |
| ↓ | ↑ |
| ↓ | ↑ |
| ↓ | ↑ |
| ↓ | ↑ |
| r s l | ↑ |
_______________| ← ↓ → | ↑ |_____________
| ↑ r
← ← ← ← ← ← ← | ← s ← ← ← ← ← lane3
| ↓ l
_________________________|_______________________
l ↑ |
→ → → → → s → | → → → → → → lane4
r ↓ |
_______________ | _____________
| | ← ↑ → |
| ↓ | l s r |
| ↓ | ↑ |
| ↓ | ↑ |
| ↓ | ↑ |
| ↓ | ↑ |
| ↓ | ↑ |
North
| ↓ | ↑ |
| ↓ | ↑ |
| | |
| | |
| | |
| | |
_______________| | |_______________
← ← ← ←
East --------------- --------------- West
→ → → →
_______________ _______________
| | |
| | |
| | |
| | |
| | |
| ↓ | ↑ |
| ↓ | ↑ |
South
```
For clarification reasons we will assume that a lane can have three different routes (consider that you are in the vehicle position):
**2 Traffic lights**
- `r`, turning right
- `s`, straight ahead
- `l`, turning left
Traffic lights are signaling devices positioned at road intersections that follow a universal color code. We all know the normal colors for traffic lights, but for this exercise, your traffic lights will only have **red** and **green**.
2. Traffic lights
You will position those traffic lights at the point where each lane enters the intersection.
Traffic lights are signalize devices positioned at road intersections that follows an universal color code,
it's usually green, red and amber, but for this project you will just use the colors **red** and **green**.
You can implement any algorithm you choose to control the traffic lights system, but bare in mind that traffic congestion should not be too high (8 or more vehicles).
You will then have to create some kind of representation for the traffic lights and distribute them for each lane in the intersection.
The primary function of **your** traffic light system, is to avoid collisions between vehicles passing through the intersection.
You are free to decide what algorithm you want to implement to represent traffic light system, but keep in mind that traffic congestion should not be too high (8 or more vehicles).
3. Vehicles
**3. Vehicles**
```
______
@ -65,56 +64,46 @@ You are free to decide what algorithm you want to implement to represent traffic
=`-(_)--(_)-'
```
Vehicles must obey this rules:
The vehicles traveling through your capital city's new junction must follow these rules:
- Vehicles must have a color so that it's possible to identify which route it will follow (ex:`r`- purple, `s`- Blue and `l`- Yellow). This information about the colors must be given to the auditor of the raid. The colors are up to you to decide.
- Vehicles must be painted in a color which illustrates the route they will follow. The colors are up to you to decide, and your choices will need to be made available during the audit of the raid. For example, all cars which make a right turn could be painted yellow. It's really up to you though.
- Autonomous vehicles driving on a lane with a **given route** must follow the direction of that route, it is not possible for the autonomous vehicle to change lanes or routes.
- It is not possible for the vehicle to change its selected route.
- Each vehicle must have a fixed velocity.
- A safety distance from other vehicles must be kept, if one vehicle stop the other vehicle that's
behind him must stop and keep it's distance.
- A safety distance from other vehicles must be maintained. If one vehicle stops, the following vehicle must also stop before it gets to close to the stationary vehicle in front.
- Vehicles must stop if the traffic light is red and proceed otherwise.
- Vehicles must have different routes, either `r`, `s` or `l`.
- Other vehicles such as emergency vehicles are not considered.
- There are no other vehicle types with special privileges. You can consider that there are no emergency vehicles in your capital city.
---
#### **Commands**
The generating of vehicles must be done using the keyboard event. You must be able to generate
vehicles in different lanes and with different routes.
For this it must be possible to do the following:
- The `Arrow` keys must generate one vehicle in a specific direction and with a random route ( `r`, `s` and `l`):
- `Up` south to north.
- `Down` north to south.
- `Right` west to east.
- `Left` east to west.
- The `R` key must generate random vehicles with random lanes and routes.
You will use your keyboard to spawn vehicles for your simulation. You will use the arrow keys to spawn a vehicle on the appropriate side of the road, and with a random route.
- The `Esc` key must finish the simulation.
- **`↑` Up:** moves towards the intersection **from the south.**
- **`↓` Down:** moves towards the intersection **from the north.**
- **`→` Right:** moves towards the intersection **from the west.**
- **`←` Left:** moves towards the intersection **from the east.**
- **`r`:** moves towards the intersection **from a random direction.**
- **`Esc` Escape:** ends the simulation.
> Arrow keys must not let the user spam the creation of vehicles, they must be created with a safe distance between them.
> It must not be possible to use the keyboard to spam the creation of vehicles; they must be created with a safe distance between them.
> A safe distance is any distance that allows the vehicles not to crash into each other.
> A safe distance is any distance which enables the vehicles to avoid crashing into each other.
### Example
You can see an example for the road_intersection [here](https://www.youtube.com/watch?v=6B0-ZBET6mo).
You can see an example for road_intersection [here](https://www.youtube.com/watch?v=6B0-ZBET6mo).
### Bonus
You can implement the following optional features:
- Vehicle and traffic lights animation and image rendering. You can find some cool assets:
- Vehicle and traffic light animations, and image rendering. You can find some cool assets here:
- [limezu](https://limezu.itch.io/)
- [finalbossblue](http://finalbossblues.com/timefantasy/free-graphics/).

58
subjects/road_intersection/audit/README.md

@ -2,89 +2,93 @@
##### Try to run the application.
###### Is the application running?
###### Does the application start?
##### Try to generate a vehicle by pressing the `"Arrow Up"` key.
###### Was a vehicle generated from the cardinal south?
###### Was a vehicle generated from the south, with a random route?
##### Try to generate a vehicle by pressing the `"Arrow Down"` key.
###### Was a vehicle generated from the cardinal North?
###### Was a vehicle generated from the north, with a random route?
##### Try to generate a vehicle by pressing the `"Arrow Right"` key.
###### Was a vehicle generated from the cardinal west?
###### Was a vehicle generated from the west, with a random route?
##### Try to generate a vehicle by pressing the `"Arrow left"` key.
###### Was a vehicle generated from the cardinal east?
###### Was a vehicle generated from the east, with a random route?
##### Try pressing the `"R"` key.
##### Try pressing the `"r"` key.
###### Was the vehicle generated randomly (random lane and route)?
###### Was the vehicle generated from a random direction, with a random route?
##### Try pressing the `"R"` key more than 5 times to generate multiple vehicles in different lines.
##### Try pressing the `"r"` key more than 5 times to generate multiple vehicles, from multiple directions.
###### Can you confirm that the vehicles were created and maintain a safe distance from one another?
##### Try to generate three vehicles in the same lane (do this on all lanes one at a time).
##### Try to generate three vehicles from the same direction. Do this for each of the four directions.
###### Can you confirm that the vehicles were created with a safe distance one from another?
###### Can you confirm that the vehicles were created and maintain a safe distance from one another?
##### Try to generate two vehicles at the same time, one using the `"Up"` key and the other using the `"Down"` key (do this at least 3 times).
###### Did all the vehicles passed the intersection without any collision?
###### Did all the vehicles pass through the intersection without any collisions?
##### Try to generate two vehicles at the same time, one using the `"Right"` key and the other using the `"Left"` key (do this at least 3 times).
###### Did all the vehicles passed the intersection without any collision?
###### Did all the vehicles pass through the intersection without any collisions?
##### Try to generate two vehicles at the same time, one using the `"Up"` key and the other using the `"Left"` key (do this at least 3 times).
###### Did all the vehicles passed the intersection without any collision?
###### Did all the vehicles pass through the intersection without any collisions?
##### Try to generate two vehicles at the same time, one using the `"Up"` key and the other using the `"Right"` key (do this at least 3 times).
###### Did all the vehicles passed the intersection without any collision?
###### Did all the vehicles pass through the intersection without any collisions?
##### Try to generate two vehicles at the same time, one using the `"Down"` key and the other using the `"Left"` key (do this at least 3 times).
###### Did all the vehicles passed the intersection without any collision?
###### Did all the vehicles pass through the intersection without any collisions?
##### Try to generate two vehicles at the same time, one using the `"Down"` key and the other using the `"Right"` key (do this at least 3 times).
###### Did all the vehicles passed the intersection without any collision?
###### Did all the vehicles pass through the intersection without any collisions?
##### Try to generate five vehicles using the `"Up"` key, at the same time generate two vehicles using the `"Right"` key.
###### Did all the vehicles passed the intersection without any collision?
###### Did all the vehicles pass through the intersection without any collisions?
##### Try to generate one vehicle for all the lanes (do this at least 3 times).
###### Did all the vehicles passed the intersection without any collision?
###### Did all the vehicles pass through the intersection without any collisions?
##### Try to generate vehicles randomly using the `"R"` key. Then wait for at least 1 min.
##### Try to generate many vehicles randomly using the `"r"` key. Then wait for at least 1 min.
###### Did all the vehicles passed the intersection without any collision?
###### Did all the vehicles pass through the intersection without any collisions?
##### Try to generate multiple vehicles in lanes of your choice.
##### Try to generate many vehicles in lanes of your choice.
###### Did all the vehicles passed the intersection without any collision?
###### Did all the vehicles pass through the intersection without any collisions?
##### Try pressing the `"Esc"` key.
###### Was the simulation finished?
###### Was the simulation ended?
###### Was there a low traffic congestion while running the application? (ex: high traffic congestion can be 8 or more vehicles in the same lane without proceeding)?
###### High traffic congestion is when there are 8 or more vehicles in the same lane without proceeding. Was there low traffic congestion while running the simulation?
#### General
###### Can you confirm that it is impossible to spam the creation of vehicles (by pressing the arrow keys to many times or leave it pressed)?
###### Can you confirm that it is impossible to spam the creation of vehicles by pressing the arrow keys too many times or leave one pressed?
##### Ask the captain of the raid to show you information about how the color of cars relates to its random route.
###### Was the information about colors and routes available?
###### Are vehicles assigned to their own route, and if so, do they obey that route? (you can use the colors for each route to see this, ask the owner of the raid for instructions)
###### Are vehicles assigned to their own route with an appropriate color? If so, do they obey that route?
###### Do the vehicles kept a safe distance (do not collide whenever one stops)?
###### Do the vehicles keep a safe distance by avoiding a collision when the car in front stops?
###### Do vehicles stop whenever there is a red light?

6
subjects/roman_numbers/README.md

@ -2,11 +2,11 @@
### Instructions
Implement the `From<u32> Trait` to create a roman number from a `u32`. The roman number should be in subtractive notation (the common way to write roman number I, II, III, IV, V, VI, VII, VIII, IX, X ...)
Implement the `From<u32>` trait to create a roman number from a number. The roman number should be in subtractive notation (the common way to write roman number I, II, III, IV, V, VI, VII, VIII, IX, X ...).
For this start by defining the digits as `RomanDigit` with the values I, V, X, L, C, D, M and Nulla for 0
Start by defining the digits as `RomanDigit` (`Nulla` is 0).
Next define `RomanNumber` as a wrapper to a vector of RomanDigit's And implement the Trait `From<u32>`.
Next define `RomanNumber` as a wrapper to a vector of `RomanDigit`, and implement the Trait `From<u32>`.
### Expected Functions and Data Structures

2
subjects/roman_numbers_iter/README.md

@ -21,7 +21,7 @@ impl Iterator for RomanNumber {}
Here is a program to test your function.
```rust
use roman_numbers::RomanNumber;
use roman_numbers_iterator::RomanNumber;
fn main() {
let mut number = RomanNumber::from(15);

27
subjects/rotargn/README.md

@ -0,0 +1,27 @@
## rot-arg-n
### Instructions
Write a program that takes arguments from the command line and rotates them by the number in the first argument.
- If the number of arguments is less than 3 print (`'\n'`)
- If the first argument is not a number, the program should print `"Error\n"`
- If the first argument is negative, the program should print `"Error\n"`
- If the first argument is zero, the program should print the original arguments
- Prints the rotated arguments with a space between each argument and a newline at the end.
### Usage
```console
$ go run . | cat -e
$
$ go run . 1 2 3 4 5 | cat -e
3 4 5 2$
$ go run . 2 "Hello" "World" | cat -e
Hello World$
$ go run . -1 2 3 4 5 | cat -e
Error$
$ go run . 0 2 3 4 5 | cat -e
2 3 4 5$
$ go run . 3 "Hello" "World" | cat -e
World Hello$
```

18
subjects/rt/README.md

@ -1,6 +1,6 @@
## rt
There are two ways to render a 3d scene into a 2d image: `rasterization` which basically converts the shapes and geometric figures to pixels and applies calculations to obtain the color, the shadows, the refraction, etc... of those pixels. The other method is called `ray tracing` and consist in drawing each pixel with its color, shadows, refraction, reflection, etc.... already present from the start.
There are two ways to render a 3d scene into a 2d image: `rasterization`, which converts the shapes and geometric figures to pixels and applies calculations to obtain the color, the shadows, the refraction, etc... of those pixels. The other method is called `ray tracing` and consists in drawing each pixel with its color, shadows, refraction, reflection, etc.... already present from the start.
Imagine a camera pointing at a scene, and from that camera, a bunch of rays are coming, which bounce from object to object until they reach the light source (lamp, sun, etc...). This is basically how a ray tracer works.
@ -16,10 +16,10 @@ Below is an example of an image which your ray tracer should be able to produce:
In this project, you have to implement the ray tracer method in order to be able to render a computer generated image containing a few objects.
When building your ray tracer you have to take some points into consideration:
When building your ray tracer, you have to take some points into consideration:
- you need to be able to create at least 4 simple objects: a sphere, a cube, a flat plane and a cylinder.
- your program must be able to change an object location before creating the image. (Example: render a sphere with its center on the point (1,1,1)).
- your program must be able to change an object's location before creating the image. (Example: render a sphere with its center on the point (1,1,1)).
- you have to be able to look at the same scene from different angles by moving the camera/point of view.
- you also have to implement simple light management, which includes: different brightness and shadows.
@ -30,13 +30,13 @@ As your ray tracer will probably be a bit slow to render high resolution scenes,
- a scene with one of each of all the objects (one cube, one sphere, one cylinder and one flat plane);
- a scene like the previous one, but with the camera in another position (thus generating the same image from a different perspective).
All of the images should be in the format of 800x600. However, while testing you should use smaller resolution images in order to reduce your rendering time (a 1200x1000 can take up to 40 mins to create).
All of the images should be in the format of 800x600. However, while testing, you should use smaller resolution images in order to reduce your rendering time (a 1200x1000 can take up to 40 mins to create). It would be best to consider the possibility of changing the output image's resolution easily.
Another aspect you should consider is that the auditor will have to use your ray tracer, so make it as usable and optimized as possible. You should provide the auditor clear documentation.
#### Documentation
By documentation we mean, the explaining of how does the ray tracer work and how to work with it, for example: how to create an object, how to change brightness in a scene, etc... A new user of your ray tracer, after reading the documentation has to be able to use it without much guessing work.
By documentation we mean the explaining of how the ray tracer work and how to work with it, for example: how to create an object, how to change brightness in a scene, etc... After reading the documentation, a new user of your ray tracer has to be able to use it without much guessing work.
You will have to create a [markdown](https://www.markdownguide.org/getting-started/) file, which will have to contain:
@ -74,15 +74,15 @@ P3 \
The image header consists of three lines:
- the first one is the image format: what type of PPM (full color, ASCII enconding) image it is. P3 stands for the Portable PixMap type so you will be using this one.
- the next stands for how many columns and rows of pixels the image will contain.
- the first one is the image format: what type of PPM (full color, ASCII encoding) image it is. P3 stands for the Portable PixMap type, so you will be using this one.
- the following stands for how many columns and rows of pixels the image will contain.
- and the third line is the maximum color value, 255 is the most common value since the rgb color code is very well known.
All the other lines below, are the rgb values for each pixel, for example the first line of the image body represents a black pixel (rgb(0,0,0) -> black). Each line represents one pixel, starting on the top left corner transitioning to the right and, in this case, the fifth line is the pixel in the first row on the second column.
So with this in mind, you will have to make an algorithm that fills a file by printing each line. You can use the cargo command this way: `cargo run > output.ppm`. This will print the standard output to the file `output.ppm`.
In order to create the previous mentioned objects you will need to search online for documentation about the geometrics of each.
In order to create the previously mentioned objects, you will need to search online for documentation about the geometrics of each.
### Bonus
@ -93,6 +93,8 @@ As bonus for this project you can implement:
- Add particles
- Add fluids
Consider putting your bonuses behind command-line flags to achieve a reasonable performance standard defined above. For example, to render textures on your image, you can use a flag -t. Otherwise, textures will be ignored.
This project will help you learn about:
- [Ray Tracing](<https://en.wikipedia.org/wiki/Ray_tracing_(graphics)>)

2
subjects/rt/audit/README.md

@ -4,6 +4,8 @@
###### Does the image correspond to the scene you created?
###### Is it possible for you to reduce the resolution of the output image?
##### Move the camera and render the same scene.
###### Does the image correspond to the same scene, but from a different perspective?

48
subjects/sales/README.md

@ -2,25 +2,17 @@
### Instructions
In this exercise a shopping system will have to be created. There will be :
Your going to make a shopping system. It will have a store where the products will be saved, and a cart which will contain items from which a receipt will be generated.
- A store that will save all the products in it
- A cart that will have `items` that the client will buy, and a `receipt`
**"Buy three, get one free".**
This store is having a promotion, "Buy three and get one for free" (the free item must be the cheapest). The receipt must not present
any value as 0, so the promotion must be a reduction to be applied to all items instead.(see the example)
The store is having a promotion. The cheapest of three items will be free. But there is a problem with the printer interface, it cannot receive any zero values. We can create a workaround. We will reduce all of the values in the cart by a small amount to show the correct total price. You can see the example to see how it works.
You will have to implement for the Cart structure the following **functions**:
You will have to implement for the `Cart` structure the following **functions**:
- `new`, that will initialize the cart
- `insert_item`, that will receive a reference to `Store` and a `String`. Just like the name says you will
have to insert the item to the cart
- `generate_receipt`, that returns a vector of sorted floats. This function must generate the receipt just
like the example above, using the promotion. Also saving the result in the filed `receipt`.
### Notions
- [closures](https://doc.rust-lang.org/rust-by-example/fn/closures.html)
- `new`: that will initialize the cart.
- `insert_item`: will receive a reference to `Store` and a `String`. Just like the name says, it will insert the item to the cart.
- `generate_receipt`: returns a vector of sorted floats. This function must generate the receipt just like the example below, using the promotion. AIt should save the result in the `receipt` field.
### Expected Function
@ -48,20 +40,24 @@ impl Cart {
### Example
`[1.23, 3.12, 23.1]` -> the receipt will be `[1.17, 2.98, 22.07]`
Because `1.17 + 2.98 + 22.07 == 0 + 3.12 + 23.1`
```
[1.23, 3.12, 23.1]` => `[1.17, 2.98, 22.07]
```
This is a percentage calculation, and it can be applied to a set of three items.
If the client purchase 9 items, the promotion will be applied, three for free, to all items
Because `1.17 + 2.98 + 22.07` == `0 + 3.12 + 23.1`
This is a percentage calculation, and it can be applied to a set of three items. If the client purchases 9 items, they will receive three for free, with the discount applied to all items.
`[1.23, 23.1, 3.12, 9.75, 1.75, 23.75, 2.75, 1.64, 15.23]` -> the receipt will be `[1.16, 1.55, 1.65, 2.6, 2.94, 9.2, 14.38, 21.8, 22.42]`
```
[1.23, 23.1, 3.12, 9.75, 1.75, 23.75, 2.75, 1.64, 15.23] => [1.16, 1.55, 1.65, 2.6, 2.94, 9.2, 14.38, 21.8, 22.42]
```
`[3.12, 9.75, 1.75, 23.75, 2.75, 1.64, 15.23]` -> the receipt will be `[1.54, 1.65, 2.59, 2.94, 9.18, 14.34, 22.36]`
```
[3.12, 9.75, 1.75, 23.75, 2.75, 1.64, 15.23] => [1.54, 1.65, 2.59, 2.94, 9.18, 14.34, 22.36]
```
and so on... (hint: Closures is the way)
> Hint: Closures are the way.
### Usage
@ -95,7 +91,11 @@ And its output:
```console
$ cargo run
Store { products: [("product A", 1.23), ("product B", 23.1), ("product C", 3.12)] }
[1.17, 2.98, 22.07]
[1.17, 2.98, 22.06]
Cart { items: [("product A", 1.23), ("product B", 23.1), ("product C", 3.12)], receipt: [1.17, 2.98, 22.07] }
$
```
### Notions
- [closures](https://doc.rust-lang.org/rust-by-example/fn/closures.html)

5
subjects/series/README.md

@ -2,9 +2,8 @@
### Instructions
Create a function `series` that takes an array of async functions.
It must execute them in series and return the results in order.
Create a function named `series` that takes an array of `async` functions. It must execute them in series and return the results in order.
### Notions
- [nan-academy.github.io/js-training/examples/promise](https://nan-academy.github.io/js-training/examples/promise.js)
- [Promise](https://nan-academy.github.io/js-training/examples/promise.js)

54
subjects/shopping_mall/README.md

@ -4,14 +4,15 @@
Using the `mall` module provided, create the following **functions** to help run a shopping mall:
- `biggest_store`: receives a `mall::Mall` and returns the `Store` with the biggest `square_meters`.
- `highest_paid_employees`: receives a `mall::Mall` and returns a vector containing the `Employee`(s) with the highest salary.
- `nbr_of_employees`: receives a `mall::Mall` and returns the number of employees and guards as a `usize`.
- `fire_old_guards`: receives a `mall::Mall` and removes from the `mall::Mall.guards` all guards who are 50 years old or over.
- `check_for_guards`: receives a `mall::Mall` and a vector of `Guard`. If there is not at least 1 guard for every 200 square meters of floor size, a guard should be added to the `mall::Mall.guards`.
- `cut_or_raise`: receives a `mall::Mall`. For each employee, the salary will be raised by 10% if they work more than 10 hours, else their salary will be decreased by 10%. You can consider that guards are not employees of the mall.
- `biggest_store`: receives a `Mall` and returns the `Store` with the biggest `square_meters`.
- `highest_paid_employees`: receives a `Mall` and returns a vector containing the `Employee`(s) with the highest salary.
- `nbr_of_employees`: receives a `Mall` and returns the number of employees and guards as a `usize`.
- `fire_old_guards`: receives a `Mall` and removes from the `Mall.guards` all guards who are 50 years old or over.
- `check_for_guards`: receives a `Mall` and a vector of `Guard`. If there is not at least 1 guard for every 200 square meters of floor size, a guard should be added to the `Mall.guards`.
- `cut_or_raise`: receives a `Mall`. For each employee, the salary will be raised by 10% if they work more than 10 hours, else their salary will be decreased by 10%. You can consider that guards are not employees of the mall.
### Expected Function
> You'll need to work out the function signatures for yourself.
### mall&#46;rs
@ -277,7 +278,42 @@ fn main() {
floor::Floor::new("Supermarket", supermarket, 1000),
];
let mall_la_vie = mall::Mall::new("La Vie Funchal", secs, floors);
let mut mall_la_vie = mall::Mall::new("La Vie Funchal", secs, floors);
println!("{:?}", &mall_la_vie);
//returns the biggest store
println!("{:?}",biggest_store(mall_la_vie.clone()));
//returns the list with the highest paid employees
println!("{:?}", highest_paid_employee(mall_la_vie.clone()));
//returns the number of employees
println!("{:?}", nbr_of_employees(mall_la_vie.clone()));
//fires old securities
fire_old_securities(&mut mall_la_vie);
//checks if it is needed to add securities
check_for_securities(
&mut mall_la_vie,
vec![
mall::guard::Guard::new("Peter Solomons", 45, 20),
mall::guard::Guard::new("William Charles", 32, 10),
mall::guard::Guard::new("Leonardo Changretta", 23, 0),
mall::guard::Guard::new("Vlad Levi", 38, 8),
mall::guard::Guard::new("Faruk Berkai", 40, 15),
mall::guard::Guard::new("Chritopher Smith", 35, 9),
mall::guard::Guard::new("Jason Mackie", 26, 2),
mall::guard::Guard::new("Kenzie Mair", 34, 8),
mall::guard::Guard::new("Bentley Larson", 33, 10),
mall::guard::Guard::new("Ray Storey", 37, 12),
],
);
//raises or cuts the salary of every employee
cut_or_raise(&mut mall_la_vie);
println!("{:?}", &mall_la_vie);
}
@ -288,5 +324,9 @@ And its ouput:
```rs
$ cargo run
Mall { name: "La Vie Funchal", guards: [Guard { name: "John Oliver", age: 34, years_experience: 7 }, Guard { name: "Logan West", age: 23, years_experience: 2 }, Guard { name: "Bob Schumacher", age: 53, years_experience: 15 }], floors: [Floor { name: "Ground Floor", stores: [Store { name: "Footzo", square_meters: 50, employees: [Employee { name: "Finbar Haines", age: 36, working_hours: (9, 14), salary: 650.88 }, Employee { name: "Roksanna Rocha", age: 45, working_hours: (13, 22), salary: 772.0 }, Employee { name: "Sienna-Rose Penn", age: 26, working_hours: (9, 22), salary: 1000.43 }] }, Store { name: "Swashion", square_meters: 43, employees: [Employee { name: "Abdallah Stafford", age: 54, working_hours: (8, 22), salary: 1234.21 }, Employee { name: "Marian Snyder", age: 21, working_hours: (8, 14), salary: 831.9 }, Employee { name: "Amanda Mclean", age: 29, working_hours: (13, 22), salary: 1222.12 }, Employee { name: "Faizaan Castro", age: 32, working_hours: (11, 18), salary: 1106.43 }] }], size_limit: 300 }, Floor { name: "Food Floor", stores: [Store { name: "PizBite", square_meters: 60, employees: [Employee { name: "Juniper Cannon", age: 21, working_hours: (16, 23), salary: 804.35 }, Employee { name: "Alena Simon", age: 28, working_hours: (9, 15), salary: 973.54 }, Employee { name: "Yasemin Collins", age: 29, working_hours: (9, 19), salary: 986.33 }, Employee { name: "Areeb Roberson", age: 54, working_hours: (9, 22), salary: 957.82 }, Employee { name: "Rocco Amin", age: 44, working_hours: (13, 23), salary: 689.21 }] }, Store { name: "Chillout Grill", square_meters: 50, employees: [Employee { name: "Rhian Crowther", age: 45, working_hours: (9, 15), salary: 841.18 }, Employee { name: "Nikkita Steadman", age: 52, working_hours: (14, 22), salary: 858.61 }, Employee { name: "Reginald Poole", age: 32, working_hours: (9, 22), salary: 1197.64 }, Employee { name: "Minnie Bull", age: 54, working_hours: (14, 22), salary: 1229.73 }] }, Store { name: "Sumo Food", square_meters: 30, employees: [Employee { name: "Chantelle Barajas", age: 20, working_hours: (8, 22), salary: 969.22 }, Employee { name: "Hywel Rudd", age: 49, working_hours: (12, 22), salary: 695.74 }, Employee { name: "Marianne Beasley", age: 55, working_hours: (8, 14), salary: 767.83 }] }], size_limit: 500 }, Floor { name: "Supermarket", stores: [Store { name: "Pretail", square_meters: 950, employees: [Employee { name: "Amara Schaefer", age: 23, working_hours: (9, 14), salary: 796.21 }, Employee { name: "Yara Wickens", age: 39, working_hours: (9, 14), salary: 853.42 }, Employee { name: "Tomi Boyer", age: 64, working_hours: (9, 14), salary: 881.83 }, Employee { name: "Greta Dickson", age: 42, working_hours: (9, 14), salary: 775.1 }, Employee { name: "Caroline Finnegan", age: 41, working_hours: (9, 14), salary: 702.92 }, Employee { name: "Indiana Baxter", age: 33, working_hours: (13, 20), salary: 991.71 }, Employee { name: "Jadine Page", age: 48, working_hours: (13, 20), salary: 743.21 }, Employee { name: "Husna Ryan", age: 43, working_hours: (13, 20), salary: 655.75 }, Employee { name: "Tyler Hunt", age: 63, working_hours: (13, 20), salary: 668.25 }, Employee { name: "Dahlia Caldwell", age: 56, working_hours: (13, 20), salary: 781.38 }, Employee { name: "Chandler Mansell", age: 20, working_hours: (19, 24), salary: 656.75 }, Employee { name: "Mohsin Mcgee", age: 30, working_hours: (19, 24), salary: 703.83 }, Employee { name: "Antoine Goulding", age: 45, working_hours: (19, 24), salary: 697.12 }, Employee { name: "Mark Barnard", age: 53, working_hours: (19, 24), salary: 788.81 }] }], size_limit: 1000 }] }
Store { name: "Pretail", square_meters: 950, employees: [Employee { name: "Amara Schaefer", age: 23, working_hours: (9, 14), salary: 796.21 }, Employee { name: "Yara Wickens", age: 39, working_hours: (9, 14), salary: 853.42 }, Employee { name: "Tomi Boyer", age: 64, working_hours: (9, 14), salary: 881.83 }, Employee { name: "Greta Dickson", age: 42, working_hours: (9, 14), salary: 775.1 }, Employee { name: "Caroline Finnegan", age: 41, working_hours: (9, 14), salary: 702.92 }, Employee { name: "Indiana Baxter", age: 33, working_hours: (13, 20), salary: 991.71 }, Employee { name: "Jadine Page", age: 48, working_hours: (13, 20), salary: 743.21 }, Employee { name: "Husna Ryan", age: 43, working_hours: (13, 20), salary: 655.75 }, Employee { name: "Tyler Hunt", age: 63, working_hours: (13, 20), salary: 668.25 }, Employee { name: "Dahlia Caldwell", age: 56, working_hours: (13, 20), salary: 781.38 }, Employee { name: "Chandler Mansell", age: 20, working_hours: (19, 24), salary: 656.75 }, Employee { name: "Mohsin Mcgee", age: 30, working_hours: (19, 24), salary: 703.83 }, Employee { name: "Antoine Goulding", age: 45, working_hours: (19, 24), salary: 697.12 }, Employee { name: "Mark Barnard", age: 53, working_hours: (19, 24), salary: 788.81 }] }
[Employee { name: "Abdallah Stafford", age: 54, working_hours: (8, 22), salary: 1234.21 }]
36
Mall { name: "La Vie Funchal", guards: [Guard { name: "John Oliver", age: 34, years_experience: 7 }, Guard { name: "Logan West", age: 23, years_experience: 2 }, Guard { name: "Peter Solomons", age: 45, years_experience: 20 }, Guard { name: "William Charles", age: 32, years_experience: 10 }, Guard { name: "Leonardo Changretta", age: 23, years_experience: 0 }, Guard { name: "Vlad Levi", age: 38, years_experience: 8 }, Guard { name: "Faruk Berkai", age: 40, years_experience: 15 }, Guard { name: "Chritopher Smith", age: 35, years_experience: 9 }, Guard { name: "Jason Mackie", age: 26, years_experience: 2 }], floors: [Floor { name: "Ground Floor", stores: [Store { name: "Footzo", square_meters: 50, employees: [Employee { name: "Finbar Haines", age: 36, working_hours: (9, 14), salary: 585.792 }, Employee { name: "Roksanna Rocha", age: 45, working_hours: (13, 22), salary: 694.8 }, Employee { name: "Sienna-Rose Penn", age: 26, working_hours: (9, 22), salary: 1100.473 }] }, Store { name: "Swashion", square_meters: 43, employees: [Employee { name: "Abdallah Stafford", age: 54, working_hours: (8, 22), salary: 1357.631 }, Employee { name: "Marian Snyder", age: 21, working_hours: (8, 14), salary: 748.71 }, Employee { name: "Amanda Mclean", age: 29, working_hours: (13, 22), salary: 1099.908 }, Employee { name: "Faizaan Castro", age: 32, working_hours: (11, 18), salary: 995.787 }] }], size_limit: 300 }, Floor { name: "Food Floor", stores: [Store { name: "PizBite", square_meters: 60, employees: [Employee { name: "Juniper Cannon", age: 21, working_hours: (16, 23), salary: 723.915 }, Employee { name: "Alena Simon", age: 28, working_hours: (9, 15), salary: 876.1859999999999 }, Employee { name: "Yasemin Collins", age: 29, working_hours: (9, 19), salary: 1084.963 }, Employee { name: "Areeb Roberson", age: 54, working_hours: (9, 22), salary: 1053.602 }, Employee { name: "Rocco Amin", age: 44, working_hours: (13, 23), salary: 758.1310000000001 }] }, Store { name: "Chillout Grill", square_meters: 50, employees: [Employee { name: "Rhian Crowther", age: 45, working_hours: (9, 15), salary: 757.0619999999999 }, Employee { name: "Nikkita Steadman", age: 52, working_hours: (14, 22), salary: 772.749 }, Employee { name: "Reginald Poole", age: 32, working_hours: (9, 22), salary: 1317.404 }, Employee { name: "Minnie Bull", age: 54, working_hours: (14, 22), salary: 1106.757 }] }, Store { name: "Sumo Food", square_meters: 30, employees: [Employee { name: "Chantelle Barajas", age: 20, working_hours: (8, 22), salary: 1066.142 }, Employee { name: "Hywel Rudd", age: 49, working_hours: (12, 22), salary: 765.314 }, Employee { name: "Marianne Beasley", age: 55, working_hours: (8, 14), salary: 691.047 }] }], size_limit: 500 }, Floor { name: "Supermarket", stores: [Store { name: "Pretail", square_meters: 950, employees: [Employee { name: "Amara Schaefer", age: 23, working_hours: (9, 14), salary: 716.589 }, Employee { name: "Yara Wickens", age: 39, working_hours: (9, 14), salary: 768.078 }, Employee { name: "Tomi Boyer", age: 64, working_hours: (9, 14), salary: 793.647 }, Employee { name: "Greta Dickson", age: 42, working_hours: (9, 14), salary: 697.59 }, Employee { name: "Caroline Finnegan", age: 41, working_hours: (9, 14), salary: 632.6279999999999 }, Employee { name: "Indiana Baxter", age: 33, working_hours: (13, 20), salary: 892.539 }, Employee { name: "Jadine Page", age: 48, working_hours: (13, 20), salary: 668.889 }, Employee { name: "Husna Ryan", age: 43, working_hours: (13, 20), salary: 590.175 }, Employee { name: "Tyler Hunt", age: 63, working_hours: (13, 20), salary: 601.425 }, Employee { name: "Dahlia Caldwell", age: 56, working_hours: (13, 20), salary: 703.242 }, Employee { name: "Chandler Mansell", age: 20, working_hours: (19, 24), salary: 591.075 }, Employee { name: "Mohsin Mcgee", age: 30, working_hours: (19, 24), salary: 633.447 }, Employee { name: "Antoine Goulding", age: 45, working_hours: (19, 24), salary: 627.408 }, Employee { name: "Mark Barnard", age: 53, working_hours: (19, 24), salary: 709.929 }] }], size_limit: 1000 }] }
$
```

38
subjects/smart-road/README.md

@ -1,18 +1,15 @@
#### Smart Road
## Smart Road
### Objectives
Do you remember the [`road_intersection`](https://public.01-edu.org/subjects/road_intersection/) raid done in the Rust Piscine? Well, you
will have to create another traffic control strategy and its simulation. However, this time it will have to be done without traffic lights and with a smart intersection management strategy.
Do you remember the [`road_intersection`](https://public.01-edu.org/subjects/road_intersection/) raid done in the Rust Piscine? Well, you will have to create another traffic control strategy and its simulation. However, it will have to be done without traffic lights and with a smart intersection management strategy this time.
Most of the time, overused intersections might lead to serious traffic jams on multiple roads, which wastes drivers'time and money, and also causes unnecessary air pollution. Additionally, according to a study from the National Highway Traffic Safety administration in the U.S., it is reported that about 96% of the intersection-related crashes had critical reasons to be the drivers fault, such as inadequate surveillance, false assumption of other actions, and turns with obstructed view.
Overused intersections might lead to severe traffic jams on multiple roads, which wastes drivers' time and money and causes unnecessary air pollution. Additionally, according to a study from the National Highway Traffic Safety Administration in the U.S., it is reported that about 96% of the intersection-related crashes had critical reasons to be the driver's fault, such as inadequate surveillance, false assumption of other actions, and turns with an obstructed view.
[Autonomous vehicles](https://en.wikipedia.org/wiki/Self-driving_car) (AVs) are a promising solution to traffic accidents. An optimistic prediction is that AVs will be publicly available in the next decade, and thus traffic issues related to autonomous vehicles are also being extensively investigated.
Current intersection management strategies, such as the traditional traffic lights and other more advanced methods are designed exclusively
for human drivers. With the rapid development of AVs, new traffic strategies must be taken into account.\
This is where you come in. You will have to create this new traffic strategy algorithm, so that AVs can pass an intersection without any
collisions and with a minimum of traffic congestion.
Current intersection management strategies, such as the traditional traffic lights and other more advanced methods, are designed exclusively for human drivers. With the rapid development of AVs, new traffic strategies must be taken into account.
This is where you come in. You will have to create this new traffic strategy algorithm so that AVs can pass an intersection without any collisions and with a minimum of traffic congestion.
### Instructions
@ -66,37 +63,35 @@ intersection area can only be represented by the corresponding lane.
As stated above you will be considering that all vehicles are autonomous (AVs), also known as self-driving cars.
You will have to implement the physics for this type of vehicles by taking into account the following rules :
1. AVs driving on a lane with a **given route** must follow the direction of
that route, it is not possible for the AVs to change lanes or route.
1. AVs driving on a lane with a **given route** must follow the direction of that route; the AVs can't change lanes or routes.
2. AVs must have at least 3 different velocities, therefore the **smart intersection system** can control the velocity of the vehicle.\
2. AVs must have at least 3 different velocities. Therefore the **smart intersection system** can control the velocity of the vehicle.\
This will be the way of controlling the current velocity/time/distance (depending on the algorithm you implement) of the AVs.
3. Each AV must respect a safety distance from other AVs.\
If a vehicle is driving with a high velocity and encounters another vehicle, it must detect that vehicle and keep a safe distance from it. It should not collide!
You are free to decide what is the safety distance but it must a strictly positive value.
If a vehicle is driving at a high velocity and encounters another vehicle, it must detect that vehicle and keep a safe distance from it. It should not collide!
You are free to decide the safety distance, but it must be a strictly positive value.
4. Other vehicles such as emergency vehicles are not considered in this project.
4. Other vehicles, such as emergency vehicles, are not considered in this project.
5. You must implement physics for the vehicle, such as `velocity = distance / time`. Each vehicle must have a :
- `time`: the time that the AV takes to leave the intersection
- `distance`: the distance that the AV takes to leave the intersection
- `velocity`: the speed of the AV at current time
- `velocity`: the speed of the AV at the current time
---
#### **Animation**
Animation is required for this project, you will have to find some assets for the vehicles and roads. Here are some assets for this:
Animation is required for this project. You will have to find some assets for the vehicles and roads. Here are some assets for this:
- [limezu](https://limezu.itch.io/)
- [finalbossblue](http://finalbossblues.com/timefantasy/free-graphics/).
- [mobilegamegraphics](https://mobilegamegraphics.com/product-category/all_products/freestuff/).
- [spriters-resource](https://www.spriters-resource.com/).
Animation is not just rendering an image into the canvas. By using assets you get to decide your "world coordinate system"
for the rendered image and therefore you create your own animation. But this is not enough.Basically you must animate while moving.
Animation is not just rendering an image into the canvas. By using assets, you get to decide your "world coordinate system" for the rendered image and therefore you create your own animation. But this is not enough. Basically, you must animate while moving.
A simple example of movement animation is imagining a vehicle with a route of `r`. This means that the vehicle arrives at the
intersection and turns right. If we render just an image of the vehicle facing down and it arrives to the point of turning, the rendered image
@ -119,9 +114,9 @@ You will have to implement several commands so that the simulation can be well t
2. It must also be possible to use the key `R` to continually generate random vehicles (using the game loop).
3. The `Esc` key must finish the simulation and generate a window with all statistics (you can see more about the statistics on its section).
3. The `Esc` key must finish the simulation and generate a window with all statistics (you can see more about the statistics in the below section).
4. When spamming the same key the vehicles should not be generated all at the same time, in other words, the vehicles should not be created on top of each other.
4. When spamming the same key, the vehicles should not be generated all at the same time. In other words, the vehicles should not be created on top of each other.
---
@ -133,7 +128,7 @@ The statistics must include:
- Max number of vehicles that passed the intersection
- Max velocity of all vehicles (Display the fastest speed achieved)
- Min velocity of all vehicles (Dislay the slowest speed reached)
- Min velocity of all vehicles (Display the slowest speed reached)
- Max time that the vehicles took to pass the intersection (for all vehicles, display the one that took more time)
- Min time that the vehicles took to pass the intersection (for all vehicles, display the one that took less time)
- The time starts to count whenever the vehicle is detected by the **smart intersection algorithm** until the end of the intersection, which is when the vehicle is removed from the canvas.
@ -153,6 +148,7 @@ You can implement the following optional features:
- Create your own assets for the animation of the vehicles
- Add more statistics
- Consider acceleration and deceleration on the physics of your game. That means that the cars don't change automatically of speed (e.g. different cars can take different times to change from 50 to 10 depending on how good the brakes are)
This project will help you learn about:

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

Loading…
Cancel
Save