Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1-kokeunho #1

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}')