Compare commits

...

69 Commits

Author SHA1 Message Date
MSilva95 eb95584405 small fix 2 years ago
Hamza elkhatri 3bdf80b9c6 Update README.md 2 years ago
Hamza elkhatri 216b1a9efa rewrite description 2 years ago
hamza e0693e278a add(subject):getarea 2 years ago
davhojt 25400daa15 docs(ultimatedivmod): correct grammar 2 years ago
estlop 7e4af38af0 chore: Format with prettier 2 years ago
estlop 7c304d8b30 docs: Update audit file to include example with contiguous new line characters 2 years ago
estlop f740ba0a03 docs: Update description to include example with contiguous new line characters 2 years ago
estlop 3097cd47f3 docs: Add what to do when string is empty as per review 2 years ago
estlop f5679a6ca6 docs: Add readme for ascii subject 2 years ago
Dav Hojt fcc042a38e
Update README.md 2 years ago
davhojt c84959b8ba docs(manipulate-values): fix typo 2 years ago
Hamza elkhatri 5cbf005b3b Update README.md 2 years ago
Hamza elkhatri fbb90f82d2 Update README.md 2 years ago
hamza 66624b671d add(subject): print-ascii 2 years ago
Hamza elkhatri 69b19b2269 Update README.md 2 years ago
hamza 69245b40ba fix name of file 2 years ago
hamza 016714770e fix output 2 years ago
hamza 3266406fb2 subject(communmultiple):add readme 2 years ago
Hamza elkhatri 54c5214072 Update README.md 2 years ago
hamza 1d8cacc5c6 subject(Count-Negative):add readme 2 years ago
davhojt 9fd8117c3b docs(clonernews): correct audit grammar 2 years ago
davhojt 36a9dc25e2 docs(clonernews): correct subject grammar 2 years ago
davhojt 9e13f453a6 docs(race): correct grammar 2 years ago
davhojt 8e1024a6a3 docs(series): correct grammar 2 years ago
davhojt 0eb520dad0 docs(all): correct grammar 2 years ago
davhojt 44cfb248db docs(gougle-search): correct grammar 2 years ago
davhojt 5e8ef51a75 docs(is-winner): correct grammar 2 years ago
hamza f8a9d72f0a Subject(rot-arg-n):add README 2 years ago
Hamza elkhatri abbfbd4031 Update README.md 2 years ago
Hamza elkhatri ad23781b3b Update README.md 2 years ago
hamza 1fb9df9b5b add(subject):leap year 2 years ago
Hamza elkhatri 2e04c1e2ba Update README.md 2 years ago
Hamza elkhatri e8a3809405 Update README.md 2 years ago
Hamza elkhatri 6f590b8f6e Update README.md 2 years ago
Hamza elkhatri 2f7f49f495 Update README.md 2 years ago
hamza 6b4208a56e add usage 2 years ago
hamza 89394634fd subject(binaryaddition):add readmed 2 years ago
zainabdnaya 241dcf3b70 Devisors 2 years ago
zainabdnaya c7e4e42d0a devisors 2 years ago
zainabdnaya 310d16d23d feat:Add test cases 2 years ago
zainabdnaya 294315a72b feat : Add devisors subject 2 years ago
Hamza elkhatri fbb007535d Update README.md 2 years ago
Hamza elkhatri 745609bf47 Update README.md 2 years ago
Hamza elkhatri d6544fb2db Update README.md 2 years ago
hamza 9fc547d843 subject(param_range):add Readme 2 years ago
Hamza elkhatri 4ed04e41ec Update README.md 2 years ago
Hamza elkhatri c8f6198854 Update README.md 2 years ago
hamza ba97b8f27b subject(SumArray):add readme 2 years ago
Hamza elkhatri 084e1decc3 Update README.md 2 years ago
Hamza elkhatri 0344c096fd Update README.md 2 years ago
hamza bedf3d69ff subject(Add-if-positive):add readme 2 years ago
Hamza elkhatri 3130318a76 Update README.md 2 years ago
Hamza elkhatri d66915e3b0 Update README.md 2 years ago
Hamza elkhatri 1727ae0d86 Update README.md 2 years ago
hamza 270e1f370b add(subject): add subject betweenus 2 years ago
Hamza elkhatri 9fed0ac66a Update README.md 2 years ago
Hamza elkhatri d119045dc5 Update README.md 2 years ago
hamza 97464fd121 add(subject): alphaPostion 2 years ago
zoevig 2cc51d266a
Small typo correction 2 years ago
davidrobert99 3d7ff3c1d3 update ref_cell 2 years ago
davhojt bf06961810 docs(get-json): correct grammar 2 years ago
davhojt a55dccefd6 docs(keep-trying-or-giveup): correct grammar 2 years ago
davhojt 6327a1e6bb docs(interpolation): correct grammar 2 years ago
davhojt 1ec58a46e4 docs(throttle): correct grammar 2 years ago
davhojt d043c1544d docs(debounce): correct grammar 2 years ago
davhojt 3b53b3dfca docs(events): make small changes to @Zewasik #1225 2 years ago
Zewasik e7dde746f6 updated description to fit the task 2 years ago
Maxim Mihajlov 7a0e6fcdc0 Update README.md for roman_numbers_iter 2 years ago
  1. 2
      README.md
  2. 43
      subjects/addifpositive/README.md
  3. 15
      subjects/all/README.md
  4. 46
      subjects/alphaposition/README.md
  5. 43
      subjects/arraysum/README.md
  6. 18
      subjects/ascii-art/README.md
  7. 24
      subjects/ascii-art/audit/README.md
  8. 38
      subjects/ascii/README.md
  9. 46
      subjects/betweenus/README.md
  10. 47
      subjects/binaryaddition/README.md
  11. 27
      subjects/clonernews/README.md
  12. 18
      subjects/clonernews/audit/README.md
  13. 40
      subjects/countnegative/README.md
  14. 10
      subjects/debounce/README.md
  15. 41
      subjects/divisors/README.md
  16. 36
      subjects/events/README.md
  17. 27
      subjects/get-json/README.md
  18. 25
      subjects/getarea/README.md
  19. 36
      subjects/gougle-search/README.md
  20. 17
      subjects/interpolation/README.md
  21. 22
      subjects/is-winner/README.md
  22. 45
      subjects/ismultiple/README.md
  23. 32
      subjects/keep-trying-or-giveup/README.md
  24. 41
      subjects/leapyear/README.md
  25. 2
      subjects/manipulate-values/README.md
  26. 20
      subjects/paramrange/README.md
  27. 23
      subjects/printascii/README.md
  28. 20
      subjects/race/README.md
  29. 12
      subjects/ref_cell/README.md
  30. 2
      subjects/roman_numbers_iter/README.md
  31. 27
      subjects/rotargn/README.md
  32. 5
      subjects/series/README.md
  33. 13
      subjects/throttle/README.md
  34. 2
      subjects/tron/audit/README.md
  35. 9
      subjects/ultimatedivmod/README.md

2
README.md

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

43
subjects/addifpositive/README.md

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

15
subjects/all/README.md

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

46
subjects/alphaposition/README.md

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

43
subjects/arraysum/README.md

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

18
subjects/ascii-art/README.md

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

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

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

38
subjects/ascii/README.md

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

46
subjects/betweenus/README.md

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

47
subjects/binaryaddition/README.md

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

27
subjects/clonernews/README.md

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

18
subjects/clonernews/audit/README.md

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

40
subjects/countnegative/README.md

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

10
subjects/debounce/README.md

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

41
subjects/divisors/README.md

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

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`:
- `Remainder(text)`:
- `size`: `50`
- `color`: `(50, 50, 50)`
- `position`: `Bottom`
- `content`: the slice associated to the enum value.
- `content`: the `text` associated to the enum variant
- `Registration(chrono::Duration)`:
- `size`: `30`
- `color`: `(255, 2, 22)`
- `position`: `Top`
- `content`: `"You have {duration} left before the registration ends"`
- `Appointment(text)`
- `size: 100`
- `color: (200, 200, 3)`
- `position: Center`
- `content: text associated to the value`
- `Holiday`
- `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 2 hours, 32 minutes and 3 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 13 hours, 38 minutes and 14 seconds left, then the content will be `"You have 13H:38M:14S left before the registration ends"`
Implement the `std::fmt::Display` trait so the text of the notifications are printed in the right color in the command line.
@ -37,6 +37,8 @@ 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
@ -44,22 +46,22 @@ use chrono::Duration;
use colored::*;
#[derive(Debug, Eq, PartialEq)]
enum Position {
pub enum Position {
Top,
Bottom,
Center,
}
#[derive(Debug, Eq, PartialEq)]
struct Notification {
size: u32,
color: (u8, u8, u8),
position: Position,
content: String,
pub struct Notification {
pub size: u32,
pub color: (u8, u8, u8),
pub position: Position,
pub content: String,
}
#[derive(Debug)]
enum Event<'a> {
pub enum Event<'a> {
Remainder(&'a str),
Registration(Duration),
Appointment(&'a str),
@ -74,7 +76,7 @@ impl fmt::Display for Notification {
use Event::*;
impl Event {
fn notify(&self) -> Notification {
pub fn notify(&self) -> Notification {
}
}
```

27
subjects/get-json/README.md

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

25
subjects/getarea/README.md

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

36
subjects/gougle-search/README.md

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

17
subjects/interpolation/README.md

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

22
subjects/is-winner/README.md

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

45
subjects/ismultiple/README.md

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

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

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

41
subjects/leapyear/README.md

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

2
subjects/manipulate-values/README.md

@ -4,7 +4,7 @@
Let's buy groceries.
You have a grocery cart with some items you need. The item's name if the `key`, and the `value` will represent nutrition facts per 100 grams.
You have a grocery cart with some items you need. The item's name is the `key`, and the `value` will represent nutrition facts per 100 grams.
Create 3 functions that 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.

20
subjects/paramrange/README.md

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

23
subjects/printascii/README.md

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

20
subjects/race/README.md

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

12
subjects/ref_cell/README.md

@ -18,31 +18,35 @@ 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 too X% of your quote"` 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 to X% of your quota"` 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
@ -96,11 +100,11 @@ And its output:
```console
$ cargo run
("Info", "you are using up too 40% of your quote")
("Info", "you are using up to 40% of your quota")
("Warning", "you have used up over 90% of your quota! Proceeds with precaution")
("Error", "you are over your quota!")
[
"Info: you are using up too 40% of your quote",
"Info: you are using up to 40% of your quota",
"Warning: you have used up over 80% of your quota! Proceeds with precaution",
"Warning: you have used up over 90% of your quota! Proceeds with precaution",
"Error: you are over your quota!"

2
subjects/roman_numbers_iter/README.md

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

27
subjects/rotargn/README.md

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

5
subjects/series/README.md

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

13
subjects/throttle/README.md

@ -2,14 +2,13 @@
### Instructions
Create two functions that will work like `_.throttle` from lodash
Create two functions that will work like `_.throttle` from lodash.
- `throttle`, this function doesn't need to take care of the options
- `opThrottle`, this function will take care of
the `trailing` and `leading` options
- `throttle`: don't worry about the options.
- `opThrottle`: implement the `trailing` and `leading` options.
### Notions
- [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)
- [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)

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 won against your AI?
###### +Did the audited AI win against your AI?

9
subjects/ultimatedivmod/README.md

@ -2,7 +2,7 @@
### Instructions
- Write a function that will be formatted as below.
Create the following function.
### Expected function
@ -11,10 +11,9 @@ func UltimateDivMod(a *int, b *int) {
}
```
- 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**.
`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.
### Usage

Loading…
Cancel
Save