From b4722f365b56ebb8a01ce4d4b136f16d26698cd6 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Thu, 15 Feb 2024 19:30:30 +0000 Subject: - Added solutions by Luca Ferrari. - Added solutions by Athanasius. - Added solutions by Laurent Rosenfeld. - Added solutions by Mohammad Meraj Zia. --- challenge-256/luca-ferrari/python/ch-1.py | 26 ++++++++++++++++++++++ challenge-256/luca-ferrari/python/ch-1.python | 26 ---------------------- challenge-256/luca-ferrari/python/ch-2.py | 32 +++++++++++++++++++++++++++ challenge-256/luca-ferrari/python/ch-2.python | 32 --------------------------- 4 files changed, 58 insertions(+), 58 deletions(-) create mode 100644 challenge-256/luca-ferrari/python/ch-1.py delete mode 100644 challenge-256/luca-ferrari/python/ch-1.python create mode 100644 challenge-256/luca-ferrari/python/ch-2.py delete mode 100644 challenge-256/luca-ferrari/python/ch-2.python (limited to 'challenge-256/luca-ferrari/python') diff --git a/challenge-256/luca-ferrari/python/ch-1.py b/challenge-256/luca-ferrari/python/ch-1.py new file mode 100644 index 0000000000..e8456319db --- /dev/null +++ b/challenge-256/luca-ferrari/python/ch-1.py @@ -0,0 +1,26 @@ +#!python + +# +# Perl Weekly Challenge 256 +# Task 1 +# +# See +# + +import sys + +# task implementation +# the return value will be printed +def task_1( args ): + max = 0 + for w in args: + count = len( list( filter( lambda rw: rw == ''.join( reversed( w ) ), args ) ) ) + if count > max: + max = count + + return max + + +# invoke the main without the command itself +if __name__ == '__main__': + print( task_1( sys.argv[ 1: ] ) ) diff --git a/challenge-256/luca-ferrari/python/ch-1.python b/challenge-256/luca-ferrari/python/ch-1.python deleted file mode 100644 index e8456319db..0000000000 --- a/challenge-256/luca-ferrari/python/ch-1.python +++ /dev/null @@ -1,26 +0,0 @@ -#!python - -# -# Perl Weekly Challenge 256 -# Task 1 -# -# See -# - -import sys - -# task implementation -# the return value will be printed -def task_1( args ): - max = 0 - for w in args: - count = len( list( filter( lambda rw: rw == ''.join( reversed( w ) ), args ) ) ) - if count > max: - max = count - - return max - - -# invoke the main without the command itself -if __name__ == '__main__': - print( task_1( sys.argv[ 1: ] ) ) diff --git a/challenge-256/luca-ferrari/python/ch-2.py b/challenge-256/luca-ferrari/python/ch-2.py new file mode 100644 index 0000000000..abf9af51de --- /dev/null +++ b/challenge-256/luca-ferrari/python/ch-2.py @@ -0,0 +1,32 @@ +#!python + +# +# Perl Weekly Challenge 256 +# Task 2 +# +# See +# + +import sys + +# task implementation +# the return value will be printed +def task_2( args ): + left = args[ 0 ] + right = args[ 1 ] + output = '' + + max_index = max( len( left ), len( right ) ) + + for i in range( 0, max_index ): + if i < len( left ): + output += left[ i ] + if i < len( right ): + output += right[ i ] + + return output + + +# invoke the main without the command itself +if __name__ == '__main__': + print( task_2( sys.argv[ 1: ] ) ) diff --git a/challenge-256/luca-ferrari/python/ch-2.python b/challenge-256/luca-ferrari/python/ch-2.python deleted file mode 100644 index abf9af51de..0000000000 --- a/challenge-256/luca-ferrari/python/ch-2.python +++ /dev/null @@ -1,32 +0,0 @@ -#!python - -# -# Perl Weekly Challenge 256 -# Task 2 -# -# See -# - -import sys - -# task implementation -# the return value will be printed -def task_2( args ): - left = args[ 0 ] - right = args[ 1 ] - output = '' - - max_index = max( len( left ), len( right ) ) - - for i in range( 0, max_index ): - if i < len( left ): - output += left[ i ] - if i < len( right ): - output += right[ i ] - - return output - - -# invoke the main without the command itself -if __name__ == '__main__': - print( task_2( sys.argv[ 1: ] ) ) -- cgit