-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b1b83e
commit f363b11
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- coding: utf-8 -*- | ||
# UTF-8 encoding when using korean | ||
|
||
|
||
def solution(commands): | ||
move = [[-1, 0], [1, 0], [0, 1], [0, -1]] # 순서대로 L R U D | ||
answer = [0, 0] | ||
|
||
for i in commands: | ||
if i == 'L': | ||
answer[0] += move[0][0] | ||
answer[1] += move[0][1] | ||
if i == 'R': | ||
answer[0] += move[1][0] | ||
answer[1] += move[1][1] | ||
if i == 'U': | ||
answer[0] += move[2][0] | ||
answer[1] += move[2][1] | ||
if i == 'D': | ||
answer[0] += move[3][0] | ||
answer[1] += move[3][1] | ||
|
||
return(answer) | ||
|
||
|
||
|
||
commands = "URDDL" | ||
ret = solution(commands) | ||
|
||
print("solution 함수의 반환 값은", ret, "입니다.") |