import random
def mp(Matrix):
for m in Matrix:
print m
def fill(Matrix, pos, start_x, end_x, start_y, end_y):
if (start_x == end_x) or (start_y == end_y):
return
mid_x = start_x + ( ( end_x - start_x) / 2)
mid_y = start_y + ( ( end_y - start_y) / 2)
q = int(pos[1] > mid_x)
q = q + (int(pos[0] > mid_y)) * 2
s = ['*', '#', '@', '1', '+', '~', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'X', 'U', 'L', 'W']
it = s[random.randint(0, len(s)-1)]
if q != 0:
Matrix[mid_y][mid_x] = it
fill(Matrix, (mid_y, mid_x), start_x, mid_x, start_y, mid_y)
else:
fill(Matrix, (pos[0], pos[1]), start_x, mid_x, start_y, mid_y)
if q != 1:
Matrix[mid_y][mid_x+1] = it
fill(Matrix, (mid_y, mid_x+1), mid_x + 1, end_x, start_y, mid_y)
else:
fill(Matrix, (pos[0], pos[1]), mid_x + 1, end_x, start_y, mid_y)
if q != 2:
Matrix[mid_y+1][mid_x] = it
fill(Matrix, (mid_y+1, mid_x), start_x, mid_x, mid_y + 1, end_y)
else:
fill(Matrix, (pos[0], pos[1]), start_x, mid_x, mid_y + 1, end_y)
if q != 3:
Matrix[mid_y+1][mid_x+1] = it
fill(Matrix, (mid_y + 1, mid_x + 1), mid_x + 1, end_x, mid_y + 1, end_y)
else:
fill(Matrix, (pos[0], pos[1]), mid_x + 1, end_x, mid_y + 1, end_y)
exp = 5
size = 2**exp
Matrix = [[0 for x in range(size)] for x in range(size)]
rand = (random.randint(0, size-1), random.randint(0, size-1))
Matrix[rand[0]][rand[1]] = '0'
fill(Matrix, rand, 0, size - 1, 0, size - 1)
mp(Matrix)