-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path18108 (1998년인 내가 태국에서는 2541년생?!).js
78 lines (70 loc) · 1.54 KB
/
18108 (1998년인 내가 태국에서는 2541년생?!).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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"use strict";
const ps = (function (process) {
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let lines = [];
let cursor = 0;
rl.on("line", function (line) {
lines.push(line);
});
return {
main(f) {
f()
.catch((err) => {
console.error(err);
process.exit(1);
})
.finally(() => {
rl.close();
});
},
use(name, f) {
this[name] = f;
},
readLine: async function readLine() {
return new Promise((resolve) => {
if (cursor < lines.length) {
resolve(lines[cursor++]);
} else {
setTimeout(() =>
readLine().then((line) => {
resolve(line);
})
);
}
});
},
async readArrayLine() {
const line = await this.readLine();
return line.split(/\s/).map((t) => parseInt(t));
},
write(data) {
process.stdout.write(data + "");
},
writeLine(data) {
process.stdout.write((data === undefined ? "" : data) + "\n");
},
range(start, end, step = 1) {
if (end === undefined) {
end = start;
start = 0;
}
return {
[Symbol.iterator]: function* () {
for (let i = start; i < end; i += step) {
yield i;
}
},
};
},
};
})(process);
ps.main(async () => {
/* main logic goes here */
let year = await ps.readLine();
year -= 543;
console.log(year);
});