손영빈// base: main( 필수 기능 구현) <- compare: dev(도전 기능 구현) #1
Open
ybin4548 wants to merge 3 commits into
Open
Conversation
devBambu
reviewed
Jan 13, 2026
|
|
||
| totalCount += 1 //기록 저장용 Count + 1 | ||
|
|
||
| let inputChars = Array(input) //입력받은 값을 배열에 담음 |
Collaborator
There was a problem hiding this comment.
20번 줄에서 guard let num = Optional(input.compactMap{ Int(String($0)) }) 코드로 num: [Int]로 정의해주신 걸로 봤습니다!
그래서 inputChars에 다시 Array(input)으로 넣지 않아도 inputChars = num을 바로 사용해주시거나 따로 새로운 정의 없이 num을 그대로 사용하셔도 좋을 것 같습니당!
그렇게하면 40번 줄 for문 내에서 inputChars를 타입 변환 없이 그대로 사용하실 수 있을 것 같아요ㅎㅎ
Collaborator
Author
There was a problem hiding this comment.
아이코, 그냥 휙 넘어갔던 부분이라 생각도 못하고있었던 것 같아요.
감사합니다 !
TyrHanz
reviewed
Jan 15, 2026
| print("게임 기록 보기") | ||
| for (idx, score) in scoreRecord.enumerated() { //고차함수 enumerated를 사용하여 idx: 인덱스 score: 점수 반환 후 출력 | ||
| print("\(idx + 1)번째 게임 : 시도 횟수 - \(score)") | ||
| } |
Collaborator
There was a problem hiding this comment.
배열의 인덱스 값을 이용하여 플레이 횟수를 유추하는 방법 너무 인상적입니다!
This file contains hidden or 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
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.
하나의 함수 내부에 동작들을 전부 생성할 경우, 코드가 지저분해질 수 있어서 필요 기능들에 따라 함수로 분리했습니다.
startGame 함수로 호출하여 게임을 시작할 수 있습니다.
과제 속의 기능들만 구현해뒀기에 최적화가 덜 된 부분들이 존재합니다.
비슷한 개념들은 여러 방법으로 접근해서 풀어보고자 했습니다.