diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2024-08-02 09:52:11 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-02 09:52:11 +0100 |
| commit | 1d4f26465d71bbf664717f1dcdbc4dc03e8a92fa (patch) | |
| tree | 65d4f82a408dae2a8ec2783f2bbc9fd91e9be3c4 /challenge-280/packy-anderson/python/ch-2.py | |
| parent | e712b5491ed008a9e318935fc5d0f11b07b16f54 (diff) | |
| parent | b863d69689ab5c27820954f0534d8b47a2c7bd86 (diff) | |
| download | perlweeklychallenge-club-1d4f26465d71bbf664717f1dcdbc4dc03e8a92fa.tar.gz perlweeklychallenge-club-1d4f26465d71bbf664717f1dcdbc4dc03e8a92fa.tar.bz2 perlweeklychallenge-club-1d4f26465d71bbf664717f1dcdbc4dc03e8a92fa.zip | |
Merge pull request #10530 from packy/master
Challenge 280 solutions by Packy Anderson
Diffstat (limited to 'challenge-280/packy-anderson/python/ch-2.py')
| -rwxr-xr-x | challenge-280/packy-anderson/python/ch-2.py | 21 |
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") |
