This repository has been archived by the owner. It is now read-only.
Permalink
Newer
100644
40 lines (38 sloc)
1.06 KB
1
///////////////////////////////////////
2
// Try CodeIQ Q3458
3
// author: Leonardone @ NEETSDKASU
4
// (TypeScript -> JavaScript(Node.js))
5
///////////////////////////////////////
6
7
function solve(lines: string[]): void {
8
const N = parseInt(lines[0].trim(), 10);
9
if (N % 2 === 0) {
10
console.log('invalid');
11
return;
12
}
13
function repeat(s: string, c: number): string {
14
let ret: string[] = [];
15
for (let i = 0; i < c; i++) { ret[i] = s; }
16
return ret.join('');
17
}
18
const ALLP = repeat('p', N);
19
const TWOP = 'p' + repeat('.', N - 2) + 'p';
20
const ONEP = 'p' + repeat('.', N - 1);
21
for (let i = 0; i < N; i++) {
22
if (i === 0 || i === N >> 1) {
23
console.log(ALLP);
24
} else {
25
console.log(i + i < N ? TWOP : ONEP);
26
}
27
}
28
}
29
30
let buf = '';
31
process.stdin.setEncoding('utf8');
32
process.stdin.on('readable', () => {
33
const s: Buffer | string | null = process.stdin.read();
34
if (s !== null) {
35
buf += s.toString();
36
}
37
});
38
process.stdin.on('end', () => {
39
solve(buf.trim().split("\n"));
40
});