Browse Source

Merge branch '01-edu:master' into master

content-update
nik-don 3 years ago committed by GitHub
parent
commit
b80441a346
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 193
      js/tests/diamon_test.js
  2. 48
      subjects/ascii-art/fs/audit.md
  3. 2
      subjects/ascii-art/reverse/audit.md
  4. 16
      subjects/ascii-art/reverse/example.md
  5. 32
      subjects/diamon/README.md
  6. 2
      subjects/give-back/README.md
  7. 10
      subjects/using-reduce/README.md

193
js/tests/diamon_test.js

@ -0,0 +1,193 @@
export const tests = []
const t = f => tests.push(f)
t(({ code }) => code.split('\n').filter(s => s.trim()).length < 78)
t(({ code }) => !code.includes('$'))
t(({ eq }) => eq(diamon('x', 1)), $a.trim())
t(({ eq }) => eq(diamon('x', 2)), $b.trim())
t(({ eq }) => eq(diamon('x', 3)), $c.trim())
t(({ eq }) => eq(diamon('<>', 4)), $d.trim())
t(({ eq }) => eq(diamon('#', 40)), $e.trim())
t(({ eq }) => eq(diamon('{}', 12)), $f.trim())
t(({ eq }) => eq(diamon('ABC', 7)), $g.trim())
t(({ eq }) => eq(diamon('<^>', 13)), $h.trim())
Object.freeze(tests)
const $a = `x`
const $b = `
x
xxx
x
`
const $c = `
x
xxx
xxxxx
xxx
x
`
const $d = `
<>
<><><>
<><><><><>
<><><><><><><>
<><><><><>
<><><>
<>
`
const $e = `
#
###
#####
#######
#########
###########
#############
###############
#################
###################
#####################
#######################
#########################
###########################
#############################
###############################
#################################
###################################
#####################################
#######################################
#########################################
###########################################
#############################################
###############################################
#################################################
###################################################
#####################################################
#######################################################
#########################################################
###########################################################
#############################################################
###############################################################
#################################################################
###################################################################
#####################################################################
#######################################################################
#########################################################################
###########################################################################
#############################################################################
###############################################################################
#############################################################################
###########################################################################
#########################################################################
#######################################################################
#####################################################################
###################################################################
#################################################################
###############################################################
#############################################################
###########################################################
#########################################################
#######################################################
#####################################################
###################################################
#################################################
###############################################
#############################################
###########################################
#########################################
#######################################
#####################################
###################################
#################################
###############################
#############################
###########################
#########################
#######################
#####################
###################
#################
###############
#############
###########
#########
#######
#####
###
#
`
const $f = `
{}
{}{}{}
{}{}{}{}{}
{}{}{}{}{}{}{}
{}{}{}{}{}{}{}{}{}
{}{}{}{}{}{}{}{}{}{}{}
{}{}{}{}{}{}{}{}{}{}{}{}{}
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
{}{}{}{}{}{}{}{}{}{}{}{}{}
{}{}{}{}{}{}{}{}{}{}{}
{}{}{}{}{}{}{}{}{}
{}{}{}{}{}{}{}
{}{}{}{}{}
{}{}{}
{}
`
const $g = `
ABC
ABCABCABC
ABCABCABCABCABC
ABCABCABCABCABCABCABC
ABCABCABCABCABCABCABCABCABC
ABCABCABCABCABCABCABCABCABCABCABC
ABCABCABCABCABCABCABCABCABCABCABCABCABC
ABCABCABCABCABCABCABCABCABCABCABC
ABCABCABCABCABCABCABCABCABC
ABCABCABCABCABCABCABC
ABCABCABCABCABC
ABCABCABC
ABC
`
const $h = `
<^>
<^><^><^>
<^><^><^><^><^>
<^><^><^><^><^><^><^>
<^><^><^><^><^><^><^><^><^>
<^><^><^><^><^><^><^><^><^><^><^>
<^><^><^><^><^><^><^><^><^><^><^><^><^>
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^>
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^>
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^>
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^>
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^>
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^>
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^>
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^>
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^>
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^>
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^>
<^><^><^><^><^><^><^><^><^><^><^><^><^>
<^><^><^><^><^><^><^><^><^><^><^>
<^><^><^><^><^><^><^><^><^>
<^><^><^><^><^><^><^>
<^><^><^><^><^>
<^><^><^>
<^>
`

