密码要求:
1.长度超过8位
2.包括大小写字母.数字.其它符号,以上四种至少三种
3.不能有长度大于2的包含公共元素的子串重复 (注:其他符号不含空格或换行)
数据范围:输入的字符串长度满足 1 \le n \le 100 \1≤n≤100
一组字符串。
如果符合要求输出:OK,否则输出NG
输入:
021Abc9000 021Abc9Abc1 021ABC9000 021$bc9000
复制输出:
OK NG NG OK
- while(line = readline()){
- if(line.length < 9){
- print('NG');
- continue;
- }
- if(isRepeat(line)){
- var count = 0;
- if((/[A-Z]/g).test(line)) count++;
- if((/[a-z]/g).test(line)) count++;
- if((/[\d]/g).test(line)) count++;
- if((/[^a-zA-Z0-9]/g).test(line) && !((/[ ]|[\r\n]/g).test(line))) count++;
- if(count >= 3){
- print('OK');
- }else{
- print('NG');
- }
- }else{
- print('NG');
- }
- }
- function isRepeat(line){
- for(var i = 0; i < line.length - 2; i ++){
- let sub = line.substring(i, i+3);
- let str = line.substring(i+3)
- if(str.indexOf(sub) > -1){
- return false;
- }
- }
- return true;
- }