Skip to content

Commit b72ed50

Browse files
committed
feat:구현
1 parent a3ba2ff commit b72ed50

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# 3:51 ~
2+
# Hint : 1부터 0까지 좌표를 저장하는 딕셔너리를 선언한다.
3+
4+
pad = {
5+
'1' : (0,0),
6+
'2' : (0,1),
7+
'3' : (0,2),
8+
'4' : (1,0),
9+
'5' : (1,1),
10+
'6' : (1,2),
11+
'7' : (2,0),
12+
'8' : (2,1),
13+
'9' : (2,2),
14+
'0' : (3,1),
15+
'*' : (3,0),
16+
'#' : (3,2)
17+
}
18+
19+
def solution(numbers, hand):
20+
answer = ''
21+
22+
left = pad['*']
23+
right = pad['#']
24+
25+
for n in numbers:
26+
if n in [1, 4, 7]:
27+
answer += 'L'
28+
left = pad[str(n)]
29+
if n in [3, 6, 9]:
30+
answer += 'R'
31+
right = pad[str(n)]
32+
if n in [2,5,8,0]:
33+
L1 = abs(pad[str(n)][0] - left[0]) + abs(pad[str(n)][1] - left[1])
34+
R1 = abs(pad[str(n)][0] - right[0]) + abs(pad[str(n)][1] - right[1])
35+
if L1 == R1:
36+
if hand == "right":
37+
right = pad[str(n)]
38+
answer += "R"
39+
else:
40+
left = pad[str(n)]
41+
answer += "L"
42+
elif L1 > R1:
43+
answer += "R"
44+
right = pad[str(n)]
45+
else:
46+
answer += "L"
47+
left = pad[str(n)]
48+
return answer
49+
50+
numbers = [0,0]
51+
hand = "right"
52+
print(solution(numbers, hand))

0 commit comments

Comments
 (0)