aboutsummaryrefslogtreecommitdiff
path: root/challenge-280/eric-cheung/python/ch-2.py
blob: d7bbc31000dc1e4d3bb1c5e6919e56d6ea5cd9a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
## Ref.
## https://leetcode.ca/2022-07-26-2315-Count-Asterisks/

## strInput = "p|*e*rl|w**e|*ekly|"  ## Example 1
## strInput = "perl"  ## Example 2
strInput = "th|ewe|e**|k|l***ych|alleng|e"  ## Example 3

if strInput.count("|") < 2:
    print (strInput.count("*"))
else:
    arrSplit = strInput.split("|")
    strResult = "".join([arrSplit[nIndx] for nIndx in range(len(arrSplit)) if nIndx % 2 == 0])
    print (strResult.count("*"))