diff options
| author | Paulo Custodio <pauloscustodio@gmail.com> | 2023-04-07 11:52:10 +0100 |
|---|---|---|
| committer | Paulo Custodio <pauloscustodio@gmail.com> | 2023-04-07 11:52:10 +0100 |
| commit | c27917c2860cb2a203262d9cdeebd264c29456f2 (patch) | |
| tree | 3b024d7c86e48d197d470779ceca31d31a6971a5 /challenge-211/manfredi/python | |
| parent | bd0ea1891b53fb4cff93b57af6481f37dd268509 (diff) | |
| parent | 419cb48e0bd7736f9b625a9f60ce52bc77be8f7a (diff) | |
| download | perlweeklychallenge-club-c27917c2860cb2a203262d9cdeebd264c29456f2.tar.gz perlweeklychallenge-club-c27917c2860cb2a203262d9cdeebd264c29456f2.tar.bz2 perlweeklychallenge-club-c27917c2860cb2a203262d9cdeebd264c29456f2.zip | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-211/manfredi/python')
| -rwxr-xr-x | challenge-211/manfredi/python/ch-1.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/challenge-211/manfredi/python/ch-1.py b/challenge-211/manfredi/python/ch-1.py new file mode 100755 index 0000000000..fed72bd18f --- /dev/null +++ b/challenge-211/manfredi/python/ch-1.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# Python 3.9.2 on Debian GNU/Linux 11 (bullseye) + +print('challenge-211-task1') + +# Task 1: Toeplitz Matrix +# You are given a matrix m x n +# Write a script to find out if the given matrix is Toeplitz Matrix + +matrix = [ + [4, 3, 2, 1], + [5, 4, 3, 2], + [6, 5, 4, 3], +] + +# matrix = [ +# [1, 2, 3], +# [3, 2, 1], +# ] + +print(matrix) +is_toeplitz = True + +for row in range(0, len(matrix) - 1): + if not is_toeplitz: break + for col in range(0, len(matrix[row]) - 1): + if not is_toeplitz: break + print(matrix[row][col], matrix[row+1][col+1]) + if not matrix[row][col] == matrix[row+1][col+1]: + is_toeplitz = False + + +print('Toeplitz Matrix!') if is_toeplitz else print('Not Toeplitz Matrix') |
