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 c82c1fe

Browse files
Create Super-Reduced-String.py
1 parent ebceaf7 commit c82c1fe

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

‎String/Super-Reduced-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 superReducedString function below.
10+
def superReducedString(s):
11+
flag=0
12+
for i in range(0,len(s)-1):
13+
if s[i]==s[i+1]:
14+
flag=1
15+
s=s[:i]+s[i+2:]
16+
break
17+
if(flag==1):
18+
s=superReducedString(s)
19+
if(flag==0):
20+
return s
21+
else:
22+
if s=="":
23+
fptr.write("Empty String"+ '\n')
24+
else:
25+
fptr.write(s+'\n')
26+
27+
if __name__ == '__main__':
28+
fptr = open(os.environ['OUTPUT_PATH'], 'w')
29+
30+
s = input()
31+
32+
superReducedString(s)
33+
34+
#fptr.write(result + '\n')
35+
36+
fptr.close()

0 commit comments

Comments
(0)

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