We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 08c2f86 commit 721c128Copy full SHA for 721c128
1 file changed
checkio/long_repeat.py
@@ -0,0 +1,26 @@
1
+def long_repeat(line):
2
+ """
3
+ length the longest substring that consists of the same char
4
5
+ n=''
6
+ a=''
7
+ for i in line:
8
+ if i!=n:
9
+ n=i
10
+ a=a+','+i
11
+ else :
12
+ a=a+i
13
+ b=a.strip(',').split(',')
14
+ sum=0
15
+ for i in b:
16
+ if sum<len(i):
17
+ sum=len(i)
18
+ # your code here
19
+ return sum
20
+if __name__ == '__main__':
21
+ #These "asserts" using only for self-checking and not necessary for auto-testing
22
+ assert long_repeat('sdsffffse') == 4, "First"
23
+ assert long_repeat('ddvvrwwwrggg') == 3, "Second"
24
+ assert long_repeat('abababaab') == 2, "Third"
25
+ assert long_repeat('') == 0, "Empty"
26
+ print('"Run" is good. How is "Check"?')
0 commit comments