aboutsummaryrefslogtreecommitdiff
path: root/challenge-275/luca-ferrari/python/ch-1.py
blob: f131b1e6020e4df716b9214591f15b6c65b6e5f8 (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
29
30
31
32
33
34
#!python

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

import sys

# task implementation
# the return value will be printed
def task_1( args ):
    sentence = args[ 0 ]
    keys     = args[ 1: ]
    words_ok = 0

    for word in sentence.lower().split():
        bad = 0
        for k in keys:
            k = k.lower()
            if k in word:
                bad += 1
                break

        if bad == 0:
            words_ok += 1

    return words_ok

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