48
subjects/ascii-art/fs/audit.md

@ -105,14 +105,14 @@ o \ / $
##### Try passing as arguments `"ABCDEFGHIJKLMNOPQRSTUVWXYZ" shadow | cat -e`
```
$
_|_| _|_|_| _|_|_| _|_|_| _|_|_|_| _|_|_|_| _|_|_| _| _| _|_|_| _| _| _| _| _| _| _| _| _|_| _|_|_| _|_| _|_|_| _|_|_| _|_|_|_|_| _| _| _| _| _| _| _| _| _| _| _|_|_|_|_| $
_| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _|_| _|_| _|_| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| $
_|_|_|_| _|_|_| _| _| _| _|_|_| _|_|_| _| _|_| _|_|_|_| _| _| _|_| _| _| _| _| _| _| _| _| _| _|_|_| _| _|_| _|_|_| _|_| _| _| _| _| _| _| _| _| _| _| _| $
_| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| $
_| _| _|_|_| _|_|_| _|_|_| _|_|_|_| _| _|_|_| _| _| _|_|_| _|_| _| _| _|_|_|_| _| _| _| _| _|_| _| _|_| _| _| _| _|_|_| _| _|_| _| _| _| _| _| _| _|_|_|_|_| $
$
$
$
_|_| _|_|_| _|_|_| _|_|_| _|_|_|_| _|_|_|_| _|_|_| _| _| _|_|_| _| _| _| _| _| _| _| _| _|_| _|_|_| _|_| _|_|_| _|_|_| _|_|_|_|_| _| _| _| _| _| _| _| _| _| _| _|_|_|_|_| $
_| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _|_| _|_| _|_| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| $
_|_|_|_| _|_|_| _| _| _| _|_|_| _|_|_| _| _|_| _|_|_|_| _| _| _|_| _| _| _| _| _| _| _| _| _| _|_|_| _| _|_| _|_|_| _|_| _| _| _| _| _| _| _| _| _| _| _| $
_| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| $
_| _| _|_|_| _|_|_| _|_|_| _|_|_|_| _| _|_|_| _| _| _|_|_| _|_| _| _| _|_|_|_| _| _| _| _| _|_| _| _|_| _| _| _| _|_|_| _| _|_| _| _| _| _| _| _| _|_|_|_|_| $
$
$
```
###### Does it display the string in the right template as an ASCII art representation as shown above?
@ -120,14 +120,14 @@ _| _| _|_|_| _|_|_| _|_|_| _|_|_|_| _| _|_|_| _| _| _|_|_|
##### Try passing as arguments `"\"#$%&/()*+,-./" thinkertoy | cat -e`
```
| | $
| | | | -O-O- O o / \ o | o o $
-O-O- o | | o / o / o o \|/ | / $
| | -O-O- / /| o | | --O-- -o- o $
-O-O- | | o / o o-O- / o o /|\ | o-o / $
| | -O-O- O | o \ / o | o o O o $
| | | $
$
o o | | $
| | | | -O-O- O o / \ o | o o $
-O-O- o | | o / o / o o \|/ | / $
| | -O-O- / /| o | | --O-- -o- o $
-O-O- | | o / o o-O- / o o /|\ | o-o / $
| | -O-O- O | o \ / o | o o O o $
| | | $
$
```
###### Does it display the string in the right template as an ASCII art representation as shown above?
@ -135,14 +135,14 @@ _| _| _|_|_| _|_|_| _|_|_| _|_|_|_| _| _|_|_| _| _| _|_|_|
##### Try passing as arguments `"It's Working" thinkertoy | cat -e`
```
o $
o-O-o o | o o o $
| | | | | / o $
| -o- o-o o o o o-o o-o OO o-o o--o $
| | \ \ / \ / | | | | \ | | | | | $
o-O-o o o-o o o o-o o o o | o o o--O $
| $
o--o $
o $
o-O-o o | o o o $
| | | | | / o $
| -o- o-o o o o o-o o-o OO o-o o--o $
| | \ \ / \ / | | | | \ | | | | | $
o-O-o o o-o o o o-o o o o | o o o--O $
| $
o--o $
```
###### Does it display the string in the right template as an ASCII art representation as shown above?

