File tree Expand file tree Collapse file tree 1 file changed +8
-20
lines changed
Expand file tree Collapse file tree 1 file changed +8
-20
lines changed Original file line number Diff line number Diff line change @@ -61,25 +61,13 @@ def _set_direction(direction: str,
6161 leaving bounds or revisiting filled cells.
6262 """
6363 row , col = x_y
64- if direction == "right" :
65- if col + 1 < size and result [row ][col + 1 ] == 0 :
66- direction = "right"
67- else :
68- direction = "down"
69- elif direction == "down" :
70- if row + 1 < size and result [row + 1 ][col ] == 0 :
71- direction = "down"
72- else :
73- direction = "left"
74- elif direction == "up" :
75- if row - 1 >= 0 and result [row - 1 ][col ] == 0 :
76- direction = "up"
77- else :
78- direction = "right"
79- elif direction == "left" :
80- if col - 1 >= 0 and result [row ][col - 1 ] == 0 :
81- direction = "left"
82- else :
83- direction = "up"
64+ if direction == "right" and not (col + 1 < size and result [row ][col + 1 ] == 0 ):
65+ direction = "down"
66+ elif direction == "down" and not (row + 1 < size and result [row + 1 ][col ] == 0 ):
67+ direction = "left"
68+ elif direction == "up" and not (row - 1 >= 0 and result [row - 1 ][col ] == 0 ):
69+ direction = "right"
70+ elif direction == "left" and not (col - 1 >= 0 and result [row ][col - 1 ] == 0 ):
71+ direction = "up"
8472
8573 return direction
You can’t perform that action at this time.
0 commit comments