Guest User

Untitled

a guest
May 23rd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import sys
  2. sys.setrecursionlimit(900000000)
  3.  
  4. file_e = open('file.txt','r')
  5. file = file_e.readlines()
  6. file_e.close()
  7. file.reverse()
  8. for index,line in enumerate(file):
  9. file[index] = line.split(' ')
  10. print(len(file)-1, len(file[0])-1)
  11. def end(file,y,x):
  12.  
  13. if y == len(file)-1 and x == len(file[0])-1: return 1
  14.  
  15. try:
  16. if file[y+1][x] == '0': up = True
  17. except: pass
  18. try:
  19. if file[y][x+1] == '0': right = True
  20. except: pass
  21.  
  22. try:
  23. if up == True and right == True: return end(file,y+1,x) + end(file,y,x+1)
  24. except: pass
  25.  
  26.  
  27. try:
  28. if up == True: return end(file,y+1,x)
  29. except: pass
  30.  
  31. try:
  32. if right == True: return end(file,y,x+1)
  33. except: pass
  34.  
  35.  
  36. if file[y+1][x] == '1' or file[y][x+1] == '1':
  37. return 0
  38.  
  39.  
  40.  
  41. print(end(file,0,0))
Add Comment
Please, Sign In to add comment