From 4f679ef537828bb24ccfaf5f4f81294a9b505a69 Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Fri, 24 Oct 2025 20:44:01 +0900 Subject: [PATCH] =?UTF-8?q?[20251024]=20PGM=20/=20Lv2=20/=20=EB=B0=A9?= =?UTF-8?q?=EB=AC=B8=20=EA=B8=B8=EC=9D=B4=20/=20=EC=9D=B4=EA=B0=95?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...1\353\254\270 \352\270\270\354\235\264.md" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "lkhyun/202510/24 PGM Lv2 \353\260\251\353\254\270 \352\270\270\354\235\264.md" diff --git "a/lkhyun/202510/24 PGM Lv2 \353\260\251\353\254\270 \352\270\270\354\235\264.md" "b/lkhyun/202510/24 PGM Lv2 \353\260\251\353\254\270 \352\270\270\354\235\264.md" new file mode 100644 index 00000000..8f6b7cdd --- /dev/null +++ "b/lkhyun/202510/24 PGM Lv2 \353\260\251\353\254\270 \352\270\270\354\235\264.md" @@ -0,0 +1,25 @@ +```python +def solution(dirs): + answer = 0 + history = set() + posX = 0 + posY = 0 + for dir in dirs: + if(dir == 'L'): + if posX == -5: continue + history.update([(posX,posY,posX-1,posY),(posX-1,posY,posX,posY)]) + posX -= 1 + elif(dir == 'R'): + if posX == 5: continue + history.update([(posX,posY,posX+1,posY),(posX+1,posY,posX,posY)]) + posX += 1 + elif(dir == 'U'): + if posY == 5: continue + history.update([(posX,posY,posX,posY+1),(posX,posY+1,posX,posY)]) + posY += 1 + elif(dir == 'D'): + if posY == -5: continue + history.update([(posX,posY,posX,posY-1),(posX,posY-1,posX,posY)]) + posY -= 1 + return len(history)/2 +```