Compare commits

..

10 Commits

Author SHA1 Message Date
zainabdnaya c69ab67f11 corrected 2 years ago
zainabdnaya 71472ab94d Merge branch '1162-numofdigits' of https://github.com/01-edu/public into 1162-numofdigits 2 years ago
zainabdnaya 75d5db05d9 numofdegit 2 years ago
Hamza elkhatri bb26c19359
Update README.md 2 years ago
zainabdnaya 0df69140b0 numofdegit 2 years ago
zainabdnaya 4eb4b6566d numofdegit 2 years ago
zainabdnaya b76f31da0c Correcting number of digits 2 years ago
zainabdnaya f8be55413a Correcting number of digits 2 years ago
zainabdnaya a70a9e20db Correcting number of digita 2 years ago
zainabdnaya dfdae345c1 feat Add numofdigits subject 2 years ago
  1. 2
      README.md
  2. 43
      subjects/addifpositive/README.md
  3. 4
      subjects/adding/README.md
  4. 13
      subjects/adding_twice/README.md
  5. 15
      subjects/all/README.md
  6. 46
      subjects/alphaposition/README.md
  7. 43
      subjects/arraysum/README.md
  8. 18
      subjects/ascii-art/README.md
  9. 24
      subjects/ascii-art/audit/README.md
  10. 38
      subjects/ascii/README.md
  11. 46
      subjects/betweenus/README.md
  12. 47
      subjects/binaryaddition/README.md
  13. 44
      subjects/build-brick-and-break/README.md
  14. 27
      subjects/clonernews/README.md
  15. 18
      subjects/clonernews/audit/README.md
  16. 11
      subjects/closures/README.md
  17. 40
      subjects/countnegative/README.md
  18. 48
      subjects/curry-entries/README.md
  19. 10
      subjects/debounce/README.md
  20. 2
      subjects/deep-copy/README.md
  21. 41
      subjects/divisors/README.md
  22. 36
      subjects/events/README.md
  23. 31
      subjects/fifty-shades-of-cold/README.md
  24. 22
      subjects/filter/README.md
  25. 7
      subjects/flagger/README.md
  26. 3
      subjects/flow/README.md
  27. 8
      subjects/for-each/README.md
  28. 14
      subjects/fusion/README.md
  29. 27
      subjects/get-json/README.md
  30. 69
      subjects/get-them-all/README.md
  31. 20
      subjects/get_products/README.md
  32. 25
      subjects/getarea/README.md
  33. 36
      subjects/gossip-grid/README.md
  34. 36
      subjects/gougle-search/README.md
  35. 25
      subjects/harder-bigger-bolder-stronger/README.md
  36. 23
      subjects/highest/README.md
  37. 17
      subjects/interpolation/README.md
  38. 4
      subjects/invert/README.md
  39. 22
      subjects/is-winner/README.md
  40. 45
      subjects/ismultiple/README.md
  41. 32
      subjects/keep-trying-or-giveup/README.md
  42. 25
      subjects/keycodes-symphony/README.md
  43. 41
      subjects/leapyear/README.md
  44. 15
      subjects/long-words/README.md
  45. 40
      subjects/manipulate-entries/README.md
  46. 37
      subjects/manipulate-keys/README.md
  47. 44
      subjects/manipulate-values/README.md
  48. 18
      subjects/mapper/README.md
  49. 35
      subjects/mouse-trap/README.md
  50. 3
      subjects/neuron/README.md
  51. 44
      subjects/numofdigits/README.md
  52. 20
      subjects/paramrange/README.md
  53. 54
      subjects/pick-and-click/README.md
  54. 10
      subjects/pick-omit/README.md
  55. 31
      subjects/pimp-my-style/README.md
  56. 23
      subjects/printascii/README.md
  57. 17
      subjects/pronoun/README.md
  58. 24
      subjects/quantifiers/README.md
  59. 20
      subjects/race/README.md
  60. 12
      subjects/ref_cell/README.md
  61. 7
      subjects/replica/README.md
  62. 2
      subjects/roman_numbers_iter/README.md
  63. 27
      subjects/rotargn/README.md
  64. 48
      subjects/sales/README.md
  65. 5
      subjects/series/README.md
  66. 97
      subjects/sortable/README.md
  67. 44
      subjects/sortable/audit/README.md
  68. 10
      subjects/sweet-curry/README.md
  69. 13
      subjects/throttle/README.md
  70. 2
      subjects/tron/audit/README.md
  71. 9
      subjects/ultimatedivmod/README.md
  72. 50
      subjects/using-filter/README.md
  73. 44
      subjects/using-map/README.md
  74. 31
      subjects/using-reduce/README.md
  75. 53
      subjects/where-do-we-go/README.md

2
README.md

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

43
subjects/addifpositive/README.md

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

4
subjects/adding/README.md

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

13
subjects/adding_twice/README.md

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

15
subjects/all/README.md

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

46
subjects/alphaposition/README.md

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

43
subjects/arraysum/README.md

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

18
subjects/ascii-art/README.md

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

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

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

38
subjects/ascii/README.md

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

46
subjects/betweenus/README.md

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

47
subjects/binaryaddition/README.md

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

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

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

27
subjects/clonernews/README.md

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

18
subjects/clonernews/audit/README.md

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

11
subjects/closures/README.md

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

40
subjects/countnegative/README.md

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

48
subjects/curry-entries/README.md

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

10
subjects/debounce/README.md

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

2
subjects/deep-copy/README.md

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

41
subjects/divisors/README.md

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

36
subjects/events/README.md

