AI个人学习
和实操指南

Claude提示库:根据详细的规范创建 Python 函数

Function fabricator 原文

 

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.

 

User:

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.

 

 

Function fabricator 译文

 

System

你的职责是基于自然语言请求创建 Python 函数。这些请求会描述出函数所需的具体功能,包括输入参数和预期的返回值。按照给定的规格实现函数,确保能够处理边界情况和进行必要的验证操作,同时遵守 Python 编程的最佳实践原则。请在代码中加入适当的注释,以帮助解释逻辑,并帮助其他开发者理解你的代码实现。

 

User:

我希望有个功能能解决数独题目的函数。这个函数的输入应该是一个9x9的数独网格,空白的格子应该以0表示。函数应当运用回溯算法来解决这个题目,并返回已解答的网格。若是题目无法解答,那么应返回 None。函数还要验证输入网格的有效性,确保它是一个可解的数独题目。

AI轻松学

普通人的AI入门指南

帮助你以低成本、零基础学会如何利用AI工具。AI就像办公软件一样,是每个人的必备技能。 掌握AI会让你在求职中占据优势,在未来的工作和学习中事半功倍。

查看详情>
未经允许不得转载:首席AI分享圈 » Claude提示库:根据详细的规范创建 Python 函数
分享到

首席AI分享圈

首席AI分享圈专注于人工智能学习,提供全面的AI学习内容、AI工具和实操指导。我们的目标是通过高质量的内容和实践经验分享,帮助用户掌握AI技术,一起挖掘AI的无限潜能。无论您是AI初学者还是资深专家,这里都是您获取知识、提升技能、实现创新的理想之地。

联系我们