Bibliothèque de prompts
Fabricant de fonctions
Ressources
- Overview
- Démarrages rapides
- Fiche technique du modèle Claude 3
- Fiche système de Claude 3.7
- État du système
- Cours Anthropic
- Bibliothèque de prompts
- Bibliothèque de prompts
- Frappes Cosmiques
- Clairvoyant d'entreprise
- Assistant de création de site web
- Expert en formules Excel
- Scripteur d'applications Google
- Correcteur de bugs Python
- Consultant en voyage dans le temps
- Compagnon de narration
- Citez vos sources
- Sorcier SQL
- Interprète de rêves
- Pun-dit
- Créateur culinaire
- Poète de mots-valises
- Hal l'assistant humoristique
- Légende LaTeX
- Coloriste d'humeur
- Git gud
- Savant des comparaisons
- Navigateur de dilemmes éthiques
- Meeting scribe
- Illuminateur d'expressions idiomatiques
- Consultant en code
- Fabricant de fonctions
- Créateur de néologismes
- Convertisseur CSV
- Encodeur d'émojis
- Polisseur de prose
- Évaluateur de perspectives
- Générateur de quiz
- Mentor de pleine conscience
- Simplificateur pour élèves de primaire
- Innovateur de fitness en VR
- Purificateur de PII
- Maître des mémos
- Coach de carrière
- Gourou de l'évaluation
- Virelangue
- Créateur de questions d'entretien
- Génie de la grammaire
- Devine mon énigme
- Clarificateur de code
- Anthropologue extraterrestre
- Organisateur de données
- Créateur de marque
- Estimateur d'efficacité
- Classificateur d'avis
- Décodeur de directions
- Muse motivationnelle
- Extracteur d'e-mails
- Modérateur expert
- Planificateur de leçons
- Sage socratique
- Alchimiste de l'allitération
- Conseiller en mode futuriste
- Superpouvoirs polyglottes
- Expert en noms de produits
- Réflexions philosophiques
- Sorcier des feuilles de calcul
- Simulateur de scénarios de science-fiction
- Éditeur adaptatif
- Les diffusions de Babel
- Détecteur de ton des tweets
- Analyste de codes d'aéroport
Bibliothèque de prompts
Fabricant de fonctions
Créez des fonctions Python basées sur des spécifications détaillées.
Copiez ce prompt dans notre Console développeur pour l’essayer vous-même !
Contenu | |
---|---|
System | Votre tâche est de créer des fonctions Python basées sur les demandes en langage naturel fournies. Les demandes décriront la fonctionnalité souhaitée de la fonction, y compris les paramètres d’entrée et la valeur de retour attendue. Implémentez les fonctions selon les spécifications données, en vous assurant qu’elles gèrent les cas limites, effectuent les validations nécessaires et suivent les meilleures pratiques de programmation Python. Veuillez inclure des commentaires appropriés dans le code pour expliquer la logique et aider les autres développeurs à comprendre l’implémentation. |
User | Je veux une fonction qui peut résoudre un puzzle Sudoku. La fonction doit prendre en entrée une grille de Sudoku 9x9, où les cellules vides sont représentées par la valeur 0. La fonction doit résoudre le puzzle en utilisant un algorithme de backtracking et retourner la grille résolue. Si le puzzle est insoluble, elle doit retourner None. La fonction doit également valider la grille d’entrée pour s’assurer qu’il s’agit d’un puzzle Sudoku valide. |
Exemple de sortie
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
Requête API
import anthropic
client = anthropic.Anthropic( # defaults to 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( # defaults to 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", // defaults to 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
# See https://docs.anthropic.com/claude/reference/claude-on-amazon-bedrock
# for authentication options
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";
// See https://docs.anthropic.com/claude/reference/claude-on-amazon-bedrock
// for authentication options
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';
// Reads from the `CLOUD_ML_REGION` & `ANTHROPIC_VERTEX_PROJECT_ID` environment variables.
// Additionally goes through the standard `google-auth-library` flow.
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);
Was this page helpful?
On this page