-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1065.js
45 lines (38 loc) · 880 Bytes
/
1065.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
const { triggerAsyncId } = require("async_hooks");
var readline = require("readline");
var r = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let input = [];
r.on("line", function (line) {
input.push(line);
}).on("close", function () {
main(input);
process.exit();
});
function main(input) {
const [N] = input;
let result = 99;
let numArr = N.split('');
if (numArr.length <= 2) {
console.log(N);
return;
}
for (let i = 100; i <= N; i++) {
if (checkDungcha(i.toString())) {
++result;
}
}
console.log(result);
}
function checkDungcha(i) {
let arr = i.toString().split('');
let t = arr[1] - arr[0];
for (let j = 2; j < arr.length; j++) {
if (arr[j] - arr[j - 1] !== t) {
return false;
}
}
return true
}