import random
v = [[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]]
for i in range(5):
v[i] = [random.choice([0,2]) for x in v[i]]
a = random.randint(0,4)
b = random.randint(0,4)
c = random.randint(2,5)
d = 0
e = 0
v[a][b] = 4
if c ==2:
start = b
end = b+2
if end >5:
end =5
for num in range(0,2):
if a+num >4:
pass
else:
for num2 in v[a+num][start:end]:
if num2 ==2 :
d +=1
if c == 3:
start = b-1
end = b+2
if start <-1:
start=0
if end >5:
end =5
for num in range(0,2):
if a+num >4:
pass
else:
for num2 in v[a+num][start:end]:
if num2 ==2 :
d +=1
for num in range(1,2):
if a-num <0:
pass
else:
for num2 in v[a-num][start:end]:
if num2 ==2 :
d +=1
if c ==4:
start = b
end = b+4
if end >5:
end =5
for num in range(0,3):
if a+num >4:
pass
else:
for num2 in v[a+num][start:end]:
if num2 ==2 :
d +=1
if c == 5:
start = b-2
end = b+3
if start <-1:
start=0
if end >5:
end =5
for num in range(0,3):
if a+num >4:
pass
else:
for num2 in v[a+num][start:end]:
if num2 ==2 :
d +=1
for num in range(1,3):
if a-num <0:
pass
else:
for num2 in v[a-num][start:end]:
if num2 ==2 :
d +=1
print('{0:5} {1:5} {2:5} {3:5} {4:5}'.format(v[0][0], v[0][1], v[0][2], v[0][3], v[0][4]))
print('{0:5} {1:5} {2:5} {3:5} {4:5}'.format(v[1][0], v[1][1], v[1][2], v[1][3], v[1][4]))
print('{0:5} {1:5} {2:5} {3:5} {4:5}'.format(v[2][0], v[2][1], v[2][2], v[2][3], v[2][4]))
print('{0:5} {1:5} {2:5} {3:5} {4:5}'.format(v[3][0], v[3][1], v[3][2], v[3][3], v[3][4]))
print('{0:5} {1:5} {2:5} {3:5} {4:5}'.format(v[4][0], v[4][1], v[4][2], v[4][3], v[4][4]))
print(' 鳄鱼家占地面积:%d'%(c*c))
print(' 他有%d个小伙伴'%(d))