blob: bdbf0cbfc0ba57ae0076b7f513809481a2b38245 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#!/usr/bin/env python
from collections import Counter
import re
def countAsterisks(str):
count = Counter(re.sub(r'\|[^|]+\|', '', str))
return count["*"]
def solution(str):
print(f'Input: $str = "{str}"')
print(f'Output: {countAsterisks(str)}')
print('Example 1:')
solution("p|*e*rl|w**e|*ekly|")
print('\nExample 2:')
solution("perl")
print('\nExample 3:')
solution("th|ewe|e**|k|l***ych|alleng|e")
|