Loading...
    • 개발자 가이드
    • API 참조
    • MCP
    • 리소스
    • 릴리스 노트
    Search...
    ⌘K
    리소스
    개요용어집시스템 프롬프트
    프롬프트 라이브러리Cosmic KeystrokesCorporate clairvoyantWebsite wizardExcel formula expertGoogle apps scripterPython bug busterTime travel consultantStorytelling sidekick출처 인용SQL sorcererDream interpreterPun-ditCulinary creatorPortmanteau poetHal the humorous helperLaTeX legendMood colorizerGit gudSimile savantEthical dilemma navigatorMeeting scribeIdiom illuminatorCode consultantFunction fabricatorNeologism creatorCSV converterEmoji encoderProse polisherPerspectives pondererTrivia generatorMindfulness mentorSecond-grade simplifierVR fitness innovatorPII purifierMemo maestroCareer coachGrading guruTongue twisterInterview question crafterGrammar genieRiddle me thisCode clarifierAlien anthropologistData organizerBrand builderEfficiency estimatorReview classifierDirection decoderMotivational museEmail extractorMaster moderatorLesson plannerSocratic sageAlliteration alchemistFuturistic fashion advisorPolyglot superpowersProduct naming proPhilosophical musingsSpreadsheet sorcererSci-fi scenario simulatorAdaptive editorBabel's broadcastsTweet tone detectorAirport code analyst
    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):
           # 현재 행과 열에서 숫자가 유효한지 확인
           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 요청

    • API 요청