aboutsummaryrefslogtreecommitdiff
path: root/challenge-280/packy-anderson/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-280/packy-anderson/python/ch-2.py')
-rwxr-xr-xchallenge-280/packy-anderson/python/ch-2.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/challenge-280/packy-anderson/python/ch-2.py b/challenge-280/packy-anderson/python/ch-2.py
new file mode 100755
index 0000000000..bdbf0cbfc0
--- /dev/null
+++ b/challenge-280/packy-anderson/python/ch-2.py
@@ -0,0 +1,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")