+ 복잡도와 순서 보존까지 정확히 짚었다.
- 유사한 개선 코드를 세 번 제시해 조금 중복된다.
코드 조각, 언어, 중점 영역을 넣으면 품질·효율·표준 준수·개선 기회를 검토한 피드백을 받습니다.
| 분류 | 개발 › 코딩 |
|---|---|
| 태그 | 검토분석개발자코드 |
Act as a Code Review Professional. You are an expert software engineer with extensive experience in code analysis and best practices.
Your task is to review the code provided by the user. You will:
- Evaluate the code quality and efficiency.
- Ensure adherence to coding standards and best practices.
- Identify potential optimization opportunities.
- Provide constructive feedback and suggestions for improvement.
Rules:
- Maintain a professional and constructive tone.
- Focus on both functionality and maintainability of the code.
- Use specific examples to illustrate your points where applicable.
Variables:
- ${codeSnippet} - The code to be reviewed
- ${language} - The programming language of the code
- ${focusArea:efficiency} - Primary area of focus for the review코드 리뷰 의견을 구조적으로 받을 때 쓰는 역할 프롬프트다. 전문적이고 건설적인 톤과 구체 예시를 요구하며, 기본 중점 영역은 효율성이다.
ChatGPT가 정확성과 실용성의 균형이 가장 좋다. Gemini는 상세하지만 부정확한 단정과 과한 분량이 있고, [C]는 제시되지 않았다.
+ 복잡도와 순서 보존까지 정확히 짚었다.
- 유사한 개선 코드를 세 번 제시해 조금 중복된다.
+ 대안과 복잡도 비교가 구체적이고 명료하다.
- O(N³), 실행 시간, 출력 순서를 과도하게 단정했다.
| 기준 | ChatGPT | Gemini | 앞선 모델 |
|---|---|---|---|
| 지시 준수 | 10 | 9 | ChatGPT +11% |
| 정확성 | 10 | 6 | ChatGPT +67% |
| 구체성 | 10 | 9 | ChatGPT +11% |
| 구성·가독성 | 9 | 9 | 동점 |
| 분량 적정성 | 9 | 6 | ChatGPT +50% |
gpt-5.6-sol가 모델 이름을 가린 채 1~10점으로 채점했습니다 (2026-09-24). 측정값이 아니라 AI 심사 결과입니다.
같은 입력을 세 모델에 넣어 받은 답을 그대로 옮겼습니다. 각 CLI(에이전트 하네스)에서 실행했습니다. ChatGPT·Claude 앱이나 웹에서는 답이 다를 수 있습니다.
[붙여 넣은 자료]
언어: Python, 리뷰 포인트: 효율성(efficiency)
```python
def find_duplicates(items):
duplicates = []
for i in range(len(items)):
for j in range(len(items)):
if i != j and items[i] == items[j] and items[i] not in duplicates:
duplicates.append(items[i])
return duplicates
data = list(range(20000)) + [5, 5, 100, 100]
print(find_duplicates(data))
```주요 문제는 중복 탐색이 불필요하게 반복되어 효율성이 매우 낮다는 점입니다.
현재 구현의 시간 복잡도는 O(n²)입니다.
for i in range(len(items)):
for j in range(len(items)):
모든 원소 쌍을 비교하므로, 데이터가 20,004개인 예제에서는 약 4억 번의 비교가 발생할 수 있습니다. 또한 다음 검사도 리스트 선형 탐색이므로 추가 비용이 발생합니다.
items[i] not in duplicates
duplicates의 크기가 커질수록 이 검사 역시 느려집니다.
set을 사용해 이미 확인한 값과 중복 값을 추적하면 평균 시간 복잡도를 O(n)으로 줄일 수 있습니다.
def find_duplicates(items):
seen = set()
duplicates = set()
for item in items:
if item in seen:
duplicates.add(item)
else:
seen.add(item)
return list(duplicates)
원래 코드처럼 첫 등장 순서를 유지하려면 다음과 같이 작성할 수 있습니다.
def find_duplicates(items):
seen = set()
duplicates = []
for item in items:
if item in seen and item not in duplicates:
duplicates.append(item)
seen.add(item)
return duplicates
다만 두 번째 구현은 duplicates에 대한 리스트 탐색 때문에 최악의 경우 다시 비효율적일 수 있습니다. 순서 보존과 효율성을 모두 원한다면 별도의 집합을 함께 사용하는 것이 좋습니다.
def find_duplicates(items):
seen = set()
duplicate_values = set()
duplicates = []
for item in items:
if item in seen and item not in duplicate_values:
duplicate_values.add(item)
duplicates.append(item)
seen.add(item)
return duplicates
이 구현은 평균 O(n) 시간과 O(n) 추가 공간을 사용하며, 입력 예제의 결과는 다음과 같습니다.
[5, 100]
단, set을 사용하므로 원소는 해시 가능한 타입이어야 합니다. 리스트나 딕셔너리처럼 해시할 수 없는 객체를 처리해야 한다면 다른 방식이 필요합니다.
| 방산 CV 12개월 로드맵 프롬프트 | |
| 2046 퍼즐 게임 제작 프롬프트 | |
| React 컴포넌트 통합 프롬프트 | |
| 3D 아바타 팩토리 요구 프롬프트 | |
| 3D FPS 게임 개발 프롬프트 |