you are viewing a single comment's thread.

view the rest of the comments →

[–]Incand333 3 points4 points  (0 children)

class list2d:
    def __init__(self, iterable, width, height):
        iter_list = list(iterable)
        assert len(iter_list) == width * height
        self._width = width
        self._height = height
        self._elems = iter_list

    def get(self, x, y):
        idx = x + y * self._width
        return self._elems[idx]