aboutsummaryrefslogtreecommitdiff
path: root/challenge-278/luca-ferrari/python/ch-1.py
diff options
context:
space:
mode:
authorLuca Ferrari <fluca1978@gmail.com>2024-07-15 12:24:13 +0200
committerLuca Ferrari <fluca1978@gmail.com>2024-07-15 14:02:42 +0200
commitd5c82371fcc0e58f01b3457e71d7fff99a709eb4 (patch)
treeaad57e58fecade3d23321171e93767ad9eff1eff /challenge-278/luca-ferrari/python/ch-1.py
parentf1533357698083086127e85e17fd8e2a80780e76 (diff)
downloadperlweeklychallenge-club-d5c82371fcc0e58f01b3457e71d7fff99a709eb4.tar.gz
perlweeklychallenge-club-d5c82371fcc0e58f01b3457e71d7fff99a709eb4.tar.bz2
perlweeklychallenge-club-d5c82371fcc0e58f01b3457e71d7fff99a709eb4.zip
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
Diffstat (limited to 'challenge-278/luca-ferrari/python/ch-1.py')
-rw-r--r--challenge-278/luca-ferrari/python/ch-1.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/challenge-278/luca-ferrari/python/ch-1.py b/challenge-278/luca-ferrari/python/ch-1.py
new file mode 100644
index 0000000000..c2a980ed76
--- /dev/null
+++ b/challenge-278/luca-ferrari/python/ch-1.py
@@ -0,0 +1,30 @@
+#!python
+
+#
+# Perl Weekly Challenge 278
+# Task 1
+#
+# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-278>
+#
+
+import sys
+import re
+
+# task implementation
+# the return value will be printed
+def task_1( args ):
+ sorted_words = {}
+ pattern = re.compile( "^([a-zA-Z]+)(\\d)+$" )
+
+ for w in args:
+ m = pattern.match( w )
+ sorted_words[ str( m.group( 2 ) ) ] = m.group( 1 )
+
+ sorted_words = dict( sorted( sorted_words.items() ) )
+ return ' '.join( sorted_words.values() )
+
+
+
+# invoke the main without the command itself
+if __name__ == '__main__':
+ print( task_1( sys.argv[ 1: ] ) )