Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. def throwingBlocks(field):
  2. def isFirstColumnFull(field):
  3. result = True
  4. for i in range(len(field)):
  5. result = result and (field[i][0] == '#')
  6. return result
  7.  
  8. def countMoves(field, result, moves):
  9. if isFirstColumnFull(field):
  10. result[0] = min(result[0], moves)
  11. result[1] = max(result[1], moves)
  12. return
  13. for i in range(len(field)):
  14. if field[i][0] == '#':
  15. continue
  16. j = i
  17. column = 0
  18. while column < len(field[j]) and field[j][column] == '.':
  19. column += 1
  20. j -= 1
  21. while j < len(field) and field[j][column] == '.':
  22. j += 1
  23. j -= 1
  24. field[j][column] = '#'
  25. countMoves(field, result, moves + 1)
  26. field[j][column] = '.'
  27.  
  28. INF = len(field) * len(field[0]) + 1
  29. result = [INF, -INF]
  30. countMoves(field, result, 0)
  31. return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement