-
Notifications
You must be signed in to change notification settings - Fork 5
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
17-jung0115 #175
Open
jung0115
wants to merge
15
commits into
main
Choose a base branch
from
17-jung0115
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
17-jung0115 #175
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
janghw0126
approved these changes
Oct 12, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 5보다 작은 경우는 엘리베이터가 내려가고, 5보다 큰 경우는 올라가는 것이 유리하다고 생각해서 이를 바탕으로 코드를 구현해보았습니다!
def solution(storey):
answer = 0
while storey:
div=storey%10
if div==5 and storey//10%10>=5 or div>5:
storey+=10-div
answer+=10-div
else:
answer+=div
storey=storey//10
return answer
정미님의 로직과 거의 동일하네요! 이번 PR도 수고하셨습니다😊
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
➡️ 문제 풀이 코드
🔗 문제 링크
프로그래머스 | 그리디 알고리즘 - 마법의 엘리베이터(Lv.2)
✔️ 소요된 시간
40분
✨ 수도 코드
풀이 방법을 고민하는 데에 시간이 걸렸지만 생각보다 설명은 간단합니다!
층을 1과 10의 제곱수만큼 아래/위로 이동할 수 있기 때문에 각 자리 수마다 구분하여 생각했습니다
1 ~ 4일 경우
-
버튼을 눌러 내려가는 게 빠르고,6 ~ 9일 경우
+
버튼을 눌러 올라갔다가 -10을 해주는 게 빠릅니다.그리고 5일 경우 더하거나 빼는 양이 같기 때문에,
앞자리수까지 확인하여 더 효율적인 방법을 찾아줍니다!
📚 새롭게 알게된 내용