aboutsummaryrefslogtreecommitdiff
path: root/challenge-280/luca-ferrari/python/ch-2.py
blob: 82ff85167f38c7819924e85f4bfc0f0541c6427f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!python

#
# Perl Weekly Challenge 280
# Task 2
#
# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-280>
#

import sys

# task implementation
# the return value will be printed
def task_2( args ):
    pos = 0
    count = 0
    for needle in args[ 0 ]:
        if needle == '|':
            pos += 1
            continue
        elif needle == '*' and pos % 2 != 0:
            count += 1

    return count

# invoke the main without the command itself
if __name__ == '__main__':
    print( task_2( sys.argv[ 1: ] ) )