version
stringclasses
1 value
style
stringclasses
2 values
subset
stringclasses
12 values
question_id
stringlengths
9
23
question
stringlengths
27
8.13k
solution
stringlengths
99
5.97k
test
stringlengths
105
4.45k
test_info
listlengths
0
13
gpt_pass_sequence
listlengths
1
10
gpt_pass_trial_num
int64
1
10
gpt_difficulty
stringclasses
3 values
gpt_pass_percentage
float64
0.1
1
trials
dict
chosen_trial
stringclasses
10 values
metadata
dict
benchmark_similarity
float64
0.16
0.93
benchmark_instruction
stringclasses
1 value
benchmark_task_id
stringclasses
1 value
filter_reason
stringclasses
1 value
base_id
stringlengths
7
21
variant
stringclasses
2 values
top_function_names
listlengths
2
13
n_top_functions
int64
2
13
helper_call_edges
listlengths
1
16
n_helper_call_edges
int64
1
16
harness_functions
listlengths
0
3
structural_wrapper
bool
1 class
class_names
listlengths
0
5
has_class
bool
2 classes
test_kind
stringclasses
1 value
test_has_solution_import
bool
2 classes
third_party_imports
listlengths
0
5
stdlib_only
bool
2 classes
question_norm_sha1
stringlengths
40
40
solution_ast_sha1
stringlengths
40
40
v1.0
instruct
Filter
Filter_76546_I
Can you provide a Python script that demonstrates how to create a WebSocket server using the `websockets` library, and a client that connects to this server? This example should include basic functionality such as sending and receiving messages.
import asyncio import websockets async def echo(websocket, path): async for message in websocket: print(f"Received message from client: {message}") response = f"Echo: {message}" await websocket.send(response) print(f"Sent message to client: {response}") async def start_server(): ...
import pytest import asyncio import websockets @pytest.fixture(scope="module") def server(): server = websockets.serve(echo, "localhost", 8765) asyncio.get_event_loop().run_until_complete(server) yield server.ws_server.close() @pytest.mark.asyncio async def test_websocket_communication(server): ...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import asyncio\nimport websockets\n\nasync def echo(websocket, path):\n async for message in websocket:\n print(f\"Received message: {message}\")\n await websocket.send(f\"Ech...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076546", "row_id": 76546, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_155325']" }
0.48062
Filter_76546
I
[ "echo", "start_server" ]
2
[ [ "start_server", "echo" ] ]
1
[]
false
[]
false
pytest
false
[ "websockets" ]
false
a39ffd1ce1e7ff31ba20b8065f6171cc57b33a60
a821d23489770062505c009b57160fd1ce2c3134
v1.0
instruct
Filter
Filter_76557_I
Write a Python function to check if a number is a circular prime. A circular prime is a prime number that remains prime under all rotations of its digits. For example, 197 is a circular prime, since 197, 971, and 719 are all prime.
def is_prime(n): """ Checks if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return Tru...
from solution import is_circular_prime def test_is_circular_prime_known_circular_prime(): assert is_circular_prime(197) == True assert is_circular_prime(2) == True assert is_circular_prime(11) == True def test_is_circular_prime_known_non_circular_prime(): assert is_circular_prime(23) == False ...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates all rotations of the digits of a number.", "function_declaration": "def get_rotations(num):", "function_name": ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00076557", "row_id": 76557, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_155345']" }
0.692859
Filter_76557
I
[ "is_prime", "get_rotations", "is_circular_prime" ]
3
[ [ "is_circular_prime", "get_rotations" ], [ "is_circular_prime", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e8dcdbdc21c429ae9973b4ee4c7042f852cb7ef3
73db6bb60cf3a50c0d7ec967a25a56bd39505af3
v1.0
instruct
Filter
Filter_76577_I
Can you provide a Python script to simulate a simple dice game where two players roll a six-sided die three times each, and the player with the highest total score wins? If the scores are tied, it should declare a tie. The script should also display the individual rolls and the total scores for each player.
import random def roll_dice(): """ Simulates rolling a six-sided die. """ return random.randint(1, 6) def play_dice_game(): """ Simulates a dice game where two players roll a six-sided die three times each. Determines the winner based on the total score. """ player1_rolls = [roll_d...
from solution import play_dice_game def test_play_dice_game(): result = play_dice_game() # Check that the result contains all expected keys assert 'player1_rolls' in result assert 'player2_rolls' in result assert 'player1_total' in result assert 'player2_total' in result assert 'winner...
[ { "docstring": "Simulates rolling a six-sided die.", "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": "Simulates a dice game where two players roll a six-sided die three times each.\nDetermines the winner based on the total sc...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef roll_die():\n \"\"\"Roll a six-sided die and return the result.\"\"\"\n return random.randint(1, 6)\n\ndef play_dice_game():\n \"\"\"Simulate a dice game where tw...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076577", "row_id": 76577, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_155385']" }
0.472487
Filter_76577
I
[ "roll_dice", "play_dice_game" ]
2
[ [ "play_dice_game", "roll_dice" ] ]
1
[]
false
[]
false
pytest
true
[]
true
15d925623ca600a5b2bbcd55f0f36d687f8d9295
6c7a5c53f13f4daef31b44ba18d0e97d1105feda
v1.0
instruct
Filter
Filter_76587_I
Create a Python script that generates a list of prime numbers within a given range. The script should use a function to determine if a number is prime and should be efficient for large ranges.
def is_prime(n): """ Checks if a number is prime. Args: n (int): The number to check. Returns: bool: True if n is a prime number, False otherwise. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i ...
from solution import is_prime, generate_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(19) == True def test_generate_primes_empty(): assert generate_prime...
[ { "docstring": "Checks if a number is prime.\n\nArgs:\nn (int): The number to check.\n\nReturns:\nbool: True if n is a prime number, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates a list of prim...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00076587", "row_id": 76587, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_155407']" }
0.652267
Filter_76587
I
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a34d4f1a2a08ec1dd12c9cf7b15ce3ac97516fa7
ced171853911229d9684c7daeceda5eb0fdeed25
v1.0
instruct
Filter
Filter_76643_I
How can I write a Python script to remove duplicate files in a directory, keeping only one copy of each duplicate file?
import os import hashlib def get_file_hash(file_path): """ Generates a SHA-1 hash for the file located at file_path. """ sha1 = hashlib.sha1() with open(file_path, 'rb') as f: while True: data = f.read(65536) # Read the file in chunks of 64KB if not data: ...
import os import pytest # Sample directory path for testing, should ideally be a temp directory test_dir = 'test_directory' def create_test_files(): os.makedirs(test_dir, exist_ok=True) file_paths = [os.path.join(test_dir, f'test_file_{i}.txt') for i in range(5)] duplicate_file_content = 'This is a test f...
[ { "docstring": "Generates a SHA-1 hash for the file located at file_path.", "function_declaration": "def get_file_hash(file_path):", "function_name": "get_file_hash", "parameter_list": "(file_path)" }, { "docstring": "Removes duplicate files in the specified directory by retaining\nonly the ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\nimport hashlib\n\ndef get_file_hash(file_path):\n \"\"\"\n Returns the md5 hash of the file.\n \"\"\"\n hash_md5 = hashlib.md5()\n with open(file_path, \"rb\") as f:\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00076643", "row_id": 76643, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_155524']" }
0.589878
Filter_76643
I
[ "get_file_hash", "remove_duplicates" ]
2
[ [ "remove_duplicates", "get_file_hash" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1de027857afd38b0cc4561fea7c6c06d21d21abc
1ed01fb640a3ff103639286319ded4c97f40a07c
v1.0
instruct
Filter
Filter_76661_I
I'm working on a Python project and I need to create a function that reads a CSV file, performs some data cleaning, and then writes the cleaned data back to a new CSV file. The CSV file contains columns like 'Name', 'Age', 'Email', and 'City'. I want to ensure that the 'Email' column contains valid email addresses, 'Ag...
import csv import re def is_valid_email(email): """ Validate email address using regex. """ regex = r'^\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b' return re.match(regex, email) is not None def clean_csv(input_csv, output_csv): """ Clean the input_csv by validating and cleaning the...
import pytest import csv from solution import clean_csv, is_valid_email def test_is_valid_email(): assert is_valid_email('test@example.com') assert not is_valid_email('invalid-email') assert is_valid_email('valid_email@example.co.in') assert not is_valid_email('invalid@com') def test_clean_csv(tmp...
[ { "docstring": "Validate email address using regex.", "function_declaration": "def is_valid_email(email):", "function_name": "is_valid_email", "parameter_list": "(email)" }, { "docstring": "Clean the input_csv by validating and cleaning the columns and write the cleaned data to output_csv.",...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import csv\nimport re\n\ndef is_valid_email(email):\n regex = r'^\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b'\n return re.match(regex, email) is not None\n\ndef is_positive_in...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076661", "row_id": 76661, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_155558']" }
0.550351
Filter_76661
I
[ "is_valid_email", "clean_csv" ]
2
[ [ "clean_csv", "is_valid_email" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0b49e33db1c7e640903a95b5d324dda9a656c50e
c1a1db718c433709f8a1d15eea082bf53b6ac32c
v1.0
instruct
Filter
Filter_76662_I
What are the various ways to generate a list of prime numbers up to a certain number N in Python?
def is_prime(n): """ Returns True if n is a prime number, False otherwise. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import is_prime, generate_primes_simple, generate_primes_sieve, generate_primes_optimized_sieve def test_is_prime(): assert is_prime(2) == True assert is_prime(4) == False assert is_prime(13) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(17) == Tr...
[ { "docstring": "Returns True if n is a prime number, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates a list of prime numbers up to N using a simple trial division method.", "function_declarat...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determines if the number n is a prime.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076662", "row_id": 76662, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_155559']" }
0.625434
Filter_76662
I
[ "is_prime", "generate_primes_simple", "generate_primes_sieve", "generate_primes_optimized_sieve" ]
4
[ [ "generate_primes_simple", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
786ae94086f16c11ce5b12782abfafd2feec7552
06e2e966daffb4f301be8647ed4cfba07a0849e1
v1.0
instruct
Filter
Filter_76758_I
Devise a method to generate a random selection of 100 unique words from a given text file, ensuring that each word is at least 4 characters long. How can this be efficiently implemented in a programming language like Python?
import random def read_words_from_file(file_path): """ Reads words from a given text file, filters them by length (>= 4), and returns a list of unique words. """ with open(file_path, 'r') as f: words = f.read().split() unique_words = set(word for word in words if len(word) >= 4) return ...
import os from solution import get_random_selection # Helper function to create a temporary text file for testing def create_temp_text_file(content, file_name='temp_test_file.txt'): with open(file_name, 'w') as f: f.write(content) return file_name def test_get_random_selection_with_valid_data(): c...
[ { "docstring": "Reads words from a given text file, filters them by length (>= 4), and returns a list of unique words.", "function_declaration": "def read_words_from_file(file_path):", "function_name": "read_words_from_file", "parameter_list": "(file_path)" }, { "docstring": "Returns a rando...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef get_unique_words(filepath):\n \"\"\"\n Reads a text file and returns a list of unique words\n that are at least 4 characters long.\n \"\"\"\n with open(file...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076758", "row_id": 76758, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_155770']" }
0.606902
Filter_76758
I
[ "read_words_from_file", "get_random_selection" ]
2
[ [ "get_random_selection", "read_words_from_file" ] ]
1
[]
false
[]
false
pytest
true
[]
true
82c3c539036a960fb7039ee85102d87d95d34a67
11fe7a379325ed1e3133954fa004f388c379c9d6
v1.0
instruct
Filter
Filter_76787_I
You have been tasked to design a function-based programming (FBP) flow that facilitates data transformation and flow management in a data pipeline. The data pipeline involves two primary tasks: data cleaning and data transformation. The components involved in the data cleaning process are `RemoveNulls` and `NormalizeDa...
def remove_nulls(data): """ Remove null values from the dataset. """ return [item for item in data if item is not None] def normalize_data(data): """ Normalize the data values (for simplicity, just a placeholder function). """ max_value = max(data) return [item / max_value for item ...
from solution import remove_nulls, normalize_data, calculate_stats, format_data, data_pipeline def test_remove_nulls(): assert remove_nulls([1, None, 2, 3, None, 4]) == [1, 2, 3, 4] def test_normalize_data(): assert normalize_data([1, 2, 3, 4]) == [0.25, 0.5, 0.75, 1.0] def test_calculate_stats(): data =...
[ { "docstring": "Remove null values from the dataset.", "function_declaration": "def remove_nulls(data):", "function_name": "remove_nulls", "parameter_list": "(data)" }, { "docstring": "Normalize the data values (for simplicity, just a placeholder function).", "function_declaration": "def...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def remove_nulls(dataset):\n \"\"\"\n Removes null entries from the dataset.\n \"\"\"\n return [record for record in dataset if all(value is not None for value in record.values())]...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076787", "row_id": 76787, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_155828']" }
0.373944
Filter_76787
I
[ "remove_nulls", "normalize_data", "calculate_stats", "format_data", "data_pipeline" ]
5
[ [ "data_pipeline", "calculate_stats" ], [ "data_pipeline", "format_data" ], [ "data_pipeline", "normalize_data" ], [ "data_pipeline", "remove_nulls" ] ]
4
[]
false
[]
false
pytest
true
[]
true
a2d10016922002741118e48248643dba22ede28a
25783fa64f1b08609bcd987346f1ab6f3dd1296d
v1.0
instruct
Filter
Filter_76807_I
Given a list of number strings, write a Python function to filter out the strings that represent numbers which are prime. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The function should return a list of strings that represent prime numbers.
def is_prime(n): # Handle edge cases for numbers less than 2 if n <= 1: return False # Check divisors from 2 up to the square root of n for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def filter_prime_number_strings(number_strings): """ ...
from solution import filter_prime_number_strings def test_only_primes(): assert filter_prime_number_strings(["2", "3", "5", "7"]) == ["2", "3", "5", "7"] def test_mixed_numbers(): assert filter_prime_number_strings(["4", "5", "6", "7", "8"]) == ["5", "7"] def test_no_primes(): assert filter_prime...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Filters out the strings in the input list that represent prime numbers.\n:param number_strings: List of strings representing numbers\n:return: List of stri...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00076807", "row_id": 76807, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_155857']" }
0.722076
Filter_76807
I
[ "is_prime", "filter_prime_number_strings" ]
2
[ [ "filter_prime_number_strings", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6883164eb15fd29df1bf07eb62b4ae90007199aa
df9b1b86ec1d5357278465a0258916b6e21d4ea9
v1.0
instruct
Filter
Filter_76820_I
How can I create a Python program to encrypt and decrypt a file using the AES encryption algorithm with a password-based key?
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.padding import PKCS7 from base64 im...
import os import pytest from solution import encrypt_file, decrypt_file def test_encryption_decryption(): password = "my_strong_password" file_content = b"Hello, this is a test file!" # Create a test file test_file = "test_file.txt" with open(test_file, 'wb') as f: f.write(file_content) ...
[ { "docstring": null, "function_declaration": "def derive_key(password, salt, iterations=100000):", "function_name": "derive_key", "parameter_list": "(password, salt, iterations=100000)" }, { "docstring": null, "function_declaration": "def encrypt_file(file_path, password):", "functio...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import hashlib\nfrom Crypto.Cipher import AES\nfrom Crypto.Protocol.KDF import PBKDF2\nfrom Crypto.Util.Padding import pad, unpad\nimport base64\nimport os\n\ndef derive_key_and_iv(password, s...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076820", "row_id": 76820, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_155875']" }
0.669029
Filter_76820
I
[ "derive_key", "encrypt_file", "decrypt_file" ]
3
[ [ "decrypt_file", "derive_key" ], [ "encrypt_file", "derive_key" ] ]
2
[]
false
[]
false
pytest
true
[ "cryptography" ]
false
83b1577a5f6dd6f088c0c28964f51a263e74c62a
a2f128f9210ce64a9cecf32ccf7b6eeb3e13a037
v1.0
instruct
Filter
Filter_76843_I
Create a Python program that takes a list of strings and returns a new list containing only the strings that are palindromes. A palindrome is a string that reads the same backward as forward.
def is_palindrome(s): """ Checks if a given string is a palindrome. """ return s == s[::-1] def filter_palindromes(strings): """ Returns a list of strings that are palindromes from the given list of strings. """ return [s for s in strings if is_palindrome(s)]
from solution import is_palindrome, filter_palindromes def test_is_palindrome(): assert is_palindrome("madam") == True assert is_palindrome("racecar") == True assert is_palindrome("hello") == False assert is_palindrome("a") == True assert is_palindrome("") == True def test_filter_palindromes(): ...
[ { "docstring": "Checks if a given string is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns a list of strings that are palindromes from the given list of strings.", "function_declaration...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Check if the string s is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef filter_palindromes(strings):\n \"\"\"\n Returns a list of all pa...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00076843", "row_id": 76843, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_155930']" }
0.764792
Filter_76843
I
[ "is_palindrome", "filter_palindromes" ]
2
[ [ "filter_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
63078e3a12d14914c2474714888d9e7347af6ea6
3c0e40687c1e9402f39e140c31a4b9c5d158826e
v1.0
instruct
Filter
Filter_76845_I
I need to create a Python function that converts a list of integers into a list of their corresponding ordinal numbers. For example, the integer 1 becomes '1st', 2 becomes '2nd', and so on. How can I implement this?
def int_to_ordinal(num: int) -> str: """ Convert an integer into its ordinal representation as a string. """ if 10 <= num % 100 <= 20: suffix = 'th' else: suffix = {1: 'st', 2: 'nd', 3: 'rd'}.get(num % 10, 'th') return f"{num}{suffix}" def list_to_ordinals(lst): """ Conv...
import pytest from solution import list_to_ordinals def test_empty_list(): assert list_to_ordinals([]) == [] def test_single_element_list(): assert list_to_ordinals([1]) == ['1st'] assert list_to_ordinals([2]) == ['2nd'] assert list_to_ordinals([3]) == ['3rd'] assert list_to_ordinals([4]) == ['4th...
[ { "docstring": "Convert an integer into its ordinal representation as a string.", "function_declaration": "def int_to_ordinal(num):", "function_name": "int_to_ordinal", "parameter_list": "(num)" }, { "docstring": "Convert a list of integers into a list of their ordinal numbers.", "functi...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def ordinal_suffix(n):\n \"\"\"\n Returns the ordinal suffix for a given integer n.\n \"\"\"\n if 11 <= (n % 100) <= 13:\n suffix = 'th'\n else:\n suffix = {1: 'st...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00076845", "row_id": 76845, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_155932']" }
0.590755
Filter_76845
I
[ "int_to_ordinal", "list_to_ordinals" ]
2
[ [ "list_to_ordinals", "int_to_ordinal" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e4087640a6843aba219164b0bf1878318e69da73
b00e575417c5c1a745f0e5170ce80d9b1c6b7828
v1.0
instruct
Filter
Filter_76873_I
Write a Python script to simulate a simple dice game where two players roll a six-sided die three times each. The player with the highest total score after three rolls wins the game.
import random def roll_dice(): """ Simulates rolling a six-sided die. """ return random.randint(1, 6) def play_game(): """ Simulates a dice game where two players roll a six-sided die three times each. Returns a tuple with the scores of player 1 and player 2, followed by the winner. If...
from solution import roll_dice, play_game def test_roll_dice_range(): for _ in range(1000): # Roll the dice multiple times to check the range roll = roll_dice() assert 1 <= roll <= 6 def test_play_game_score_type(): player1_score, player2_score, winner = play_game() assert isinstance(play...
[ { "docstring": "Simulates rolling a six-sided die.", "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": "Simulates a dice game where two players roll a six-sided die three times each.\nReturns a tuple with the scores of player 1...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef roll_die():\n return random.randint(1, 6)\n\ndef play_game():\n player1_scores = [roll_die() for _ in range(3)]\n player2_scores = [roll_die() for _ in range(3)]\...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076873", "row_id": 76873, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156006']" }
0.494731
Filter_76873
I
[ "roll_dice", "play_game" ]
2
[ [ "play_game", "roll_dice" ] ]
1
[]
false
[]
false
pytest
true
[]
true
949c0bc99367be87ad92d7ae7c199e01b2fc3a21
8407cf9abd3546f5bff36bcfdc31f9e128d160b9
v1.0
instruct
Filter
Filter_76876_I
Can you generate a Python code snippet that calculates the sum of all prime numbers below a given number n?
def is_prime(num): """ Helper function to determine if a number is prime. """ if num <= 1: return False if num == 2: return True # 2 is the only even prime number if num % 2 == 0: return False # Other even numbers are not primes for i in range(3, int(num**0.5) + 1, ...
from solution import is_prime, sum_of_primes_below def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(20) == False assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-10)...
[ { "docstring": "Helper function to determine if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers below `n`.", "function_declaration": "def sum_of_primes_below(...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % 2 == 0 or num % 3 == 0:...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076876", "row_id": 76876, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156014']" }
0.696459
Filter_76876
I
[ "is_prime", "sum_of_primes_below" ]
2
[ [ "sum_of_primes_below", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
41f85510cdb0e172576e1aa42ef8277fd8332535
5e13d4e0d77f7b00e74595839cc02f7f15b178d9
v1.0
instruct
Filter
Filter_76909_I
I have a list of strings and I want to find out which strings are palindromes. A palindrome is a string that reads the same forward and backward, ignoring spaces, punctuation, and capitalization. How can I do this in Python?
def is_palindrome(s): """ Checks if a given string is a palindrome. A palindrome reads the same forward and backward, ignoring spaces, punctuation, and capitalization. """ # Normalize the string by converting to lowercase, removing spaces and non-alphanumeric characters normalized_str = ''....
from solution import is_palindrome, find_palindromes def test_is_palindrome(): assert is_palindrome("A man, a plan, a canal, Panama") == True assert is_palindrome("racecar") == True assert is_palindrome("No lemon, no melon") == True assert is_palindrome("hello") == False assert is_palindrome("Was i...
[ { "docstring": "Checks if a given string is a palindrome.\n\nA palindrome reads the same forward and backward, ignoring spaces, punctuation, and capitalization.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Giv...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Determines if a given string is a palindrome, ignoring spaces, punctuation, and capitalization.\n \"\"\"\n # Remove spaces and capitalize string\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00076909", "row_id": 76909, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156077']" }
0.796837
Filter_76909
I
[ "is_palindrome", "find_palindromes" ]
2
[ [ "find_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
afc0020f47e86a095b12945c3721f1fc2239dbcf
a67c32aed86067eac7a28e1968e3928acde8215d
v1.0
instruct
Filter
Filter_76922_I
Write a Python function that takes a list of integers and returns a new list with each element decremented by 2. The function should be named `decrement_by_two` and should not modify the original list. Additionally, include a simple check function to verify the correctness of your solution with provided data points.
def decrement_by_two(lst): """ Returns a new list with each element decremented by 2. Parameters: lst (list): List of integers Returns: list: New list with each element decremented by 2 """ return [x - 2 for x in lst] # Simple check function def check_function(): test_data...
from solution import decrement_by_two, check_function def test_decrement_by_two_with_positives(): assert decrement_by_two([4, 5, 6]) == [2, 3, 4] def test_decrement_by_two_with_negatives(): assert decrement_by_two([-2, -1, 0]) == [-4, -3, -2] def test_decrement_by_two_with_mixed_numbers(): assert decreme...
[ { "docstring": "Returns a new list with each element decremented by 2.\n\nParameters:\nlst (list): List of integers\n\nReturns:\nlist: New list with each element decremented by 2", "function_declaration": "def decrement_by_two(lst):", "function_name": "decrement_by_two", "parameter_list": "(lst)" ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def decrement_by_two(lst):\n \"\"\"\n Returns a new list with each element in lst decremented by 2.\n \"\"\"\n return [x - 2 for x in lst]", "test_code": "from solution import ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00076922", "row_id": 76922, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156102']" }
0.621124
Filter_76922
I
[ "decrement_by_two", "check_function" ]
2
[ [ "check_function", "decrement_by_two" ] ]
1
[]
false
[]
false
pytest
true
[]
true
12256b491685bec90de77b09c195941b52a3175a
70365921f86176be8f292fe5a4fea2e25bd9223e
v1.0
instruct
Filter
Filter_76932_I
Please provide a Python code to plot the critical points of the function g(x) = x^3 - 3x + 2 using matplotlib and scipy.
import numpy as np import matplotlib.pyplot as plt from scipy.misc import derivative def g(x): return x**3 - 3*x + 2 def plot_critical_points(): x = np.linspace(-3, 3, 400) y = g(x) # Find critical points critical_points = [0] # Plot function plt.plot(x, y, label='g(x) = x^3 - 3x + 2') ...
def test_plot_critical_points(): plot_critical_points() # Since the function is meant to plot, we won't have assert statements here. # This test checks if the function runs without errors.
[ { "docstring": null, "function_declaration": "def g(x):", "function_name": "g", "parameter_list": "(x)" }, { "docstring": null, "function_declaration": "def plot_critical_points():", "function_name": "plot_critical_points", "parameter_list": "()" } ]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy.optimize import fsolve\n\ndef g(x):\n return x**3 - 3*x + 2\n\ndef g_prime(x):\n return 3*x**2 - 3\n\n# Find critical poin...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00076932", "row_id": 76932, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156121']" }
0.430722
Filter_76932
I
[ "g", "plot_critical_points" ]
2
[ [ "plot_critical_points", "g" ] ]
1
[]
false
[]
false
pytest
false
[ "matplotlib", "numpy", "scipy" ]
false
1d3eb46cbf4575dfaa23648988173e3d01ea85f1
8377e98acc9093350d7b959998cc784e4990faea
v1.0
instruct
Filter
Filter_76956_I
Could you provide a Python script to crop an image using the Pillow library, and perhaps include a function to handle multiple images in a directory?
from PIL import Image import os def crop_image(image_path, left, top, right, bottom, output_path): """ Crops the image at image_path with the provided coordinates and saves the cropped image at output_path. """ with Image.open(image_path) as img: cropped_img = img.crop((left, top, right, bottom...
from solution import crop_image, crop_images_in_directory import os import pytest from PIL import Image # Utility function to create a dummy image for testing def create_dummy_image(image_path, size=(100, 100), color=(255, 0, 0, 0)): image = Image.new("RGBA", size, color) image.save(image_path) def test_crop_...
[ { "docstring": "Crops the image at image_path with the provided coordinates and saves the cropped image at output_path.", "function_declaration": "def crop_image(image_path, left, top, right, bottom, output_path):", "function_name": "crop_image", "parameter_list": "(image_path, left, top, right, bot...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from PIL import Image\nimport os\n\ndef crop_image(image_path, crop_box, save_path):\n \"\"\"\n Crops a single image based on the given bounding box and saves it.\n \n :param image...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00076956", "row_id": 76956, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156174']" }
0.441665
Filter_76956
I
[ "crop_image", "crop_images_in_directory" ]
2
[ [ "crop_images_in_directory", "crop_image" ] ]
1
[]
false
[]
false
pytest
true
[ "PIL" ]
false
dc5b5f6c96a63141e405f5d859392ff0a84abf92
9325f31f40021895fd52358d8d59825f7a7e5f42
v1.0
instruct
Filter
Filter_76957_I
How can I create a function in Python that checks if a given number is a perfect power of another number? How can I modify the function to find all perfect powers up to a given number?
import math def is_perfect_power(n): if n < 2: return False for base in range(2, int(math.sqrt(n)) + 1): exponent = 2 while True: power = base ** exponent if power == n: return True if power > n: break expon...
from solution import is_perfect_power, find_all_perfect_powers # Tests for is_perfect_power def test_is_perfect_power_true(): assert is_perfect_power(8) == True # 2^3 assert is_perfect_power(9) == True # 3^2 assert is_perfect_power(16) == True # 2^4 assert is_perfect_power(27) == True # 3^3 asser...
[ { "docstring": null, "function_declaration": "def is_perfect_power(n):", "function_name": "is_perfect_power", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def find_all_perfect_powers(up_to):", "function_name": "find_all_perfect_powers", "parameter_list...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_perfect_power(n):\n if n < 2:\n return False\n for base in range(2, int(math.sqrt(n)) + 1):\n exponent = 2\n while True:\n power = b...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00076957", "row_id": 76957, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156175']" }
0.661224
Filter_76957
I
[ "is_perfect_power", "find_all_perfect_powers" ]
2
[ [ "find_all_perfect_powers", "is_perfect_power" ] ]
1
[]
false
[]
false
pytest
true
[]
true
86138e2f5be896ac3dbd5f9e0b11af8e450588b8
5ec8405543c7a0238973257355175ba4f72c9994
v1.0
instruct
Filter
Filter_76984_I
I'm interested in creating a Python script for a word game where a player can guess letters of a word, but the word is unknown to them. This game should reveal the word progressively as the player guesses correct letters. How can I implement a simple version of this game in Python?
def create_display_word(word, guessed_letters): """ Creates a display version of the word based on guessed letters. Parameters: word (str): The word to guess. guessed_letters (set of str): The set of letters that have been guessed correctly. Returns: str: The word display with '_' ...
def test_create_display_word_initial_empty(): word = "python" guessed_letters = set() assert create_display_word(word, guessed_letters) == "______" def test_create_display_word_partial(): word = "python" guessed_letters = {'p', 'y', 'o'} assert create_display_word(word, guessed_letters) == "py_...
[ { "docstring": "Creates a display version of the word based on guessed letters.\n\nParameters:\nword (str): The word to guess.\nguessed_letters (set of str): The set of letters that have been guessed correctly.\n\nReturns:\nstr: The word display with '_' for unguessed letters.", "function_declaration": "def...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def initialize_game(word):\n \"\"\"\n Initializes the game with the given word.\n \"\"\"\n return [\"_\" for _ in word], set(), set(word)\n\ndef guess_letter(guessed_letters, word,...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00076984", "row_id": 76984, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156228']" }
0.486795
Filter_76984
I
[ "create_display_word", "guess_letter" ]
2
[ [ "guess_letter", "create_display_word" ] ]
1
[]
false
[]
false
pytest
false
[]
true
2f5e4c92478a146462cc862244c1e6cd1dcb5e68
84b29397fd4b991b838202f94b7891ed15967bcc
v1.0
instruct
Filter
Filter_77016_I
Can you provide a Python code snippet that simulates the behavior of a simple blockchain without random mining?
import hashlib import time class Block: def __init__(self, index, previous_hash, timestamp, data, hash): self.index = index self.previous_hash = previous_hash self.timestamp = timestamp self.data = data self.hash = hash def calculate_hash(index, previous_hash, timestamp, da...
from solution import Block, calculate_hash, create_genesis_block, create_new_block import time def test_genesis_block(): block = create_genesis_block() assert block.index == 0 assert block.previous_hash == "0" assert len(block.hash) == 64 def test_calculate_hash(): hash_value = calculate_hash(0, "...
[]
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import hashlib\nimport time\n\nclass Block:\n def __init__(self, index, previous_hash, timestamp, data, hash):\n self.index = index\n self.previous_hash = previous_hash\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077016", "row_id": 77016, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156293']" }
0.385363
Filter_77016
I
[ "calculate_hash", "create_genesis_block", "create_new_block" ]
3
[ [ "create_genesis_block", "calculate_hash" ], [ "create_new_block", "calculate_hash" ] ]
2
[]
false
[ "Block" ]
true
pytest
true
[]
true
6c267605d1e8568eed9262c43a04d89f02a2c50c
7b3d4c8df259239665b6dfec2e62116a4bcb1115
v1.0
instruct
Filter
Filter_77021_I
Develop a Python script that calculates the nth Fibonacci number using recursion. Additionally, include a function to calculate the nth Fibonacci number iteratively and compare the performance of both methods for the 30th Fibonacci number.
def fibonacci_recursive(n): """ Calculate the nth Fibonacci number using recursion. """ if n <= 0: return 0 elif n == 1: return 1 else: return fibonacci_recursive(n-1) + fibonacci_recursive(n-2) def fibonacci_iterative(n): """ Calculate the nth Fibonacci number u...
from solution import fibonacci_recursive, fibonacci_iterative, compare_performance def test_fibonacci_recursive(): assert fibonacci_recursive(0) == 0 assert fibonacci_recursive(1) == 1 assert fibonacci_recursive(2) == 1 assert fibonacci_recursive(3) == 2 assert fibonacci_recursive(10) == 55 def te...
[ { "docstring": "Calculate the nth Fibonacci number using recursion.", "function_declaration": "def fibonacci_recursive(n):", "function_name": "fibonacci_recursive", "parameter_list": "(n)" }, { "docstring": "Calculate the nth Fibonacci number using an iterative approach.", "function_decl...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import time\n\ndef fibonacci_recursive(n):\n \"\"\"\n Calculate the nth Fibonacci number using recursion.\n \"\"\"\n if n <= 0:\n return 0\n elif n == 1:\n return ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077021", "row_id": 77021, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156307']" }
0.635746
Filter_77021
I
[ "fibonacci_recursive", "fibonacci_iterative", "compare_performance" ]
3
[ [ "compare_performance", "fibonacci_iterative" ], [ "compare_performance", "fibonacci_recursive" ] ]
2
[]
false
[]
false
pytest
true
[]
true
38174f36274dc85794ea426c8698cd954e99fc96
0eac36704442bc62c15a2f6b90b073165d2081cb
v1.0
instruct
Filter
Filter_77024_I
Can you explain the working of the `guvectorize` decorator in Numba? How does it differ from the `vectorize` decorator, and in what scenarios is `guvectorize` particularly useful?
from numba import guvectorize import numpy as np # Define the generalized ufunc for element-wise addition @guvectorize(['void(float64[:], float64[:], float64[:])'], '(n),(n)->(n)', target='cpu') def add_arrays(a, b, c): """ Performs element-wise addition of two arrays a and b, storing the result in array c...
from solution import add_arrays, example_usage import numpy as np def test_add_arrays_simple(): a = np.array([1.0, 2.0, 3.0]) b = np.array([4.0, 5.0, 6.0]) c = np.zeros_like(a) add_arrays(a, b, c) assert np.array_equal(c, np.array([5.0, 7.0, 9.0])) def test_add_arrays_with_zeros(): a = np.arra...
[ { "docstring": "Performs element-wise addition of two arrays a and b,\nstoring the result in array c.", "function_declaration": "def add_arrays(a, b, c):", "function_name": "add_arrays", "parameter_list": "(a, b, c)" }, { "docstring": null, "function_declaration": "def example_usage():",...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nfrom numba import guvectorize\n\n@guvectorize(['void(float64[:], float64, float64[:])'], '(n),()->(n)')\ndef add_scalar(arr, scalar, result):\n for i in range(arr.shape[...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077024", "row_id": 77024, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156313']" }
0.314239
Filter_77024
I
[ "add_arrays", "example_usage" ]
2
[ [ "example_usage", "add_arrays" ] ]
1
[]
false
[]
false
pytest
true
[ "numba", "numpy" ]
false
6ea33f03fad0117cd84f331f0eb7c65eb8d15e46
e41c4977bd86294486c7441ada3a474fffb2a72c
v1.0
instruct
Filter
Filter_77040_I
Write a Python script to simulate a simple game where a player can move a character up, down, left, or right on a 5x5 grid. The player starts at position (2, 2). The grid is represented as a list of lists, and the player's position is marked with 'P'. Empty spaces are represented by '.'. The game continues until the pl...
def initialize_grid(): """ Initialize a 5x5 grid with the player starting at position (2, 2). """ grid = [['.' for _ in range(5)] for _ in range(5)] grid[2][2] = 'P' return grid, (2, 2) def display_grid(grid): """ Display the 5x5 grid. """ for row in grid: print(' '.join...
from solution import initialize_grid, move_player def test_initialize_grid(): grid, position = initialize_grid() assert position == (2, 2) assert grid[2][2] == 'P' assert all(grid[i][j] == '.' for i in range(5) for j in range(5) if (i, j) != (2, 2)) def test_move_player_up(): grid, position = init...
[ { "docstring": "Initialize a 5x5 grid with the player starting at position (2, 2).", "function_declaration": "def initialize_grid():", "function_name": "initialize_grid", "parameter_list": "()" }, { "docstring": "Display the 5x5 grid.", "function_declaration": "def display_grid(grid):", ...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class Game:\n def __init__(self):\n # Initialize the grid and set the player's starting position\n self.grid_size = 5\n self.grid = [['.' for _ in range(self.grid_size)...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077040", "row_id": 77040, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156346']" }
0.575806
Filter_77040
I
[ "initialize_grid", "display_grid", "move_player", "play_game" ]
4
[ [ "play_game", "display_grid" ], [ "play_game", "initialize_grid" ], [ "play_game", "move_player" ] ]
3
[]
false
[]
false
pytest
true
[]
true
8462165743ac50272aee6d136ca600979d62c4d8
c55e4c55aba978884941522860d198448de6bbe0
v1.0
instruct
Filter
Filter_77042_I
Given a binary tree, your task is to construct a balanced binary search tree (BST) with the same node values. Return the root node of the new BST.
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def inorder_traversal(root): """ Perform an inorder traversal of the binary tree and return the node values in an ascending list. """ if not root: ...
from solution import TreeNode, balance_bst, inorder_traversal def trees_are_equal(tree1: TreeNode, tree2: TreeNode) -> bool: # Helper function to compare two trees for equality if not tree1 and not tree2: return True if tree1 and tree2 and tree1.val == tree2.val: return trees_are_equal(tree...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef inorder_traversal(root):\n if roo...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077042", "row_id": 77042, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156348']" }
0.649776
Filter_77042
I
[ "inorder_traversal", "construct_balanced_bst", "balance_bst" ]
3
[ [ "balance_bst", "construct_balanced_bst" ], [ "balance_bst", "inorder_traversal" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
fcda8cb761872a130a3c147deef27691af48bfd9
5fc8be6d3287c95362078ac0ce3c31e1d6945ec1
v1.0
instruct
Filter
Filter_77063_I
Can you show me how to create a Python program that can find the sum of all prime numbers below a given number, say 10?
def is_prime(n): """ Returns True if n is a prime number, else False. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def sum_of_primes_below(n): """ Returns the sum of all prime numbers below n. """...
from solution import is_prime, sum_of_primes_below def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(11) == True assert is_prime(15) == False assert is_prime(1) == False def test_sum_of_primes_below(): assert sum_of_prime...
[ { "docstring": "Returns True if n is a prime number, else False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers below n.", "function_declaration": "def sum_of_primes_below(n):", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n re...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077063", "row_id": 77063, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156391']" }
0.719122
Filter_77063
I
[ "is_prime", "sum_of_primes_below" ]
2
[ [ "sum_of_primes_below", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8db20e72de6cd68f2364cc113e39250b7ca984cb
19b1902d32ff9d67ce18a7f44f5ddcaef8918f34
v1.0
instruct
Filter
Filter_77085_I
Could you provide a Python code snippet for a simple text-based version of the game "Hangman"?
import random def pick_random_word(word_list): """ Picks a random word from the provided word list. """ return random.choice(word_list) def display_hangman(tries): stages = [""" -------- | | | O | \\|/ ...
import pytest from solution import pick_random_word, display_hangman, hangman def test_pick_random_word(): word_list = ["PYTHON", "JAVA", "HANGMAN", "PROGRAMMING"] chosen_word = pick_random_word(word_list) assert chosen_word in word_list def test_display_hangman(): assert len(display_hangman(6)) > 0 ...
[ { "docstring": "Picks a random word from the provided word list.", "function_declaration": "def pick_random_word(word_list):", "function_name": "pick_random_word", "parameter_list": "(word_list)" }, { "docstring": null, "function_declaration": "def display_hangman(tries):", "function...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef pick_random_word(word_list):\n \"\"\"\n Picks a random word from the provided word list.\n \"\"\"\n return random.choice(word_list)\n\ndef display_hangman(trie...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00077085", "row_id": 77085, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156443']" }
0.439124
Filter_77085
I
[ "pick_random_word", "display_hangman", "hangman" ]
3
[ [ "hangman", "display_hangman" ], [ "hangman", "pick_random_word" ] ]
2
[]
false
[]
false
pytest
true
[]
true
77a2b6766e930da02c8d9c5abeed8da70154f9bc
661c0bfb3479a73efbb37c5a3f7df2288a425c80
v1.0
instruct
Filter
Filter_77097_I
Write a Python function that takes a list of integers and returns a new list containing only the perfect squares from the original list.
def is_perfect_square(n): """ Returns True if n is a perfect square, otherwise False. """ if n < 0: return False root = int(n ** 0.5) return root * root == n def filter_perfect_squares(lst): """ Returns a new list containing only the perfect squares from the original list. "...
from solution import filter_perfect_squares, is_perfect_square def test_is_perfect_square(): assert is_perfect_square(0) == True assert is_perfect_square(1) == True assert is_perfect_square(4) == True assert is_perfect_square(9) == True assert is_perfect_square(16) == True assert is_perfect_squ...
[ { "docstring": "Returns True if n is a perfect square, otherwise False.", "function_declaration": "def is_perfect_square(n):", "function_name": "is_perfect_square", "parameter_list": "(n)" }, { "docstring": "Returns a new list containing only the perfect squares from the original list.", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_perfect_square(n):\n if n < 0:\n return False\n return int(math.sqrt(n)) ** 2 == n\n\ndef filter_perfect_squares(nums):\n \"\"\"\n Returns a list conta...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077097", "row_id": 77097, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156486']" }
0.734294
Filter_77097
I
[ "is_perfect_square", "filter_perfect_squares" ]
2
[ [ "filter_perfect_squares", "is_perfect_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fae42cc8f52742bb23c4e13dfbc159e3ad861eec
f37f43c080d96d6a730de25a586563816df2f7d9
v1.0
instruct
Filter
Filter_77156_I
How can I use the `scipy.optimize` module to find the roots of a polynomial equation in Python?
import numpy as np from scipy.optimize import root def polynomial_function(x, coeffs): """ Evaluates the polynomial with the given coefficients at x. """ return np.polyval(coeffs, x) def find_roots(coeffs, initial_guesses): """ Finds the roots of the polynomial with the given coefficients usin...
from solution import find_roots import numpy as np def test_find_roots(): coeffs = [1, -3, 2] # Coefficients for (x-1)(x-2) = x^2 - 3x + 2 initial_guesses = [0, 3] # Initial guesses near the actual roots roots = find_roots(coeffs, initial_guesses) np.testing.assert_allclose(roots, [1, 2], rtol=...
[ { "docstring": "Evaluates the polynomial with the given coefficients at x.", "function_declaration": "def polynomial_function(x, coeffs):", "function_name": "polynomial_function", "parameter_list": "(x, coeffs)" }, { "docstring": "Finds the roots of the polynomial with the given coefficients...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from scipy.optimize import fsolve\nimport numpy as np\n\ndef polynomial_roots(coefficients):\n \"\"\"\n Finds the roots of a polynomial equation based on its coefficients.\n\n Paramet...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077156", "row_id": 77156, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156601']" }
0.513346
Filter_77156
I
[ "polynomial_function", "find_roots" ]
2
[ [ "find_roots", "polynomial_function" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy", "scipy" ]
false
f2ac8dde1e9db013be3e0faba15b78e13eb3128c
e0977acf56878c4f67038fbcb081946f9ff89c34
v1.0
instruct
Filter
Filter_77175_I
Can you provide a Python code to implement a basic genetic algorithm for solving a binary optimization problem? Certainly! Below is a simple implementation of a genetic algorithm in Python for a binary optimization problem. In this example, the problem is to maximize the value of a binary string where the fitness funct...
import random def generate_individual(length): """ Generate a random individual of given length """ return [random.randint(0, 1) for _ in range(length)] def generate_population(size, length): """ Generate a population of random individuals """ return [generate_individual(length) for _ in range(size)] ...
from solution import generate_individual, generate_population, fitness, select_pair, crossover, mutate, genetic_algorithm def test_generate_individual(): individual = generate_individual(10) assert len(individual) == 10 assert all(gene in [0, 1] for gene in individual) def test_generate_population(): ...
[ { "docstring": "Generate a random individual of given length ", "function_declaration": "def generate_individual(length):", "function_name": "generate_individual", "parameter_list": "(length)" }, { "docstring": "Generate a population of random individuals ", "function_declaration": "def ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef generate_individual(length):\n \"\"\" Generate a random individual of given length \"\"\"\n return [random.randint(0, 1) for _ in range(length)]\n\ndef generate_popu...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00077175", "row_id": 77175, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156636']" }
0.428674
Filter_77175
I
[ "generate_individual", "generate_population", "fitness", "select_pair", "crossover", "mutate", "genetic_algorithm" ]
7
[ [ "generate_population", "generate_individual" ], [ "genetic_algorithm", "crossover" ], [ "genetic_algorithm", "generate_population" ], [ "genetic_algorithm", "mutate" ], [ "genetic_algorithm", "select_pair" ], [ "select_pair", "fitness" ] ]
6
[]
false
[]
false
pytest
true
[]
true
8402d0058e4202634d32dfa200b4810b6f8e83f9
de8a0a97985c5a5ef9269ad36853deae26637351
v1.0
instruct
Filter
Filter_77177_I
Can you explain the differences between the `quick_sort` and `merge_sort` algorithms in terms of their time and space complexities, and provide a simple implementation of each in Python?
def quick_sort(arr): """ Quick sort algorithm """ if len(arr) <= 1: return arr pivot = arr[len(arr) // 2] # Choosing the middle element as the pivot left = [x for x in arr if x < pivot] middle = [x for x in arr if x == pivot] right = [x for x in arr if x > pivot] return quick...
from solution import quick_sort, merge_sort def test_quick_sort(): assert quick_sort([3, 6, 8, 10, 1, 2, 1]) == [1, 1, 2, 3, 6, 8, 10] assert quick_sort([1]) == [1] assert quick_sort([]) == [] assert quick_sort([5, -3, 9, 1, 0, -2]) == [-3, -2, 0, 1, 5, 9] assert quick_sort([2, 2, 2, 2, 2]) == [2, ...
[ { "docstring": "Quick sort algorithm", "function_declaration": "def quick_sort(arr):", "function_name": "quick_sort", "parameter_list": "(arr)" }, { "docstring": "Merge sort algorithm", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def quick_sort(arr):\n \"\"\"\n Sorts an array using the Quick Sort algorithm.\n \n Quick Sort works by selecting a pivot element from the array and partitioning \n the other el...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077177", "row_id": 77177, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156638']" }
0.416956
Filter_77177
I
[ "quick_sort", "merge_sort", "merge" ]
3
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
aa251aa9097bf38623daa1bb23a64dbfef92dc32
dbb26fc1dd6e9747c5721285503bdecd92d60d7e
v1.0
instruct
Filter
Filter_77213_I
Create a Python function to simulate a simple game of war between two players. Each player starts with half the deck of cards. The game is played by flipping over the top card of each player's deck and comparing them. The player with the higher card wins both cards and places them at the bottom of their deck. If the ca...
import random def create_deck(): """Creates a deck of 52 cards, 13 ranks in 4 suits.""" suits = 'hearts diamonds clubs spades'.split() ranks = list(range(2, 15)) # 2 through Ace (represented by 14) deck = [(rank, suit) for rank in ranks for suit in suits] random.shuffle(deck) return deck def c...
from solution import play_war_game, create_deck, card_value def test_deck_creation(): deck = create_deck() assert len(deck) == 52 assert len(set(deck)) == 52 def test_card_value(): assert card_value((2, 'hearts')) == 2 assert card_value((14, 'spades')) == 14 def test_war_game_result(): result...
[ { "docstring": "Creates a deck of 52 cards, 13 ranks in 4 suits.", "function_declaration": "def create_deck():", "function_name": "create_deck", "parameter_list": "()" }, { "docstring": "Returns the value of the card.", "function_declaration": "def card_value(card):", "function_name"...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\nclass Card:\n values = {\n '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, \n '7': 7, '8': 8, '9': 9, '10': 10, \n 'J': 11, 'Q': 12, 'K': 13, 'A': 14\n }\n\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077213", "row_id": 77213, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156723']" }
0.542616
Filter_77213
I
[ "create_deck", "card_value", "play_war_game" ]
3
[ [ "play_war_game", "card_value" ], [ "play_war_game", "create_deck" ] ]
2
[]
false
[]
false
pytest
true
[]
true
59d81b41ef845ee476187a34dc6d4b73202e5ccd
0d536f77a4172c8ea4fe387dfdd3c29959cea497
v1.0
instruct
Filter
Filter_77222_I
Write a program to sum up prime numbers up to 100 using Python.
def is_prime(n): """ Check if a number is a prime number. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def sum_primes_up_to_100(): """ Sum all prime numbers up to 100. """ return sum(n for n i...
from solution import is_prime, sum_primes_up_to_100 def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(13) == True def test_sum_primes_up_to_100(): assert sum_primes_...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Sum all prime numbers up to 100.", "function_declaration": "def sum_primes_up_to_100():", "function_name": "sum_p...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True # 2 is the only even prime number...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077222", "row_id": 77222, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156742']" }
0.642772
Filter_77222
I
[ "is_prime", "sum_primes_up_to_100" ]
2
[ [ "sum_primes_up_to_100", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
802667abd75deac09423b62ca4b68a5f2d0b80f3
2c75b190cdfe268d4c86c6b98c7a16d5c2237020
v1.0
instruct
Filter
Filter_77239_I
Can you provide a Python script that loads a CSV file, checks if each row contains a valid email address, and writes the rows with valid email addresses to a new CSV file? The script should use regular expressions for email validation and handle potential exceptions that may occur during file operations.
import csv import re def is_valid_email(email): """ Check if the email address is valid using a regular expression. """ email_regex = r'^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$' return re.match(email_regex, email) is not None def filter_valid_emails(input_file, output_file): """ Lo...
import pytest import os import csv from solution import is_valid_email, filter_valid_emails def create_test_csv(file_path, rows): with open(file_path, mode='w', newline='') as file: writer = csv.writer(file) writer.writerows(rows) def test_is_valid_email(): assert is_valid_email("test.email@ex...
[ { "docstring": "Check if the email address is valid using a regular expression.", "function_declaration": "def is_valid_email(email):", "function_name": "is_valid_email", "parameter_list": "(email)" }, { "docstring": "Load a CSV file, checks if each row contains a valid email address,\nand w...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\nimport csv\n\ndef is_valid_email(email):\n \"\"\"\n Check if the given email address is valid using regular expressions.\n \"\"\"\n regex = r'^[A-Za-z0-9._%+-]+@[A-Za-z0...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077239", "row_id": 77239, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156771']" }
0.674004
Filter_77239
I
[ "is_valid_email", "filter_valid_emails" ]
2
[ [ "filter_valid_emails", "is_valid_email" ] ]
1
[]
false
[]
false
pytest
true
[]
true
13b835623514ebb2dd3097b10d007fdc93497b3e
8c769d7e8e31b51d7552efd94b9c0e610f0f69cd
v1.0
instruct
Filter
Filter_77264_I
Can you explain how to implement the cut-off time for a specific workflow in a Python script? Suppose I have a workflow that needs to be executed only during business hours from 9 AM to 5 PM, Monday to Friday. How can I incorporate this into my Python script?
from datetime import datetime def is_within_business_hours(current_time=None, start_hour=9, end_hour=17): """ Checks if the current time is within business hours from 9 AM to 5 PM, Monday to Friday. :param current_time: current date and time :param start_hour: hour at which business hours start (24-ho...
from datetime import datetime from solution import is_within_business_hours def test_is_within_business_hours_monday_morning(): # Monday at 10:00 AM test_time = datetime(2023, 10, 9, 10, 0) assert is_within_business_hours(test_time) == True def test_is_within_business_hours_friday_evening(): # Friday ...
[ { "docstring": "Checks if the current time is within business hours from 9 AM to 5 PM, Monday to Friday.\n\n:param current_time: current date and time\n:param start_hour: hour at which business hours start (24-hour format)\n:param end_hour: hour at which business hours end (24-hour format)\n:return: True if wit...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from datetime import datetime\n\ndef is_within_business_hours():\n \"\"\"\n Returns True if the current time is within business hours (9 AM to 5 PM) on a weekday (Monday to Friday). \n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077264", "row_id": 77264, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156828']" }
0.494948
Filter_77264
I
[ "is_within_business_hours", "execute_workflow" ]
2
[ [ "execute_workflow", "is_within_business_hours" ] ]
1
[]
false
[]
false
pytest
true
[]
true
333db6eb00f6404c9de968965e3fd8caa6602353
1f997895e26e0a035df8027064e44561da520d99
v1.0
instruct
Filter
Filter_77271_I
I'm trying to write some Python code that processes a text file. The file contains a list of temperatures in Celsius, one per line, and I need to convert these temperatures to Fahrenheit. The output should be written to a new file. How can I achieve this?
def celsius_to_fahrenheit(celsius): """ Converts a temperature from Celsius to Fahrenheit. """ return (celsius * 9/5) + 32 def convert_temperatures(input_file_path, output_file_path): """ Reads temperatures in Celsius from an input file, converts them to Fahrenheit, and writes them to an ou...
from solution import celsius_to_fahrenheit, convert_temperatures def test_celsius_to_fahrenheit(): assert celsius_to_fahrenheit(0) == 32 assert celsius_to_fahrenheit(100) == 212 assert celsius_to_fahrenheit(-40) == -40 assert celsius_to_fahrenheit(37) == 98.6 def test_convert_temperatures(tmp_path): ...
[ { "docstring": "Converts a temperature from Celsius to Fahrenheit.", "function_declaration": "def celsius_to_fahrenheit(celsius):", "function_name": "celsius_to_fahrenheit", "parameter_list": "(celsius)" }, { "docstring": "Reads temperatures in Celsius from an input file, converts them to Fa...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def celsius_to_fahrenheit(celsius):\n \"\"\"\n Converts a temperature from Celsius to Fahrenheit.\n \"\"\"\n return celsius * 9/5 + 32\n\ndef convert_temperatures(input_file, outpu...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077271", "row_id": 77271, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156840']" }
0.468973
Filter_77271
I
[ "celsius_to_fahrenheit", "convert_temperatures" ]
2
[ [ "convert_temperatures", "celsius_to_fahrenheit" ] ]
1
[]
false
[]
false
pytest
true
[]
true
541a9ab36f91b0d1e31f5b4ffcc5a78723727715
eed53a729484f82d9d147f6115eb19ddcbdbcbb0
v1.0
instruct
Filter
Filter_77282_I
I want to train a model for binary classification using PyTorch. Can you guide me through the process with a simple example?
import torch import torch.nn as nn import torch.optim as optim from torch.utils.data import DataLoader, TensorDataset class BinaryClassificationModel(nn.Module): def __init__(self, input_dim): super(BinaryClassificationModel, self).__init__() self.linear = nn.Linear(input_dim, 1) def f...
import torch from solution import BinaryClassificationModel, train_model def test_model_initialization(): model = BinaryClassificationModel(input_dim=1) assert isinstance(model, nn.Module) assert hasattr(model, 'linear') assert model.linear.in_features == 1 assert model.linear.out_features == 1 de...
[]
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import torch\nimport torch.nn as nn\nimport torch.optim as optim\nfrom torch.utils.data import DataLoader, TensorDataset\n\nclass BinaryClassificationModel(nn.Module):\n def __init__(self, ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00077282", "row_id": 77282, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156879']" }
0.32425
Filter_77282
I
[ "train_model", "example" ]
2
[ [ "example", "train_model" ] ]
1
[]
false
[ "BinaryClassificationModel" ]
true
pytest
true
[ "torch" ]
false
684bd50bb280f8fa144d71f16f0b4874e59926bd
59396c0920e041c3e4a79cba753aabf27e96a563
v1.0
instruct
Filter
Filter_77283_I
Can you provide a Python code snippet to find the closest pair of points in a set of points using a divide and conquer approach?
import math def distance(p1, p2): """ Returns the Euclidean distance between two points p1 and p2. """ return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) def brute_force(points): """ A brute-force method to return the smallest distance between two points in points """ min_di...
from solution import closest_pair def test_closest_pair_simple(): points = [(2, 3), (12, 30), (40, 50), (5, 1), (12, 10), (3, 4)] assert math.isclose(closest_pair(points), 1.4142135623730951, rel_tol=1e-9) def test_closest_pair_same_points(): points = [(1, 1), (1, 1), (1, 1)] assert closest_pair(point...
[ { "docstring": "Returns the Euclidean distance between two points p1 and p2.", "function_declaration": "def distance(p1, p2):", "function_name": "distance", "parameter_list": "(p1, p2)" }, { "docstring": "A brute-force method to return the smallest distance between two points in points", ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef distance(p1, p2):\n \"\"\"\n Returns the Euclidean distance between two points p1 and p2.\n \"\"\"\n return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00077283", "row_id": 77283, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156880']" }
0.653093
Filter_77283
I
[ "distance", "brute_force", "closest_util", "closest_pair" ]
4
[ [ "brute_force", "distance" ], [ "closest_pair", "closest_util" ], [ "closest_util", "brute_force" ], [ "closest_util", "distance" ] ]
4
[]
false
[]
false
pytest
true
[]
true
32e424eb023f94e6666a61b44e8739eb443830ed
c9533e14bdfba5fdeace611be7626ec290da7c75
v1.0
instruct
Filter
Filter_77311_I
Can you explain what a monad is in programming? Can you also provide an example in Python?
class Maybe: def __init__(self, value): self.value = value def is_nothing(self): return self.value is None def bind(self, func): if self.is_nothing(): return self else: return func(self.value) def __repr__(self): if self.is_nothing(): ...
from solution import Maybe, unit, safe_divide def test_unit_with_value(): assert str(unit(10)) == 'Just(10)' def test_unit_with_none(): assert str(unit(None)) == 'Nothing' def test_safe_divide_non_zero_denominator(): assert str(safe_divide(10, 2)) == 'Just(5.0)' def test_safe_divide_zero_denominator(): ...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class Maybe:\n def __init__(self, value):\n self.value = value\n\n @staticmethod\n def unit(value):\n return Maybe(value)\n\n def flat_map(self, func):\n if se...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077311", "row_id": 77311, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156935']" }
0.405915
Filter_77311
I
[ "unit", "safe_divide" ]
2
[ [ "safe_divide", "unit" ] ]
1
[]
false
[ "Maybe" ]
true
pytest
true
[]
true
688ac1dcbca2b0d7c215a138af3095af735017a4
3bf7e9ed3a475039b8056663e1bb0bb7ca2cc3e9
v1.0
instruct
Filter
Filter_77335_I
Write a Python program that simulates a digital clock using a microcontroller. The clock should display the time in hours, minutes, and seconds format (HH:MM:SS), and it should update every second. Assume that the microcontroller has a built-in function `delay_ms(ms)` that pauses the execution for a specified number of...
def delay_ms(ms): """ Simulates a delay by pausing the execution for the given milliseconds. For testing purposes, this function will not actually halt code execution, but it can be redefined during real runs. """ pass # This will be redefined during actual runs def update_time(seconds, minut...
from solution import update_time, format_time def test_update_time_seconds_incrementation(): assert update_time(0, 0, 0) == (1, 0, 0) assert update_time(58, 0, 0) == (59, 0, 0) assert update_time(59, 0, 0) == (0, 1, 0) def test_update_time_minutes_incrementation(): assert update_time(59, 58, 0) == (0,...
[ { "docstring": "Simulates a delay by pausing the execution for the given milliseconds.\nFor testing purposes, this function will not actually halt code execution, \nbut it can be redefined during real runs.", "function_declaration": "def delay_ms(ms):", "function_name": "delay_ms", "parameter_list":...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def delay_ms(ms):\n \"\"\"\n Simulates a delay by pausing the execution for the given milliseconds.\n For testing purposes, this function will not actually halt code execution, \n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00077335", "row_id": 77335, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_156987']" }
0.53904
Filter_77335
I
[ "delay_ms", "update_time", "format_time", "digital_clock" ]
4
[ [ "digital_clock", "delay_ms" ], [ "digital_clock", "format_time" ], [ "digital_clock", "update_time" ] ]
3
[]
false
[]
false
pytest
true
[]
true
643cf7002dd1cd7a7fa62ac9de2fe084021ae47f
754e9a9e18513f8e40bca7bffc8bf252501b8991
v1.0
instruct
Filter
Filter_77354_I
Can you provide a detailed explanation of how to implement a genetic algorithm for string optimization, specifically for evolving a population of binary strings to match a target string of the same length? The algorithm should include steps for initialization, fitness evaluation, crossover, mutation, and selection. Eac...
import random def initialize_population(size, string_length): """Initialize a population of random binary strings.""" population = [''.join(random.choice('01') for _ in range(string_length)) for _ in range(size)] return population def calculate_fitness(target, individual): """Calculate fitness score a...
from solution import (initialize_population, calculate_fitness, selection, crossover, mutate, genetic_algorithm) def test_initialize_population(): population = initialize_population(10, 5) assert len(population) == 10 assert all(len(individual) == 5 for individual in population) assert all(char in '01'...
[ { "docstring": "Initialize a population of random binary strings.", "function_declaration": "def initialize_population(size, string_length):", "function_name": "initialize_population", "parameter_list": "(size, string_length)" }, { "docstring": "Calculate fitness score as the number of match...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef initialize_population(size, length):\n \"\"\"\n Initializes a population of binary strings of the given size and length.\n \"\"\"\n population = []\n for _ ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077354", "row_id": 77354, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157034']" }
0.479637
Filter_77354
I
[ "initialize_population", "calculate_fitness", "selection", "crossover", "mutate", "genetic_algorithm" ]
6
[ [ "genetic_algorithm", "calculate_fitness" ], [ "genetic_algorithm", "crossover" ], [ "genetic_algorithm", "initialize_population" ], [ "genetic_algorithm", "mutate" ], [ "genetic_algorithm", "selection" ], [ "selection", "calculate_fitness" ] ]
6
[]
false
[]
false
pytest
true
[]
true
938d2239c60f74c4d2526d3012f5fc3435e7b12b
5d27e135af96999c76c5ee055e9e84f09c0f7656
v1.0
instruct
Filter
Filter_77356_I
I'm trying to create a simple AI chatbot using Python and Flask. Could you provide a basic outline of the steps involved?
from flask import Flask, request, jsonify app = Flask(__name__) @app.route('/chat', methods=['POST']) def chat(): user_message = request.json.get('message') if not user_message: return jsonify({"response": "Please provide a message."}) response = generate_response(user_message) return jsonify...
import pytest from flask import Flask, request, jsonify from solution import app @pytest.fixture def client(): with app.test_client() as client: yield client def test_chat_no_message(client): response = client.post('/chat', json={}) json_data = response.get_json() assert response.status_code =...
[ { "docstring": null, "function_declaration": "def chat():", "function_name": "chat", "parameter_list": "()" }, { "docstring": "Basic response generation logic.\nThis is just a simple example and can be replaced with a more complex AI.", "function_declaration": "def generate_response(user...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from flask import Flask, request, jsonify\n\napp = Flask(__name__)\n\n@app.route('/chat', methods=['POST'])\ndef chat():\n user_message = request.json.get('message')\n if not user_messag...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00077356", "row_id": 77356, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157039']" }
0.404059
Filter_77356
I
[ "chat", "generate_response" ]
2
[ [ "chat", "generate_response" ] ]
1
[]
false
[]
false
pytest
true
[ "flask" ]
false
ccc91208b18b14e904ec6f5af9b9677cfb4f5956
88ad060510f5667d7535e883d5c7046ff346d6a2
v1.0
instruct
Filter
Filter_77369_I
Given the string s, check if it is a palindrome. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string. Return all the palindromic substrings of a given string.
def is_palindrome(s): """ Check if the given string s is a palindrome. """ return s == s[::-1] def palindromic_substrings(s): """ Return all palindromic substrings of a given string s. """ n = len(s) palindromes = [] for i in range(n): for j in range(i, n): ...
from solution import is_palindrome, palindromic_substrings def test_is_palindrome(): assert is_palindrome("racecar") == True assert is_palindrome("abba") == True assert is_palindrome("hello") == False assert is_palindrome("a") == True assert is_palindrome("") == True def test_palindromic_substring...
[ { "docstring": "Check if the given string s is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Return all palindromic substrings of a given string s.", "function_declaration": "def palindromic_s...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Check if the string s is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef palindromic_substrings(s):\n \"\"\"\n Return all palindromic sub...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077369", "row_id": 77369, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157069']" }
0.726604
Filter_77369
I
[ "is_palindrome", "palindromic_substrings" ]
2
[ [ "palindromic_substrings", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0b93246a3e9e4c889b225744e8c7f27271ef053f
a950c04a199ec55ea37ffb28a9f7878bdd1a35ff
v1.0
instruct
Filter
Filter_77372_I
Suppose I have a Python function `distance` that calculates the distance between two points in a 2D space. This function currently only handles the calculation for two points. How can I modify the function to handle multiple points and return a matrix of distances between all pairs of points?
import math def distance(x1, y1, x2, y2): """ Calculate the distance between two points (x1, y1) and (x2, y2). """ return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) def distance_matrix(points): """ Calculate and return a matrix of distances between each pair of points. :param points: ...
from solution import distance_matrix def test_distance_matrix_single_point(): points = [(0, 0)] expected = [[0]] assert distance_matrix(points) == expected def test_distance_matrix_two_points(): points = [(0, 0), (3, 4)] expected = [ [0, 5.0], [5.0, 0] ] assert distance_mat...
[ { "docstring": "Calculate the distance between two points (x1, y1) and (x2, y2).", "function_declaration": "def distance(x1, y1, x2, y2):", "function_name": "distance", "parameter_list": "(x1, y1, x2, y2)" }, { "docstring": "Calculate and return a matrix of distances between each pair of poi...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef distance(x1, y1, x2, y2):\n \"\"\"\n Calculate the distance between two points in 2D space.\n \"\"\"\n return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)\n\ndef d...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077372", "row_id": 77372, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157074']" }
0.620445
Filter_77372
I
[ "distance", "distance_matrix" ]
2
[ [ "distance_matrix", "distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
26b78ebcb5e88c99c0e64e474e48933abd2d228d
9c4ab174ad72b824f044cd570646b51e8240c5e0
v1.0
instruct
Filter
Filter_77373_I
Can you provide a Python code to simulate a simple game where a player rolls two six-sided dice and wins if the sum is 7 or 11, and loses if the sum is 2, 3, or 12? Any other sum results in the player needing to roll again until they either match the sum or roll a 7, in which case they lose?
import random def roll_dice(): """ Simulates rolling two six-sided dice and returns the result as a tuple. """ die1 = random.randint(1, 6) die2 = random.randint(1, 6) return (die1, die2) def check_initial_win_or_loss(sum_of_dice): """ Checks if the initial sum of dice is a win, loss, o...
from solution import roll_dice, check_initial_win_or_loss, play_round def test_roll_dice(): for _ in range(100): die1, die2 = roll_dice() assert 1 <= die1 <= 6 assert 1 <= die2 <= 6 def test_check_initial_win_or_loss(): assert check_initial_win_or_loss(7) == "win" assert check_init...
[ { "docstring": "Simulates rolling two six-sided dice and returns the result as a tuple.", "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": "Checks if the initial sum of dice is a win, loss, or needs further rolls.", "funct...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef roll_dice():\n \"\"\"\n Simulate rolling two six-sided dice.\n Returns a tuple of two integers between 1 and 6, representing the outcome of each die.\n \"\"\"\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077373", "row_id": 77373, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157075']" }
0.525319
Filter_77373
I
[ "roll_dice", "check_initial_win_or_loss", "play_round" ]
3
[ [ "play_round", "check_initial_win_or_loss" ], [ "play_round", "roll_dice" ] ]
2
[]
false
[]
false
pytest
true
[]
true
dd34ea474814d386714e59531474e9de5f9325c4
d5b678b266b7ffe6401095d8ba5321f6ab90bc64
v1.0
instruct
Filter
Filter_77400_I
Can you help me with a Python code to simulate a simple game of rock-paper-scissors using random choices for both players?
import random def rock_paper_scissors(): """ Simulates a game of rock-paper-scissors between two players with random choices. Returns the result of the match as a string. """ choices = ["rock", "paper", "scissors"] player1_choice = random.choice(choices) player2_choice = random.choice(...
from solution import rock_paper_scissors, determine_winner def test_rock_beats_scissors(): assert determine_winner('rock', 'scissors') == "Player 1 wins" assert determine_winner('scissors', 'rock') == "Player 2 wins" def test_scissors_beats_paper(): assert determine_winner('scissors', 'paper') == "Player ...
[ { "docstring": "Simulates a game of rock-paper-scissors between two players with random choices.\nReturns the result of the match as a string.", "function_declaration": "def rock_paper_scissors():", "function_name": "rock_paper_scissors", "parameter_list": "()" }, { "docstring": "Determines ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef rock_paper_scissors():\n \"\"\"\n Simulates a game of rock-paper-scissors between two players with random choices.\n Returns the result of the match as a string.\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00077400", "row_id": 77400, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157128']" }
0.392606
Filter_77400
I
[ "rock_paper_scissors", "determine_winner" ]
2
[ [ "rock_paper_scissors", "determine_winner" ] ]
1
[]
false
[]
false
pytest
true
[]
true
81db94e7b17494b5cd7b146a6e9cd30f50dc30b9
6b3e22880886109329f2dd5c07ddfc2094f5ef7b
v1.0
instruct
Filter
Filter_77410_I
Can you help me design a simple asynchronous web server in Python using the `aiohttp` library?
from aiohttp import web async def handle(request): """ Handles incoming requests. """ name = request.match_info.get('name', "Anonymous") text = f"Hello, {name}!" return web.Response(text=text) def create_app(): """ Creates and configures the aiohttp application. """ app = web.A...
import asyncio from aiohttp import web import pytest from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop from solution import create_app class TestWebServer(AioHTTPTestCase): async def get_application(self): """ Override the get_application method to return the app. """ ...
[ { "docstring": "Creates and configures the aiohttp application.", "function_declaration": "def create_app():", "function_name": "create_app", "parameter_list": "()" } ]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import aiohttp\nfrom aiohttp import web\n\nasync def handle(request):\n \"\"\"\n Simple request handler that greets the user.\n \"\"\"\n name = request.rel_url.query.get('name', 'A...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077410", "row_id": 77410, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157154']" }
0.527562
Filter_77410
I
[ "handle", "create_app" ]
2
[ [ "create_app", "handle" ] ]
1
[]
false
[]
false
pytest
true
[ "aiohttp" ]
false
b4a7e338534b88b8dcd7b594a91de811212d46ed
8a92801b212061288de6104c7b1d98900de2399d
v1.0
instruct
Filter
Filter_77413_I
I'm developing a Python script for a simple game where the user can guess a number between 1 and 100. The game should provide feedback on whether the guess is too high, too low, or correct. It should also allow the user to play the game again if they choose. How can I implement this?
import random def guess_number_game(): """ A simple guessing game where the user tries to guess a number between 1 and 100. """ number_to_guess = random.randint(1, 100) attempts = 0 while True: try: guess = int(input("Guess a number between 1 and 100: ")) attempt...
from unittest.mock import patch from solution import guess_number_game, play_game def test_guess_number_game_correct_on_first_try(): with patch('builtins.input', side_effect=['50']), patch('random.randint', return_value=50): assert guess_number_game() == 1 def test_guess_number_game_too_low_then_correct()...
[ { "docstring": "A simple guessing game where the user tries to guess a number between 1 and 100.", "function_declaration": "def guess_number_game():", "function_name": "guess_number_game", "parameter_list": "()" }, { "docstring": "Starts the guessing game and prompts if the user wants to pla...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef guess_number_game():\n \"\"\"\n Function to play a number guessing game. The user tries to guess a number between 1 and 100,\n with feedback on whether the guess ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077413", "row_id": 77413, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157157']" }
0.590536
Filter_77413
I
[ "guess_number_game", "play_game" ]
2
[ [ "play_game", "guess_number_game" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d7c0df9c6c9cdeed6f7b9ecbf2a5a07fa0892c69
e4406a7542e1538651cd5724d35ac03ef96313a7
v1.0
instruct
Filter
Filter_77416_I
Could you provide a Python code to generate a simple fractal, such as the Mandelbrot set?
import numpy as np import matplotlib.pyplot as plt def mandelbrot(c, max_iter): """ Determine if a point is in the Mandelbrot set. Arguments: c -- complex number representing the point. max_iter -- maximum number of iterations to check for divergence. Returns: Number of iterations...
import numpy as np from solution import mandelbrot, generate_mandelbrot_image def test_mandelbrot_in_set(): assert mandelbrot(complex(0, 0), 100) == 100 assert mandelbrot(complex(-1, 0), 100) == 100 def test_mandelbrot_outside_set(): assert mandelbrot(complex(2, 2), 100) < 100 assert mandelbrot(comple...
[ { "docstring": "Determine if a point is in the Mandelbrot set.\n\nArguments:\nc -- complex number representing the point.\nmax_iter -- maximum number of iterations to check for divergence.\n\nReturns:\nNumber of iterations before escaping, or max_iter if does not escape.", "function_declaration": "def mande...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nimport matplotlib.pyplot as plt\n\ndef mandelbrot(c, max_iter):\n \"\"\"\n Generates the number of iterations required for |z| to exceed 2 for each complex number in ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077416", "row_id": 77416, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157161']" }
0.416255
Filter_77416
I
[ "mandelbrot", "generate_mandelbrot_image", "plot_mandelbrot" ]
3
[ [ "generate_mandelbrot_image", "mandelbrot" ] ]
1
[]
false
[]
false
pytest
true
[ "matplotlib", "numpy" ]
false
9c5ac4bb5488e6f53ca7471e3c43a979cf5eb83c
c667bfbee0e401341bae2e490983105935f0a4a9
v1.0
instruct
Filter
Filter_77515_I
Can you write a Python script to manage an inventory system for a small business? This script should include functionalities to add items, update quantities, remove items, and view the current inventory. The inventory data should be stored in a text file. Each item in the inventory should have a unique ID, name, and qu...
import json INVENTORY_FILE = 'inventory.txt' def load_inventory(): try: with open(INVENTORY_FILE, 'r') as file: return json.load(file) except FileNotFoundError: return {} def save_inventory(inventory): with open(INVENTORY_FILE, 'w') as file: json.dump(inventory, file) ...
import os from solution import add_item, update_quantity, remove_item, view_inventory, INVENTORY_FILE def setup_module(module): if os.path.exists(INVENTORY_FILE): os.remove(INVENTORY_FILE) def test_add_item(): success, msg = add_item("123", "Apple", 50) assert success == True assert msg == "It...
[ { "docstring": null, "function_declaration": "def load_inventory():", "function_name": "load_inventory", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def save_inventory(inventory):", "function_name": "save_inventory", "parameter_list": "(inventory)" }...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import json\n\nINVENTORY_FILE = 'inventory.txt'\n\ndef load_inventory():\n try:\n with open(INVENTORY_FILE, 'r') as file:\n return json.load(file)\n except FileNotFound...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00077515", "row_id": 77515, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157375']" }
0.3408
Filter_77515
I
[ "load_inventory", "save_inventory", "add_item", "update_quantity", "remove_item", "view_inventory" ]
6
[ [ "add_item", "load_inventory" ], [ "add_item", "save_inventory" ], [ "remove_item", "load_inventory" ], [ "remove_item", "save_inventory" ], [ "update_quantity", "load_inventory" ], [ "update_quantity", "save_inventory" ], [ "view_inventor...
7
[]
false
[]
false
pytest
true
[]
true
944047a80f89c70d5a8dbe2e3230082f6258aa12
60cfdcdc9532d82c61e6cb108656540828045b68
v1.0
instruct
Filter
Filter_77542_I
Can you provide a Python function to simulate the heap sort algorithm? Heap sort is a comparison-based sorting technique based on a binary heap data structure. It divides the input into a sorted and an unsorted region and iteratively shrinks the unsorted region by extracting the largest/smallest element from it and mov...
def heapify(arr, n, i): """ Function to heapify a subtree rooted with node i which is an index in arr[]. n is size of heap. """ largest = i # Initialize largest as root left = 2 * i + 1 # left = 2*i + 1 right = 2 * i + 2 # right = 2*i + 2 # See if left child of root exists and is gre...
from solution import heap_sort def test_heap_sort_empty(): assert heap_sort([]) == [] def test_heap_sort_single_element(): assert heap_sort([1]) == [1] def test_heap_sort_sorted_array(): assert heap_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_heap_sort_reverse_sorted_array(): assert heap_sort(...
[ { "docstring": "Function to heapify a subtree rooted with node i which is\nan index in arr[]. n is size of heap.", "function_declaration": "def heapify(arr, n, i):", "function_name": "heapify", "parameter_list": "(arr, n, i)" }, { "docstring": "Main function to perform heap sort.", "func...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def heapify(arr, n, i):\n \"\"\"\n Helper function to maintain the heap property.\n \"\"\"\n largest = i\n left = 2 * i + 1\n right = 2 * i + 2\n \n if left < n and arr...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077542", "row_id": 77542, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157438']" }
0.654328
Filter_77542
I
[ "heapify", "heap_sort" ]
2
[ [ "heap_sort", "heapify" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a90f8c8d6784754da116761f124ff835680483f9
386f878809a66a1ab49216f1cdd20c8d1d2dae84
v1.0
instruct
Filter
Filter_77545_I
Design a simple login system using Python with file-based storage for user credentials. The program should include functions to register new users, log in existing users, and change passwords. The credentials (username, password) should be stored in a text file, not a database. For security reasons, passwords should be...
import hashlib CREDENTIALS_FILE = 'credentials.txt' def hash_password(password): return hashlib.sha256(password.encode()).hexdigest() def register_user(username, password): hashed_password = hash_password(password) with open(CREDENTIALS_FILE, 'a') as f: f.write(f"{username} {hashed_password}\n"...
import os from solution import register_user, login_user, change_password, CREDENTIALS_FILE def setup_module(module): if os.path.exists(CREDENTIALS_FILE): os.remove(CREDENTIALS_FILE) def test_register_and_login_user(): setup_module(None) register_user('test_user', 'test_password') assert login...
[ { "docstring": null, "function_declaration": "def hash_password(password):", "function_name": "hash_password", "parameter_list": "(password)" }, { "docstring": null, "function_declaration": "def register_user(username, password):", "function_name": "register_user", "parameter_lis...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import hashlib\nimport os\n\nCREDENTIALS_FILE = \"credentials.txt\"\n\n\ndef hash_password(password):\n return hashlib.sha256(password.encode()).hexdigest()\n\n\ndef register_user(username,...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077545", "row_id": 77545, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157441']" }
0.500508
Filter_77545
I
[ "hash_password", "register_user", "login_user", "change_password" ]
4
[ [ "change_password", "hash_password" ], [ "login_user", "hash_password" ], [ "register_user", "hash_password" ] ]
3
[]
false
[]
false
pytest
true
[]
true
561031b180f66fd323f5fe006e298b22319c2e29
61b1a4fd130c06415268781e394009658a62d8a1
v1.0
instruct
Filter
Filter_77561_I
How can I implement the Fuzzy C-Means clustering algorithm in Python?
import numpy as np def initialize_membership_matrix(data, num_clusters): num_data_points = data.shape[0] membership_matrix = np.random.rand(num_data_points, num_clusters) membership_matrix = membership_matrix / membership_matrix.sum(axis=1, keepdims=True) return membership_matrix def calculate_cluster...
import numpy as np from solution import fuzzy_c_means, initialize_membership_matrix, calculate_cluster_centers, update_membership_matrix def test_initialize_membership_matrix(): data = np.array([[1, 2], [2, 1], [4, 5], [5, 4]]) num_clusters = 2 membership = initialize_membership_matrix(data, num_clusters) ...
[ { "docstring": null, "function_declaration": "def initialize_membership_matrix(data, num_clusters):", "function_name": "initialize_membership_matrix", "parameter_list": "(data, num_clusters)" }, { "docstring": null, "function_declaration": "def calculate_cluster_centers(data, membership_...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\n\ndef initialize_membership_matrix(data, num_clusters):\n num_data_points = data.shape[0]\n membership_matrix = np.random.rand(num_data_points, num_clusters)\n mem...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00077561", "row_id": 77561, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157488']" }
0.563201
Filter_77561
I
[ "initialize_membership_matrix", "calculate_cluster_centers", "update_membership_matrix", "fuzzy_c_means" ]
4
[ [ "fuzzy_c_means", "calculate_cluster_centers" ], [ "fuzzy_c_means", "initialize_membership_matrix" ], [ "fuzzy_c_means", "update_membership_matrix" ] ]
3
[]
false
[]
false
pytest
true
[ "numpy" ]
false
2c9e99e3a98f4754a88b70763832200051790154
579edb733dc1d67036fb3a6108d8d42bb6bcd516
v1.0
instruct
Filter
Filter_77567_I
Hello, I'm trying to create a Python script to monitor the CPU usage of a system and send an email alert if the CPU usage exceeds a certain threshold. How can I achieve this?
import smtplib import psutil from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart def send_email(subject, body, to_email, from_email, from_password): """ Sends an email with the given subject and body to the specified recipient. """ msg = MIMEMultipart() msg['From'] =...
def test_send_email(monkeypatch): def mock_smtplib_smtp(*args, **kwargs): class MockSMTP: def __init__(self, *args, **kwargs): pass def starttls(self): pass def login(self, user, password): pass def sendmail(self...
[ { "docstring": "Sends an email with the given subject and body to the specified recipient.", "function_declaration": "def send_email(subject, body, to_email, from_email, from_password):", "function_name": "send_email", "parameter_list": "(subject, body, to_email, from_email, from_password)" }, {...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import smtplib\nimport psutil\nfrom email.mime.text import MIMEText\nfrom email.mime.multipart import MIMEMultipart\n\ndef check_cpu_usage(threshold):\n \"\"\"\n Check the current CPU us...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077567", "row_id": 77567, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157509']" }
0.634517
Filter_77567
I
[ "send_email", "monitor_cpu" ]
2
[ [ "monitor_cpu", "send_email" ] ]
1
[]
false
[]
false
pytest
true
[ "psutil" ]
false
48f7bf5a2271dfe315a7bf0c7d1481ccee70b69c
8c22b10449483f21bb07a6314c2dd5f6429a8d46
v1.0
instruct
Filter
Filter_77585_I
Write a Python code to simulate a simple neural network for a binary classification problem using the sigmoid function as the activation function. The network should have two input neurons, one hidden layer with two neurons, and one output neuron. The weights and biases should be initialized randomly. The network shoul...
import numpy as np def sigmoid(x): return 1 / (1 + np.exp(-x)) def sigmoid_derivative(x): return x * (1 - x) # Initialize random weights and biases input_size = 2 hidden_size = 2 output_size = 1 np.random.seed(42) weights_input_hidden = np.random.rand(input_size, hidden_size) weights_hidden_output = np.ran...
import numpy as np from solution import train, predict def test_neural_network_initialization(): assert weights_input_hidden.shape == (2, 2) assert weights_hidden_output.shape == (2, 1) assert bias_hidden.shape == (2,) assert bias_output.shape == (1,) def test_neural_network_training(): np.random....
[ { "docstring": null, "function_declaration": "def sigmoid(x):", "function_name": "sigmoid", "parameter_list": "(x)" }, { "docstring": null, "function_declaration": "def sigmoid_derivative(x):", "function_name": "sigmoid_derivative", "parameter_list": "(x)" }, { "docstring...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\n\ndef sigmoid(x):\n return 1 / (1 + np.exp(-x))\n\ndef sigmoid_derivative(x):\n return x * (1 - x)\n\nclass SimpleNeuralNetwork:\n def __init__(self):\n sel...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077585", "row_id": 77585, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157552']" }
0.486117
Filter_77585
I
[ "sigmoid", "sigmoid_derivative", "train", "predict" ]
4
[ [ "predict", "sigmoid" ], [ "train", "sigmoid" ], [ "train", "sigmoid_derivative" ] ]
3
[]
false
[]
false
pytest
true
[ "numpy" ]
false
e7e8c71d9f06cf8f8eb49d4e304b1392eb9f5ff2
86df47e37e4de51b7b7d173743c56350e3c0b54e
v1.0
instruct
Filter
Filter_77600_I
I want to create a Python script that should check the size of a file or directory and print its human-readable format. How can I achieve this?
import os def get_human_readable_size(size): """ Convert a size in bytes into a human-readable format. """ for unit in ['B', 'KB', 'MB', 'GB', 'TB']: if size < 1024: return f"{size:.2f} {unit}" size /= 1024 def get_size(path): """ Return the size of a file or direct...
import pytest import os from solution import get_size, get_human_readable_size, print_human_readable_size def test_get_human_readable_size(): assert get_human_readable_size(1023) == "1023.00 B" assert get_human_readable_size(1024) == "1.00 KB" assert get_human_readable_size(1048576) == "1.00 MB" assert...
[ { "docstring": "Convert a size in bytes into a human-readable format.", "function_declaration": "def get_human_readable_size(size):", "function_name": "get_human_readable_size", "parameter_list": "(size)" }, { "docstring": "Return the size of a file or directory in bytes.", "function_dec...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\n\ndef get_size(start_path='.'):\n \"\"\"\n Returns the total size of the given directory or file in bytes.\n \"\"\"\n total_size = 0\n if os.path.isfile(start_path):\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077600", "row_id": 77600, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157586']" }
0.586579
Filter_77600
I
[ "get_human_readable_size", "get_size", "print_human_readable_size" ]
3
[ [ "print_human_readable_size", "get_human_readable_size" ], [ "print_human_readable_size", "get_size" ] ]
2
[]
false
[]
false
pytest
true
[]
true
4c54a08b011b8bda78589efed7b906499e600848
6d21670c3a7dd1e5edecfe1c6c98ddf75f9027fd
v1.0
instruct
Filter
Filter_77621_I
Write a Python function named `calculate_sum` that takes a single argument `numbers`, which is a list of integers. The function should return the sum of all integers in the list. Additionally, include a docstring that describes the function's purpose, includes examples of how to use the function, and what it returns. A...
def calculate_sum(numbers): """ Calculates the sum of all integers in the list. Parameters: numbers (list): A list of integers to be summed. Returns: int: The sum of all integers in the list. Examples: >>> calculate_sum([1, 2, 3, 4]) 10 >>> calculate_sum([10, -5, 6]) 11 ...
from solution import calculate_sum, verify_solution def test_calculate_sum_with_positive_numbers(): assert calculate_sum([1, 2, 3, 4]) == 10 def test_calculate_sum_with_mixed_numbers(): assert calculate_sum([10, -5, 6]) == 11 def test_calculate_sum_with_empty_list(): assert calculate_sum([]) == 0 def te...
[ { "docstring": "Calculates the sum of all integers in the list.\n\nParameters:\nnumbers (list): A list of integers to be summed.\n\nReturns:\nint: The sum of all integers in the list.\n\nExamples:\n>>> calculate_sum([1, 2, 3, 4])\n10\n>>> calculate_sum([10, -5, 6])\n11\n>>> calculate_sum([])\n0", "function_...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_sum(numbers):\n \"\"\"\n Calculates the sum of all integers in the list.\n \n Args:\n numbers (list): A list of integers.\n \n Returns:\n int: The sum of ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077621", "row_id": 77621, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157626']" }
0.701785
Filter_77621
I
[ "calculate_sum", "verify_solution" ]
2
[ [ "verify_solution", "calculate_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ed0934ffb54e49f2e39dcfbb043225fb621eb202
29d089490718979be5b9482df3aa9dbcbc0fb330
v1.0
instruct
Filter
Filter_77657_I
Can you provide a Python script that generates a CSV file with random data? The CSV should have three columns: 'Name', 'Age', 'Email', and include 100 rows.
import csv import random import string def generate_random_name(): first_names = ['John', 'Jane', 'Sam', 'Sara', 'Mike', 'Anna', 'Tom', 'Linda', 'Alex', 'Emma'] last_names = ['Smith', 'Doe', 'Brown', 'Johnson', 'Jones', 'Miller', 'Davis', 'Garcia', 'Rodriguez', 'Wilson'] return random.choice(first_names) +...
import os import csv def test_csv_file_creation(): filename = 'test_random_data.csv' generate_csv(filename, 100) # Check if file exists assert os.path.exists(filename) # Check file content with open(filename, mode='r') as file: reader = csv.reader(file) rows = list(rea...
[ { "docstring": null, "function_declaration": "def generate_random_name():", "function_name": "generate_random_name", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def generate_random_age():", "function_name": "generate_random_age", "parameter_list": "()"...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import csv\nimport random\nimport string\n\ndef generate_random_name():\n first_names = ['John', 'Jane', 'Sam', 'Sara', 'Mike', 'Anna', 'Tom', 'Linda', 'Alex', 'Emma']\n last_names = ['S...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00077657", "row_id": 77657, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157701']" }
0.708485
Filter_77657
I
[ "generate_random_name", "generate_random_age", "generate_random_email", "generate_csv" ]
4
[ [ "generate_csv", "generate_random_age" ], [ "generate_csv", "generate_random_email" ], [ "generate_csv", "generate_random_name" ] ]
3
[]
false
[]
false
pytest
false
[]
true
8c41bf10dde257970872cb5428036fcd7560755d
f48e595cb31a7e7f3b3743724d406aab4546e322
v1.0
instruct
Filter
Filter_77676_I
Can you explain how to create a Python script that finds and prints all prime numbers within a given range?
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True...
from solution import is_prime, find_primes_in_range def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(13) == True assert is_prime(19) == True assert is_prime(1) =...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of all prime numbers in the given range [start, end].", "function_declaration": "def find_primes_in_range(start...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True # 2 is the only even prime numbe...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077676", "row_id": 77676, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157742']" }
0.685613
Filter_77676
I
[ "is_prime", "find_primes_in_range" ]
2
[ [ "find_primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
36ef5f3933baeab4e1bdc0f59fa7e902ea211e10
31bf377fe864d5459a1547fffc400d0ea73323e3
v1.0
instruct
Filter
Filter_77695_I
How can I convert a synchronous function to an asynchronous one in Python? In the following example, how can I make the `calculate_square` function asynchronous?
import asyncio def calculate_square(x): """ Returns the square of x. """ return x * x async def calculate_square_async(x): loop = asyncio.get_running_loop() return await loop.run_in_executor(None, calculate_square, x)
import pytest import asyncio from solution import calculate_square_async, calculate_square @pytest.mark.asyncio async def test_calculate_square_async(): result = await calculate_square_async(4) assert result == 16 @pytest.mark.asyncio async def test_calculate_square_async_with_zero(): result = await calcu...
[ { "docstring": "Returns the square of x.", "function_declaration": "def calculate_square(x):", "function_name": "calculate_square", "parameter_list": "(x)" } ]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import asyncio\n\nasync def calculate_square(x):\n \"\"\"\n An asynchronous function that calculates the square of a number.\n \"\"\"\n return x * x", "test_code": "import asyn...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077695", "row_id": 77695, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157789']" }
0.472374
Filter_77695
I
[ "calculate_square", "calculate_square_async" ]
2
[ [ "calculate_square_async", "calculate_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
81f41a0d455efd4060691d3e11307942e58482df
508951e04d5bf51d41c87841d4a43e2e490fde4d
v1.0
instruct
Filter
Filter_77699_I
How can I create a Python function that simulates a simple dice roll game where a player rolls a six-sided die and collects points based on the roll? The game continues until a specific point threshold is reached or exceeded.
import random def roll_dice(): """ Simulates rolling a six-sided die. Returns a random integer between 1 and 6 inclusive. """ return random.randint(1, 6) def dice_game(point_threshold): """ Simulates a dice roll game where a player continues to roll a six-sided die until their total sc...
from solution import roll_dice, dice_game def test_roll_dice(): for _ in range(100): # run multiple times to ensure randomness within range roll = roll_dice() assert 1 <= roll <= 6 def test_dice_game_threshold_reached(): threshold = 10 total_points = dice_game(threshold) assert total_...
[ { "docstring": "Simulates rolling a six-sided die.\nReturns a random integer between 1 and 6 inclusive.", "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": "Simulates a dice roll game where a player continues to roll a six-side...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef roll_dice():\n \"\"\"\n Simulates rolling a six-sided die.\n Returns:\n int: A random integer between 1 and 6 inclusive.\n \"\"\"\n return random.ran...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077699", "row_id": 77699, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157795']" }
0.545907
Filter_77699
I
[ "roll_dice", "dice_game" ]
2
[ [ "dice_game", "roll_dice" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5147186a3a737562be374be6d761ff69e51d30a4
b66e96fe52f82aadf250fdf934de8003bbc698c1
v1.0
instruct
Filter
Filter_77724_I
Can you provide a Python function to check if a given number is a prime number and also list all prime numbers within a given range?
def is_prime(n): """ Check if a number is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 ...
from solution import is_prime, list_primes_in_range def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(0) == False assert is_prime(1) == False assert is_prime(-7) == False assert is_prime(97) ...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "List all prime numbers within a given range [start, end].", "function_declaration": "def list_primes_in_range(start, ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077724", "row_id": 77724, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157846']" }
0.728193
Filter_77724
I
[ "is_prime", "list_primes_in_range" ]
2
[ [ "list_primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
42613d29ef67d480846bf9183621d4b88ed1ac15
5f9bf0872057a026d487fef34f81dbeb74b4dc60
v1.0
instruct
Filter
Filter_77738_I
How can we compute the nested radial basis functions (RBF) for a given dataset using Python?
import numpy as np def rbf_kernel(x, y, gamma): """ Computes the Radial Basis Function (RBF) kernel between two vectors. Parameters: - x (np.array): The first vector. - y (np.array): The second vector. - gamma (float): The gamma parameter for the RBF kernel. Returns: - float: ...
from solution import rbf_kernel, nested_rbf import numpy as np def test_rbf_kernel_same_vector(): x = np.array([1, 2, 3]) y = np.array([1, 2, 3]) gamma = 0.5 assert np.isclose(rbf_kernel(x, y, gamma), 1.0) def test_rbf_kernel_different_vectors(): x = np.array([1, 0]) y = np.array([0, 1]) g...
[ { "docstring": "Computes the Radial Basis Function (RBF) kernel between two vectors.\n\nParameters:\n- x (np.array): The first vector.\n- y (np.array): The second vector.\n- gamma (float): The gamma parameter for the RBF kernel.\n\nReturns:\n- float: The RBF kernel value.", "function_declaration": "def rbf_...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\n\ndef rbf_kernel(x, y, gamma=1.0):\n \"\"\"\n Compute the Radial Basis Function (RBF) kernel between two samples.\n \n Parameters:\n x (numpy.array): First s...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077738", "row_id": 77738, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157872']" }
0.403551
Filter_77738
I
[ "rbf_kernel", "nested_rbf" ]
2
[ [ "nested_rbf", "rbf_kernel" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
5a5155c5b7f8112eb7c4601ec10b750ee1551da0
47dac22ff17c47a4371450837fa9d6df86b9fe58
v1.0
instruct
Filter
Filter_77740_I
Write a Python function to generate a random HTML document with a specified number of paragraphs and a specified number of links per paragraph. Each paragraph should contain random text, and each link should have a random URL and a random anchor text.
import random import string def generate_random_text(length): """ Generate a random text of specified length. """ letters = string.ascii_letters + string.digits + ' ' * 10 return ''.join(random.choice(letters) for _ in range(length)) def generate_random_url(): """ Generate a random URL. ...
from solution import generate_random_html_document import re def test_paragraph_count(): html = generate_random_html_document(3, 2) paragraphs = re.findall(r'<p>.*?</p>', html, re.DOTALL) assert len(paragraphs) == 3 def test_link_count_per_paragraph(): html = generate_random_html_document(3, 4) pa...
[ { "docstring": "Generate a random text of specified length.", "function_declaration": "def generate_random_text(length):", "function_name": "generate_random_text", "parameter_list": "(length)" }, { "docstring": "Generate a random URL.", "function_declaration": "def generate_random_url():...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport string\n\ndef generate_random_text(length):\n \"\"\"\n Generates a random string of specified length.\n \"\"\"\n letters = string.ascii_lowercase + ' '\n r...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077740", "row_id": 77740, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157874']" }
0.523741
Filter_77740
I
[ "generate_random_text", "generate_random_url", "generate_random_html_document" ]
3
[ [ "generate_random_html_document", "generate_random_text" ], [ "generate_random_html_document", "generate_random_url" ] ]
2
[]
false
[]
false
pytest
true
[]
true
08068278842708734bd147998ec7d5f195ce685e
93032d51941586fd5d1bb87911d614b0ec5097b0
v1.0
instruct
Filter
Filter_77753_I
How can I update my To Do list in a simple text file using Python?
def read_todo_list(file_path): """ Reads the To Do list from the specified file. """ try: with open(file_path, 'r') as file: tasks = file.readlines() return [task.strip() for task in tasks] except FileNotFoundError: return [] def write_todo_list(file_path, tasks)...
import os from solution import read_todo_list, write_todo_list, add_task, update_task def test_read_and_write_todo_list(tmp_path): file_path = tmp_path / "todo.txt" # Write tasks and read them back tasks = ["Buy milk", "Go for a run"] write_todo_list(file_path, tasks) read_tasks = read_todo_li...
[ { "docstring": "Reads the To Do list from the specified file.", "function_declaration": "def read_todo_list(file_path):", "function_name": "read_todo_list", "parameter_list": "(file_path)" }, { "docstring": "Writes the To Do list to the specified file.", "function_declaration": "def writ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def add_task(file_path, task):\n \"\"\"\n Adds a new task to the to-do list stored in a text file.\n\n :param file_path: The path to the to-do list text file.\n :param task: The ta...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077753", "row_id": 77753, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157903']" }
0.469095
Filter_77753
I
[ "read_todo_list", "write_todo_list", "add_task", "update_task" ]
4
[ [ "add_task", "read_todo_list" ], [ "add_task", "write_todo_list" ], [ "update_task", "read_todo_list" ], [ "update_task", "write_todo_list" ] ]
4
[]
false
[]
false
pytest
true
[]
true
1c11b5cc573e114d8768191dbf5b38bc41905786
39bc3670dac260223713200bc8289673216a4d0e
v1.0
instruct
Filter
Filter_77801_I
Write a program to create a simple calculator using Python. This calculator should be able to perform the basic arithmetic operations: addition, subtraction, multiplication, and division. The program should be interactive, allowing the user to choose the operation and input the numbers. It should also handle division b...
def add(a, b): return a + b def subtract(a, b): return a - b def multiply(a, b): return a * b def divide(a, b): if b == 0: return "Error: Division by zero is not allowed." return a / b def calculator(): print("Options:") print("1. Add") print("2. Subtract") print("3. Mult...
from solution import add, subtract, multiply, divide def test_add(): assert add(3, 5) == 8 assert add(-1, 1) == 0 assert add(0, 0) == 0 def test_subtract(): assert subtract(10, 5) == 5 assert subtract(0, 5) == -5 assert subtract(5, 5) == 0 def test_multiply(): assert multiply(3, 4) == 12 ...
[ { "docstring": null, "function_declaration": "def add(a, b):", "function_name": "add", "parameter_list": "(a, b)" }, { "docstring": null, "function_declaration": "def subtract(a, b):", "function_name": "subtract", "parameter_list": "(a, b)" }, { "docstring": null, "fu...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def add(a, b):\n return a + b\n\ndef subtract(a, b):\n return a - b\n\ndef multiply(a, b):\n return a * b\n\ndef divide(a, b):\n if b == 0:\n return \"Error: Division by zer...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077801", "row_id": 77801, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_157993']" }
0.592791
Filter_77801
I
[ "add", "subtract", "multiply", "divide", "calculator" ]
5
[ [ "calculator", "add" ], [ "calculator", "divide" ], [ "calculator", "multiply" ], [ "calculator", "subtract" ] ]
4
[]
false
[]
false
pytest
true
[]
true
ba157e295616beaacb042e9ad7e0d789b89bef1e
11460085f4194c5e48303836621a93e4bda77791
v1.0
instruct
Filter
Filter_77808_I
Write a Python script that calculates the sum of all prime numbers up to a given number `n`. The script should include a function to check if a number is prime and another function to calculate the sum of primes up to `n`.
def is_prime(num): """ Returns True if num is a prime number, else False. """ if num <= 1: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True def sum_of_primes(n): """ Returns the sum of all prime numbers up to and ...
from solution import is_prime, sum_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(20) == False def test_sum_of_primes(): assert sum_of_primes(10) == 17 # 2 + 3 + 5 + 7 = 17 assert...
[ { "docstring": "Returns True if num is a prime number, else False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers up to and including n.", "function_declaration": "def sum_of_p...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Returns True if num is a prime number, else False.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num ** 0.5) + 1):\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00077808", "row_id": 77808, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_158010']" }
0.663759
Filter_77808
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ac43bfa8f5f18c62c5750f4679b89e931704f586
ad2fe7c2f0eb1ce491daa2da5b25d30f84e64b0a
v1.0
instruct
Filter
Filter_77825_I
Can you explain the concept of parallel computing and provide a simple example in Python?
import multiprocessing def compute_square(n): """ Computes the square of a number. """ return n * n def parallel_square(numbers): """ Computes the square of each number in the list in parallel. """ with multiprocessing.Pool() as pool: result = pool.map(compute_square, numbers) ...
from solution import compute_square, parallel_square def test_compute_square(): assert compute_square(2) == 4 assert compute_square(3) == 9 assert compute_square(-4) == 16 assert compute_square(0) == 0 def test_parallel_square(): numbers = [1, 2, 3, 4, 5] expected = [1, 4, 9, 16, 25] asser...
[ { "docstring": "Computes the square of a number.", "function_declaration": "def compute_square(n):", "function_name": "compute_square", "parameter_list": "(n)" }, { "docstring": "Computes the square of each number in the list in parallel.", "function_declaration": "def parallel_square(nu...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def parallel_sum(arr):\n \"\"\"\n Returns the sum of the elements of the array arr using parallel computing.\n \"\"\"\n from multiprocessing import Pool\n\n def chunk_sum(sub_ar...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00077825", "row_id": 77825, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_158051']" }
0.47535
Filter_77825
I
[ "compute_square", "parallel_square" ]
2
[ [ "parallel_square", "compute_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bf7c8fa58bb9199bcfb9ca36a08bf66cd6d68032
30d0a92fae12ae6b68567b8fbe6a8ffc4d62718d
v1.0
instruct
Filter
Filter_77843_I
Can you explain how to use MapReduce in Python for a simple word count example?
from collections import defaultdict from itertools import groupby from operator import itemgetter def map_function(document): """ Map function that processes each line of the document and emits a key-value pair. In this case, the key is each word and the value is 1. """ for word in document.split()...
import pytest from solution import map_function, reduce_function, map_reduce def test_map_function(): document = "This is a test. This test is only a test." result = list(map_function(document)) expected = [('this', 1), ('is', 1), ('a', 1), ('test.', 1), ('this', 1), ('test', 1), ('is', 1)...
[ { "docstring": "Map function that processes each line of the document and emits a key-value pair.\nIn this case, the key is each word and the value is 1.", "function_declaration": "def map_function(document):", "function_name": "map_function", "parameter_list": "(document)" }, { "docstring":...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import defaultdict\n\ndef map_function(document):\n \"\"\"\n Map function for a word count example.\n Takes a document (a string) and returns a list of (word, 1) tupl...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077843", "row_id": 77843, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_158087']" }
0.562857
Filter_77843
I
[ "map_function", "reduce_function", "map_reduce" ]
3
[ [ "map_reduce", "map_function" ], [ "map_reduce", "reduce_function" ] ]
2
[]
false
[]
false
pytest
true
[]
true
00bcae35af8d805a0012348b16b02681909abcc2
01f0ceaee0c23f3deff2c9dfb043636f19f5c84e
v1.0
instruct
Filter
Filter_77865_I
Can you provide a Python code snippet to simulate a simple card game where players receive random cards from a deck? Each player starts with 5 cards, and the deck is standard consisting of 52 cards. The cards should be dealt randomly without replacement.
import random def shuffle_deck(): """Returns a shuffled deck of 52 cards.""" suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] values = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'] deck = [value + ' of ' + suit for suit in suits for value in values] random.shuffle(deck) re...
from solution import shuffle_deck, deal_cards def test_shuffle_deck(): deck = shuffle_deck() assert len(deck) == 52, f"Expected 52 cards, got {len(deck)}" assert len(set(deck)) == 52, "Deck contains duplicate cards" def test_deal_cards_valid(): num_players = 4 players_hands = deal_cards(num_player...
[ { "docstring": "Returns a shuffled deck of 52 cards.", "function_declaration": "def shuffle_deck():", "function_name": "shuffle_deck", "parameter_list": "()" }, { "docstring": "Deals 5 random cards to each player from a shuffled deck.\n\nArgs:\nnum_players (int): Number of players to deal ca...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef shuffle_deck():\n \"\"\"\n Shuffles and returns a standard 52-card deck.\n \"\"\"\n suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades']\n ranks = ['2', '3', '...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077865", "row_id": 77865, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_158139']" }
0.569698
Filter_77865
I
[ "shuffle_deck", "deal_cards" ]
2
[ [ "deal_cards", "shuffle_deck" ] ]
1
[]
false
[]
false
pytest
true
[]
true
58d11f32f941459aa9809f5d4d4d269aaf7680b8
0fb5aa0435856f3965768a20d712085d17618caa
v1.0
instruct
Filter
Filter_77876_I
Write a Python function that reads a JSON file containing user data and constructs a directed graph where each user follows another user if they are present in the user's "following" list. Use the `Graph` class from the `graphlib` module to represent and manipulate the graph.
import json from graphlib import TopologicalSorter def read_user_data(file_path): """ Reads a JSON file of user data and constructs a directed graph of user followers using NetworkX. Parameters: - file_path: path to the JSON file Returns: - dict: representation of the directed gra...
import pytest import json from solution import read_user_data, create_topological_sorter, read_and_sort # Helper function to create a temporary JSON file with user data @pytest.fixture def tmp_json(tmp_path): data = [ {"name": "Alice", "following": ["Bob", "Charlie"]}, {"name": "Bob", "following": ...
[ { "docstring": "Reads a JSON file of user data and constructs a directed graph\nof user followers using NetworkX.\n\nParameters:\n- file_path: path to the JSON file\n\nReturns:\n- dict: representation of the directed graph", "function_declaration": "def read_user_data(file_path):", "function_name": "rea...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import json\nfrom graphlib import TopologicalSorter\n\ndef read_user_data(file_path):\n \"\"\"\n Reads a JSON file of user data and constructs a directed graph\n of user followers usi...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00077876", "row_id": 77876, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_158170']" }
0.406395
Filter_77876
I
[ "read_user_data", "create_topological_sorter", "read_and_sort" ]
3
[ [ "read_and_sort", "create_topological_sorter" ], [ "read_and_sort", "read_user_data" ] ]
2
[]
false
[]
false
pytest
true
[]
true
3fc20eba091ea1e47bd23312d6d5909b825c4341
7e11afeb306f1170940e5b95f32e7b03b6a3d263
v1.0
instruct
Filter
Filter_77883_I
I want to create a script that monitors the CPU and memory usage of a server and logs it periodically. I want this to be done in Python. Can you provide a sample script for this task?
import psutil import time import logging def setup_logging(log_file): # Configure the logging logging.basicConfig(filename=log_file, level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') def monitor_system(interval=5, duration=60, log_file='sys...
from unittest.mock import patch, MagicMock from solution import monitor_system import logging def test_monitor_system(): with patch("solution.psutil.cpu_percent", return_value=20.0) as mock_cpu, \ patch("solution.psutil.virtual_memory") as mock_memory, \ patch("solution.time.sleep"), \ p...
[ { "docstring": null, "function_declaration": "def setup_logging(log_file):", "function_name": "setup_logging", "parameter_list": "(log_file)" }, { "docstring": "Monitors the CPU and memory usage at regular intervals and logs the information to a file.\n\n:param interval: Time interval in sec...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import psutil\nimport time\nimport logging\n\ndef setup_logging(log_file):\n # Configure the logging\n logging.basicConfig(filename=log_file,\n level=logging.INFO,...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00077883", "row_id": 77883, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_158178']" }
0.644502
Filter_77883
I
[ "setup_logging", "monitor_system" ]
2
[ [ "monitor_system", "setup_logging" ] ]
1
[]
false
[]
false
pytest
true
[ "psutil" ]
false
776a1ebc3c501176861957a48eb8a3e03be1c69b
678c6f9bd2a07dbd0e63a221a4b66576d21dbf2f
v1.0
instruct
Filter
Filter_77969_I
How can I convert a list of numbers into a binary tree in Python?
class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right def insert_level_order(arr, root, i, n): if i < n: temp = TreeNode(arr[i]) root = temp # Insert left child root.left = inse...
from solution import list_to_binary_tree, TreeNode def tree_to_list(root): if not root: return [] result = [] queue = [root] while queue: current = queue.pop(0) result.append(current.value if current else None) if current: queue.append(current.left)...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef list_to_binary_tree(lst):\n \"\"\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077969", "row_id": 77969, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_158357']" }
0.530092
Filter_77969
I
[ "insert_level_order", "list_to_binary_tree" ]
2
[ [ "list_to_binary_tree", "insert_level_order" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
0b28cb02e2b8ee7e3dc75c130b8235eb3d206d1b
93a19d5ab346abef06b2f8b03af0225010212a14
v1.0
instruct
Filter
Filter_77990_I
How can I create a Python function that finds all the prime numbers between two given numbers, inclusive?
def is_prime(num): """ Checks if a number is prime. """ if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def find_primes(start, end): """ Finds all prime numbers between start and end, inclusive. ""...
from solution import is_prime, find_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(19) == True def test_find_primes(): assert find_primes(10, 20) == [11, ...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Finds all prime numbers between start and end, inclusive.", "function_declaration": "def find_primes(start, end):", "...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00077990", "row_id": 77990, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_158406']" }
0.703555
Filter_77990
I
[ "is_prime", "find_primes" ]
2
[ [ "find_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e01da073ef60f1dc3abb59e43f74e7fe94d5bce6
a807717607f081aec44ca81c04ef4aa591fb3526
v1.0
instruct
Filter
Filter_78004_I
Can you explain the concept of pagination in web development and provide a simple example of how to implement it in Python using Flask?
from flask import Flask, request, jsonify app = Flask(__name__) # Mock data ITEMS = [f'Item {i}' for i in range(100)] def paginate(items, page, per_page): """ Paginate the list of items. :param items: List of items :param page: Current page number (1-based) :param per_page: Number of items p...
import pytest from flask import url_for from solution import app @pytest.fixture def client(): with app.test_client() as client: yield client def test_get_items_first_page(client): response = client.get('/items?page=1&per_page=10') data = response.get_json() assert response.status_code == 200 ...
[ { "docstring": "Paginate the list of items.\n\n:param items: List of items\n:param page: Current page number (1-based)\n:param per_page: Number of items per page\n:return: Paginated items and metadata", "function_declaration": "def paginate(items, page, per_page):", "function_name": "paginate", "par...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from flask import Flask, request, jsonify\n\napp = Flask(__name__)\n\n# Dummy data for demonstration\ndata = [{'id': i, 'name': f'Item {i}'} for i in range(1, 101)]\n\n@app.route('/items', met...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00078004", "row_id": 78004, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_158424']" }
0.45681
Filter_78004
I
[ "paginate", "get_items" ]
2
[ [ "get_items", "paginate" ] ]
1
[]
false
[]
false
pytest
true
[ "flask" ]
false
2a14962fde4641b0762eb61eb555443b394599ac
fc193e5bd56c06e2fb7497423850c02b81b3faec
v1.0
instruct
Filter
Filter_78006_I
Write a Python function that implements logistic regression for binary classification. The function should take in the feature matrix `X`, the target vector `y`, and the number of iterations `num_iterations` as inputs. It should return the fitted model parameters `weights` and `bias`.
import numpy as np def sigmoid(z): return 1 / (1 + np.exp(-z)) def logistic_regression(X, y, num_iterations, learning_rate=0.01): """ Implements logistic regression for binary classification. Parameters: X (numpy.ndarray): Feature matrix of shape (num_samples, num_features). y (numpy.ndar...
import numpy as np from solution import logistic_regression def test_logistic_regression_zero_initialization(): X = np.array([[1, 2], [2, 3], [3, 4], [4, 5]]) y = np.array([0, 0, 1, 1]) weights, bias = logistic_regression(X, y, num_iterations=1000, learning_rate=0.1) assert weights is not None ...
[ { "docstring": null, "function_declaration": "def sigmoid(z):", "function_name": "sigmoid", "parameter_list": "(z)" }, { "docstring": "Implements logistic regression for binary classification.\n\nParameters:\nX (numpy.ndarray): Feature matrix of shape (num_samples, num_features).\ny (numpy.n...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\n\ndef sigmoid(z):\n return 1 / (1 + np.exp(-z))\n\ndef logistic_regression(X, y, num_iterations, learning_rate=0.01):\n \"\"\"\n Implements logistic regression for...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078006", "row_id": 78006, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_158426']" }
0.588248
Filter_78006
I
[ "sigmoid", "logistic_regression" ]
2
[ [ "logistic_regression", "sigmoid" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
13eb71f06449d6daed1747bdde67047a63bd6f0f
66cffe86ef0f3f45f5403ead221cfadac2aae237
v1.0
instruct
Filter
Filter_78008_I
Can you provide a Python code example that processes a JSON file and calculates the sum of all numeric values within it, including those nested within objects or arrays?
import json def sum_numeric_values(json_obj): """ Recursively sum all numeric values within a JSON object. """ total_sum = 0 if isinstance(json_obj, dict): for value in json_obj.values(): total_sum += sum_numeric_values(value) elif isinstance(json_obj, list): fo...
import pytest from solution import sum_numeric_values, sum_numeric_values_in_json_file import json import os def test_sum_numeric_values(): assert sum_numeric_values({"a": 10, "b": 5}) == 15 assert sum_numeric_values([1, 2, 3, {"a": 4}]) == 10 assert sum_numeric_values({"a": {"b": {"c": 5}}, "d": [1, 2, 3]...
[ { "docstring": "Recursively sum all numeric values within a JSON object.", "function_declaration": "def sum_numeric_values(json_obj):", "function_name": "sum_numeric_values", "parameter_list": "(json_obj)" }, { "docstring": "Reads a JSON file and calculates the sum of all numeric values.", ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import json\n\ndef sum_numeric_values(json_data):\n \"\"\"\n Returns the sum of all numeric values in the given JSON data.\n The function is recursive to handle nested objects and arr...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078008", "row_id": 78008, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_158438']" }
0.553891
Filter_78008
I
[ "sum_numeric_values", "sum_numeric_values_in_json_file" ]
2
[ [ "sum_numeric_values_in_json_file", "sum_numeric_values" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fbfdfcd16a4752730478b3cac549cb2149ee0a34
1b57ae4186dc38cb0d67e2cc78cc44961b0045ca
v1.0
instruct
Filter
Filter_78043_I
Write a Python program to implement the K-Means clustering algorithm from scratch. The program should include functions to initialize centroids, assign data points to the nearest centroid, update centroids, and iterate until convergence or a maximum number of iterations is reached. The program should also include a fun...
import numpy as np import matplotlib.pyplot as plt def initialize_centroids(data, k): """ Randomly initialize the centroids. """ np.random.seed(42) centroids = data[np.random.choice(data.shape[0], k, replace=False)] return centroids def assign_clusters(data, centroids): """ Assign each...
from solution import initialize_centroids, assign_clusters, update_centroids, kmeans, has_converged def test_initialize_centroids(): data = np.array([[1, 2], [3, 4], [5, 6], [7, 8]]) k = 2 centroids = initialize_centroids(data, k) assert centroids.shape == (k, data.shape[1]) def test_assign_clusters()...
[ { "docstring": "Randomly initialize the centroids.", "function_declaration": "def initialize_centroids(data, k):", "function_name": "initialize_centroids", "parameter_list": "(data, k)" }, { "docstring": "Assign each data point to the nearest centroid.", "function_declaration": "def assi...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nimport random\nimport matplotlib.pyplot as plt\n\ndef initialize_centroids(data, k):\n \"\"\"\n Randomly initialize k centroids from the data points.\n \"\"\"\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00078043", "row_id": 78043, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_158508']" }
0.660746
Filter_78043
I
[ "initialize_centroids", "assign_clusters", "update_centroids", "has_converged", "kmeans", "plot_clusters" ]
6
[ [ "kmeans", "assign_clusters" ], [ "kmeans", "has_converged" ], [ "kmeans", "initialize_centroids" ], [ "kmeans", "update_centroids" ] ]
4
[]
false
[]
false
pytest
true
[ "matplotlib", "numpy" ]
false
ac3e97a661ab90e9cb71668f2624ba01412c21b5
684171e0b54b5f60e8864c6ac07ccc25bb199dc0
v1.0
instruct
Filter
Filter_78045_I
Can you provide a Python code to generate a random Sudoku puzzle with a unique solution?
import random def is_valid(board, row, col, num): """ Check if placing num at (row, col) is valid. """ for i in range(9): if board[row][i] == num or board[i][col] == num: return False startRow, startCol = 3 * (row // 3), 3 * (col // 3) for i in range(3): for j in ra...
from solution import generate_sudoku, solve_sudoku, is_valid def test_generate_sudoku(): puzzle = generate_sudoku() assert len(puzzle) == 9 assert all(len(row) == 9 for row in puzzle) def test_sudoku_solvable(): puzzle = generate_sudoku() solved_puzzle = [row[:] for row in puzzle] assert solve...
[ { "docstring": "Check if placing num at (row, col) is valid.", "function_declaration": "def is_valid(board, row, col, num):", "function_name": "is_valid", "parameter_list": "(board, row, col, num)" }, { "docstring": "Find an empty location on the board.", "function_declaration": "def fin...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef is_valid(board, row, col, num):\n \"\"\"\n Check if num can be placed in board[row][col]\n \"\"\"\n for i in range(9):\n if board[row][i] == num or boar...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078045", "row_id": 78045, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_158510']" }
0.505707
Filter_78045
I
[ "is_valid", "find_empty_location", "solve_sudoku", "generate_sudoku" ]
4
[ [ "generate_sudoku", "is_valid" ], [ "generate_sudoku", "solve_sudoku" ], [ "solve_sudoku", "find_empty_location" ], [ "solve_sudoku", "is_valid" ] ]
4
[]
false
[]
false
pytest
true
[]
true
e9018e1618e0e385e776193e707348c4fa6fa932
d837f017cf888cb381812dbcaddccfeca0ab1306
v1.0
instruct
Filter
Filter_78115_I
How can I perform a simulation of a simple game of dice where each player rolls two dice and the player with the higher sum wins? In Python, how can I simulate this game and print the winner for 100 games?
import random def roll_dice(): """ Simulate rolling two six-sided dice and return the sum. """ return random.randint(1, 6) + random.randint(1, 6) def play_game(): """ Simulate a single game where two players roll two dice. Returns 'Player 1' if Player 1 wins, 'Player 2' if Player 2 wins, o...
from solution import roll_dice, play_game, simulate_games def test_roll_dice(): for _ in range(1000): result = roll_dice() assert 2 <= result <= 12, f"Result out of bounds: {result}" def test_play_game(): for _ in range(1000): result = play_game() assert result in ['Player 1', ...
[ { "docstring": "Simulate rolling two six-sided dice and return the sum.", "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": "Simulate a single game where two players roll two dice.\nReturns 'Player 1' if Player 1 wins, 'Player ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef roll_dice():\n \"\"\"\n Simulate rolling two dice.\n Returns the sum of the two dice.\n \"\"\"\n die1 = random.randint(1, 6)\n die2 = random.randint(1, 6...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078115", "row_id": 78115, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_158665']" }
0.532376
Filter_78115
I
[ "roll_dice", "play_game", "simulate_games" ]
3
[ [ "play_game", "roll_dice" ], [ "simulate_games", "play_game" ] ]
2
[]
false
[]
false
pytest
true
[]
true
041cf8eb1543008f6a31d752a98638d54554b238
2f91f9ba548b785c93d67b65528282cb0ad64d78
v1.0
instruct
Filter
Filter_78125_I
How can I generate a table of prime numbers using Python?
def is_prime(num): """ Returns True if the number is prime, otherwise False. """ if num <= 1: return False for i in range(2, int(num ** 0.5) + 1): if num % i == 0: return False return True def generate_primes(n): """ Generates a list of prime numbers up to n ...
from solution import is_prime, generate_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(19) == True assert is_prime(20) == Fal...
[ { "docstring": "Returns True if the number is prime, otherwise False.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Generates a list of prime numbers up to n (inclusive).", "function_declaration": "def generate_p...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_prime_table(n):\n \"\"\"\n Generates a list of prime numbers up to n.\n \n :param n: The upper limit for generating prime numbers.\n :return: A list of prime number...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078125", "row_id": 78125, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_158686']" }
0.58754
Filter_78125
I
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c8beed49b9a2761e9b8e7bbf1402c34cb5476473
8f597d3eedeb7d06c44a5b0826c36bb9a970ecb9
v1.0
instruct
Filter
Filter_78157_I
If I have a Python script that can take a fraction as input and simplify it to its lowest terms, how can I modify the script to handle complex numbers, specifically focusing on simplifying the real and imaginary parts of the complex number?
from fractions import Fraction def simplify_fraction(fraction): """ Simplify a fraction to its lowest terms. input: (fraction: str): Fraction in 'numerator/denominator' format. returns: Simplified fraction as a string in 'numerator/denominator' format. """ frac = Fraction(fraction) return f...
from solution import simplify_fraction, simplify_complex def test_simplify_fraction(): assert simplify_fraction("4/8") == "1/2" assert simplify_fraction("10/5") == "2/1" assert simplify_fraction("35/49") == "5/7" assert simplify_fraction("100/25") == "4/1" def test_simplify_complex(): assert simpl...
[ { "docstring": "Simplify a fraction to its lowest terms.\ninput: (fraction: str): Fraction in 'numerator/denominator' format.\nreturns: Simplified fraction as a string in 'numerator/denominator' format.", "function_declaration": "def simplify_fraction(fraction):", "function_name": "simplify_fraction", ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from fractions import Fraction\n\ndef simplify_fraction(fraction):\n \"\"\"\n Simplify a fraction to its lowest terms.\n input: (fraction: str): Fraction in 'numerator/denominator' fo...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00078157", "row_id": 78157, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_158751']" }
0.552281
Filter_78157
I
[ "simplify_fraction", "simplify_complex" ]
2
[ [ "simplify_complex", "simplify_fraction" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5b90cbca9869d0ef43e31004fde8ca2f36039a41
62209ca5c6b66c4694193b24032c9449481a8491
v1.0
instruct
Filter
Filter_78174_I
Can you generate a Python script to simulate a simple lottery system? The system should allow users to enter their names and tickets, and then randomly select a winner. If a winner is selected multiple times, they should be re-entered into the pool until a unique winner is found. Ensure the script is user-friendly and ...
import random def enter_lottery(participants): """ Simulates entering a lottery system. Participants should be a dictionary where the key is the participant's name and the value is the number of tickets they have. """ lottery_pool = [] for name, tickets in participants.items(): if ...
from solution import enter_lottery, draw_winner, unique_winner_lottery def test_enter_lottery_valid(): participants = { "Alice": 2, "Bob": 3, "Charlie": 1 } expected_pool = ["Alice", "Alice", "Bob", "Bob", "Bob", "Charlie"] assert enter_lottery(participants) == expected_pool de...
[ { "docstring": "Simulates entering a lottery system.\nParticipants should be a dictionary where the key is the participant's name\nand the value is the number of tickets they have.", "function_declaration": "def enter_lottery(participants):", "function_name": "enter_lottery", "parameter_list": "(par...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef enter_lottery(participants):\n \"\"\"\n Simulates entering a lottery system.\n Participants should be a dictionary where the key is the participant's name\n an...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00078174", "row_id": 78174, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_158783']" }
0.447852
Filter_78174
I
[ "enter_lottery", "draw_winner", "unique_winner_lottery" ]
3
[ [ "unique_winner_lottery", "draw_winner" ], [ "unique_winner_lottery", "enter_lottery" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5809bf3babc32f0fd7db4a8cba12d30e92ed1666
084c0a5a2e08f3d7b59ba1ae9112a6bb567df8da
v1.0
instruct
Filter
Filter_78212_I
How can I convert JSON data with nested elements to a CSV format in Python?
import json import csv from collections.abc import MutableMapping def flatten_json(y): """ Recursively flattens a JSON object. :param y: JSON object to be flattened. :return: A dictionary with flattened keys. """ out = {} def flatten(x, name=''): if isinstance(x, MutableMapping): ...
import json import os from solution import json_to_csv, flatten_json def test_flatten_json(): json_data = { "id": 1, "name": "John", "address": { "city": "New York", "zip": "10001" }, "phones": ["123-456-7890", "987-654-3210"] } expected_resul...
[ { "docstring": "Recursively flattens a JSON object.\n\n:param y: JSON object to be flattened.\n:return: A dictionary with flattened keys.", "function_declaration": "def flatten_json(y):", "function_name": "flatten_json", "parameter_list": "(y)" }, { "docstring": "Converts JSON data to CSV fo...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import pandas as pd\nimport json\n\ndef flatten_json(y):\n out = {}\n\n def flatten(x, name=''):\n if type(x) is dict:\n for a in x:\n flatten(x[a], name...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00078212", "row_id": 78212, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_158857']" }
0.681013
Filter_78212
I
[ "flatten_json", "json_to_csv" ]
2
[ [ "json_to_csv", "flatten_json" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fb10d608bbac98fe93cdaac6f3ac60d9a70aa29e
068b509a44c25381b4d7a63e8ea00d91ca43cb38
v1.0
instruct
Filter
Filter_78215_I
How can I handle a situation where I need to perform a series of actions in sequence with conditional checks in Python?
def action_a(): return "Action A performed" def action_b(): return "Action B performed" def action_c(): return "Action C performed" def perform_actions(condition_a, condition_b, condition_c): result = [] if condition_a: result.append(action_a()) if condition_b: result.app...
from solution import perform_actions, action_a, action_b, action_c def test_perform_actions_all_conditions_met(): result = perform_actions(True, True, False) assert result == ["Action A performed", "Action B performed", "Action C performed"] def test_perform_actions_no_conditions_met(): result = perform_a...
[ { "docstring": null, "function_declaration": "def action_a():", "function_name": "action_a", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def action_b():", "function_name": "action_b", "parameter_list": "()" }, { "docstring": null, "function...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def perform_actions(actions):\n \"\"\"\n Perform a series of actions in sequence with conditional checks.\n \n Args:\n actions (list): A list of tuples where each tuple contains...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078215", "row_id": 78215, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_158861']" }
0.452035
Filter_78215
I
[ "action_a", "action_b", "action_c", "perform_actions" ]
4
[ [ "perform_actions", "action_a" ], [ "perform_actions", "action_b" ], [ "perform_actions", "action_c" ] ]
3
[]
false
[]
false
pytest
true
[]
true
4d5761676aa333926d2f05fe9488356968935ef6
20069aa84ef31a0b1657fcde7b6902bf1a7f88d8
v1.0
instruct
Filter
Filter_78304_I
Create a rule for a simple calculator in Python that checks if the input is a number before performing any operations. This rule should apply to addition and subtraction operations.
def is_number(value): """ Check if the value is a number. """ return isinstance(value, (int, float)) def add(a, b): """ Returns the sum of a and b if both are numbers. """ if not is_number(a) or not is_number(b): raise ValueError("Both operands must be numbers.") return a + ...
from solution import add, subtract def test_add_valid_numbers(): assert add(2, 3) == 5 def test_add_with_zero(): assert add(0, 5) == 5 assert add(5, 0) == 5 def test_add_negative_numbers(): assert add(-1, -1) == -2 def test_add_mixed_sign_numbers(): assert add(-1, 3) == 2 def test_add_invalid_o...
[ { "docstring": "Check if the value is a number.", "function_declaration": "def is_number(value):", "function_name": "is_number", "parameter_list": "(value)" }, { "docstring": "Returns the sum of a and b if both are numbers.", "function_declaration": "def add(a, b):", "function_name":...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_number(value):\n \"\"\"\n Checks if the given value is a number (int or float).\n \n Parameters:\n - value: The value to check.\n \n Returns:\n - True if the val...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00078304", "row_id": 78304, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_159037']" }
0.551601
Filter_78304
I
[ "is_number", "add", "subtract" ]
3
[ [ "add", "is_number" ], [ "subtract", "is_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e6c78a592cd390eb4073e7b7c5e2b191b9abb769
e8dd21a0a7253bae409efc53361e604420c40454
v1.0
instruct
Filter
Filter_78320_I
I want to set up a system using a lambda function to process incoming data from a DynamoDB stream. Each item in the DynamoDB stream should trigger a lambda function that processes the item and performs some operations based on the item's attributes. How can I set up such a system?
import json def lambda_handler(event, context): for record in event['Records']: if record['eventName'] == 'INSERT': new_image = record['dynamodb']['NewImage'] process_new_record(new_image) elif record['eventName'] == 'MODIFY': old_image = record['dynamodb']['OldI...
from solution import lambda_handler, process_new_record, process_modified_record, process_removed_record def test_process_new_record(capsys): record = {'Field': {'S': 'Value'}} process_new_record(record) captured = capsys.readouterr() assert "Processing new record: " in captured.out def test_process_m...
[ { "docstring": null, "function_declaration": "def lambda_handler(event, context):", "function_name": "lambda_handler", "parameter_list": "(event, context)" }, { "docstring": null, "function_declaration": "def process_new_record(record):", "function_name": "process_new_record", "p...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import json\nimport boto3\n\ndef lambda_handler(event, context):\n \"\"\"\n Lambda function to process records from DynamoDB stream.\n \"\"\"\n for record in event['Records']:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00078320", "row_id": 78320, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_159069']" }
0.362865
Filter_78320
I
[ "lambda_handler", "process_new_record", "process_modified_record", "process_removed_record" ]
4
[ [ "lambda_handler", "process_modified_record" ], [ "lambda_handler", "process_new_record" ], [ "lambda_handler", "process_removed_record" ] ]
3
[]
false
[]
false
pytest
true
[]
true
653c52c87d0bcdefa85dc99ec551d51768faab96
6f8fa01f88351482b625e273333c39bd60758e15
v1.0
instruct
Filter
Filter_78333_I
Write a Python code snippet to calculate the highest prime number within a given range, say from 1 to 100, and display it.
def is_prime(n): """ Checks if a number n is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False p = 3 while p * p <= n: if n % p == 0: return False p += 2 return True def highest_prime_in_range(st...
from solution import is_prime, highest_prime_in_range def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(29) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == False def test_highest_pri...
[ { "docstring": "Checks if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the highest prime number in the given range [start, end].", "function_declaration": "def highest_prime_in_range(sta...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks whether a number is prime or not.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00078333", "row_id": 78333, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_159092']" }
0.644858
Filter_78333
I
[ "is_prime", "highest_prime_in_range" ]
2
[ [ "highest_prime_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6ed5bbff840dd35676d816c9e4c09c69f25687d7
45daa4b441b6ef9516055a3e0c9cf2d23b2ffdef
v1.0
instruct
Filter
Filter_78367_I
Write a Python script to convert a given list of numbers into their corresponding textual representation in English. For example, converting [34, 23, 5] should output ['thirty-four', 'twenty-three', 'five'].
def number_to_words(n): """ Convert a number into words. """ if n == 0: return 'zero' ones = ["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"] teens = ["", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"] ...
from solution import list_to_textual_representation def test_single_digits(): assert list_to_textual_representation([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [ 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'zero'] def test_teen_numbers(): assert list_to_textual_representation([11, 1...
[ { "docstring": "Convert a number into words.", "function_declaration": "def number_to_words(n):", "function_name": "number_to_words", "parameter_list": "(n)" }, { "docstring": "Convert a list of numbers into their corresponding textual representation in English.", "function_declaration":...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def number_to_words(n):\n \"\"\"\n Converts a number into its words representation in English.\n \"\"\"\n if n == 0:\n return \"zero\"\n\n ones = [\"\", \"one\", \"two\",...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078367", "row_id": 78367, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_159145']" }
0.470923
Filter_78367
I
[ "number_to_words", "list_to_textual_representation" ]
2
[ [ "list_to_textual_representation", "number_to_words" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a9a790095cd20269f551d26436557ffd3ea5691c
6dc1fda534d64c38959e35955805c68f60dd307b
v1.0
instruct
Filter
Filter_78370_I
How can I train a simple neural network from scratch using numpy without using any deep learning framework like TensorFlow or PyTorch?
import numpy as np def sigmoid(x): """ Compute the sigmoid of x. """ return 1 / (1 + np.exp(-x)) def sigmoid_derivative(x): """ Compute the derivative of the sigmoid of x. """ return x * (1 - x) def train_neural_network(X, y, learning_rate=0.1, epochs=10000): """ Train a simpl...
import numpy as np from solution import sigmoid, sigmoid_derivative, train_neural_network, predict def test_sigmoid(): assert np.isclose(sigmoid(0), 0.5) assert np.isclose(sigmoid(1), 0.7310585786300049) def test_sigmoid_derivative(): assert np.isclose(sigmoid_derivative(0.5), 0.25) def test_train_neural...
[ { "docstring": "Compute the sigmoid of x.", "function_declaration": "def sigmoid(x):", "function_name": "sigmoid", "parameter_list": "(x)" }, { "docstring": "Compute the derivative of the sigmoid of x.", "function_declaration": "def sigmoid_derivative(x):", "function_name": "sigmoid_...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\n\nclass SimpleNeuralNetwork:\n def __init__(self, input_size, hidden_size, output_size, learning_rate=0.01):\n # Initialize weights\n self.W1 = np.random.r...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078370", "row_id": 78370, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_159151']" }
0.351051
Filter_78370
I
[ "sigmoid", "sigmoid_derivative", "train_neural_network", "predict" ]
4
[ [ "predict", "sigmoid" ], [ "train_neural_network", "sigmoid" ], [ "train_neural_network", "sigmoid_derivative" ] ]
3
[]
false
[]
false
pytest
true
[ "numpy" ]
false
5b0c30057854dfddaa7278c4371e6c12c6a1ce3b
9db403cb597598e8c51c715a37770492d9264f3f
v1.0
instruct
Filter
Filter_78373_I
Can you provide a Python function that can find the closest pair of points in a given set of points in a 2D plane? The function should return the distance between these points. The closest pair of points problem is a classic problem in computational geometry.
import math from itertools import combinations def euclidean_distance(point1, point2): """ Calculate the Euclidean distance between two points in 2D space. """ return math.sqrt((point1[0] - point2[0]) ** 2 + (point1[1] - point2[1]) ** 2) def closest_pair_of_points(points): """ Find the closest...
from solution import euclidean_distance, closest_pair_of_points def test_euclidean_distance(): assert euclidean_distance((0, 0), (3, 4)) == 5.0 assert euclidean_distance((1, 1), (1, 1)) == 0.0 assert euclidean_distance((1, 1), (4, 5)) == 5.0 def test_closest_pair_of_points_standard_cases(): points = [...
[ { "docstring": "Calculate the Euclidean distance between two points in 2D space.", "function_declaration": "def euclidean_distance(point1, point2):", "function_name": "euclidean_distance", "parameter_list": "(point1, point2)" }, { "docstring": "Find the closest pair of points in a given set ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nimport itertools\n\ndef euclidean_distance(point1, point2):\n return math.sqrt((point1[0] - point2[0])**2 + (point1[1] - point2[1])**2)\n\ndef closest_pair_of_points(points):\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078373", "row_id": 78373, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_159165']" }
0.612095
Filter_78373
I
[ "euclidean_distance", "closest_pair_of_points" ]
2
[ [ "closest_pair_of_points", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
65131c33dc6c5331ebcf9f856d5e7b90af2a045d
d2b3cf4b59234c56a5e9e78031c36efc515b9fe3
v1.0
instruct
Filter
Filter_78376_I
Can you provide a simple example of a code snippet in Python that demonstrates how to use list comprehensions to clean and transform data? Suppose we have a list of strings that represent temperatures in Celsius, some of which are empty or contain errors, and we want to convert only the valid temperatures to Fahrenheit...
def celsius_to_fahrenheit(celsius): """ Converts Celsius to Fahrenheit. """ try: return (float(celsius) * 9/5) + 32 except ValueError: return None def clean_and_transform_temperatures(celsius_list): """ Cleans and transforms a list of temperatures in Celsius to Fahrenheit. ...
from solution import clean_and_transform_temperatures def test_clean_and_transform_temperatures_all_valid(): assert clean_and_transform_temperatures(["0", "100", "37"]) == [32.0, 212.0, 98.6] def test_clean_and_transform_temperatures_with_invalid(): assert clean_and_transform_temperatures(["0", "abc", "37", "...
[ { "docstring": "Converts Celsius to Fahrenheit.", "function_declaration": "def celsius_to_fahrenheit(celsius):", "function_name": "celsius_to_fahrenheit", "parameter_list": "(celsius)" }, { "docstring": "Cleans and transforms a list of temperatures in Celsius to Fahrenheit.\nFilters out inva...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def celsius_to_fahrenheit(celsius):\n \"\"\"\n Converts Celsius to Fahrenheit.\n \"\"\"\n try:\n return (float(celsius) * 9/5) + 32\n except ValueError:\n return N...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00078376", "row_id": 78376, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_159170']" }
0.47851
Filter_78376
I
[ "celsius_to_fahrenheit", "clean_and_transform_temperatures" ]
2
[ [ "clean_and_transform_temperatures", "celsius_to_fahrenheit" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ec14c48ee4afc0d79d00163fd3958c79c4dc8a17
92e394dd611554cbad57d0c67307bad6c49ea581
v1.0
instruct
Filter
Filter_78380_I
Can you create a Python function that translates a given text from one language to another using a hypothetical translation API? Assume the API provides a method `translate_text` that takes the text, source language, and target language as parameters and returns the translated text.
# Hypothetical translation API def translate_text(text, source_lang, target_lang): """ Mock function simulating translation. For the sake of the example, we'll assume it understands and translates text based on some basic rules. """ # This is a mock implementation and does not perform real translati...
from solution import translate, translate_text def test_translate_english_to_spanish(): assert translate("hello", "en", "es") == "hola" assert translate("goodbye", "en", "es") == "adiós" def test_translate_spanish_to_english(): assert translate("hola", "es", "en") == "hello" assert translate("adiós", ...
[ { "docstring": "Mock function simulating translation. For the sake of the example, we'll assume\nit understands and translates text based on some basic rules.", "function_declaration": "def translate_text(text, source_lang, target_lang):", "function_name": "translate_text", "parameter_list": "(text,...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "# Assuming the hypothetical translation API\nclass TranslationAPI:\n @staticmethod\n def translate_text(text, source_language, target_language):\n # Hypothetical implementation\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078380", "row_id": 78380, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_159183']" }
0.457028
Filter_78380
I
[ "translate_text", "translate" ]
2
[ [ "translate", "translate_text" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9249c5d697f0c286bf0d4271e07ce914ee21c85c
806010df2f96bf3855b4df657b651c977e83a2ac
v1.0
instruct
Filter
Filter_78407_I
Given a parent-child relationship represented as a list of tuples, where each tuple contains two elements (parent, child), write a Python function to find the Least Common Ancestor (LCA) of two nodes in a tree. The function should return the LCA if it exists, otherwise return `None`. The tree is guaranteed to be rooted...
def find_parents(relationships): """ Create a dictionary with child nodes as keys and their respective parent nodes as values. :param relationships: List of tuples representing parent-child relationships :return: Dictionary representing child to parent relationships """ child_to_parent = {}...
from solution import find_lca def test_lca_simple_tree(): relationships = [(1, 2), (1, 3), (2, 4), (2, 5), (3, 6), (3, 7)] assert find_lca(relationships, 4, 5) == 2 assert find_lca(relationships, 4, 6) == 1 assert find_lca(relationships, 3, 7) == 3 assert find_lca(relationships, 2, 7) == 1 def tes...
[ { "docstring": "Create a dictionary with child nodes as keys and their respective parent nodes as values.\n\n:param relationships: List of tuples representing parent-child relationships\n:return: Dictionary representing child to parent relationships", "function_declaration": "def find_parents(relationships)...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_lca(parent_child_pairs, node1, node2):\n \"\"\"\n Finds the Least Common Ancestor (LCA) of two nodes in a tree.\n\n Args:\n parent_child_pairs (list of tuple): List of par...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078407", "row_id": 78407, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_159246']" }
0.531296
Filter_78407
I
[ "find_parents", "find_path_to_root", "find_lca" ]
3
[ [ "find_lca", "find_parents" ], [ "find_lca", "find_path_to_root" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5fc9e3fc8fbf6b806ccf1a8902dba68af40f6ca0
a33351f6aefc6ae29f11e2740b3c0e7a3c5f70ac
v1.0
instruct
Filter
Filter_78419_I
How can I create a Python program that simulates a simple dice roll game with two players?
import random def roll_dice(): """ Simulates rolling a six-sided dice and returns the result. """ return random.randint(1, 6) def simulate_dice_game(): """ Simulates a simple dice roll game with two players. Each player rolls the dice once and the player with the higher roll wins. It retur...
import pytest from solution import roll_dice, simulate_dice_game def test_roll_dice(): for _ in range(100): result = roll_dice() assert 1 <= result <= 6 def test_simulate_dice_game_tie(monkeypatch): monkeypatch.setattr('random.randint', lambda a, b: 3) assert simulate_dice_game() == "It's ...
[ { "docstring": "Simulates rolling a six-sided dice and returns the result.", "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": "Simulates a simple dice roll game with two players. Each player rolls the dice once\nand the player...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef roll_dice():\n \"\"\"\n Simulates a dice roll and returns a random number between 1 and 6.\n \"\"\"\n return random.randint(1, 6)\n\ndef play_dice_game():\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00078419", "row_id": 78419, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_159276']" }
0.51004
Filter_78419
I
[ "roll_dice", "simulate_dice_game" ]
2
[ [ "simulate_dice_game", "roll_dice" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c1294bd6ba5a325eee9350a59c95343011043749
3cbd5adb2845604cd13499008540d062acb7ec57
v1.0
instruct
Filter
Filter_78453_I
Can you provide a Python script that generates a fractal using the Mandelbrot set?
import numpy as np import matplotlib.pyplot as plt def mandelbrot(c, max_iter): """ Determines if the number c is in the Mandelbrot set. :param c: complex number to be checked :param max_iter: the maximum number of iterations :return: number of iterations or max_iter if max reached """ ...
import numpy as np from solution import mandelbrot, mandelbrot_set, plot_mandelbrot def test_mandelbrot_inside_set(): c = 0 + 0j assert mandelbrot(c, 100) == 100 def test_mandelbrot_outside_set(): c = 3 + 0j assert mandelbrot(c, 100) < 100 def test_mandelbrot_set_shape(): width, height = 300, 400...
[ { "docstring": "Determines if the number c is in the Mandelbrot set.\n\n:param c: complex number to be checked\n:param max_iter: the maximum number of iterations\n:return: number of iterations or max_iter if max reached", "function_declaration": "def mandelbrot(c, max_iter):", "function_name": "mandelbr...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nimport matplotlib.pyplot as plt\n\ndef mandelbrot(c, max_iter):\n \"\"\"\n Determines if the point c belongs to the Mandelbrot set based on the maximum number of iter...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078453", "row_id": 78453, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_159356']" }
0.366005
Filter_78453
I
[ "mandelbrot", "mandelbrot_set", "plot_mandelbrot" ]
3
[ [ "mandelbrot_set", "mandelbrot" ], [ "plot_mandelbrot", "mandelbrot_set" ] ]
2
[]
false
[]
false
pytest
true
[ "matplotlib", "numpy" ]
false
36f146779cd87796b1ad059564e7b52b64dc62e1
000278a6ef6b254b5eece358b06154305838c055
v1.0
instruct
Filter
Filter_78465_I
How can I plot the solutions of a system of differential equations using Python and Matplotlib?
import numpy as np import matplotlib.pyplot as plt from scipy.integrate import solve_ivp def system_of_odes(t, y): """ Defines the system of differential equations. Example system is a simple harmonic oscillator: y'' + y = 0 represented as a system: y1' = y2 y2' = -y1 """ y1, y2 = y ...
from solution import system_of_odes, plot_solution import numpy as np def test_system_of_odes(): t = 0 y = [1, 0] # Initial condition: y1 = 1, y2 = 0 dy_dt = system_of_odes(t, y) assert np.allclose(dy_dt, [0, -1]), f"Expected [0, -1], but got {dy_dt}" def test_plot_solution(): t_span = (0, 10) ...
[ { "docstring": "Defines the system of differential equations.\nExample system is a simple harmonic oscillator: \ny'' + y = 0 represented as a system:\ny1' = y2\ny2' = -y1", "function_declaration": "def system_of_odes(t, y):", "function_name": "system_of_odes", "parameter_list": "(t, y)" }, { ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy.integrate import solve_ivp\n\ndef system_of_equations(t, y):\n \"\"\"\n Defines the system of differential equations.\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00078465", "row_id": 78465, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_159378']" }
0.382297
Filter_78465
I
[ "system_of_odes", "plot_solution" ]
2
[ [ "plot_solution", "system_of_odes" ] ]
1
[]
false
[]
false
pytest
true
[ "matplotlib", "numpy", "scipy" ]
false
082ec340042964cb920011e6e86a2de3e79f6337
6f19efd812165cccef5cd1ca4806485bf98935c9
v1.0
instruct
Filter
Filter_78468_I
Write a Python function named `calculate_sum` that takes a list of integers as its argument and returns the sum of all the integers in the list. The function should handle an empty list by returning 0. Additionally, write a simple check function named `verify_sum` that takes a list of integers and the expected sum as a...
def calculate_sum(numbers): """ Returns the sum of all integers in the list. Handles an empty list by returning 0. """ return sum(numbers) def verify_sum(numbers, expected_sum): """ Verifies that calculate_sum(numbers) matches expected_sum. """ assert calculate_sum(numbers) == expec...
from solution import calculate_sum, verify_sum def test_calculate_sum_with_positive_numbers(): assert calculate_sum([1, 2, 3, 4, 5]) == 15 def test_calculate_sum_with_mixed_numbers(): assert calculate_sum([1, -2, 3, -4, 5]) == 3 def test_calculate_sum_with_negative_numbers(): assert calculate_sum([-1, -2...
[ { "docstring": "Returns the sum of all integers in the list.\nHandles an empty list by returning 0.", "function_declaration": "def calculate_sum(numbers):", "function_name": "calculate_sum", "parameter_list": "(numbers)" }, { "docstring": "Verifies that calculate_sum(numbers) matches expecte...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_sum(numbers):\n \"\"\"\n Returns the sum of all integers in the list. \n Handles the case of an empty list by returning 0.\n \"\"\"\n return sum(numbers)\n\ndef ve...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078468", "row_id": 78468, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_159382']" }
0.687858
Filter_78468
I
[ "calculate_sum", "verify_sum" ]
2
[ [ "verify_sum", "calculate_sum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
952236f4f1ea24dc58b0a7ea8145a52270ac8057
5231df5dd1d41272ce4d9e3dbc6ec5ace9750309
v1.0
instruct
Filter
Filter_78474_I
Can you explain how to use the `map` function in Python with a custom function that squares a number?
def square(x): """ Returns the square of the number x. """ return x * x def square_numbers(numbers): """ Returns a list of the squares of the numbers in the input list. """ return list(map(square, numbers))
from solution import square_numbers def test_square_numbers_empty(): assert square_numbers([]) == [] def test_square_numbers_single(): assert square_numbers([2]) == [4] def test_square_numbers_multiple(): assert square_numbers([1, 2, 3, 4]) == [1, 4, 9, 16] def test_square_numbers_negative(): assert...
[ { "docstring": "Returns the square of the number x.", "function_declaration": "def square(x):", "function_name": "square", "parameter_list": "(x)" }, { "docstring": "Returns a list of the squares of the numbers in the input list.", "function_declaration": "def square_numbers(numbers):", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def square(x):\n \"\"\"\n Returns the square of x.\n \"\"\"\n return x * x\n\ndef apply_map_to_square(numbers):\n \"\"\"\n Takes a list of numbers and returns a list of their...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00078474", "row_id": 78474, "seed_ids": "['Qwen2.5-Coder-32B-Instruct_159395']" }
0.581156
Filter_78474
I
[ "square", "square_numbers" ]
2
[ [ "square_numbers", "square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
25d010cbba241fec89c99f04cf314bd9f7c19b11
cf0084cb344ac517fe2ca3c7c343ca7e743b7974