-
Notifications
You must be signed in to change notification settings - Fork 2
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
[김명준 ] 3주차 문제풀이 #15
base: main
Are you sure you want to change the base?
[김명준 ] 3주차 문제풀이 #15
Conversation
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.
알아보기 쉽게 잘 쪼개신거 같네요 굳
graph[i][j] = 1; | ||
makeWallDfs(graph, N, M, wallAmount + 1); | ||
graph[i][j] = 0; |
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.
0, 1로 나타내면 true, false를 나타내는 것인지 헷갈립니다.
뒤에 2도 나오던데, enum class나 상수를 사용해 매직넘버를 줄이는건 어떨까요?
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.
문제에서 0을 열린경로, 1을 벽, 2를 바이러스로 취급해서 그대로 graph를 사용하느라 그랬습니다..!
다음에는 가능하면 의미가 있도록 수정해서 Enum으로 최대한 매직넘버를 줄여보도록하겠습니다 감사합니다!
break; | ||
} | ||
|
||
countRemoveBlocks(check, table, m, n); |
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.
연구소 문제에서 count함수는 반환값이 있었는데, 해당 함수에는 반환값이 없네요.
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.
해당 함수 내부를 모른다면, input에 대한 output을 쉽게 예상할 수 있을까요?
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.
answer이 현재 count를 대신해서 증가되고 있습니다!
count로 변수명을 두는게 더 좋아 보이네요..👍
함수명을 더 고민해봐야할 것 같습니다.
리턴값이 없는 메서드인 countRemoveBlocks이
무엇을 갖고 동작하고 무엇을 반환하는지 메서드명에서 알 수 있도록 고려 했어야했네요...
지역변수를 최소한 하고자 파라미터로 전달했는데, 그 부분을 생각하지 못했습니다..!
if (table[k][j] != '-') { | ||
table[i][j] = table[k][j]; | ||
table[k][j] = '-'; | ||
break; |
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.
여기 break는 어디까지 멈추나요?
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.
지금 다시 봤을 때, 이전의 코드가 쉽게 이해가 되지 않네요...
break가 어디까지 동작해서 멈추는건지 유추하기 어려운 것 같습니다.
break를 걸게 된다면 어떻게 해야 쉽게 break 지점을 찾을 수 있을지
더 나은 방법을 고민해서 다음에 작성해보도록 하겠습니다.
현재 그래프가 상하로 뒤집어 놓은 상태인데,
아래에서 위로 가야하는 블록이 있다면,
세로로 차곡차곡 바꿔주고 멈추는 상태입니다..!
for (int k = i; k < m; k++) 안에서 break 가 됩니다!
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.
이 문제에서 제일 어려웠던 부분인 것 같네요..저는 한 열에 대해서 아래에서 위로 올라가면서 파괴된 블럭이 아닌 것 부터 먼저 담아주고 그 후, 모자란 만큼 파괴된 블럭으로 채웠습니다. 그리고 담은것을 뒤에서부터 꺼내면서 게임판을 변경했어요. 여기 changePositions
함수를 보면 확인할 수 있습니다.
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.
파이썬을 떠나보내니 파이썬의 강력함을 다시 느낄 수 있던 한 주였습니다. 명준님도 자바와 더 많이 친해지길 바랍니다..!
for (int i = 0; i < N; i++) { | ||
for (int j = 0; j < M; j++) { |
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.
3중 반복문으로 만들 수 있는 모든 벽의 경우의 수를 구해서 가독성이 좀 떨어진 느낌을 받았는데, dfs를 활용해볼 수도 있었네요. 이 방법으로 디버깅 해봐야겠습니다. :)
if (table[k][j] != '-') { | ||
table[i][j] = table[k][j]; | ||
table[k][j] = '-'; | ||
break; |
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.
이 문제에서 제일 어려웠던 부분인 것 같네요..저는 한 열에 대해서 아래에서 위로 올라가면서 파괴된 블럭이 아닌 것 부터 먼저 담아주고 그 후, 모자란 만큼 파괴된 블럭으로 채웠습니다. 그리고 담은것을 뒤에서부터 꺼내면서 게임판을 변경했어요. 여기 changePositions
함수를 보면 확인할 수 있습니다.
🖊️ 해결과정 기록
1️⃣ 프렌즈 4블록 (1H 30M)
💭 어떻게 접근했나요?
2️⃣ 연구소(1H)
💭 어떻게 접근했나요?
💪🏻 무엇을 얻었나요?
전역변수를 최소한해서 사용하게끔 노력했는데, 그러면서 짧은 시간 내에 더 객체지향적인 코드를 작성할 수 있을까 고민할 수 있었습니다.
함수를 쪼개기만 헀지만, 어떻게 하면 더 느슨하게 메서드가 상위 메서드에 결합할 수 있도록 고민하는게 재밌는 접근이었고 공부였다고 생각합니다.
🎸 기타 추가사항
개발할 때만 자바를 사용하다가 알고리즘을 자바로 푸니 조금 어색하기도 했지만, 재밌고 이해가 더 쉬워 구현이 더 빨라졌습니다. 이제 자바로 코테를 준비해도되는 단계인거같아요 휴휴
자바 컨벤션이나 객체지향적인 부분에서 의견이 다르거나 틀린 부분이 보이시면 거침없이 말씀 부탁드리겠습니다 감사합니다 🙇♂️