리소스
- Overview
- 빠른 시작
- Claude 3 모델 카드
- Claude 3.7 시스템 카드
- 시스템 상태
- Anthropic 코스
- 프롬프트 라이브러리
- 프롬프트 라이브러리
- 우주의 키스트로크
- 기업 선견자
- 웹사이트 마법사
- 엑셀 수식 전문가
- Google 앱스 스크립트 작성자
- Python 버그 버스터
- 시간 여행 컨설턴트
- 스토리텔링 조력자
- 출처 인용하기
- SQL 마법사
- 꿈 해석가
- 말장난꾼
- 요리 크리에이터
- 혼성어 시인
- 유머러스한 도우미 할(Hal)
- LaTeX 전문가
- 감정 색상화
- Git 마스터하기
- 비유의 달인
- 윤리적 딜레마 내비게이터
- 회의 기록자
- 관용구 해설가
- 코드 컨설턴트
- 함수 제작기
- 신조어 창작자
- CSV 변환기
- 이모지 인코더
- 문장 개선기
- 관점 분석기
- 퀴즈 생성기
- 마음챙김 멘토
- 초등학교 2학년 수준 단순화기
- VR 피트니스 혁신가
- PII 정화기
- 메모 마에스트로
- 커리어 코치
- 채점 전문가
- 혀 꼬부리기
- 면접 질문 작성기
- 문법 지니
- 수수께끼를 내겠습니다
- 코드 명확화 도구
- 외계 인류학자
- 데이터 정리기
- 브랜드 빌더
- 효율성 추정기
- 리뷰 분류기
- 방향 디코더
- 동기부여 뮤즈
- 이메일 추출기
- 마스터 중재자
- 수업 계획 작성기
- 소크라테스식 현자
- 두운법 연금술사
- 미래적 패션 어드바이저
- 다국어 초능력
- 제품 이름 짓기 전문가
- 철학적 사색
- 스프레드시트 마법사
- 공상과학 시나리오 시뮬레이터
- 적응형 에디터
- 바벨의 방송
- 트윗 톤 감지기
- 공항 코드 분석기
프롬프트 라이브러리
함수 제작기
상세한 명세를 기반으로 Python 함수를 생성합니다.
이 프롬프트를 개발자 Console에 복사하여 직접 시도해보세요!
내용 | |
---|---|
System | 당신의 임무는 제공된 자연어 요청에 기반하여 Python 함수를 생성하는 것입니다. 요청은 함수의 원하는 기능, 입력 매개변수 및 예상 반환 값을 포함하여 설명할 것입니다. 주어진 명세에 따라 함수를 구현하고, 엣지 케이스를 처리하며, 필요한 유효성 검사를 수행하고, Python 프로그래밍의 모범 사례를 따르도록 하세요. 코드에 적절한 주석을 포함하여 로직을 설명하고 다른 개발자가 구현을 이해하는 데 도움이 되도록 하세요. |
User | 스도쿠 퍼즐을 풀 수 있는 함수가 필요합니다. 이 함수는 9x9 스도쿠 그리드를 입력으로 받아야 하며, 빈 셀은 값 0으로 표시됩니다. 함수는 백트래킹 알고리즘을 사용하여 퍼즐을 풀고 해결된 그리드를 반환해야 합니다. 퍼즐을 풀 수 없는 경우 None을 반환해야 합니다. 또한 함수는 입력 그리드가 유효한 스도쿠 퍼즐인지 확인하기 위해 유효성을 검사해야 합니다. |
예제 출력
Python
def solve_sudoku(grid):
def is_valid(row, col, num):
# 현재 행과 열에서 숫자가 유효한지 확인
for i in range(9):
if grid[row][i] == num or grid[i][col] == num:
return False
# 현재 3x3 서브그리드에서 숫자가 유효한지 확인
start_row, start_col = (row // 3) * 3, (col // 3) * 3
for i in range(3):
for j in range(3):
if grid[start_row + i][start_col + j] == num:
return False
return True
def backtrack(row, col):
# 모든 셀을 채웠다면 퍼즐이 해결된 것
if row == 9:
return True
# 현재 행의 끝에 도달했다면 다음 행으로 이동
if col == 9:
return backtrack(row + 1, 0)
# 현재 셀이 이미 채워져 있다면 다음 셀로 이동
if grid[row][col] != 0:
return backtrack(row, col + 1)
# 현재 셀을 1부터 9까지의 숫자로 채우기 시도
for num in range(1, 10):
if is_valid(row, col, num):
grid[row][col] = num
if backtrack(row, col + 1):
return True
grid[row][col] = 0
# 유효한 숫자를 찾지 못했다면 백트래킹
return False
# 입력 그리드 유효성 검사
if not all(len(row) == 9 and all(0 <= cell <= 9 for cell in row) for row in grid):
return None
# 백트래킹 알고리즘 시작
if backtrack(0, 0):
return grid
else:
return None
API 요청
import anthropic
client = anthropic.Anthropic( # 기본값은 os.environ.get("ANTHROPIC_API_KEY")
api_key="my_api_key",
)
message = client.messages.create(
model="claude-opus-4-20250514",
max_tokens=1000,
temperature=0,
system="Your task is to create Python functions based on the provided natural language requests. The requests will describe the desired functionality of the function, including the input parameters and expected return value. Implement the functions according to the given specifications, ensuring that they handle edge cases, perform necessary validations, and follow best practices for Python programming. Please include appropriate comments in the code to explain the logic and assist other developers in understanding the implementation.",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "I want a function that can solve a Sudoku puzzle. The function should take a 9x9 Sudoku grid as input, where empty cells are represented by the value 0. The function should solve the puzzle using a backtracking algorithm and return the solved grid. If the puzzle is unsolvable, it should return None. The function should also validate the input grid to ensure it is a valid Sudoku puzzle.",
}
],
}
],
)
print(message.content)
import anthropic
client = anthropic.Anthropic( # 기본값은 os.environ.get("ANTHROPIC_API_KEY")
api_key="my_api_key",
)
message = client.messages.create(
model="claude-opus-4-20250514",
max_tokens=1000,
temperature=0,
system="Your task is to create Python functions based on the provided natural language requests. The requests will describe the desired functionality of the function, including the input parameters and expected return value. Implement the functions according to the given specifications, ensuring that they handle edge cases, perform necessary validations, and follow best practices for Python programming. Please include appropriate comments in the code to explain the logic and assist other developers in understanding the implementation.",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "I want a function that can solve a Sudoku puzzle. The function should take a 9x9 Sudoku grid as input, where empty cells are represented by the value 0. The function should solve the puzzle using a backtracking algorithm and return the solved grid. If the puzzle is unsolvable, it should return None. The function should also validate the input grid to ensure it is a valid Sudoku puzzle.",
}
],
}
],
)
print(message.content)
import Anthropic from "@anthropic-ai/sdk";
const anthropic = new Anthropic({
apiKey: "my_api_key", // 기본값은 process.env["ANTHROPIC_API_KEY"]
});
const msg = await anthropic.messages.create({
model: "claude-opus-4-20250514",
max_tokens: 1000,
temperature: 0,
system: "Your task is to create Python functions based on the provided natural language requests. The requests will describe the desired functionality of the function, including the input parameters and expected return value. Implement the functions according to the given specifications, ensuring that they handle edge cases, perform necessary validations, and follow best practices for Python programming. Please include appropriate comments in the code to explain the logic and assist other developers in understanding the implementation.",
messages: [
{
"role": "user",
"content": [
{
"type": "text",
"text": "I want a function that can solve a Sudoku puzzle. The function should take a 9x9 Sudoku grid as input, where empty cells are represented by the value 0. The function should solve the puzzle using a backtracking algorithm and return the solved grid. If the puzzle is unsolvable, it should return None. The function should also validate the input grid to ensure it is a valid Sudoku puzzle."
}
]
}
]
});
console.log(msg);
from anthropic import AnthropicBedrock
# 인증 옵션은 https://docs.anthropic.com/claude/reference/claude-on-amazon-bedrock 참조
# 인증 옵션
client = AnthropicBedrock()
message = client.messages.create(
model="anthropic.claude-opus-4-20250514-v1:0",
max_tokens=1000,
temperature=0,
system="Your task is to create Python functions based on the provided natural language requests. The requests will describe the desired functionality of the function, including the input parameters and expected return value. Implement the functions according to the given specifications, ensuring that they handle edge cases, perform necessary validations, and follow best practices for Python programming. Please include appropriate comments in the code to explain the logic and assist other developers in understanding the implementation.",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "I want a function that can solve a Sudoku puzzle. The function should take a 9x9 Sudoku grid as input, where empty cells are represented by the value 0. The function should solve the puzzle using a backtracking algorithm and return the solved grid. If the puzzle is unsolvable, it should return None. The function should also validate the input grid to ensure it is a valid Sudoku puzzle."
}
]
}
]
)
print(message.content)
import AnthropicBedrock from "@anthropic-ai/bedrock-sdk";
// 인증 옵션은 https://docs.anthropic.com/claude/reference/claude-on-amazon-bedrock 참조
// 인증 옵션
const client = new AnthropicBedrock();
const msg = await client.messages.create({
model: "anthropic.claude-opus-4-20250514-v1:0",
max_tokens: 1000,
temperature: 0,
system: "Your task is to create Python functions based on the provided natural language requests. The requests will describe the desired functionality of the function, including the input parameters and expected return value. Implement the functions according to the given specifications, ensuring that they handle edge cases, perform necessary validations, and follow best practices for Python programming. Please include appropriate comments in the code to explain the logic and assist other developers in understanding the implementation.",
messages: [
{
"role": "user",
"content": [
{
"type": "text",
"text": "I want a function that can solve a Sudoku puzzle. The function should take a 9x9 Sudoku grid as input, where empty cells are represented by the value 0. The function should solve the puzzle using a backtracking algorithm and return the solved grid. If the puzzle is unsolvable, it should return None. The function should also validate the input grid to ensure it is a valid Sudoku puzzle."
}
]
}
]
});
console.log(msg);
from anthropic import AnthropicVertex
client = AnthropicVertex()
message = client.messages.create(
model="claude-3-7-sonnet-v1@20250219",
max_tokens=1000,
temperature=0,
system="Your task is to create Python functions based on the provided natural language requests. The requests will describe the desired functionality of the function, including the input parameters and expected return value. Implement the functions according to the given specifications, ensuring that they handle edge cases, perform necessary validations, and follow best practices for Python programming. Please include appropriate comments in the code to explain the logic and assist other developers in understanding the implementation.",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "I want a function that can solve a Sudoku puzzle. The function should take a 9x9 Sudoku grid as input, where empty cells are represented by the value 0. The function should solve the puzzle using a backtracking algorithm and return the solved grid. If the puzzle is unsolvable, it should return None. The function should also validate the input grid to ensure it is a valid Sudoku puzzle."
}
]
}
]
)
print(message.content)
import { AnthropicVertex } from '@anthropic-ai/vertex-sdk';
// `CLOUD_ML_REGION` 및 `ANTHROPIC_VERTEX_PROJECT_ID` 환경 변수에서 읽습니다.
// 추가적으로 표준 `google-auth-library` 흐름을 통과합니다.
const client = new AnthropicVertex();
const msg = await client.messages.create({
model: "claude-3-7-sonnet-v1@20250219",
max_tokens: 1000,
temperature: 0,
system: "Your task is to create Python functions based on the provided natural language requests. The requests will describe the desired functionality of the function, including the input parameters and expected return value. Implement the functions according to the given specifications, ensuring that they handle edge cases, perform necessary validations, and follow best practices for Python programming. Please include appropriate comments in the code to explain the logic and assist other developers in understanding the implementation.",
messages: [
{
"role": "user",
"content": [
{
"type": "text",
"text": "I want a function that can solve a Sudoku puzzle. The function should take a 9x9 Sudoku grid as input, where empty cells are represented by the value 0. The function should solve the puzzle using a backtracking algorithm and return the solved grid. If the puzzle is unsolvable, it should return None. The function should also validate the input grid to ensure it is a valid Sudoku puzzle."
}
]
}
]
});
console.log(msg);