Closed
Description
the function find_blank_square()
is iterating over an int
.
In line 422. Here's the code:
def find_blank_square(self, state):
"""Return the index of the blank square in a given state"""
for row in len(state):
for column in len(row):
if state[row][column] == 0:
index_blank_square = (row, column)
return index_blank_square
len(state)
and len(row)
will always return an int
.
I wonder how it passed the tests.
Edit: Found two more such cases!
in line 477
def goal_test(self, state):
"""Given a state, return True if state is a goal state or False, otherwise"""
for row in len(state):
for column in len(row):
if state[row][col] != self.goal[row][column]:
return False
return True
and in line 496
def h(self, state):
"""Return the heuristic value for a given state. Heuristic function used is
h(n) = number of misplaced tiles."""
num_misplaced_tiles = 0
for row in len(state):
for column in len(row):
if state[row][col] != self.goal[row][column]:
num_misplaced_tiles += 1
return num_misplaced_tiles
Metadata
Metadata
Assignees
Labels
No labels