blob: f725ab5315fc3284173ec2fdb3dcc8361df71e3e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
## strInput = "abccccd" ## Example 1
## strInput = "aaabcddddeefff" ## Example 2
strInput = "abcdd" ## Example 3
arrOutput = []
strTemp = ""
for charLoop in strInput:
if not strTemp:
strTemp = charLoop
elif strTemp[-1] == charLoop:
strTemp = strTemp + charLoop
else:
if len(strTemp) >= 3:
arrOutput.append(strTemp)
strTemp = charLoop
if len(strTemp) >= 3:
arrOutput.append(strTemp)
print (arrOutput)
|