aboutsummaryrefslogtreecommitdiff
path: root/challenge-275/luca-ferrari/python
diff options
context:
space:
mode:
authorLuca Ferrari <fluca1978@gmail.com>2024-06-24 09:55:54 +0200
committerLuca Ferrari <fluca1978@gmail.com>2024-06-24 12:11:32 +0200
commite3413e5215e89c8512218669be7701def126c9cd (patch)
tree144996f6b400d6fe18d1849bc81038333a57e41e /challenge-275/luca-ferrari/python
parente706d2548a3ce7ff5d3ae480224ee3ee6c5577de (diff)
downloadperlweeklychallenge-club-e3413e5215e89c8512218669be7701def126c9cd.tar.gz
perlweeklychallenge-club-e3413e5215e89c8512218669be7701def126c9cd.tar.bz2
perlweeklychallenge-club-e3413e5215e89c8512218669be7701def126c9cd.zip
PWC 275
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-275/luca-ferrari/python')
-rw-r--r--challenge-275/luca-ferrari/python/ch-1.py34
-rw-r--r--challenge-275/luca-ferrari/python/ch-2.py32
2 files changed, 66 insertions, 0 deletions
diff --git a/challenge-275/luca-ferrari/python/ch-1.py b/challenge-275/luca-ferrari/python/ch-1.py
new file mode 100644
index 0000000000..f131b1e602
--- /dev/null
+++ b/challenge-275/luca-ferrari/python/ch-1.py
@@ -0,0 +1,34 @@
+#!python
+
+#
+# Perl Weekly Challenge 275
+# Task 1
+#
+# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-275>
+#
+
+import sys
+
+# task implementation
+# the return value will be printed
+def task_1( args ):
+ sentence = args[ 0 ]
+ keys = args[ 1: ]
+ words_ok = 0
+
+ for word in sentence.lower().split():
+ bad = 0
+ for k in keys:
+ k = k.lower()
+ if k in word:
+ bad += 1
+ break
+
+ if bad == 0:
+ words_ok += 1
+
+ return words_ok
+
+# invoke the main without the command itself
+if __name__ == '__main__':
+ print( task_1( sys.argv[ 1: ] ) )
diff --git a/challenge-275/luca-ferrari/python/ch-2.py b/challenge-275/luca-ferrari/python/ch-2.py
new file mode 100644
index 0000000000..ebe16641b0
--- /dev/null
+++ b/challenge-275/luca-ferrari/python/ch-2.py
@@ -0,0 +1,32 @@
+#!python
+
+#
+# Perl Weekly Challenge 275
+# Task 2
+#
+# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-275>
+#
+
+import sys
+
+# task implementation
+# the return value will be printed
+def task_2( args ):
+ string = args[ 0 ]
+ previous = None
+ result = ""
+
+ for c in string:
+ if c.isdigit():
+ c = chr( int( c ) + 97 )
+ else:
+ previous = c
+
+ result += c
+
+ return result
+
+
+# invoke the main without the command itself
+if __name__ == '__main__':
+ print( task_2( sys.argv[ 1: ] ) )