Use dynamic programming to speed up extract_walls()