
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.on("line", function (line) {
console.log(checkValid(line));
});
function checkValid(str) {
let output = 'OK';
let regex = /^(?![A-Za-z]+$)(?![A-Z\d]+$)(?![A-Z\W]+$)(?![a-z\d]+$)(?![a-z\W]+$)(?![\d\W]+$)\S{8,}$/
if (!str.match(regex)) {
output = 'NG';
}
for (let i = 0; i < str.length-3; i++) {
let newStr1 = str.slice(i, i+3); newStr2 = str.slice(i+3);
if (newStr2.includes(newStr1)) {
output = 'NG';
break;
}
}
return output;
}
密码验证合格程序_牛客题霸_牛客网 (nowcoder.com)