fork download
class Map2D:
    def __init__(self, width, height, val):
        self._internalMap = [[val]*height for width in range(height)]
    def fromArray2D(self, array2D):
    	self.internalMap = array2D
    def at(self, x, y):
        return self._internalMap[x][y]
    def putAt(self, x, y, val):
        self._internalMap[x][y] = val
        return self
    def putMap2DAt(self, x, y, another):
    	for ix in range(x, x+another.width()):
    		for iy in range(y, y+another.height()):
    			self.putAt(ix, iy, another.at(ix-x, iy-y))
    	return self
    def width(self):
        return len(self._internalMap[0])
    def height(self):
        return len(self._internalMap)

def printPureMap2D(map2d):
	for y in range(map2d.height()):
		row = []
		for x in range(map2d.width()):
			row.extend(map2d.at(x, y))
		print ''.join(row)

canvas = Map2D(20, 20, ' ')
stars = Map2D(5, 5, '*')

canvas.putMap2DAt(0, 0, stars).putAt(5+3, 0, 'x').putMap2DAt(10, 0, stars)
canvas.putMap2DAt(5, 5, stars)
canvas.putMap2DAt(0, 10, stars).putMap2DAt(10, 10, stars)

printPureMap2D(canvas)
Success #stdin #stdout 0.01s 7896KB
stdin
Standard input is empty
stdout
*****   x *****     
*****     *****     
*****     *****     
*****     *****     
*****     *****     
     *****          
     *****          
     *****          
     *****          
     *****          
*****     *****     
*****     *****     
*****     *****     
*****     *****     
*****     *****