aboutsummaryrefslogtreecommitdiff
path: root/challenge-266/luca-ferrari/python/ch-2.py
diff options
context:
space:
mode:
authorLuca Ferrari <fluca1978@gmail.com>2024-04-22 12:10:47 +0200
committerLuca Ferrari <fluca1978@gmail.com>2024-04-22 14:21:38 +0200
commit5dba324368d526b878978f60d55ae1db3b795804 (patch)
tree578038f03e7698696d8003236b77c99c7ac44136 /challenge-266/luca-ferrari/python/ch-2.py
parentaed41ed119210ab32e32b82af8039f2c1457726b (diff)
downloadperlweeklychallenge-club-5dba324368d526b878978f60d55ae1db3b795804.tar.gz
perlweeklychallenge-club-5dba324368d526b878978f60d55ae1db3b795804.tar.bz2
perlweeklychallenge-club-5dba324368d526b878978f60d55ae1db3b795804.zip
PWC 266
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-266/luca-ferrari/python/ch-2.py')
-rw-r--r--challenge-266/luca-ferrari/python/ch-2.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/challenge-266/luca-ferrari/python/ch-2.py b/challenge-266/luca-ferrari/python/ch-2.py
new file mode 100644
index 0000000000..7b5ce0d896
--- /dev/null
+++ b/challenge-266/luca-ferrari/python/ch-2.py
@@ -0,0 +1,35 @@
+#!python
+
+#
+# Perl Weekly Challenge 266
+# Task 2
+#
+# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-266>
+#
+
+import sys
+
+# task implementation
+# the return value will be printed
+def task_2( matrix ):
+ size = len( matrix[ 0 ] )
+ for row in range( 0, size ):
+ for col in range( 0, size ):
+ if row == col or col == size - row - 1:
+ if matrix[ row ][ col ] == 0:
+ return 'False'
+ elif matrix[ row ][ col ] != 0:
+ return 'False'
+ return 'True'
+
+
+
+# invoke the main without the command itself
+if __name__ == '__main__':
+ matrix = [
+ [1, 0, 0, 2],
+ [0, 3, 4, 0],
+ [0, 5, 6, 0],
+ [7, 0, 0, 1],
+ ]
+ print( task_2( matrix ) )