diff options
| author | Paulo Custodio <pauloscustodio@gmail.com> | 2021-11-16 18:37:40 +0000 |
|---|---|---|
| committer | Paulo Custodio <pauloscustodio@gmail.com> | 2021-11-16 18:37:40 +0000 |
| commit | 429dde959e2bbde5fa2d4b9dd98fe6c2c035e597 (patch) | |
| tree | 0261b808caec80ca728b94d19a0d2808d8caceee | |
| parent | a95e0e234d41795e483c01e0bad6e34be4433284 (diff) | |
| download | perlweeklychallenge-club-429dde959e2bbde5fa2d4b9dd98fe6c2c035e597.tar.gz perlweeklychallenge-club-429dde959e2bbde5fa2d4b9dd98fe6c2c035e597.tar.bz2 perlweeklychallenge-club-429dde959e2bbde5fa2d4b9dd98fe6c2c035e597.zip | |
Add Python solution to challenge 11
| -rw-r--r-- | challenge-011/paulo-custodio/Makefile | 2 | ||||
| -rw-r--r-- | challenge-011/paulo-custodio/python/ch-1.py | 2 | ||||
| -rw-r--r-- | challenge-011/paulo-custodio/python/ch-2.py | 29 | ||||
| -rw-r--r-- | challenge-011/paulo-custodio/test.pl | 4 |
4 files changed, 32 insertions, 5 deletions
diff --git a/challenge-011/paulo-custodio/Makefile b/challenge-011/paulo-custodio/Makefile new file mode 100644 index 0000000000..c3c762d746 --- /dev/null +++ b/challenge-011/paulo-custodio/Makefile @@ -0,0 +1,2 @@ +all: + perl ../../challenge-001/paulo-custodio/test.pl diff --git a/challenge-011/paulo-custodio/python/ch-1.py b/challenge-011/paulo-custodio/python/ch-1.py index d8f93b7668..766c48fbba 100644 --- a/challenge-011/paulo-custodio/python/ch-1.py +++ b/challenge-011/paulo-custodio/python/ch-1.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python3 # Challenge 011 # diff --git a/challenge-011/paulo-custodio/python/ch-2.py b/challenge-011/paulo-custodio/python/ch-2.py new file mode 100644 index 0000000000..7402779a99 --- /dev/null +++ b/challenge-011/paulo-custodio/python/ch-2.py @@ -0,0 +1,29 @@ +#!/usr/bin/python3 + +# Challenge 011 +# +# Challenge #2 +# Write a script to create an Indentity Matrix for the given size. For example, +# if the size is 4, then create Identity Matrix 4x4. For more information about +# Indentity Matrix, please read the wiki page. + +import sys + +def id_matrix(size): + id = [[0 for y in range(size)] for x in range(size)] + for i in range(size): + id[i][i] = 1 + return id + +def print_matrix(m): + output = "[" + sep = "" + for row in m: + output += sep+"["+", ".join([str(x) for x in row])+"]" + sep = ",\n " + output += "]" + print(output) + +size = int(sys.argv[1]) +id = id_matrix(size) +print_matrix(id) diff --git a/challenge-011/paulo-custodio/test.pl b/challenge-011/paulo-custodio/test.pl deleted file mode 100644 index ba6c37260b..0000000000 --- a/challenge-011/paulo-custodio/test.pl +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env perl -use Modern::Perl; -use Test::More; -require '../../challenge-001/paulo-custodio/test.pl'; |
