Skip to content

Commit

Permalink
Merge pull request #1 from AlgoLeadMe/1-kokeunho
Browse files Browse the repository at this point in the history
1-kokeunho
  • Loading branch information
kokeunho authored Oct 1, 2024
2 parents b209c1c + db21270 commit c81e492
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kokeunho/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

| μ°¨μ‹œ | λ‚ μ§œ | λ¬Έμ œμœ ν˜• | 링크 | 풀이 |
|:----:|:---------:|:----:|:-----:|:----:|
| 1μ°¨μ‹œ | 2024.10.01 | κ΅¬ν˜„ | [μΆ”μ–΅ 점수](https://school.programmers.co.kr/learn/courses/30/lessons/176963)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/35|
| 1μ°¨μ‹œ | 2024.09.28 | κ΅¬ν˜„ | [ν‚Ή](https://www.acmicpc.net/problem/1063) | [#1](https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/1) |
---
39 changes: 39 additions & 0 deletions kokeunho/κ΅¬ν˜„/1-kokeunho.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
king, rock, m_time = input().split()
m_time = int(m_time)
move = [input() for _ in range(m_time)]

king_x = int(ord(king[0])) - int(ord('A')) + 1
king_y = int(king[1])

rock_x = int(ord(rock[0])) - int(ord('A')) + 1
rock_y = int(rock[1])

move_way = ['R', 'L', 'T', 'B', 'RT', 'RB', 'LT', 'LB']
dx = [1, -1, 0, 0, 1, 1, -1, -1]
dy = [0, 0, 1, -1, 1, -1, 1, -1]

for i in range(m_time):
index = move_way.index(move[i])

after_king_x = king_x + dx[index]
after_king_y = king_y + dy[index]

if 0 < after_king_x <= 8 and 0 < after_king_y <= 8:
if after_king_x == rock_x and after_king_y == rock_y:
after_rock_x = rock_x + dx[index]
after_rock_y = rock_y + dy[index]
if 0 < after_rock_x <= 8 and 0 < after_rock_y <= 8:
king_x = after_king_x
king_y = after_king_y
rock_x = after_rock_x
rock_y = after_rock_y
else:
king_x = after_king_x
king_y = after_king_y

print(f'{chr(king_x + 64)}{king_y}')
print(f'{chr(rock_x + 64)}{rock_y}')




0 comments on commit c81e492

Please sign in to comment.