@ -7,28 +7,28 @@ You have to design a notification system for a platform.
Depending on the type of event, your event handler will control the size, color and position of the notification.
Create a method named `notify` which returns a `Notification` with the following characteristics for each of:
- `Remainder(text)`:
- `Remainder`:
- `size`: `50`
- `color`: `(50, 50, 50)`
- `position`: `Bottom`
- `content`: the `text` associated to the enum variant
- `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"`
- `Appointment(text)`:
- `size`: `100`
- `color`: `(200, 200, 3)`
- `position`: `Center`
- `content`: `text associated to the value`
- `Holiday`:
- `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"`
`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 2 hours, 32 minutes and 3 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.
@ -37,8 +37,6 @@ Implement the `std::fmt::Display` trait so the text of the notifications are pri
chrono = "0.4"
colored = "2.0.0"
### Expected Functions and Data Structures
```rust
@ -46,22 +44,22 @@ use chrono::Duration;
use colored::*;
#[derive(Debug, Eq, PartialEq)]
pub enum Position {
enum Position {
Top,
Bottom,
Center,
}
#[derive(Debug, Eq, PartialEq)]
pub struct Notification {
pub size: u32,
pub color: (u8, u8, u8),
pub position: Position,
pub content: String,
struct Notification {
size: u32,
color: (u8, u8, u8),
position: Position,
content: String,
}
#[derive(Debug)]
pub enum Event<'a> {
enum Event<'a> {
Remainder(&'a str),
Registration(Duration),
Appointment(&'a str),
@ -76,7 +74,7 @@ impl fmt::Display for Notification {
use Event::*;
impl Event {
pub fn notify(&self) -> Notification {
fn notify(&self) -> Notification {
}
}
```

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

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

22
subjects/filter/README.md

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

7
subjects/flagger/README.md

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

3
subjects/flow/README.md

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

8
subjects/for-each/README.md

@ -2,16 +2,16 @@
### Instructions
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.
Create a `forEach` function that takes an array as first argument, a function as second,
and that works like the method .forEach
### Notions
- [Array.prototype.forEach](https://devdocs.io/javascript/global_objects/array/foreach)
- [devdocs.io/javascript/global_objects/array/foreach](https://devdocs.io/javascript/global_objects/array/foreach)
### Code provided
> The provided code will be added to your solution, and does not need to be submitted.
> all code provided will be added to your solution and doesn't need to be submited.
```js
Array.prototype.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
Create a function named `fusion` that:
With this, create a function called `fusion` that:
- For array types, you will concatenate them.
- If the type is an array you must concatenate it
```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' ] }
```
- For strings, you must concatenate them with a space.
- If it is a string you must concatenate it 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 (if it exists).
- In case of type mismatch you must replace it with the value of the second object
```js
fusion({ a: "hello", b: [] }, { a: 4 }); // -> { a: 4, b: [] }

27
subjects/get-json/README.md

@ -4,23 +4,26 @@
In this exercise, we will focus on building complex async flows with promises.
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`.
Create a `getJSON` function that takes 2 parameters:
`getJSON` must construct a valid url with the `path` and stringified `params`, and use `fetch` to fulfil the request.
- `path`, that will be the url called by your function
- `params` _optional_, that will be the search parameters appended to your url
If the response is not OK, `getJSON` must throw an error using the response _status text_.
`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.
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
- [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)
- [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)

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

@ -2,55 +2,52 @@
### Instructions
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'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 arrive at the architects' chamber, but all you have in front of you is a bunch of unknown people.
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.
Step by step, gather information and figure out by elimination who he is.
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:
Launch the provided HTML file in the browser to begin your investigation.
- Write the body of the `getArchitects` function, which returns an array containing 2 arrays of HTML elements:
At the top of the webpage, each of the four buttons fires a function:
- the first array contains the architects, all corresponding to a `<a>` tag
- the second array contains all the non-architects people
Complete the body of the following functions. The first three functions return an array containing two arrays of HTML elements:
- Write the body of the `getClassical` function, which returns an array containing 2 arrays of HTML elements:
- `getArchitects`:
- 1st array: the architects, all corresponding to a `<a>` tag.
- 2nd array: all the non-architects.
- the first array contains the architects belonging to the `classical` class
- the second array contains the non-classical architects
- `getClassical`:
- 1st array: the architects belonging to the `classical` class.
- 2nd array: the non-classical architects.
- Write the body of the `getActive` function, which returns an array containing 2 arrays of HTML elements:
- `getActive`:
- 1st array: the classical architects who are `active` in their class.
- 2nd array: the non-active classical architects.
- the first array contains the classical architects who are `active` in their class
- the second array contains the non-active classical architects
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.
- 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.
```js
export const getArchitects = () => {...}
```
### Files
> 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 = () => {...}`
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:
### Notions
- the HTML file [get-them-all.html](./get-them-all.html) to open in the browser, which includes:
- [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 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.
### Files
- the data file [get-them-all.data.js](./get-them-all.data.js) used to generate content in the HTML.
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:
### Notions
- the HTML file [get-them-all.html](./get-them-all.html) to open in the browser, which includes:
- [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 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 data file [get-them-all.data.js](./get-them-all.data.js) used to generate content in the HTML

20
subjects/get_products/README.md

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

25
subjects/getarea/README.md

@ -1,25 +0,0 @@
## 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.
They will each be represented as a `div` with the `gossip` class.
Create 3 `type="range"` inputs with the class `range`, all wrapped in a `div` with the class `ranges`:
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.
- 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%)_
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%.
> _tips:_ use `hsl` for colors
### Notions
> Use `hsl` for colors
- [`<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)
### Files
You only need to create & submit the JS file `gossip-grid.js`; we're providing you the following files to download and test locally:
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:
- the HTML file [gossip-grid.html](./gossip-grid.html) to open in the browser, which includes:
- 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 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 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,11 +2,16 @@
### Instructions
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.
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
You need to construct 2 urls which should work like this:
```js
queryServers('pouet', 'hello+world')
// return the fastest of those 2 calls:
@ -14,26 +19,25 @@ queryServers('pouet', 'hello+world')
// -> getJSON('/pouet_backup?q=hello+world')
```
Create a function named: `gougleSearch` that takes a single query argument (`q`). It must invoke `queryServers` concurrently on 3 servers:
- `"web"`
- `"image"`
- `"video"`
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.
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.
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')`.
### Notions
- [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
> The provided code will be added to your solution, and does not need to be submitted.
> all code provided will be added to your solution and doesn't need to be submited.
```js
// 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,26 +2,27 @@
### 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` 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.
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
### Files
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:
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:
- 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 enable you to run yours.
- some CSS pre-styled classes: feel free to use those as they are, or modify them.
- the JS script running some code, and which will also allow to run yours
- some CSS pre-styled classes: feel free to use those as they are, or modify them
### 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,14 +2,19 @@
### 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 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.
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)
### Expected functions
@ -57,7 +62,3 @@ Some(70)
[500, 70, 30]
$
```
### Notions
- [Trait iterator](https://doc.rust-lang.org/std/iter/trait.Iterator.html)

17
subjects/interpolation/README.md

@ -2,15 +2,14 @@
### Instructions
Create a function named `interpolation` that takes an object with 5 properties: `step`, `start`, `end`, `callback` and `duration`.
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.
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`.
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`.
### Example
@ -42,4 +41,4 @@ duration = 10
### Notions
- [setTimeout & setInterval](https://javascript.info/settimeout-setinterval)
- [javascript.info/settimeout-setinterval](https://javascript.info/settimeout-setinterval)

4
subjects/invert/README.md

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

22
subjects/is-winner/README.md

@ -2,23 +2,27 @@
### Instructions
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.
Create a function `isWinner` that, by making use of `winners` "API", should
return a resolved Promise with the string:
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> + ' never was a winner'`, if the country passed in `isWinner` has never won the FIFA World Cup
- `"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 continent'`,
if the country passed in `isWinner` is not from the european
continent
- `"Country is not what we are looking for because of the continent"`: The country is not from the european continent.
- `<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 number of times it was champion"`: The country won the FIFA world cup fewer than 3 times.
- `<country> + ' won the FIFA World Cup in ' + <year(s)> + 'winning by ' + <results>`, otherwise.
- `"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"`
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```
### Code provided
> The provided code will be added to your solution, and does not need to be submitted.
> all code provided will be added to your solution and doesn't need to be submitted.
```js
const db = (() => {

45
subjects/ismultiple/README.md

@ -1,45 +0,0 @@
## 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,26 +2,30 @@
### Instructions
Create a `retry` function, that takes 2 arguments:
Create a `retry` function, that takes 2 arguments
- `count`: indicates maximum number of retries.
- `callback`: an `async` function that will be invoked for every attempt.
- a `count` indicates maximum amount of retries
- an async `callback`, that will be called on every try
`retry` returns a function that invokes the `callback` function. That function passes its arguments to `callback`, and returns the value from `callback`.
`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`.
The function returned by `retry` must `catch` errors from `callback`. After that function has caught `count` errors, it must `throw` an `Error`.
> for count of 3, the function will be called at most 4 times:
> the initial call + 3 retries.
> if `count` is 3, `callback` will be invoked at most 4 times, the initial call plus 3 retries.
Create a `timeout` function, that takes 2 arguments
Create function named `timeout`, that takes 2 arguments:
- a `delay` indicates maximum wait time
- an async `callback`, that will be called
- `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')`.
`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.
### Notions
- [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)
- [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)

25
subjects/keycodes-symphony/README.md

@ -2,27 +2,28 @@
### Instructions
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.
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.
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. 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.
- 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)
### Files
You only need to create & submit the JS file `keycodes-symphony.js`; we're providing you the following file to download to test locally:
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:
- 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)

41
subjects/leapyear/README.md

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

15
subjects/long-words/README.md

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

40
subjects/manipulate-entries/README.md

@ -2,23 +2,35 @@
### Instructions
Create 3 functions which work like the `.filter`, `.map` and `.reduce` array methods, but for the **entries** in the grocery cart.
Finish your groceries!!!
- `filterEntries`: filters using both key and value.
- `mapEntries`: changes the key, the value or both.
- `reduceEntries`: reduces the entries.
Create 3 functions that works like the `.filter`, `.map` and `.reduce` array method but for the entries of the grocery cart.
Create 3 additional functions that use your previously created functions:
- `filterEntries` filters using both key and value.
- `mapEntries` changes either the key or the value or both.
- `reduceEntries` reduce over entries.
- `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.
Create 3 other functions that use your previously create functions:
> Think about the shape of `Object.entries()`
- `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)
### Code provided
> The provided code will be added to your solution, and does not need to be submitted.
> all code provided will be added to your solution and doesn't need to be submited.
```js
// small database with nutrition facts, per 100 grams
@ -34,11 +46,3 @@ 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,29 +2,40 @@
### 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 methods, but for the **keys** of your grocery cart. You can see their names and how they work in the examples.
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.
### 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
> The provided code will be added to your solution, and does not need to be submitted.
> all code provided will be added to your solution and doesn't need to be submited.
```js
// small database with nutrition facts, per 100 grams
@ -40,11 +51,3 @@ 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,32 +2,48 @@
### Instructions
Let's buy groceries.
Go buy groceries!!!
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.
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.
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.
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**.
### 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
> The provided code will be added to your solution, and does not need to be submitted.
> all code provided will be added to your solution and doesn't need to be submitted.
```js
// small database with nutrition facts, per 100 grams
@ -44,11 +60,3 @@ 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,21 +2,23 @@
### Instructions
- 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 `map` function that takes an array as first argument, a function as second,
and that works like the method .map
- Create a `flatMap` function that takes an array as the first argument, a function as second, and that works like the method `.flatMap`
- 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)
### Code provided
> The provided code will be added to your solution, and does not need to be submitted.
> all code provided will be added to your solution and doesn't need to be submited.
```js
Array.prototype.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)

35
subjects/mouse-trap/README.md

@ -2,39 +2,34 @@
### 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 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 `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`
- `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 `moveCircle`: make it fire when the mouse moves, and get the last circle created and makes it move along with the mouse
- `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.
- 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.
> Hint: Be careful, a circle cannot overlap the box which has walls of `1px`. It has to be trapped **strictly** inside.
> 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)
### Provided files
### Files
You only need to create & submit the JS file `mouse-trap.js`; we're providing you the following file to download and test locally:
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:
- the HTML file [mouse-trap.html](./mouse-trap.html) to open in the browser, which includes:
- 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 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/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,7 +2,8 @@
### Instructions
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.
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.
### Example

44
subjects/numofdigits/README.md

@ -0,0 +1,44 @@
## number of digits
### Instructions
Write a function that returns the number of digits in a positive integer n.
- if the number is negative returns 0.
### Expected function
```go
func Numofdigits(num int) int {
}
```
### Usage
Here is a possible program to test your function:
```go
package main
import (
"fmt"
)
func main() {
fmt.Println(Numofdigits(3))
fmt.Println(Numofdigits(245))
fmt.Println(Numofdigits(-1))
fmt.Println(Numofdigits(885))
fmt.Println(Numofdigits(8574))
}
```
And its output :
```console
$ go run .
1
3
0
3
4

20
subjects/paramrange/README.md

@ -1,20 +0,0 @@
## 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,47 +2,43 @@
### Instructions
Today, you're going to create your own color picker.
Today, you're gonna create your own color picker.
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.
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:
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.
- 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
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`.
> Here is how a hsl value is formatted: `hsl(45, 50%, 35%)`
When the mouse is clicked, the value of the `hsl` will need to copied to the clipboard.
> Use `Math.round()` to round the values
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.
> The formatting of a `hsl` value: `hsl(45, 50%, 35%)`.
### Notions
> Use `Math.round()` to round the values.
- [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)
### Files
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:
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:
- the HTML file [pick-and-click.html](./pick-and-click.html) to open in the browser, which includes:
- 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 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://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)
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)

10
subjects/pick-omit/README.md

@ -2,12 +2,14 @@
### Instructions
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.
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.
> Those functions are pure and must not modify the given object
### Notions
- [object](https://devdocs.io/javascript/global_objects/object)
- [devdocs.io/javascript/global_objects/object](https://devdocs.io/javascript/global_objects/object)

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

@ -8,22 +8,18 @@ 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:
- 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.
- 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
Example for a `styles` array with only 3 classes:
```js
["one", "two", "three"]
```
Example for a `styles` array with only 3 classes:
```
Page load --> <button class="button"></div>
...adding
@ -39,20 +35,21 @@ 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`. Ee're providing you the following files to download and test locally.:
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:
- 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 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`.
- 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`
### 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

@ -1,23 +0,0 @@
## 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,19 +2,10 @@
### Instructions
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
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.
#### Example

24
subjects/quantifiers/README.md

@ -2,22 +2,26 @@
### Instructions
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.
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.
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
> The provided code will be added to your solution, and does not need to be submitted.
> all code provided will be added to your solution and doesn't need to be submited.
```js
Array.prototype.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,20 +2,22 @@
### Instructions
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 `race` that works like `Promise.race`
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
> The provided code will be added to your solution, and does not need to be submitted.
> all code provided will be added to your solution and doesn't need to be submited.
```js
Promise.race = undefined
```
### Notions
- [Promise](https://nan-academy.github.io/js-training/examples/promise.js)
- [Promise.race](https://devdocs.io/javascript/global_objects/promise/race)

12
subjects/ref_cell/README.md

@ -18,35 +18,31 @@ fn error(&self, msg: &str);
```
Implement the `Tracker` structure with the following fields:
- `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.
- `peek`: that will take a peek at how much usage the variable already has. It should write `"Info: you are using up too X% of your quote"` to the `info` trait function. `X` should be replaced with the calculated percentage.
### Second part (lib.rs)
Now that you've created `messenger`, you can now create the following:
Create the `Worker` structure with the following fields:
- `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.
Create the following associated functions for `Worker`:
- `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.
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
@ -100,11 +96,11 @@ And its output:
```console
$ cargo run
("Info", "you are using up to 40% of your quota")
("Info", "you are using up too 40% of your quote")
("Warning", "you have used up over 90% of your quota! Proceeds with precaution")
("Error", "you are over your quota!")
[
"Info: you are using up to 40% of your quota",
"Info: you are using up too 40% of your quote",
"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!"

7
subjects/replica/README.md

@ -2,10 +2,11 @@
### Instructions
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.
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.
> Watch out for shallow copies.
Attention with the shallow copies.
### Notions
- [data-structures](https://nan-academy.github.io/js-training/examples/data-structures.js)
- [nan-academy.github.io/js-training/examples/data-structures](https://nan-academy.github.io/js-training/examples/data-structures.js)

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_iterator::RomanNumber;
use roman_numbers::RomanNumber;
fn main() {
let mut number = RomanNumber::from(15);

27
subjects/rotargn/README.md

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

48
subjects/sales/README.md

@ -2,17 +2,25 @@
### Instructions
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.
In this exercise a shopping system will have to be created. There will be :
**"Buy three, get one free".**
- A store that will save all the products in it
- A cart that will have `items` that the client will buy, and a `receipt`
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.
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)
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`: 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.
- `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)
### Expected Function
@ -40,24 +48,20 @@ impl Cart {
### Example
```
[1.23, 3.12, 23.1]` => `[1.17, 2.98, 22.07]
```
`[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`
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.
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
```
[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]
```
`[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]`
```
[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]
```
> Hint: Closures are the way.
`[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]`
and so on... (hint: Closures is the way)
### Usage
@ -91,11 +95,7 @@ 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.06]
[1.17, 2.98, 22.07]
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,8 +2,9 @@
### Instructions
Create a function named `series` that takes an array of `async` functions. It must execute them in series and return the results in order.
Create a function `series` that takes an array of async functions.
It must execute them in series and return the results in order.
### Notions
- [Promise](https://nan-academy.github.io/js-training/examples/promise.js)
- [nan-academy.github.io/js-training/examples/promise](https://nan-academy.github.io/js-training/examples/promise.js)

97
subjects/sortable/README.md

@ -2,34 +2,43 @@
### Instructions
You are a villain and your dream is to get rid of those annoying, yoga-pant-wearing, weird masked **superheroes**.
You never understood why some of them are considered to be superheroes, just because they are rich. Others annoy you with their philosophical speeches.
You are a villain and your dream is to end with those annoying, yoga pants,
weird masks wearing **superheroes**. You never understood why are some of them
considered superheroes just because they are rich. Others annoy you with their
philosophical speeches. And of course that something tragic has had to happen
to them for the people to feel sorry for them. \
Anyway, we've found _confidential_ information about those superheroes.
We've found _confidential_ information about those superheroes.
> Your task for the moment is to build a web page in order to organize all the
> data from those smartypants.
> This information can be found here: [all.json](https://rawcdn.githack.com/akabab/superhero-api/0.2.0/api/all.json).
**Your task** is to build a web page to organize all the data about those smartypants. All that data can be found [here](https://rawcdn.githack.com/akabab/superhero-api/0.2.0/api/all.json) in `all.json`.
You must write all of the code from scratch. You are not allowed to rely on any frameworks or libraries like React, Vue, Svelte etc.
Note that since this mission is using *critical* data, you are not allowed to
rely on any frameworks or libraries, you have to be the author of every bit
of code.
#### Fetching the data
In order to get the information, you should use `fetch`.
When you use `fetch` in JS, it always returns a `Promise`. We will look more deeply into that later on. For now, tak a look at this:
In order to get the information out of the API you should use `fetch`.
In JS when you use `fetch` it always returns a `Promise` we will look
deeper into those later on, for now just refer to the code example below:
```js
// This function is called only after the data has been fetched, and parsed.
const loadData = heroes => {
console.log(heroes)
console.log(heroes) // write your code using the data in a function
// note that you can not access heroes before this function is called.
}
// Request the file with fetch, the data will downloaded to your browser cache.
// Request the file fetch, it will download it in your browser cache
fetch('https://rawcdn.githack.com/akabab/superhero-api/0.2.0/api/all.json')
.then((response) => response.json()) // parse the response from JSON
.then(loadData) // .then will call the `loadData` function with the JSON value.
.then(loadData) // .then will call the function with the JSON value
```
#### Display
Not all the information is valuable at a glance, so we will only show some of the fields in a `<table>` element. The necessary data will be:
Not every field should be presented in a `<table>` element,
the necessary data will be:
- Icon (`.images.xs`, should be displayed as images and not as a string)
- Name (`.name`)
@ -42,38 +51,46 @@ Not all the information is valuable at a glance, so we will only show some of th
- Place Of Birth (`.biography.placeOfBirth`)
- Alignement (`.biography.alignment`)
The information must be displayed in multiple pages. Use a `<select>` input to chose the page size from `10`, `20`,`50`, `100` or `all results`.
The information must be displayed in multiple pages. \
A `<select>` input is used to chose from `10`, `20`,`50`, `100` or `all results`.
The default page size selected option must be `20`.
> The default page size selected option must be `20`
#### Search
It must be possible to filter information by searching the name as a string. For example, searching _"man"_ should find all superheros with `"man"` in their name.
It must be possible to filter information by searching the name as a string
_(ex: superheroes that contain **man** in their name)._
The search should be interactive. In other words, the results should be filtered after every keystroke. So we don't need a "search" button.
- The search should be interactive, in other words, the results should be
displaying as you write, not needing a button for you to click.
#### Sort
It will be valuable to sort the information in the table by any of its columns. Results should be sortable alphabetically or numerically.
- Initially all rows should be sorted by the column `name` by `ascending` order.
- The first click on a column heading will sort the table by the data in that column in `ascending` order.
- Consecutive clicks on a column heading will toggle between `ascending` and `descending`.
- Some of the columns are composed of strings, but represent numerical values. For example, when the `weight` column is sorted in ascending order, then `"78 kg"` must be displayed before `"100 kg"`.
- Missing values should **always** be sorted last, irrespective of `ascending` or `descending`.
> When dealing with heroes, **speed** is critical. All operations must be performed quickly, without slowing the browser down.
### Bonus
Additional features will be critical to your success. Here's a few which will give you a bigger boost:
- Specify the field that the search applies to.
- Custom search operators
- `include`
- `exclude`
- `fuzzy`
- `equal`, `not equal`, `greater than` and `lesser than` for numbers (including weight and height).
- Detail view. Clicking a hero from the list will show all the details and large image.
- A slick design. Spend some time improving the look and feel by playing around with CSS. Have fun with it.
- Modify the URL with the search term, so that if you copy and paste the URL in a different tab, it will display the same column filters. If you have implemented detail view, the state of which hero is displayed should also form part of the URL.
It must be possible to sort by any columns of the table
_(either alphabetically or numerically)._
- Initially all rows should be sorted by the column `name` by `ascending` order
- First click will order the column by `ascending` value
- Consecutive clicks will toggle between `ascending` and `descending` order
- Note that, for example, the column `weight` will be composed of strings, so
the correct order would be `['78 kg', '100 kg']` instead of the other way
around
- Missing values should always be sorted last.
> As you know, when you are against heroes, **speed** is critical, every operations on
> the database should be very fast and not slow down the browser
### Optional
Any additional features will be critical to your success, everything count:
better filtering, better design, more details... here a few:
- Allow to specify the field you search on and search on any field.
- Custom search operators like allowing `include` / `exclude` or `fuzzy` string
matching and `equal` / `not equal` / `greater than` / `lesser than` for numbers
(this includes weight and height).
- Detail view when clicking on a hero that show all the details and large image.
- A slick design spend some time on the CSS, make it look great, have fun with it.
- The URL must be updated with the search, so if you copy and paste this url it
will present the same result(s). If you have implemented the detail view,
which hero is detail view is open should be also be saved in the URL.

44
subjects/sortable/audit/README.md

@ -1,57 +1,57 @@
#### Functional
#### Functionals
###### Does the data appear in a `<table>` element?
###### Does the data appear in a table element?
###### Does the table present just the required data (icon, name, full name, power stats, race, gender, height, weight, place of birth, alignment), instead of all of it?
###### Does the table presents just the requested data (icon, name, full name, powerstats, race, gender, height, weight, place of birth, alignment), instead of all of it?
###### Has client-side pagination been implemented? Are there different pages that display different information?
###### Are there different pages that display different information?
###### Does the table initially displays 20 results?
###### Can you change the amount of results displayed between **10**, **20**, **50**, **100** or **all results**?
###### Can you change the page size to one of **10**, **20**, **50**, **100** or **all results**?
###### Does the table initially displays 20 results?
###### Are the results initially sorted by the **name** column in **ascending** order?
###### Are the results initially sorted by the column **name** by **ascending** order?
###### Are all columns of the table clickable in order to sort the results?
##### Try to click once to sort the table by weight.
###### Was the table sorted numerically by weight in **ascending** order? (be aware that cases like [75 kg, 100kg] should be in that order and not the other way around)
###### Did the results became sorted numerically by weight in **ascending** order? (be aware that cases like [75 kg, 100kg] should be in that order and not the other way around)
##### Try to click twice to sort the table by place of birth.
##### Try to click twice to sort the by place of birth.
###### Were the results sorted alphabetically by place of birth in **descending** order?
###### Did the results became sorted alphabetically by place of birth in **descending** order?
##### Try to click several times on a column and observe its behavior.
###### Did the sort order toggle between **ascending** and **descending** order?
###### Did the results became sorted in **ascending** and **descending** order, alternately?
##### Try to search for `Superman`.
###### Are the missing values always shown last?
##### Write only `Cat` on the search field.
###### As you type, does the results on the table change?
###### As you type, do the results on the table change?
##### Write only `Cat` on the search field.
###### Does Catwoman appear in the results?
###### Does Catwoman appear on the results?
###### Does the project contains the use of `fetch`?
##### Check the project to ensure that it does not use any libraries of frameworks (React, Vue, Svelte etc).
###### Is the project free of any frameworks or librairies?
###### Confirm that no frameworks or librairies where used
#### Bonus
###### +Can you search for any fields apart from the name?
###### +Can you do a search with search these search operators: include/exclude for strings and equal/not equal/greater than/less than)?
###### +Can you do a search with search operators (include/exclude for strings and equal/not equal/greater than/lesser than)?
###### +If you click on a hero, does the site display the details and a large image of it?
###### +If you click on a hero, does the site displays the details and a large image of it?
###### +Does the URL change when you make a search?
###### +Does the URL changes when you make a search?
###### +After making a search and the URL changes, if you copy and paste it to a different tab, are the results displayed in the table the same as the ones from the previous tab?
###### +After making a search and the URL changes, if you copy and paste it in a different window, are the results displayed in the table the same as the ones from the search?
###### +Does the project run quickly and effectively? (Favoring recursive, no unnecessary data requests, etc)?
###### +Does the project runs quickly and effectively? (Favoring recursive, no unnecessary data requests, etc)
###### +Does the code obey the [good practices](https://public.01-edu.org/subjects/good-practices/README.md)?

10
subjects/sweet-curry/README.md

@ -2,11 +2,13 @@
### Instructions
Create the following functions with the "currying" process. Those functions should accept only one argument each.
Create the following functions with the "currying" process:
- `mult2`: that multiplies two numbers.
- `add3`: that adds three numbers.
- `sub4`: that subtracts four numbers.
- mult2 that multiplies two numbers.
- add3 that adds three numbers.
- sub4 that subtracts four numbers.
Please note that those functions can only have one argument each.
### Notions

13
subjects/throttle/README.md

@ -2,13 +2,14 @@
### Instructions
Create two functions that will work like `_.throttle` from lodash.
Create two functions that will work like `_.throttle` from lodash
- `throttle`: don't worry about the options.
- `opThrottle`: implement the `trailing` and `leading` options.
- `throttle`, this function doesn't need to take care of the options
- `opThrottle`, this function will take care of
the `trailing` and `leading` options
### Notions
- [lodash throttle](https://lodash.com/docs/4.17.15#throttle)
- [css-tricks throttle](https://css-tricks.com/debouncing-throttling-explained-examples/#throttle)
- [stackoverflow about lodash debounce](https://stackoverflow.com/questions/24079736/confused-about-the-maxwait-option-for-lodashs-debounce-method)
- [lodash.com/docs/4.17.15#throttle](https://lodash.com/docs/4.17.15#throttle)
- [https://css-tricks.com/debouncing-throttling-explained-examples/#throttle](https://css-tricks.com/debouncing-throttling-explained-examples/#throttle)
- [https://stackoverflow.com/questions/24079736/confused-about-the-maxwait-option-for-lodashs-debounce-method](https://stackoverflow.com/questions/24079736/confused-about-the-maxwait-option-for-lodashs-debounce-method)

2
subjects/tron/audit/README.md

@ -43,4 +43,4 @@ Serving HTTP on :: port 8000 (http://[::]:8000/)
##### If you have an AI, and are prepared for battle. Modify the URL to battle against your AI. Best out of 3.
###### +Did the audited AI win against your AI?
###### +Did the audited AI won against your AI?

9
subjects/ultimatedivmod/README.md

@ -2,7 +2,7 @@
### Instructions
Create the following function.
- Write a function that will be formatted as below.
### Expected function
@ -11,9 +11,10 @@ func UltimateDivMod(a *int, b *int) {
}
```
`UltimateDivMod` should divide the dereferenced value of `a` by the dereferenced value of `b`.
- Store the result of the division in the `int` which `a` points to.
- Store the remainder of the division in the `int` which `b` points to.
- This function will divide the `int` **a** and **b**.
- The result of this division will be stored in the `int` pointed by **a**.
- The remainder of this division will be stored in the `int` pointed by **b**.
### Usage

50
subjects/using-filter/README.md

@ -2,24 +2,50 @@
### Instructions
Create the following functions:
- Create a function `filterShortStateName` that takes an array of
strings and that returns the ones with less than 7 characters.
> Your solutions **must** use `filter`.
> Example: `'Iowa'` only contains 4 characters
- `filterShortStateName`: accepts an array of strings, and returns only those strings which contain less than 7 characters.
- Create a function `filterStartVowel` that takes an array of strings
and that returns only the ones that start with a vowel (a,e,i,o,u).
- `filterStartVowel`: accepts an array of strings, and returns only those that start with any vowel (a,e,i,o,u).
> Example: `'Alabama'` starts with a vowel
- `filter5Vowels`: accepts an array of strings, and returns only those which contain at least 5 of any vowels (a,e,i,o,u).
- Create a function `filter5Vowels` that takes an array of strings
and that returns only the ones which contain at least 5
vowels (a,e,i,o,u).
- `filter1DistinctVowel`: accepts an array of strings, and returns only those which contain distinct vowels (a,e,i,o,u). For example, `"Alabama"` contains only 1 distinct vowel `"a"`.
> Example: `'California'` contains at least 5 vowels
- `multiFilter`: accepts an array of objects, and returns only those which:
- the key `capital` contains at least 8 characters.
- the key `name` does not start with a vowel.
- the key `tag` has at least one vowel.
- the key `region` is not `"South"`
- Create a function `filter1DistinctVowel` that takes an array of
strings and that returns only the ones which vowels are of only
one distinct one (a,e,i,o,u).
> Example: `'Alabama'` only contains 1 distinct vowels `'a'`.
- Create a function `multiFilter` that takes an array of
objects and that returns only the ones which:
- the key `capital` contains at least 8 characters.
- the key `name` does not start with a vowel
- the key `tag` has at least one vowel.
- the key `region` is not `'South'`
> Example of an array of objects matching the criterias:
```js
[
{ tag: 'CA', name: 'California', capital: 'Sacramento', region: 'West' },
{ tag: 'PA', name: 'Pennsylvania', capital: 'Harrisburg', region: 'Northeast' }
]
```
#### Special instruction
The goal of this exercise is to learn to use `filter`, as such all your
solution **MUST** use `filter`
### Notions
- [Array.prototype.filter](https://devdocs.io/javascript/global_objects/array/filter)
- [devdocs.io/javascript/global_objects/array/filter](https://devdocs.io/javascript/global_objects/array/filter)

44
subjects/using-map/README.md

@ -2,13 +2,10 @@
### Instructions
Create the following functions:
- Create a function named `citiesOnly` which takes an array of objects and which return an array of strings from the key `city`.
> Your solutions **must** use `map`.
#### Example:
#### Cities Only
`citiesOnly`: accepts an array of objects and returns an array of strings from the `city` key.
```js
citiesOnly([
{
@ -22,20 +19,34 @@ citiesOnly([
]) // -> ['Los Angeles', 'San Francisco']
```
#### Upper Casing States
`upperCasingStates`: accepts an array of strings, and returns a new array of strings. The returned array will be the same as the argument, except the first letter of every word must be capitalized.
- Create a function named `upperCasingStates` which takes an array of strings
and which Upper Case the first letter of each word in a string. \
The function returns then an array of strings.
#### Example:
```js
upperCasingStates(['alabama', 'new jersey']) // -> ['Alabama', 'New Jersey']
```
#### Fahrenheit to Celsius
`fahrenheitToCelsius`: accepts an array of fahrenheit temperatures as strings, and returns an array of strings converted to celsius. Round down the result.
- Create a function named `fahrenheitToCelsius` which takes an array
of fahrenheit temperatures which converts them to Celsius.
Round down the result.
The function then returns the result as an array of strings like below:
#### Example:
```js
fahrenheitToCelsius(['68°F', '59°F', '25°F']) // -> ['20°C', '15°C', '-4°C']
```
#### Trim Temp
`trimTemp`: accepts an array of objects, and returns a new array of objects with the same structure. The `temperature` strings must have their spaces removed in the new array.
- Create a function named `trimTemp` which takes an array of objects
and which removes the spaces from the string in the key `temperature`. \
The function then returns an array of objects with the modification.
#### Example:
```js
trimTemp([
{ city: 'Los Angeles', temperature: ' 101 °F ' },
@ -46,8 +57,9 @@ trimTemp([
] */
```
#### Temp Forecasts
`tempForecasts`: accepts an array of objects, and returns an array of formatted strings. See the example below:
- Create a `tempForecasts` function which will take an array of objects, and which will
return an array of strings formatted as below:
```js
tempForecasts([
{
@ -59,7 +71,11 @@ tempForecasts([
]) // -> ['38°Celsius in Pasadena, California']
```
#### Special instruction
The goal of this exercise is to learn to use `map`, as such all your
solution **MUST** use `map`
### Notions
- [Array.prototype.map](https://devdocs.io/javascript/global_objects/array/map)
- [devdocs.io/javascript/global_objects/array/map](https://devdocs.io/javascript/global_objects/array/map)

31
subjects/using-reduce/README.md

@ -2,24 +2,33 @@
### Instructions
Create the following functions:
Create three functions :
> Your solutions **must** use `reduce`.
- `adder` that receives an array and adds its elements.
- `adder`: accepts an array of numbers, and returns the sum as a `number`.
- `sumOrMul` that receives an array and adds or multiplies its elements
depending on whether the element is an odd or an even number, where:
- even = multiply
- odd = add
- `sumOrMul`: accepts an array of numbers and adds or multiplies its elements depending on whether the element is odd or even. Even = multiply. Odd = add.
- `funcExec` that receives an array of functions and executes them.
- `funcExec`: accepts an array of functions and executes them using `reduce`, returning the result.
All functions may or may not receive an extra argument that should be the
initial value for the functions execution.
> Each function may accept an optional argument, which should be the initial value for the function's execution.
#### Example:
Example:
```js
sumOrMul([1, 2, 3, 5, 8], 5) // (((((5 + 1) * 2) + 3) + 5) * 8) -> 160
```
sumOrMul([1, 2, 3, 5, 8], 5)
// -> ((((5 + 1) * 2) + 3) + 5) * 8
// -> 160
````
#### Special instruction
The goal of this exercise is to learn to use `reduce`, as such all your
solution **MUST** use `reduce`
### Notions
- [Array.prototype.reduce](https://devdocs.io/javascript/global_objects/array/reduce)
- [devdocs.io/javascript/global_objects/array/reduce](https://devdocs.io/javascript/global_objects/array/reduce)

53
subjects/where-do-we-go/README.md

@ -2,47 +2,42 @@
### Instructions
Where will you go on your next holiday?
Let's make a page to index your options, so that next time you ask yourself that question, you'll be ready with some ideas.
Create a function named `explore`, which creates a page displaying the list of `places` provided in the data file below.
- sort the `places` from north to south, so that the northern-most place is first.
- display a fullscreen-size `<section>` for each place. Use the pics hosted in the `./where-do-we-go_images` folder below. Set the `background` attribute with the corresponding image URL. The URL has to be formatted like so: `./where-do-we-go_images/name-of-the-place.jpg`.
- display a location indicator as an `<a>` tag in the middle of the screen. It should:
- have the class `location`
- display the `name` and `coordinates` of the current place, as text strings separated by `\n`.
- set the text color as `color`.
- update the `name`, `coordinates` and `color` on scroll, at the point when the next image reaches the middle of the screen height.
- make the `href` attribute open **a new tab** redirecting to a Google Maps URL with the coordinates of the place currently displayed.
- display a compass as a `div` tag, indicating the latitude direction which:
Tired of staying home for too long, you decide to develop a page to index ideas for your next travel destinations, so that next time you'll ask yourself 'Where do we go?', you won't need to get lost for 3 hours!
Write the function `explore` which creates a page displaying the list of `places` provided in the data file below:
- sort the `places` from the Northest to the Southest
- display a fullscreen-size `<section>` for each place ; use the pics hosted in the `./where-do-we-go_images` folder (find the download link below) to set the `background` attribute with the corresponding image URL. The URL has to be formatted like so: `./where-do-we-go_images/name-of-the-place.jpg`
- display a location indicator as a `<a>` tag in the middle of the screen which:
- has the class `location`
- displays as text strings separated by `\n`, the `name` and the `coordinates` of the current place featured in the image
- using the corresponding `color` as text color
- updates the `name`, `coordinates` and `color` on scroll, when the top of the next image reaches the middle of the screen height
- has the `href` attribute set to open **a new tab** redirecting to a Google Maps' URL with the coordinates of the place currently displayed
- display a compass as a `div` tag indicating the latitude direction which:
- has the class `direction`
- displays `N` for North if the user is scrolling up
- displays `S` for South if he's scrolling down
### Notions
- [Scroll event](https://developer.mozilla.org/en-US/docs/Web/API/Element/scroll_event)
- [`window`](https://developer.mozilla.org/en-US/docs/Web/API/Window): [`innerHeight`](https://developer.mozilla.org/en-US/docs/Web/API/Window/innerHeight), [`scrollY`](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY), [`pageYOffset`](https://developer.mozilla.org/en-US/docs/Web/API/Window/pageYOffset)
- Take a look at the [DMS coordinates system](https://en.wikipedia.org/wiki/Decimal_degrees)
### Files
You only need to create & submit the JS file `where-do-we-go.js`; we're providing you the following files to download and test test locally:
You only need to create & submit the JS file `where-do-we-go.js` ; we're providing you the following files to download (click right and save link) & test locally:
- the HTML file [where-do-we-go.html](./where-do-we-go.html) to open in the browser, which includes:
- 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 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 data file [where-do-we-go.data.js](./where-do-we-go.data.js) from which you can import `places`.
- the data file [where-do-we-go.data.js](./where-do-we-go.data.js) from which you can import `places`
- the images to use, in this [compressed folder](https://assets.01-edu.org/where-do-we-go_images.zip).
- the images to use, in this [compressed folder](https://assets.01-edu.org/where-do-we-go_images.zip)
### Expected result
You can see an example of the expected result [here](https://youtu.be/BLxNi1WH6_0)
### Notions
- [Scroll event](https://developer.mozilla.org/en-US/docs/Web/API/Element/scroll_event)
- [window](https://developer.mozilla.org/en-US/docs/Web/API/Window)
- [innerHeight](https://developer.mozilla.org/en-US/docs/Web/API/Window/innerHeight)
- [scrollY](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY)
- [pageYOffset](https://developer.mozilla.org/en-US/docs/Web/API/Window/pageYOffset)
- Take a look at the [DMS coordinates system](https://en.wikipedia.org/wiki/Decimal_degrees)

Loading…
Cancel
Save