Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit aad7abf

Browse files
Create Funny-String.py
1 parent eb043fa commit aad7abf

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

‎String/Funny-String.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/python3
2+
3+
import math
4+
import os
5+
import random
6+
import re
7+
import sys
8+
9+
# Complete the funnyString function below.
10+
def funnyString(s):
11+
r=s[::-1]
12+
l1=[ord(i) for i in r]
13+
l2=[ord(j) for j in s]
14+
l3= [ abs(l1[i+1]-l1[i]) for i in range(0,len(l1)-2)]
15+
l4= [ abs(l2[i+1]-l2[i]) for i in range(0,len(l2)-2)]
16+
for i,j in zip(l3,l4):
17+
if i!=j:
18+
return "Not Funny"
19+
return "Funny"
20+
#for i,j in r,s:
21+
# l1.append(ord(i))
22+
# l2.append(ord(j))
23+
24+
if __name__ == '__main__':
25+
fptr = open(os.environ['OUTPUT_PATH'], 'w')
26+
27+
q = int(input())
28+
29+
for q_itr in range(q):
30+
s = input()
31+
32+
result = funnyString(s)
33+
34+
fptr.write(result + '\n')
35+
36+
fptr.close()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /