From 394f3c07bd08a53116168a620d215dfd7fdc58e2 Mon Sep 17 00:00:00 2001 From: heerucan Date: Tue, 4 Jan 2022 03:02:33 +0900 Subject: [PATCH] =?UTF-8?q?[=EC=BD=94=EB=94=A9=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EC=B1=85]=204-1.=20=EC=83=81=ED=95=98=EC=A2=8C=EC=9A=B0(#2)=20?= =?UTF-8?q?-=20https://www.notion.so/huree-can-do-it/4-1-643768e2fd4a487ab?= =?UTF-8?q?b05892b486dff21?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CH4 \352\265\254\355\230\204/4-1.py" | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 "CodingTest/CH4 \352\265\254\355\230\204/4-1.py" 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