Loading...
    • 개발자 가이드
    • API 레퍼런스
    • MCP
    • 리소스
    • 릴리스 노트
    Search...
    ⌘K
    리소스
    개요용어집시스템 프롬프트
    프롬프트 라이브러리Cosmic Keystrokes기업 예측가웹사이트 마법사Excel 수식 전문가Google Apps 스크립터Python 버그 버스터시간 여행 컨설턴트스토리텔링 도우미출처 인용하기SQL 마법사꿈 해석가말장난 전문가요리 창작가합성어 시인유머러스한 도우미 HalLaTeX 달인감정 색채화Git 달인직유법 달인윤리적 딜레마 안내자회의록 작성자관용구 해설가코드 컨설턴트함수 제작자신조어 창작가CSV 변환기이모지 인코더문장 다듬기관점 탐구가퀴즈 생성기마음챙김 멘토초등학생 눈높이 설명VR 피트니스 혁신가개인정보 정제기메모 달인커리어 코치채점 전문가잰말놀이면접 질문 제작자문법 요정수수께끼 풀기코드 해설가외계인 인류학자데이터 정리자브랜드 빌더효율성 추정기리뷰 분류기방향 해독기동기부여 뮤즈이메일 추출기마스터 모더레이터수업 계획자소크라테스식 현자두운법 연금술사미래형 패션 어드바이저다국어 초능력제품 네이밍 전문가철학적 사색스프레드시트 마법사SF 시나리오 시뮬레이터적응형 편집기바벨의 방송트윗 톤 감지기공항 코드 분석가
    Console
    Log in
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...

    Solutions

    • AI agents
    • Code modernization
    • Coding
    • Customer support
    • Education
    • Financial services
    • Government
    • Life sciences

    Partners

    • Amazon Bedrock
    • Google Cloud's Vertex AI

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Company

    • Anthropic
    • Careers
    • Economic Futures
    • Research
    • News
    • Responsible Scaling Policy
    • Security and compliance
    • Transparency

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Help and security

    • Availability
    • Status
    • Support
    • Discord

    Terms and policies

    • Privacy policy
    • Responsible disclosure policy
    • Terms of service: Commercial
    • Terms of service: Consumer
    • Usage policy
    프롬프트 라이브러리

    함수 제작기

    상세한 사양을 기반으로 Python 함수를 생성합니다.

    이 프롬프트를 개발자 Console에 복사하여 직접 사용해 보세요!

    내용
    System제공된 자연어 요청을 기반으로 Python 함수를 생성하는 것이 당신의 작업입니다. 요청에는 입력 매개변수와 예상 반환 값을 포함하여 함수의 원하는 기능이 설명됩니다. 주어진 사양에 따라 함수를 구현하되, 엣지 케이스를 처리하고, 필요한 유효성 검사를 수행하며, Python 프로그래밍의 모범 사례를 따르도록 하세요. 로직을 설명하고 다른 개발자가 구현을 이해하는 데 도움이 되도록 코드에 적절한 주석을 포함해 주세요.
    User스도쿠 퍼즐을 풀 수 있는 함수를 원합니다. 이 함수는 9x9 스도쿠 그리드를 입력으로 받아야 하며, 빈 셀은 값 0으로 표현됩니다. 함수는 백트래킹 알고리즘을 사용하여 퍼즐을 풀고 완성된 그리드를 반환해야 합니다. 퍼즐을 풀 수 없는 경우 None을 반환해야 합니다. 또한 함수는 입력 그리드가 유효한 스도쿠 퍼즐인지 검증해야 합니다.

    예시 출력

    Python
    def solve_sudoku(grid):
       def is_valid(row, col, num):
           # Check if the number is valid in the current row and column
           for i in range(9):
               if grid[row][i] == num or grid[i][col] == num:
                   return False
    
           # Check if the number is valid in the current 3x3 subgrid
           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 we have filled all cells, the puzzle is solved
           if row == 9:
               return True
    
           # Move to the next row if we have reached the end of the current row
           if col == 9:
               return backtrack(row + 1, 0)
    
           # If the current cell is already filled, move to the next cell
           if grid[row][col] != 0:
               return backtrack(row, col + 1)
    
           # Try filling the current cell with numbers from 1 to 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
    
           # If no valid number is found, backtrack
           return False
    
       # Validate the input grid
       if not all(len(row) == 9 and all(0 <= cell <= 9 for cell in row) for row in grid):
           return None
    
       # Start the backtracking algorithm
       if backtrack(0, 0):
           return grid
       else:
           return None
    

    API 요청

    Was this page helpful?

    • API 요청