From d5c82371fcc0e58f01b3457e71d7fff99a709eb4 Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Mon, 15 Jul 2024 12:24:13 +0200 Subject: PWC 278 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-278/luca-ferrari/python/ch-2.py | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 challenge-278/luca-ferrari/python/ch-2.py (limited to 'challenge-278/luca-ferrari/python/ch-2.py') diff --git a/challenge-278/luca-ferrari/python/ch-2.py b/challenge-278/luca-ferrari/python/ch-2.py new file mode 100644 index 0000000000..f82d4cf753 --- /dev/null +++ b/challenge-278/luca-ferrari/python/ch-2.py @@ -0,0 +1,33 @@ +#!python + +# +# Perl Weekly Challenge 278 +# Task 2 +# +# See +# + +import sys + +# task implementation +# the return value will be printed +def task_2( args ): + word = args[ 0 ] + c = args[ 1 ] + + if not c in word: + return word + + left = [] + + for x in word: + left.append( x ) + if x == c: + break + + return ''.join( list( sorted( left ) ) ) + word[ len( left ) : len( word ) ] + + +# invoke the main without the command itself +if __name__ == '__main__': + print( task_2( sys.argv[ 1: ] ) ) -- cgit