aboutsummaryrefslogtreecommitdiff
path: root/challenge-278/luca-ferrari/python/ch-2.py
diff options
context:
space:
mode:
authorDave Jacoby <jacoby.david@gmail.com>2024-07-16 13:05:06 -0400
committerDave Jacoby <jacoby.david@gmail.com>2024-07-16 13:05:06 -0400
commitf1ca8f7ac614d1b7cdc97a4284cfa710ab60f6c6 (patch)
treef601757a365713812e069bd9f49d0ad05046fa41 /challenge-278/luca-ferrari/python/ch-2.py
parent99b5231db016ad59d74ae19ab4f706dab31e9207 (diff)
parentdd7b7f3344a33d4c8f1b6947e58eeb2ba02f84f3 (diff)
downloadperlweeklychallenge-club-f1ca8f7ac614d1b7cdc97a4284cfa710ab60f6c6.tar.gz
perlweeklychallenge-club-f1ca8f7ac614d1b7cdc97a4284cfa710ab60f6c6.tar.bz2
perlweeklychallenge-club-f1ca8f7ac614d1b7cdc97a4284cfa710ab60f6c6.zip
Merge branch 'master' of https://github.com/manwar/perlweeklychallenge-club
Diffstat (limited to 'challenge-278/luca-ferrari/python/ch-2.py')
-rw-r--r--challenge-278/luca-ferrari/python/ch-2.py33
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: ] ) )