Skip to content

Instantly share code, notes, and snippets.

@vlad-bezden
Last active January 21, 2019 17:41
Show Gist options
  • Save vlad-bezden/6d728a6bac22fb87523ebcf7fd49babb to your computer and use it in GitHub Desktop.
Save vlad-bezden/6d728a6bac22fb87523ebcf7fd49babb to your computer and use it in GitHub Desktop.
Example of Transform function. It rotate 2D array by 90 degree
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