fork download
  1. def is_free(y,x,t,island):
  2. if t == 'N':
  3. if y-1 < 0:
  4. return True
  5. if island[y-1][x] == '.':
  6. return is_free(y-1,x,t,island)
  7. else:
  8. return False
  9.  
  10. if t == 'S':
  11. if y+1 >= len(island):
  12. return True
  13. if island[y+1][x] == '.':
  14. return is_free(y+1,x,t,island)
  15. else:
  16. return False
  17. if t == 'E':
  18. if x+1 >= len(island[y]):
  19. return True
  20. if island[y][x+1] == '.':
  21. return is_free(y,x+1,t,island)
  22. else:
  23. return False
  24. if t == 'W':
  25. if x-1 < 0:
  26. return True
  27. if island[y][x-1] == '.':
  28. return is_free(y,x-1,t,island)
  29. else:
  30. return False
  31. if t == '.':
  32. return False
  33.  
  34. def is_ready(island):
  35. for i in range(0,len(island)):
  36. for j in range(0,len(island[i])):
  37. if island[i][j] != '.':
  38. if is_free(i,j,island[i][j],island):
  39. return False
  40. return True
  41.  
  42.  
  43.  
  44. size = input().split(' ')
  45. size[0]=int(size[0])
  46. size[1]=int(size[1])
  47. count=0
  48. island = []
  49. for i in range(0,size[0]):
  50. island.append(list(input()))
  51. while not is_ready(island):
  52. for i in range(0,size[0]):
  53. for j in range(0,size[1]):
  54. if island[i][j] != '.':
  55. if is_free(i,j,island[i][j],island):
  56. count+=1
  57. island[i][j]='.'
  58. print(count)
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.pas:1: error: syntax error before `def'
stdout
Standard output is empty