Skip to content

Commit 05f608d

Browse files
committed
74회차 2번 제출
1 parent f23b763 commit 05f608d

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

live7/test74/문제2/이지은.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const input = require('fs')
2+
.readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt')
3+
.toString()
4+
.trim()
5+
.split('\n')
6+
.map(Number);
7+
8+
function solution(input) {
9+
const result = [];
10+
for (let i = 0; i < input.length; i++) {
11+
let n = 3 ** input[i];
12+
let str = '-';
13+
let arr = str.repeat(n);
14+
15+
function three(arr) {
16+
if (arr.length === 1) {
17+
return str;
18+
}
19+
20+
let size = arr.length / 3;
21+
const forward = three(arr.slice(0, size));
22+
const backward = three(arr.slice(size * 2));
23+
24+
return forward + ' '.repeat(size) + backward;
25+
}
26+
result.push(three(arr));
27+
}
28+
return result.join('\n');
29+
}
30+
31+
console.log(solution(input));

0 commit comments

Comments
 (0)