mirror of https://github.com/01-edu/public.git
![93073558+nik-don@users.noreply.github.com](/git/assets/img/avatar_default.png)
![GitHub](/git/assets/img/avatar_default.png)
7 changed files with 264 additions and 39 deletions
@ -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 = ` |
||||||
|
<^> |
||||||
|
<^><^><^> |
||||||
|
<^><^><^><^><^> |
||||||
|
<^><^><^><^><^><^><^> |
||||||
|
<^><^><^><^><^><^><^><^><^> |
||||||
|
<^><^><^><^><^><^><^><^><^><^><^> |
||||||
|
<^><^><^><^><^><^><^><^><^><^><^><^><^> |
||||||
|
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^> |
||||||
|
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^> |
||||||
|
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^> |
||||||
|
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^> |
||||||
|
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^> |
||||||
|
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^> |
||||||
|
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^> |
||||||
|
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^> |
||||||
|
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^> |
||||||
|
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^><^> |
||||||
|
<^><^><^><^><^><^><^><^><^><^><^><^><^><^><^> |
||||||
|
<^><^><^><^><^><^><^><^><^><^><^><^><^> |
||||||
|
<^><^><^><^><^><^><^><^><^><^><^> |
||||||
|
<^><^><^><^><^><^><^><^><^> |
||||||
|
<^><^><^><^><^><^><^> |
||||||
|
<^><^><^><^><^> |
||||||
|
<^><^><^> |
||||||
|
<^> |
||||||
|
` |
@ -1,3 +1,33 @@ |
|||||||
## 🌟 Diamon |
## 🌟 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) |
||||||
|
Loading…
Reference in new issue