n = int(lst_[0][0])
maps = [[1 for i in range(1,n+1)] for _ in range(1,n+1)]
des = {"R" : [0,1], "L" : [0, -1], "U" : [-1,0], "D" : [1, 0] }
start = [0,0]
for i in lst_[1]:
if (np.array(start)[0] + np.array(des[i])[0] < 0) or (np.array(start)[1] + np.array(des[i])[1] < 0) :
pass
else:
start = np.array(start) + np.array(des[i])
print("{} {}".format(start[0]+1, start[1]+1))
['R', 'R', 'R', 'U', 'D', 'D']
dx = [0, 0, -1, 1]
dy = [-1, 1, 0 , 0]
move_types = ['L', 'R', 'U', 'D']
dx = [2, 2, -2, -2, 1, -1, 1, -1]
dy = [1, -1, 1 , -1, 2, 2, -2, -2]
input_data = input()
row = int(input_data[1])
column = int(ord(input_data[0])) - int(ord('a')) + 1
steps = [(-2,-1), (-1,-2), (1, -2), (2, -1), (2, 1), (1, 2), (-1, 2), (-2, 1)]
result = 0
for step in steps:
next_row = row + step[0]
next_column = column + step[1]
if next_row>=1 and next_row <=8 and next_column >=1 and next_column <=8:
result+=1
print(result)
1 1 1 1
1 0 0 1
1 1 0 1
1 1 1 1
[[1, 1, 1, 1], [1, 0, 0, 1], [1, 1, 0, 1], [1, 1, 1, 1]]
visited = [[x,y]]
count = 1
while True:
if x-1>=0 and y-1>=0 and x+1<n and y+1<m:
if ((maps[x-1][y] == 1) or ([x-1, y] in visited)) and ((maps[x+1][y] == 1) or ([x+1, y] in visited)) and ((maps[x][y+1] == 1) or ([x, y+1] in visited)) and ((maps[x][y-1] == 1) or ([x, y-1] in visited)):
x+= destination[z-2][0]
y+= destination[z-2][1]
if maps[x][y] == 1:
break
else:
for i in range(1,5):
if x-1>=0 and y-1>=0 and x+1<n and y+1<m:
if maps[x+ destination[z-i][0]][y + destination[z-i][1]] == 0:
if [x+destination[z-i][0],y+destination[z-i][1]] not in visited:
x+= destination[z-i][0]
y+= destination[z-i][1]
visited.append([x,y])
z = destination.index(destination[z-i])
count+=1
break
else:
pass
n, m = map(int, input().split())
d = [[0]*m for _ in range(n)]
x, y, direction = map(int, input().split())
d[x][y] = 1
array = []
for i in range(n):
array.append(list(map(int, input().split())))
dx = [-1, 0, 1, 0]
dy = [0, 1, 0, -1]
def turn_left():
global direction
direction -=1
if direction == -1:
direction = 3
count = 1
turn_time = 0
while True:
turn_left()
nx = x + dx[direction]
ny = y + dy[direction]
if d[nx][ny] == 0 and array[nx][ny] == 0:
d[nx][ny] = 1
x = nx
y = ny
count +=1
turn_time = 0
continue
else:
turn_time +=1
if turn_time ==4:
nx = x - dx[direction]
ny = y - dy[direction]
if array[nx][ny] == 0:
x = nx
y = ny
else:
break
turn_time = 0
print(count)
4 4
1 1 0
1 1 1 1
1 0 0 1
1 1 0 1
1 1 1 1
3
Comments