From e3413e5215e89c8512218669be7701def126c9cd Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Mon, 24 Jun 2024 09:55:54 +0200 Subject: PWC 275 Task 1 Raku done Task 2 Raku done Task 1 PL/Perl done Task 2 PL/Perl done Task 1 PL/PgSQL done Task 2 PL/PgSQL done Task 1 PL/Java done Task 2 PL/Java done Task 1 Python done Task 2 Python done --- challenge-275/luca-ferrari/python/ch-1.py | 34 +++++++++++++++++++++++++++++++ challenge-275/luca-ferrari/python/ch-2.py | 32 +++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 challenge-275/luca-ferrari/python/ch-1.py create mode 100644 challenge-275/luca-ferrari/python/ch-2.py (limited to 'challenge-275/luca-ferrari/python') 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 +# + +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 +# + +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: ] ) ) -- cgit