Skip to content

Commit

Permalink
[코딩테스트책] 4-1. 상하좌우(#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
heerucan committed Jan 3, 2022
1 parent b93c35d commit 394f3c0
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions CodingTest/CH4 구현/4-1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 5
# R R R U D D
n = int(input())
direction = input().split()

x, y = 1, 1

for i in range(len(direction)):
if direction[i] == 'R':
if x == n:
y += 0
else:
y += 1

elif direction[i] == 'L':
if x == 1:
y += 0
else:
y -= 1

elif direction[i] == 'U':
if x == 1:
x += 0
else:
x -= 1

elif direction[i] == 'D':
if y == n:
x += 0
else:
x += 1

print(x, y)

0 comments on commit 394f3c0

Please sign in to comment.