diff options
Diffstat (limited to 'challenge-275/luca-ferrari/python')
| -rw-r--r-- | challenge-275/luca-ferrari/python/ch-1.py | 34 | ||||
| -rw-r--r-- | challenge-275/luca-ferrari/python/ch-2.py | 32 |
2 files changed, 66 insertions, 0 deletions
diff --git a/challenge-275/luca-ferrari/python/ch-1.py b/challenge-275/luca-ferrari/python/ch-1.py new file mode 100644 index 0000000000..f131b1e602 --- /dev/null +++ b/challenge-275/luca-ferrari/python/ch-1.py @@ -0,0 +1,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: ] ) ) diff --git a/challenge-275/luca-ferrari/python/ch-2.py b/challenge-275/luca-ferrari/python/ch-2.py new file mode 100644 index 0000000000..ebe16641b0 --- /dev/null +++ b/challenge-275/luca-ferrari/python/ch-2.py @@ -0,0 +1,32 @@ +#!python + +# +# Perl Weekly Challenge 275 +# Task 2 +# +# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-275> +# + +import sys + +# task implementation +# the return value will be printed +def task_2( args ): + string = args[ 0 ] + previous = None + result = "" + + for c in string: + if c.isdigit(): + c = chr( int( c ) + 97 ) + else: + previous = c + + result += c + + return result + + +# invoke the main without the command itself +if __name__ == '__main__': + print( task_2( sys.argv[ 1: ] ) ) |
