-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path10994.js
More file actions
27 lines (21 loc) · 693 Bytes
/
10994.js
File metadata and controls
27 lines (21 loc) · 693 Bytes
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
const INPUT_FILE = process.platform === 'linux' ? '/dev/stdin' : './input';
const size = Number(require('fs').readFileSync(INPUT_FILE).toString());
const board = Array.from(
new Array(1 + 4 * (size - 1)),
() => new Array(1 + 4 * (size - 1)).fill(' '),
);
const fill = (start, length) => {
if (length === 1) {
board[start][start] = '*';
return;
}
for (let i = 0; i < length; i += 1) {
board[start][start + i] = '*';
board[start + i][start] = '*';
board[start + length - 1][start + i] = '*';
board[start + i][start + length - 1] = '*';
}
fill(start + 2, length - 4);
};
fill(0, board.length);
console.log(board.map((row) => row.join('')).join('\n'));