-
Notifications
You must be signed in to change notification settings - Fork 110
/
solution.cpp
49 lines (34 loc) · 977 Bytes
/
solution.cpp
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
#include <bits/stdc++.h>
using namespace std;
// Implementation Part
string funnyString(string s) {
// make r string as a reverse of s
string r = s;
reverse(r.begin(), r.end());
// traverse each letter of s and r
// taking absolute differnce of both ascii values
// i.e current position and (current - 1)th position
for(int i = 1; i < s.size(); i++){
int diff_s = abs(s[i] - s[i - 1]);
int diff_r = abs(r[i] - r[i - 1]);
// if that differnce not same
if(diff_r != diff_s)
return "Not Funny";
}
return "Funny";
}
int main()
{
ofstream fout(getenv("OUTPUT_PATH"));
int q;
cin >> q;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
for (int q_itr = 0; q_itr < q; q_itr++) {
string s;
getline(cin, s);
string result = funnyString(s);
fout << result << "\n";
}
fout.close();
return 0;
}