not_python bool 2
classes | no_assert_tests bool 2
classes | runable bool 2
classes | messages listlengths 2 2 | implicit_criterion bool 1
class | hidden_tests_raw stringlengths 0 7.8k | hidden_tests dict | has_explicit_criteria bool 1
class |
|---|---|---|---|---|---|---|---|
false | false | true | [
{
"content": "Given a list of financial transaction records, identify potential fraudulent transactions based on multiple criteria. Each transaction is a dictionary with keys: 'amount', 'timestamp', 'merchant', 'location', 'user_id'. Return a list of transaction IDs that are flagged as potentially fraudulent, s... | true | ```python
from datetime import datetime, timedelta
# test_1: Multiple users, overlapping fraud patterns, ensure user separation
transactions = [
{'id': 'T007', 'amount': 1200, 'timestamp': '2024-02-01 09:00', 'merchant': 'Luxury Store', 'location': 'Boston', 'user_id': 'U4'},
{'id': 'T008', 'amount': 1300, 'ti... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"Multiple users, overlapping fraud patterns, ensure user separation",
"Transactions at same location within 1 hour should not trigger location-based fraud",
"Unusual merchant for user with established patter... | true |
false | false | true | [
{
"content": "Given a list of document texts, group them into clusters based on similarity using TF-IDF vectorization and cosine similarity. Use a simple clustering approach to assign each document to a cluster. Return a list of cluster IDs (0-indexed integers) where each element corresponds to the cluster assi... | true | ```python
# setup (optional): any helper variables, imports, or fixtures needed for the tests
# test_1: All documents are identical
docs_identical = ["same text", "same text", "same text"]
assert cluster_documents(docs_identical) == [0, 0, 0]
# test_2: Each document is completely unique (no shared words)
docs_unique ... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"All documents are identical",
"Each document is completely unique (no shared words)",
"Large input with repeating patterns",
"Single document input",
"Documents with partial overlap forming a chain"... | true |
false | false | true | [
{
"content": "Write a function to parse web server access logs and extract error statistics. The function should handle multiple log formats (Apache Common Log Format, Nginx default format, and custom formats) and return a dictionary with error counts by status code and the most frequent error pattern.\n\nThe i... | true | ```python
# setup (optional): any helper variables, imports, or fixtures needed for the tests
from collections import Counter
# test_1: Handles multiple errors with tie in most common pattern (should pick one deterministically)
logs = [
'1.1.1.1 - - [01/Jan/2024:00:00:00 +0000] "GET /foo HTTP/1.1" 404 100',
'2... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"Handles multiple errors with tie in most common pattern (should pick one deterministically)",
"Handles malformed lines mixed with valid ones",
"Handles custom log format with extra fields and status at diff... | true |
false | false | true | [
{
"content": "I need help implementing a configuration management system that can parse and merge multiple config files with inheritance and override rules. The system should handle YAML-like nested structures with different merge strategies for different data types.\n\nTest cases:\nassert merge_configs([\n ... | true | ```python
# setup (optional): any helper variables, imports, or fixtures needed for the tests
# test_1: Deeply nested dictionaries with multiple overrides
assert merge_configs([
{"a": {"b": {"c": 1, "d": 2}}},
{"a": {"b": {"d": 3, "e": 4}}},
{"a": {"b": {"f": 5}}}
]) == {"a": {"b": {"c": 1, "d": 3, "e": 4,... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"Deeply nested dictionaries with multiple overrides",
"Merging lists and dicts at the same key (list replaced by dict)",
"Scalar value replaced by list, then by dict",
"Empty config in the middle should ... | true |
false | false | true | [
{
"content": "I need to parse a custom configuration file format that supports sections, key-value pairs, lists, and cross-references between sections. The format looks like this:\n\n```\n[database]\nhost = localhost\nport = 8080\nenabled = true\ntags = web,api,prod\n\n[cache] \ntype = redis\nservers = ${databa... | true | ```python
# setup
import copy
# test_1: Cross-reference to a list value, and list with whitespace
config = """
[main]
values = a, b, c
[ref]
copy = ${main.values}
"""
assert parse_config(config) == {
'main': {'values': ['a', 'b', 'c']},
'ref': {'copy': ['a', 'b', 'c']}
}
# test_2: Nested cross-references (re... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"Cross-reference to a list value, and list with whitespace",
"Nested cross-references (reference to a value that itself contains a reference)",
"Boolean and integer values in lists, and mixed types",
"Cr... | true |
false | false | true | [
{
"content": "Write a function that validates and normalizes email addresses according to simplified RFC rules. The function should:\n\n1. Validate that the email has proper structure (local@domain format)\n2. Handle quoted local parts (e.g., \"john.doe\"@example.com)\n3. Normalize by removing dots from gmail a... | true | ```python
# setup (optional): any helper variables, imports, or fixtures needed for the tests
# test_1: quoted local part with plus and dots for non-gmail domain (should not normalize)
assert normalize_email('"a.b.c+d"@example.com') == '"a.b.c+d"@example.com'
# test_2: gmail address with uppercase local part and mult... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"quoted local part with plus and dots for non-gmail domain (should not normalize)",
"gmail address with uppercase local part and multiple pluses/dots",
"domain with consecutive dots (invalid)",
"quoted l... | true |
false | false | true | [
{
"content": "I need a function that extracts product information from e-commerce HTML pages. Given HTML content, extract the product name, price, rating, and availability status. The function should be robust to different HTML structures and handle missing data gracefully.\n\nTest cases:\nassert extract_produc... | true | ```python
# setup
import math
# test_1: Handles price with comma as thousands separator and missing rating/availability
assert extract_product_info('<div><h1>TV</h1><span class="price">$1,299.50</span></div>') == {'name': 'TV', 'price': 1299.50, 'rating': None, 'availability': None}
# test_2: Handles rating as intege... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"Handles price with comma as thousands separator and missing rating/availability",
"Handles rating as integer and availability as \"Out of Stock\"",
"Handles missing price, but present name, rating, and avai... | true |
false | false | true | [
{
"content": "You're working on a log analysis system that needs to process log files from different sources. Each source uses a different format (JSON, CSV, XML), and you need to count errors by severity level across all these formats.\n\nWrite a function that takes file contents as a string and filename, auto... | true | ```python
# setup
import textwrap
# test_1: JSON log with all severity levels present and mixed case levels
json_log = (
'{"timestamp":"2024-01-01","level":"critical","message":"Crash"}\n'
'{"timestamp":"2024-01-01","level":"Error","message":"Failure"}\n'
'{"timestamp":"2024-01-01","level":"WARNING","messa... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"JSON log with all severity levels present and mixed case levels",
"CSV log with no error entries (all levels missing or unknown)",
"XML log with multiple entries of the same severity and extra irrelevant at... | true |
false | false | true | [
{
"content": "I need a function that normalizes file paths by resolving \"..\" and \".\" components, removing redundant slashes, and returning the canonical absolute path. The function should handle edge cases gracefully.\n\nTest cases:\nassert normalize_path(\"/a//b/../c/./d\") == \"/a/c/d\"\nassert normalize_... | true | ```python
# test_1: path with multiple consecutive ".." at root
assert normalize_path("/../../../../") == "/"
# test_2: path ending with multiple slashes and dots
assert normalize_path("/a/b/c/./././") == "/a/b/c"
# test_3: path with only slashes
assert normalize_path("/////") == "/"
# test_4: path with interleaved ... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"path with multiple consecutive \"..\" at root",
"path ending with multiple slashes and dots",
"path with only slashes",
"path with interleaved \".\" and \"..\" components",
"path with no directory c... | true |
false | false | true | [
{
"content": "I need to analyze server access logs to extract performance statistics. Given a list of log entries, parse them and return response time statistics (mean, median, p95) while handling malformed entries gracefully.\n\nExpected log format: \"timestamp - method path response_time status\"\nExample: \"... | true | ```python
# setup (optional): any helper variables, imports, or fixtures needed for the tests
import math
# test_1: All entries malformed, expect empty statistics (should handle gracefully)
assert analyze_server_logs(["bad log", "1234", "2023-10-15 GET /api 200 OK", ""]) == {'mean': None, 'median': None, 'p95': None}
... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"All entries malformed, expect empty statistics (should handle gracefully)",
"Large number of valid entries, test p95 calculation with 100 entries",
"Mixed valid and malformed entries, only valid ones should... | true |
false | false | true | [
{
"content": "I need to analyze web server log files to identify potentially suspicious IP addresses. Given a list of log entries, find IPs that show suspicious behavior patterns like:\n\n1. Making more than 10 requests per minute\n2. Accessing sensitive paths (containing \"admin\", \"login\", \"config\") \n3. ... | true | ```python
from datetime import datetime, timedelta
# test_1: IP with exactly 11 requests in one minute, none to sensitive paths, all successful
log_entries = [
f"1.2.3.4 2024-01-01T12:00:{str(i).zfill(2)} GET /page{i} 200" for i in range(11)
]
assert find_suspicious_ips(log_entries) == ["1.2.3.4"]
# test_2: IP wi... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"IP with exactly 11 requests in one minute, none to sensitive paths, all successful",
"IP with 3 failed requests (not suspicious), and another with 4 failed requests (suspicious)",
"Multiple IPs, one trigger... | true |
false | false | true | [
{
"content": "Given a text document, extract the N most important sentences to create a summary. The importance score should consider factors like sentence position, word frequency, and sentence length. Return the selected sentences in their original order.\n\nTest cases:\nassert extract_summary(\"Machine learn... | true | ```python
# setup (optional): any helper variables, imports, or fixtures needed for the tests
# test_1: N equals number of sentences (should return all sentences in order)
doc1 = "A. B. C. D."
assert extract_summary(doc1, 4) == ["A.", "B.", "C.", "D."]
# test_2: Sentences with repeated high-frequency words
doc2 = "Ap... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"N equals number of sentences (should return all sentences in order)",
"Sentences with repeated high-frequency words",
"Very long sentence vs. several short sentences",
"N is zero (should return empty li... | true |
false | false | true | [
{
"content": "I need to analyze server log files to detect potential brute force attacks. Given a list of log entries, each containing a timestamp (Unix epoch), IP address, and whether the login was successful, identify if any IP address has more than `threshold` failed login attempts within any sliding `window... | true | ```python
# setup (optional): any helper variables, imports, or fixtures needed for the tests
# test_1: Multiple IPs, only one exceeds threshold in window
logs = [
(1000, "1.1.1.1", False),
(1010, "1.1.1.1", False),
(1020, "1.1.1.1", False),
(1030, "2.2.2.2", False),
(1040, "2.2.2.2", False),
(... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"Multiple IPs, only one exceeds threshold in window",
"Failed attempts exactly at window boundary (inclusive/exclusive)",
"Large number of failures, but all spaced just outside the window",
"Multiple win... | true |
false | false | true | [
{
"content": "I need to parse sales data from CSV files and find the top N products by revenue within a specific date range. The CSV has columns: date, product_id, product_name, quantity, price. Handle edge cases like missing data, invalid formats, etc.\n\nTest cases:\nassert top_products_by_revenue(\"sales_q1.... | true | ```python
import tempfile
import csv
import os
# Helper to create a temporary CSV file with given rows
def make_csv(rows):
fd, path = tempfile.mkstemp(suffix=".csv")
with os.fdopen(fd, "w", newline="") as f:
writer = csv.writer(f)
writer.writerow(["date", "product_id", "product_name", "quantity... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"All rows outside date range should yield empty result",
"Rows with missing or invalid quantity/price are ignored",
"Multiple products with same revenue, N larger than unique products",
"Date range inclu... | true |
false | false | true | [
{
"content": "I need a function that extracts valid email addresses from text documents. It should handle various formats, ignore malformed addresses, and be robust against edge cases like missing domains or invalid characters. Can you help me write this?\n\nTest cases:\nassert extract_emails(\"Contact john.doe... | true | ```python
import string
# test_1: Email with subdomain and plus addressing
assert extract_emails("Send to jane+newsletter@sub.mail.example.co.uk for updates") == ["jane+newsletter@sub.mail.example.co.uk"]
# test_2: Multiple emails with mixed valid and invalid, including consecutive dots and missing TLD
text = "foo..b... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"Email with subdomain and plus addressing",
"Multiple emails with mixed valid and invalid, including consecutive dots and missing TLD",
"Email at start and end of string, with punctuation",
"Email with a... | true |
false | false | true | [
{
"content": "I need a function to validate and normalize phone numbers from a messy dataset. The function should take a list of phone number strings in various formats and return a list of normalized US phone numbers in the format \"+1-XXX-XXX-XXXX\". Invalid numbers should be filtered out.\n\nTest cases:\nass... | true | ```python
# setup (optional): any helper variables, imports, or fixtures needed for the tests
import string
# test_1: Handles numbers with country code in different formats and extra whitespace
assert normalize_phone_numbers([" +1 555 321 7654 ", "1 (555) 321-7655", "5553217656"]) == [
"+1-555-321-7654", "+1-555... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"Handles numbers with country code in different formats and extra whitespace",
"Filters out numbers with too few or too many digits, including embedded spaces and symbols",
"Accepts numbers with mixed separa... | true |
false | false | true | [
{
"content": "I need a function that can robustly parse CSV files with potentially malformed data and extract specific columns. The CSV might have issues like unescaped quotes, inconsistent delimiters, missing fields, or encoding problems. I want to extract specific columns by name and return clean data.\n\nTes... | true | ```python
# setup
import sys
# test_1: Handles rows with missing fields (fewer columns than header)
csv_missing_fields = "a,b,c\n1,2\n3,4,5\n6"
assert parse_csv_robust(csv_missing_fields, ['a', 'c']) == [{'a': '1', 'c': ''}, {'a': '3', 'c': '5'}, {'a': '6', 'c': ''}]
# test_2: Handles extra fields (more columns than ... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"Handles rows with missing fields (fewer columns than header)",
"Handles extra fields (more columns than header)",
"Handles inconsistent delimiters (mix of commas and semicolons)",
"Handles unescaped quo... | true |
false | false | true | [
{
"content": "Given a list of server log entries (strings), detect potential security anomalies and system issues. Return a list of concerning patterns with severity descriptions. Focus on detecting things like: repeated failed login attempts, suspicious IP behavior, unusual access patterns, potential injection... | true | ```python
# setup (optional): any helper variables, imports, or fixtures needed for the tests
# test_1: Detects multiple types of anomalies in a single log batch
logs = [
"8.8.8.8 - - [10/Oct/2023:13:55:36] GET /admin 401",
"8.8.8.8 - - [10/Oct/2023:13:55:37] GET /admin 401",
"8.8.8.8 - - [10/Oct/2023:13:5... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"Detects multiple types of anomalies in a single log batch",
"No anomalies present in benign logs",
"Detects failed login attempts from multiple IPs separately",
"Detects SQL injection with encoded paylo... | true |
false | false | true | [
{
"content": "I need a function that parses web server log files to identify the most frequent error patterns. An error pattern is defined as the combination of HTTP status code (4xx or 5xx) and the first word of any error message that appears in the log entry. Return the top N most frequent patterns as a list ... | true | ```python
# setup (optional): any helper variables, imports, or fixtures needed for the tests
# test_1: Handles multiple error patterns with same count, checks secondary sort by status code ascending
logs1 = [
'ip - - [date] "GET / HTTP/1.1" 404 "File missing"',
'ip - - [date] "GET / HTTP/1.1" 500 "Server cras... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"Handles multiple error patterns with same count, checks secondary sort by status code ascending",
"Ignores non-error status codes and malformed lines mixed with valid error lines",
"Handles error messages w... | true |
false | false | true | [
{
"content": "I have a messy dataset with email addresses that need cleaning and validation. Some have extra whitespace, inconsistent capitalization, and various formatting issues. I need a function that takes a list of email strings and returns only the valid, cleaned emails in lowercase.\n\nTest cases:\nasser... | true | ```python
import string
# test_1: Emails with leading/trailing tabs and newlines, and mixed case
assert clean_emails(["\tAlice@Example.COM\n", "\nBob@site.org\t"]) == ["alice@example.com", "bob@site.org"]
# test_2: Emails with multiple '@' symbols and dots in local/host parts
assert clean_emails(["a.b.c@@domain.com",... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"Emails with leading/trailing tabs and newlines, and mixed case",
"Emails with multiple '@' symbols and dots in local/host parts",
"Emails with special characters allowed in local part, and some invalid ones... | true |
false | false | true | [
{
"content": "I need to analyze database query performance logs to identify bottlenecks and prioritize optimizations. Given a list of tuples containing (query_text, execution_time_ms, frequency), return a list of queries that should be optimized first, ordered by priority.\n\nThe priority should consider:\n- Qu... | true | ```python
# setup (optional): any helper variables, imports, or fixtures needed for the tests
# test_1: All queries have low execution time and low frequency (should return empty list)
assert analyze_query_performance([
("SELECT * FROM small_table", 3, 2),
("SELECT id FROM tiny_table", 2, 1)
]) == []
# test_2... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"All queries have low execution time and low frequency (should return empty list)",
"Query with inefficient pattern but low frequency vs. high-frequency, moderate-time query",
"Multiple queries with same exe... | true |
false | false | true | [
{
"content": "I need to implement a sliding window rate limiter for an API service. Given a user ID, current timestamp, rate limit (requests per minute), and the user's recent request history, return whether this new request should be allowed or blocked.\n\nThe sliding window should track requests within the la... | true | ```python
# setup (optional): any helper variables, imports, or fixtures needed for the tests
# test_1: exactly at the rate limit boundary (should allow)
assert rate_limiter("userA", 1060, 3, [1001, 1020, 1059]) == True # 3 in window, new is 4th, but oldest is just outside
# test_2: all previous requests are outside... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"exactly at the rate limit boundary (should allow)",
"all previous requests are outside the 60s window (should allow)",
"empty history (should allow)",
"multiple requests at the same timestamp, hitting t... | true |
false | false | true | [
{
"content": "Given invoice data as a structured text string, parse the line items, apply regional tax rates, and calculate the final total amount. The invoice format includes item descriptions, quantities, unit prices, and a region code. Tax rates vary by region: 'US': 8.5%, 'CA': 12%, 'EU': 20%. Handle discou... | true | ```python
# setup (optional): any helper variables, imports, or fixtures needed for the tests
# test_1: No items, only region specified (should result in 0.00 total)
assert process_invoice("REGION:US") == 0.00
# test_2: Discount code with 0% (should not affect total)
assert process_invoice("REGION:CA\nITEM:Item1|2|50... | {
"label": [
"test_1",
"test_2",
"test_3",
"test_4",
"test_5"
],
"desc": [
"No items, only region specified (should result in 0.00 total)",
"Discount code with 0% (should not affect total)",
"Multiple items, high quantity, EU region, with discount",
"Single item, US region, 100... | true |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 49