From 1b334758e463fec45f1a05ec065759da43ebb90b Mon Sep 17 00:00:00 2001 From: heeheejj Date: Mon, 18 Dec 2023 18:29:20 +0900 Subject: [PATCH] =?UTF-8?q?Week30=20PRG=20121687=20=EC=8B=A4=EC=8A=B5?= =?UTF-8?q?=EC=9A=A9=EB=A1=9C=EB=B4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...65\354\232\251\353\241\234\353\264\207.py" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "heeheej/week30/PRG_121687_\354\213\244\354\212\265\354\232\251\353\241\234\353\264\207.py" diff --git "a/heeheej/week30/PRG_121687_\354\213\244\354\212\265\354\232\251\353\241\234\353\264\207.py" "b/heeheej/week30/PRG_121687_\354\213\244\354\212\265\354\232\251\353\241\234\353\264\207.py" new file mode 100644 index 0000000..83ba876 --- /dev/null +++ "b/heeheej/week30/PRG_121687_\354\213\244\354\212\265\354\232\251\353\241\234\353\264\207.py" @@ -0,0 +1,27 @@ +# PCCP 모의고사 2 1번 실습용로봇 + +def solution(command): + answer = [] + dx = [0, 1, 0, -1] + dy = [1, 0, -1, 0] + nx, ny = 0, 0 + d = 0 # 방향인덱스 + + def rotateRight90(d): + return (d + 1) % 4 + + for x in command: + if x == "G": + nx += dx[d] + ny += dy[d] + elif x == "B": + nx -= dx[d] + ny -= dy[d] + elif x == "R": + d = (d + 1) % 4 + elif x == "L": + d -= 1 + if d < 0: + d = 3 + answer = [nx, ny] + return answer \ No newline at end of file