# $language = "Python"
# $interface = "1.0"
# Connect to a telnet server and automate the initial login sequence.
# Note that synchronous mode is enabled to prevent server output from
# potentially being missed.
def move_right(temp_x,temp_y,matrix,result):
flag = 0
while(temp_y<3 and matrix[temp_x][temp_y]==0):
flag = flag + 1
matrix[temp_x][temp_y] = result
result = result + 1
temp_y = temp_y + 1
if matrix[temp_x][temp_y]!=0:
temp_x = temp_x + 1
temp_y = temp_y - 1
break
if flag == 0:
return
else:
move_down(temp_x,temp_y,matrix,result)
def move_down(temp_x,temp_y,matrix,result):
flag = 0
while(temp_x<3 and matrix[temp_x][temp_y]==0):
flag = flag + 1
matrix[temp_x][temp_y] = result
temp_x = temp_x + 1
result = result + 1
if matrix[temp_x][temp_y]!=0:
temp_x = temp_x - 1
temp_y = temp_y - 1
break
if flag == 0:
return
else:
move_left(temp_x,temp_y,matrix,result)
def move_left(temp_x,temp_y,matrix,result):
flag = 0
while(temp_y>0 and matrix[temp_x][temp_y]==0):
flag = flag + 1
matrix[temp_x][temp_y] = result
result = result + 1
temp_y = temp_y - 1
if flag ==0:
return
else:
move_up(temp_x,temp_y,matrix,result)