Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

[2023-10-13] wooyeol #335#336

Merged
zsmalla merged 1 commit into
mainfrom
wooyeol-#335
Mar 18, 2024
Merged

[2023-10-13] wooyeol #335#336
zsmalla merged 1 commit into
mainfrom
wooyeol-#335

Conversation

@Woo-Yeol
Copy link
Copy Markdown
Member

PR Summary

메이즈 러너
https://www.codetree.ai/training-field/frequent-problems/problems/maze-runner/description?page=1&pageSize=20

풀이시간
10:20 ~ 11 :54
13:12 ~ 14: 04
14:14 ~ 18:09 (6시간 19분)

문제 조건
N: 미로의 크기 (4≤N≤10)
M: 참가자 수 (1≤M≤10)
K: 게임 시간 (1≤K≤100)

시간 복잡도 :
O(K * (M^2 + M + MlogM + N^2 + M + N^2))
O(100 * (100 + 10 + 10log10 + 100 + 10 + 100))

접근법
무슨 알고리즘으로 풀이 할 수 있을까? -> 시뮬레이션

1초 동안 진행하기 위해 필요한 연산들

  • 현재 턴에 모든 플레이어 이동

    • 1초마다 상하좌우를 검사하고 최단 거리가 갱신되는 칸으로 이동
  • 가장 작은 정사각형 확인하기

    • 모든 플레이어를 기준으로 좌상단에 가까운 가장 작은 사각형을 만들고 그 중에서 가장 작은 정사각형 반환
  • 가장 작은 정사각형 회전하기

    • 임시 정사각형을 만들어서 회전시킨 값을 저장시키고 회전된 값을 다시 미로에 적용

@Woo-Yeol Woo-Yeol self-assigned this Oct 12, 2023
@Woo-Yeol Woo-Yeol linked an issue Oct 12, 2023 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

@zsmalla zsmalla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 플레이어 이동
  2. 정 사각형 좌표 구하기
  3. 회전하기
    이렇게 모듈화하는 부분이 같은데 다르게 구현해서 재미있었네요! 구현이 생각보다 너무 빡세고 고려할 게 많아서 메서드를 구현하기 전에 설계하는게 정말 중요했던 문제인 것 같습니다.
    설마 이것보다 어렵게 나오겠어요 코테 가서 뿌시고 오시죠 화이팅!

Comment thread CodeTree/메이즈 러너/wooyeol.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도.. 심적으로 많이 힘들었던 문제였습니다.

Comment thread CodeTree/메이즈 러너/wooyeol.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (nx, xy) == exit_coordinate 로 조건을 주면 더 간결하게 조건식을 작성할 수 있을 것 같습니다.

Comment thread CodeTree/메이즈 러너/wooyeol.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 함수와 players의 결합도를 줄이기 위해서 move 함수를 플레이어 1명 단위로 설계하고, 반복문을 함수 바깥에서 수행한다면 이렇게 별도의 리스트에 임시 이동 리스트를 두지 않아도 간결하게 함수 구성이 가능할 것 같다는 생각이 들었습니다. 개인적인 경험으로 복잡해지는 경우가 많더라고요!

@zsmalla zsmalla merged commit 50e8db7 into main Mar 18, 2024
@zsmalla zsmalla deleted the wooyeol-#335 branch March 18, 2024 10:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CodeTree] 메이즈 러너

2 participants