- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
import re
def matrix():
square = [[0 for x in range(7)] for x in range(7)]
directions = ((1,0), (0,1), (-1,0), (0,-1))
x, y, d = -1, 0, 0
for i in range(49):
while True:
x1, y1 = x + directions[d][0], y + directions[d][1]
if x1 >= 0 and x1 < 7 and y1 >= 0 and y1 < 7 and square[y1][x1] == 0:
x, y = x1, y1
break
d = (d + 1) % 4
square[y][x] = re.sub(r'\d', lambda n: ' ' * int(n.group()), '9de9mb8nv5yo4aol1rm')[i]
return square
print('\n'.join([''.join(line) for line in matrix()]).strip())