-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy path3A.py
49 lines (46 loc) · 1.17 KB
/
3A.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
s=input()
t=input()
l=[]
count=0
while s!=t:
if s[0]==t[0]:
if int(s[1])>int(t[1]):
l.append("D")
s=s[0]+str(int(s[1])-1)
count+=1
elif int(s[1])<int(t[1]):
l.append("U")
s=s[0]+str(int(s[1])+1)
count+=1
elif s[1]==t[1]:
if s[0]>t[0]:
l.append("L")
s=chr(ord(s[0])-1)+s[1]
count+=1
elif s[0]<t[0]:
l.append("R")
s=chr(ord(s[0])+1)+s[1]
count+=1
elif s[0]>t[0] and int(s[1])<int(t[1]):
s=chr(ord(s[0])-1)+s[1]
s=s[0]+str(int(s[1])+1)
l.append("LU")
count+=1
elif s[0]>t[0] and int(s[1])>int(t[1]):
s=chr(ord(s[0])-1)+s[1]
s=s[0]+str(int(s[1])-1)
l.append("LD")
count+=1
elif s[0]<t[0] and int(s[1])<int(t[1]):
s=chr(ord(s[0])+1)+s[1]
s=s[0]+str(int(s[1])+1)
l.append("RU")
count+=1
elif s[0]<t[0] and int(s[1])>int(t[1]):
s=chr(ord(s[0])+1)+s[1]
s=s[0]+str(int(s[1])-1)
l.append("RD")
count+=1
print(count)
if len(l)!=0:
print("\n".join(l))