-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunnyString.js
36 lines (33 loc) · 887 Bytes
/
funnyString.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
function processData(input) {
//Enter your code here
input = input.split("\n");
var n = parseInt(input[0]);
input.shift();
var str = "";
var rev = "";
for(var i = 0; i < n; i++){
var count = 0;
str = input[i];
rev = str.split("").reverse().join("");
for(var j = 1; j < str.length; j++){
if(Math.abs(str.charCodeAt(j) - str.charCodeAt(j-1)) != Math.abs(rev.charCodeAt(j) - rev.charCodeAt(j-1))){
count++;
break;
}
}
if(count){
console.log("Not Funny")
} else{
console.log("Funny");
}
}
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
_input += input;
});
process.stdin.on("end", function () {
processData(_input);
});