I would like to give some feedback about ...
From: http://www.checkio.org/mission/count-neighbours/solve/
HTTP_USER_AGENT:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:41.0) Gecko/20100101 Firefox/41.0
def count_neighbours(grid,row,col):
rez = 0
leng = len(grid)
if row >= leng or col >= leng:
return 0
if row-1 >= 0 and grid[row-1][col] == 1 :
rez += 1
if row+1 < leng and grid[row+1][col] == 1:
rez += 1
if row-1 >=0 and col-1 >=0 and grid[row-1][col-1] == 1:
rez += 1
if col-1 >= 0 and grid[row][col-1] == 1:
rez += 1
if row+1 < leng and col-1 >= 0 and grid[row+1][col-1] == 1 :
rez += 1
if row-1 >= 0 and col+1 < leng and grid[row-1][col+1] == 1:
rez += 1
if col+1 < leng and grid[row][col+1] == 1:
rez += 1
if row+1 < leng and col+1 < leng and grid[row+1][col+1] == 1 :
rez += 1
return rez
In my local python3 this code is good and return 0 and function ends. Maybe can you not ends after function return 0.
У на ноуте все работает правильно код возвращает 0 и заканчиваеться. Возможно у вас после срабатывание return функция работает дальше.
Created at: 2015/09/29 18:59; Updated at: 2015/09/30 05:52