A small collection of functions to get various diagonals of a 2d matrix
Project description
A small module for getting diagonals in a 2D Array
import diagonal
arr = [] #your array
Definition
get(arr, start = "0", direction = "up", type="all")
start (single character)
0 - start from the first row
m - start from m'th row
direction (string)
up - uses upward direction for traversal
down - downward direction for traversal
**type **(string)
all - default value which indicates that all diagonals are considered
main - gives the main diagonal of square matrix
anti - gives anti diagonal of square matrix
zigzag - gives zigzag traversal of the matrix
Usages
-
Square matrix
-
Main diagonal
diagonal.get(arr, type = "main")
-
Anti diagonal
diagonal.get(arr, type = "anti")
-
Also zigzags upwards and downwards
diagonal.get(arr, type = "zigzag" ,direction ="up")
-
-
Other matrices
All traversals except main and anti diagonals
Ex:
diagonal.get(arr, start = "0", direction = "up")
gives all diagonals starting from the first elements traversed in upward direction.
Return values
-
Any errors return a string
-
Main and Anti diagonal traversals returns a list
-
ZigZag traversals return a list
-
Others return a list of list having individual diagonals
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file diagonal-0.0.2.tar.gz
.
File metadata
- Download URL: diagonal-0.0.2.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 836ee3ff21398e6741a3af35f84add28b6968ddd83c2e2bf30ffb741e5c2f8cd |
|
MD5 | 7e3055e5aaf41fa34d993b200f408b41 |
|
BLAKE2b-256 | 0ec5296493b0b24d51b31248108b2ce63d66a88b5ba4686e43b4631ffa60de36 |
File details
Details for the file diagonal-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: diagonal-0.0.2-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ff482191edc57066dc7b1fd6aa51d89e85a0f53209f1518a6424a789662aaa1 |
|
MD5 | 711d3b1695da01a24d593a974687a999 |
|
BLAKE2b-256 | b52d6e1a2ccafdaee18639ad0b12b2635c49800e177f3cb437f0fdde2f760351 |