-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3972159
commit aa2e141
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Circular iterator (Citerate) | ||
|
||
Bi-dimensional matrix iterator starting from any point (i, j), going layer by layer around the starting coordinates. | ||
|
||
## Usage | ||
|
||
pip install citerate | ||
|
||
As of __14 july 2021__ it contains one method `citerator` | ||
|
||
from citerate import citerator | ||
|
||
## Examples | ||
|
||
Using the example data set: | ||
|
||
CLOCKWISE_SET = [ | ||
[10, 11, 12, 13, 14], | ||
[25, 2, 3, 4, 15], | ||
[24, 9, 1, 5, 16], | ||
[23, 8, 7, 6, 17], | ||
[22, 21, 20, 19, 18], | ||
] | ||
|
||
To iterate over the set layer by layer starting from coordinates (i=2, j=2), which corresponds to the value 1 and print each layer of values. | ||
|
||
for layer in citerate.citerator(CLOCKWISE_SET, i = 2, j = 2): | ||
print(layer) | ||
|
||
Outputs: | ||
|
||
[1] | ||
[2, 3, 4, 5, 6, 7, 8, 9] | ||
[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25] | ||
|
||
# Footnotes | ||
|
||
- It is NOT mandatory to iterate starting from the central coordinates or for the matrix to be uniform. | ||
- It HAS to be bi-dimenstional and consist of "list of lists". |