messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a Python module that provides a CircuitBreaker class and a retry_call function for unreliable operations. The Circui...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement an advanced webhook handler in Python that processes incoming HTTP-like request data for a payment provider. Write a...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Given a list of server jobs where each job is a tuple (priority, duration, job_id), implement a function schedule_jobs(jobs, k...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function `analyze_orders(orders)` that processes a list of order records and returns a summary dictionary. Each...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function `merge_ini_configs(base_path, override_path)` that loads two INI configuration files, merges them so t...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python CLI tool using argparse that accepts a required text file path and an optional --top N argument (default 5). T...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function `cached_fibonacci(n)` that returns the nth Fibonacci number using memoization to avoid repeated calcul...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python script that asks the user to enter a system command, runs that command using the subprocess module, and then pr...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function `render_invoice(template: str, customer: dict, items: list[dict], tax_rate: float) -> str` that render...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Given a pandas DataFrame named df containing sales data with the columns 'date', 'region', 'salesperson', 'category', and 'rev...
[ { "role": "system", "content": "You are an expert Python programming assistant. You write clear, correct, well-documented code that follows the user's instructions." }, { "role": "user", "content": "Can you create a function in Python for a FastAPI-based AI/ML platform that accepts a list of mod...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement an advanced webhook handler in Python using only the standard library. Write a function `handle_webhook(headers: dic...
[ { "role": "system", "content": "You are an expert Python programming assistant. You write clear, correct, well-documented code that follows the user's instructions." }, { "role": "user", "content": "Create a class that ingests cloud infrastructure billing export data from CSV files and uses Pand...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python program that uses dataclasses and type hints to manage a small inventory. Define an Item dataclass with fields...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a function that processes a live stream of integer event IDs and supports two efficient operations: inserting a new ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that merges multiple log files from a directory into a single output file. Each input file contains one...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that reads an arbitrarily large text file and prints the 10 most frequent words in a memory-efficient w...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a small Python router for a web framework that supports registering URL patterns with dynamic segments like /users/<id>...
[ { "role": "system", "content": "You are an expert Python programming assistant. You write clear, correct, well-documented code that follows the user's instructions." }, { "role": "user", "content": "Can you create a function in Python for a beginner-level AI-powered diagnostic tool used in healt...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Given a list of positive integers nums, split it into exactly two non-empty subsets such that the absolute difference between ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that simulates a simple API rate limiter. Create a function `allow_request(user_id)` that allows up to ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python script that migrates user records from an old schema to a new schema. The old data is a list of dictionaries wi...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a simple event bus using the publish/subscribe pattern. Create an EventBus class that allows functions to subscribe ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that loads application settings from a JSON configuration file named \"config.json\". If the file does ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement an advanced context manager class named `TransactionManager` for in-memory dictionary updates. It should support nes...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a function schedule_jobs(jobs) that simulates a single-threaded CPU using heap operations. Each job is a tuple (enqu...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that creates a reproducible .tar.gz archive from a source directory. The program must recursively inclu...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python program that implements a simple traffic light state machine. Start with the state \"Red\" and, each time the ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a decorator factory called retry(max_attempts) that wraps a function and retries it up to max_attempts times if it rais...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a small plugin system in Python using both the Singleton and Registry patterns. Implement a singleton class named Plugi...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python program that simulates a simple batch processing pipeline for customer orders. The program should take a prede...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python program that uses pydantic to validate user profile data. Define a UserProfile schema with these fields: usern...
[ { "role": "system", "content": "You are an expert Python programming assistant. You write clear, correct, well-documented code that follows the user's instructions." }, { "role": "user", "content": "Implement a script that builds a small Python web service using FastAPI to act as a CI/CD webhook...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that simulates a simple API rate limiter. Create a function called allow_request(user_id, timestamp) th...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a genetic algorithm that solves the Traveling Salesman Problem for a fixed set of 2D cities. Represent each individu...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function `top_k_frequent(words, k)` that uses a priority queue to return the `k` most frequent words from a lis...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a function `group_expenses(records)` that processes a list of expense records using `functools`. Each record is a tuple ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a small Python program that demonstrates the Command Pattern for a simple light switch. Define a Light class with on() ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that loads application settings from a JSON configuration file. The program should define a function `l...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement an asynchronous rate limiter for API clients using asyncio. Create a class AsyncTokenBucket that enforces throttling...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python program that defines a beginner-friendly context manager class called FileLogger. The context manager should o...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a reusable context manager class named `TransactionManager` for safely modifying a shared dictionary. The context ma...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that uses a simple genetic algorithm to find a binary string of length 20 with as many 1s as possible. ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function `summarize_orders(orders)` that processes a list of order dictionaries using list comprehensions and l...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python script that migrates user records from an old JSON file to a new CSV file. The input JSON file contains a list ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a lazy evaluation utility for processing large event streams. Create a function `windowed_unique_errors(events, wind...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function that takes a list of GPS coordinates as (latitude, longitude) tuples and computes the total travel dis...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that defines a function `update_url(url, key, value)` to parse a URL, add or update a query parameter, ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write an asynchronous Python program that simulates fetching data from three different web services. Create an async function ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that reads a list of timestamp strings in the format \"YYYY-MM-DD HH:MM\" and groups them by calendar d...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement an advanced LRU cache in Python as a class `LRUCache` with O(1) average-time `get(key)` and `put(key, value)` operat...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement an advanced configuration-driven report generation system using both Factory and Builder patterns. Create a ReportFa...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that uses itertools recipes to process a list of website visit page names. Given a list of page names i...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that simulates calling an unreliable service. Create a function that retries a failing operation up to ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program using Pillow that opens an image file named input.jpg, resizes it to 300x300 pixels, converts it to gra...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function `top_k_frequent_words(file_path, k)` that reads a potentially very large text file in a memory-efficie...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that manages a to-do list using a min-heap. Each task has a priority number and a name, where a smaller...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python CLI tool using argparse that reads integers either from command-line arguments or from standard input, then co...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that uses functools.reduce to calculate the total price of a shopping cart. The cart should be a list o...
[ { "role": "system", "content": "You are an expert Python programming assistant. You write clear, correct, well-documented code that follows the user's instructions." }, { "role": "user", "content": "Can you create a function in Python for a Telemedicine Platform that validates and schedules virt...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a function `top_k_frequent(words, k)` that returns the `k` most frequent words from a list of strings. Use a priority qu...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement a lazy round-robin merge utility for streaming data. Write a function `round_robin(*iterables)` that accepts any num...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement an advanced finite state machine for a network connection lifecycle. Create a ConnectionFSM class that supports the ...
[ { "role": "system", "content": "You are an expert Python programming assistant. You write clear, correct, well-documented code that follows the user's instructions." }, { "role": "user", "content": "Can you create a function in Python for an automated trading system that processes a time-ordered...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that computes the top 10 most frequent words in a potentially very large UTF-8 text file without loadin...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that reads a binary file named \"input.bin\", counts how many bytes in the file have a value greater th...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function `find_expression(nums, target)` that uses recursion to determine whether the integers in `nums` can be...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a Python program that uses the Factory and Builder patterns to prepare different types of drinks. Implement a DrinkFact...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Create a small event-driven system in Python for a smart home monitor. Implement an EventBus class that lets functions subscri...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement an advanced middleware pipeline in Python. Create a function `build_pipeline(middlewares, handler)` that composes a ...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Implement an advanced LRU cache class in Python with O(1) average-time get and put operations using a hash map plus a doubly l...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function `count_expressions(nums, target)` that uses recursion to count how many different arithmetic expressio...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python class called LRUCache that stores a limited number of key-value pairs. The cache should be created with a posit...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python function that computes the total length in kilometers of a GPS track on Earth using the haversine formula, whil...
[ { "role": "system", "content": "You are a helpful assistant that writes clean, well-structured Python code to solve the user's request." }, { "role": "user", "content": "Write a Python program that implements a simple Binary Search Tree (BST). Create a Node class and a BinarySearchTree class wit...
[ { "role": "system", "content": "You are an expert Python programming assistant. You write clear, correct, well-documented code that follows the user's instructions." }, { "role": "user", "content": "Create a class that monitors cloud server usage on a Cloud Computing Platform by storing the CPU ...