2
subjects/ascii-art/reverse/audit.md

@ -32,7 +32,7 @@ EX: go run . --reverse=<fileName>
##### Try passing to the reverse flag `"--reverse=example03.txt"` the [example 03](example.md).
`(somthing&234)`
`something&234`
###### Does it display the value above?

16
subjects/ascii-art/reverse/example.md

@ -76,14 +76,14 @@ $
### example05
```console
__ _ _ _ _ _ _ _ __ _ __ __ _ __ $
\ \ | | ( | ) _| || |_ | | (_) / / ___ ( ) / / \ \ /\| |/\ _ / / $
\ \ | | V V |_ __ _| / __) / / ( _ ) |/ | | | | \ ` ' / _| |_ ______ / / $
\ \ | | _| || |_ \__ \ / / / _ \/\ | | | | |_ _| |_ _| |______| / / $
\ \ |_| |_ __ _| ( / / / _ | (_> < | | | | / , . \ |_| _ _ / / $
\_\ (_) |_||_| |_| /_/ (_) \___/\/ | | | | \/|_|\/ ( ) (_) /_/ $
\_\ /_/ |/ $
$
__ _ _ _ _ _ _ _ __ _ __ __ _ __ $
\ \ | | ( | ) _| || |_ | | (_) / / ___ ( ) / / \ \ /\| |/\ _ / / $
\ \ | | V V |_ __ _| / __) / / ( _ ) |/ | | | | \ ` ' / _| |_ ______ / / $
\ \ | | _| || |_ \__ \ / / / _ \/\ | | | | |_ _| |_ _| |______| / / $
\ \ |_| |_ __ _| ( / / / _ | (_> < | | | | / , . \ |_| _ _ / / $
\_\ (_) |_||_| |_| /_/ (_) \___/\/ | | | | \/|_|\/ ( ) (_) /_/ $
\_\ /_/ |/ $
$
$
```

32
subjects/diamon/README.md

@ -1,3 +1,33 @@
## 🌟 Diamon
diamon (pyramid + reversed pyramid)
### Instructions
Create a `diamon` function that takes a string and a number as parameters
and returns a diamond shape constructed by 2 arguments:
- the characters (as a string) to be repeated
- the size of a side (as a number)
It is just like pyramid + a reversed pyramid
### Output example
- `*` character and side of 5 :
```
*
***
*****
*******
*********
*******
*****
***
*
```
> No new line in last line
### Notions
- [nan-academy.github.io/js-training/examples/loops](https://nan-academy.github.io/js-training/examples/loops.js)
- [nan-academy.github.io/js-training/examples/recursion](https://nan-academy.github.io/js-training/examples/recursion.js)

2
subjects/give-back/README.md

@ -2,7 +2,7 @@
### Instruction
Declare an `giveBack` function an argument and return a new function that when
Declare a `giveBack` function which takes an argument and returns a new function that when
called will return the argument of the `giveBack` function
### Usage

10
subjects/using-reduce/README.md

@ -7,7 +7,9 @@ Create three functions :
- `adder` that receives an array and adds its elements.
- `sumOrMul` that receives an array and adds or multiplies its elements
depending on whether the element is an odd or an even number.
depending on whether the element is an odd or an even number, where:
- even = multiply
- odd = add
- `funcExec` that receives an array of functions and executes them.
@ -17,9 +19,9 @@ initial value for the functions execution.
Example:
```js
sumOrMul([1, 2, 3, 4], 5)
// -> (((5 + 1) * 2) + 3) * 4
// -> 60
sumOrMul([1, 2, 3, 5, 8], 5)
// -> ((((5 + 1) * 2) + 3) + 5) * 8
// -> 160
````
#### Special instruction

Loading…
Cancel
Save