diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2024-07-16 11:48:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-16 11:48:42 +0100 |
| commit | c65f28455c8900599032071d018e679d67cbee1f (patch) | |
| tree | 086b3286d7c97a8cda6bb7057e8d3e072fc40cd0 /challenge-278/luca-ferrari/python/ch-2.py | |
| parent | 452785082337f497c33a2f9ce1ed96b35d9a3d4c (diff) | |
| parent | d5c82371fcc0e58f01b3457e71d7fff99a709eb4 (diff) | |
| download | perlweeklychallenge-club-c65f28455c8900599032071d018e679d67cbee1f.tar.gz perlweeklychallenge-club-c65f28455c8900599032071d018e679d67cbee1f.tar.bz2 perlweeklychallenge-club-c65f28455c8900599032071d018e679d67cbee1f.zip | |
Merge pull request #10446 from fluca1978/PWC278
PWC 278
Diffstat (limited to 'challenge-278/luca-ferrari/python/ch-2.py')
| -rw-r--r-- | challenge-278/luca-ferrari/python/ch-2.py | 33 |
1 files changed, 33 insertions, 0 deletions
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 <https://perlweeklychallenge.org/blog/perl-weekly-challenge-278> +# + +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: ] ) ) |
