-
Notifications
You must be signed in to change notification settings - Fork 0
/
krizaljka.js
52 lines (39 loc) · 1.04 KB
/
krizaljka.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
46
47
48
49
50
51
52
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', function(inputStdin) {
inputString += inputStdin;
});
process.stdin.on('end', function() {
inputString = inputString.split('\n');
main();
});
function readLine() {
return inputString[currentLine++];
}
function main() {
const s = readLine().split(' ');
let row = -1;
let col = -1;
for (let i = 0; i < s[0].length; i++) {
for (let j = 0; j < s[1].length; j++) {
if (s[1][j] === s[0][i]) {
row = j;
col = i;
break;
}
}
if (row !== -1 && col !== -1) break;
}
for (let i = 0; i < s[1].length; i++) {
let out = '';
for (let j = 0; j < s[0].length; j++) {
if (j === col) out += s[1][i];
else if (i === row) out += s[0][j];
else out += '.';
}
console.log(out);
}
}