Last active
January 21, 2019 17:41
-
-
Save vlad-bezden/6d728a6bac22fb87523ebcf7fd49babb to your computer and use it in GitHub Desktop.
Example of Transform function. It rotate 2D array by 90 degree
This file contains hidden or 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
def transform(data): | |
return [list(x) for x in zip(*data)] | |
data = [[*range(3)], [*range(3, 6)], [*range(6, 9)]] | |
# [[0, 1, 2], [3, 4, 5], [6, 7, 8]] | |
data_t = transform(data) | |
# [[0, 3, 6], [1, 4, 7], [2, 5, 8]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment