diff --git "a/CodingTest/CH4 \352\265\254\355\230\204/4-1.py" "b/CodingTest/CH4 \352\265\254\355\230\204/4-1.py" new file mode 100644 index 0000000..16519ae --- /dev/null +++ "b/CodingTest/CH4 \352\265\254\355\230\204/4-1.py" @@ -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) \ No newline at end of file