-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
45 lines (36 loc) · 1.11 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const solve = (size) => {
const top = Array.from(
{ length: size },
(_, index) => ' '.repeat(size - index - 1) + '/\\'.repeat(index + 1) + '_\\'.repeat(size),
);
const bottom = Array.from(
{ length: size },
(_, index) => ' '.repeat(index) + '\\/'.repeat(size - index) + '_/'.repeat(size),
);
return [...top, ...bottom].join('\n');
};
/*
// 100 score
const solve = (size) = >{
const box = new Array(size * 2);
for (let index = 0; index < size; index++) {
const bottom = size * 2 - index - 1;
box[index] = ' '.repeat(size - index - 1) + '/\\'.repeat(index + 1) + '_\\'.repeat(size);
box[bottom] = ' '.repeat(size - index - 1) + '\\/'.repeat(index + 1) + '_/'.repeat(size);
}
return box.join('\n');
}
*/
/*
//160 score
const solve = (size) => {
const top = [];
const bottom = [];
for (let index = 0; index < size; index++) {
top.push(' '.repeat(size - index - 1) + '/\\'.repeat(index + 1) + '_\\'.repeat(size));
bottom.push(' '.repeat(index) + '\\/'.repeat(size - index) + '_/'.repeat(size));
}
return [...top, ...bottom].join('\n');
}
*/
module.exports = { solve };