Created
January 21, 2019 17:42
-
-
Save vlad-bezden/36049f4dccf6cf18208a96f4eacbf62d to your computer and use it in GitHub Desktop.
Creates 2D array (matrix)
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
""" | |
Creates 2D matrix | |
""" | |
def matrix(rows, cols, start=0): | |
return [[c + start + r * cols for c in range(cols)] for r in range(rows)] | |
assert matrix(2, 3, 1) == [[1, 2, 3], [4, 5, 6]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment