def is_valid_move(move):
global BLANK
if move == LEFT:
if BLANK[0] >= NUMBOXHORIZONTAL - 1:
return False
elif move == RIGHT:
if BLANK[0] <= 0:
return False
elif move == DOWN:
print BLANK[1],0
if BLANK[1] <= 0:
return False
elif move == UP:
print BLANK[1],NUMBOXVERTIVAL - 1
if BLANK[1] >= NUMBOXVERTIVAL - 1:
return False
return True
def is_won(boxs):
num = 0
for i in range(NUMBOXHORIZONTAL):
for j in range(NUMBOXVERTIVAL):
num = i + j*NUMBOXVERTIVAL
if boxs[i][j].is_blank == False:
if boxs[i][j].num != num:
print boxs[i][j].num,num
return False
num+=1
return True