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_16594_I
Create a code that converts Celsius temperature to Fahrenheit and vice versa Here's an example of how the code might work: * If the user enters 30 and chooses Celsius, the program will output 86. * If the user enters 86 and chooses Fahrenheit, the program will output 30. Here's a Python code snippet to start with: ...
def celsius_to_fahrenheit(celsius): """ Converts Celsius to Fahrenheit. """ return (celsius * 9/5) + 32 def fahrenheit_to_celsius(fahrenheit): """ Converts Fahrenheit to Celsius. """ return (fahrenheit - 32) * 5/9 def convert_temperature(temperature, unit): """ Converts tempera...
from solution import celsius_to_fahrenheit, fahrenheit_to_celsius, convert_temperature def test_celsius_to_fahrenheit(): assert celsius_to_fahrenheit(0) == 32 assert celsius_to_fahrenheit(100) == 212 assert celsius_to_fahrenheit(-40) == -40 def test_fahrenheit_to_celsius(): assert fahrenheit_to_celsiu...
[ { "docstring": "Converts Celsius to Fahrenheit.", "function_declaration": "def celsius_to_fahrenheit(celsius):", "function_name": "celsius_to_fahrenheit", "parameter_list": "(celsius)" }, { "docstring": "Converts Fahrenheit to Celsius.", "function_declaration": "def fahrenheit_to_celsius...
[ 0, 0, 1 ]
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 return (celsius * 9/5) + 32\n\ndef fahrenheit_to_celsius(fahrenheit):\n return (fahrenheit - 32) * 5/9\n\ndef convert_temperature(temperature, unit)...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016594", "row_id": 16594, "seed_ids": "['Llama-3.3-70B-Instruct_42254']" }
0.505457
Filter_16594
I
[ "celsius_to_fahrenheit", "fahrenheit_to_celsius", "convert_temperature" ]
3
[ [ "convert_temperature", "celsius_to_fahrenheit" ], [ "convert_temperature", "fahrenheit_to_celsius" ] ]
2
[]
false
[]
false
pytest
true
[]
true
d53353831231560dc2782848ec6e9222edf31106
e618da8393a2ed6fa6342a445066886b776f363f
v1.0
instruct
Filter
Filter_16597_I
Can you write a code that computes the nth Fibonacci sequence using matrix exponentiation?
def matrix_mult(A, B): return [ [A[0][0]*B[0][0] + A[0][1]*B[1][0], A[0][0]*B[0][1] + A[0][1]*B[1][1]], [A[1][0]*B[0][0] + A[1][1]*B[1][0], A[1][0]*B[0][1] + A[1][1]*B[1][1]] ] def matrix_pow(matrix, n): result = [[1, 0], [0, 1]] # Identity matrix base = matrix while n > 0: ...
from solution import fibonacci def test_fibonacci_base_cases(): assert fibonacci(0) == 0 assert fibonacci(1) == 1 def test_fibonacci_small_numbers(): assert fibonacci(2) == 1 assert fibonacci(3) == 2 assert fibonacci(4) == 3 assert fibonacci(5) == 5 def test_fibonacci_large_numbers(): ass...
[ { "docstring": null, "function_declaration": "def matrix_mult(A, B):", "function_name": "matrix_mult", "parameter_list": "(A, B)" }, { "docstring": null, "function_declaration": "def matrix_pow(matrix, n):", "function_name": "matrix_pow", "parameter_list": "(matrix, n)" }, { ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def matrix_mult(A, B):\n \"\"\"\n Multiplies two 2x2 matrices A and B\n \"\"\"\n return [\n [A[0][0]*B[0][0] + A[0][1]*B[1][0], A[0][0]*B[0][1] + A[0][1]*B[1][1]],\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016597", "row_id": 16597, "seed_ids": "['Llama-3.3-70B-Instruct_42260']" }
0.598945
Filter_16597
I
[ "matrix_mult", "matrix_pow", "fibonacci" ]
3
[ [ "fibonacci", "matrix_pow" ], [ "matrix_pow", "matrix_mult" ] ]
2
[]
false
[]
false
pytest
true
[]
true
06a298af5238ac60c906548c87e319e33b26a045
56fba1d41d447832d57a4273e588de110d9d3bfb
v1.0
instruct
Filter
Filter_16607_I
Using Python, Create an entirely new Hirst painting simulation Here are the requirements: 1. The painting will have a size of 800x800 pixels. 2. The painting will contain 1000 dots, and these dots will be randomly placed. 3. The size of each dot will be randomly chosen between 10 and 50 pixels. 4. Each dot will be ass...
import random from PIL import Image, ImageDraw def random_color(): """ Returns a tuple representing an RGB color where each component is a random integer between 0 and 255. """ return (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) def draw_dot(draw, x, y, diameter, color)...
from solution import random_color, draw_dot, create_hirst_painting from PIL import Image def test_random_color(): color = random_color() assert len(color) == 3 assert all(0 <= component <= 255 for component in color) def test_draw_dot(): # Create a blank image img = Image.new('RGB', (800, 800), (2...
[ { "docstring": "Returns a tuple representing an RGB color where each component is a random integer\nbetween 0 and 255.", "function_declaration": "def random_color():", "function_name": "random_color", "parameter_list": "()" }, { "docstring": "Draws a dot on the image using the given drawing ...
[ 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, ImageDraw\nimport random\n\ndef random_color():\n \"\"\"\n Generates a random color.\n \n Returns:\n A tuple representing a random RGB color.\n \"\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016607", "row_id": 16607, "seed_ids": "['Llama-3.3-70B-Instruct_42285']" }
0.537053
Filter_16607
I
[ "random_color", "draw_dot", "create_hirst_painting" ]
3
[ [ "create_hirst_painting", "draw_dot" ], [ "create_hirst_painting", "random_color" ] ]
2
[]
false
[]
false
pytest
true
[ "PIL" ]
false
ef8c6ac07502a679d622c2436148328a47b37814
3642063c59750f43f6612545c1885b43fc4b40b8
v1.0
instruct
Filter
Filter_16620_I
I have a function that runs and returns an infinite series as a list. This list is too long and I only want to see the first n elements. Here is the example function I have: ``` def series(): n = 1 while True: yield n n += 1 for i in series(): print(i) ``` How can I modify the code so I o...
def series(): n = 1 while True: yield n n += 1 def get_first_n_elements(n): """ Returns the first n elements of the infinite series as a list. """ gen = series() result = [] for _ in range(n): result.append(next(gen)) return result
from solution import get_first_n_elements def test_get_first_5_elements(): assert get_first_n_elements(5) == [1, 2, 3, 4, 5] def test_get_first_1_element(): assert get_first_n_elements(1) == [1] def test_get_first_0_elements(): assert get_first_n_elements(0) == [] def test_get_first_10_elements(): a...
[ { "docstring": null, "function_declaration": "def series():", "function_name": "series", "parameter_list": "()" }, { "docstring": "Returns the first n elements of the infinite series as a list.", "function_declaration": "def get_first_n_elements(n):", "function_name": "get_first_n_el...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def series():\n n = 1\n while True:\n yield n\n n += 1\n\ndef get_first_n_elements(n):\n \"\"\"\n Returns the first n elements of the infinite series.\n \"\"\"\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016620", "row_id": 16620, "seed_ids": "['Llama-3.3-70B-Instruct_42314']" }
0.468984
Filter_16620
I
[ "series", "get_first_n_elements" ]
2
[ [ "get_first_n_elements", "series" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d94ecd73aa8457d63adbe498f33cc4e86b2a57c4
6b5442ef03f12c508d6387bf60233b35ae0cdec2
v1.0
instruct
Filter
Filter_16622_I
### Introduction The problem is to find the closest pair of points in an n-dimensional space. The objective is to determine the algorithm that can find the closest pair efficiently, and implement it using Python.
import math from itertools import combinations def euclidean_distance(point1, point2): """ Calculate the Euclidean distance between two points in n-dimensional space. """ return math.sqrt(sum((x - y) ** 2 for x, y in zip(point1, point2))) def closest_pair_of_points(points): """ Find the closes...
from solution import euclidean_distance, closest_pair_of_points def test_euclidean_distance(): assert euclidean_distance((0, 0), (0, 0)) == 0 assert euclidean_distance((0, 0), (3, 4)) == 5 assert euclidean_distance((1, 2, 3), (4, 5, 6)) == math.sqrt(27) def test_closest_pair_of_points_2d(): points = [...
[ { "docstring": "Calculate the Euclidean distance between two points in n-dimensional 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...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom itertools import combinations\n\ndef euclidean_distance(point1, point2):\n return math.sqrt(sum((x - y) ** 2 for x, y in zip(point1, point2)))\n\ndef closest_pair(points):...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016622", "row_id": 16622, "seed_ids": "['Llama-3.3-70B-Instruct_42317']" }
0.654379
Filter_16622
I
[ "euclidean_distance", "closest_pair_of_points" ]
2
[ [ "closest_pair_of_points", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
37d715a6f6027bd08153191f4dece546fa981b57
3100d97d72779c7d3f5a9fa99b14ef8e4a0780d5
v1.0
instruct
Filter
Filter_16629_I
I have a text file named "network.txt" with a set of linked computers. The format of the file is: user ip address and each line is a different computer. Each computer can be connected to multiple other computers. The connection between computers is established when a user logs in to another computer. The connection i...
def read_network_file(filename): with open(filename, 'r') as file: lines = file.readlines() return lines def parse_lines_to_dict(lines): user_ip_dict = {} for line in lines: user, ip = line.strip().split() if user not in user_ip_dict: user_ip_dict[user] = [] ...
import tempfile import os from solution import find_network_connections, read_network_file, parse_lines_to_dict, generate_connections, write_connections_to_file def test_read_network_file(): with tempfile.NamedTemporaryFile(delete=False) as temp: temp.write(b"user1 192.168.1.1\nuser2 192.168.1.2\nuser1 192...
[ { "docstring": null, "function_declaration": "def read_network_file(filename):", "function_name": "read_network_file", "parameter_list": "(filename)" }, { "docstring": null, "function_declaration": "def parse_lines_to_dict(lines):", "function_name": "parse_lines_to_dict", "parame...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def read_network_file(filename):\n \"\"\"\n Reads the network file and returns a dictionary mapping users to their respective IP addresses.\n \"\"\"\n network = {}\n with open(f...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016629", "row_id": 16629, "seed_ids": "['Llama-3.3-70B-Instruct_42347']" }
0.550428
Filter_16629
I
[ "read_network_file", "parse_lines_to_dict", "generate_connections", "write_connections_to_file", "find_network_connections" ]
5
[ [ "find_network_connections", "generate_connections" ], [ "find_network_connections", "parse_lines_to_dict" ], [ "find_network_connections", "read_network_file" ], [ "find_network_connections", "write_connections_to_file" ] ]
4
[]
false
[]
false
pytest
true
[]
true
254a0b995d71fd54922faa713b40a62bc4e65a9c
2895a91790ad6f50890f0befef16d525389353c8
v1.0
instruct
Filter
Filter_16634_I
Here is the code of a simple python program for calculating areas of shapes: ```python import math def calculate_circle_area(radius): return math.pi * (radius ** 2) def calculate_square_area(side): return side * side def calculate_rectangle_area(length, width): return length * width def calculate_triang...
from enum import Enum import math class Shape(Enum): CIRCLE = "circle" SQUARE = "square" RECTANGLE = "rectangle" TRIANGLE = "triangle" def calculate_circle_area(radius): return math.pi * (radius ** 2) def calculate_square_area(side): return side * side def calculate_rectangle_area(length, wi...
from solution import Shape, calculate_area def test_calculate_circle_area(): assert calculate_area(Shape.CIRCLE, radius=5) == 78.53981633974483 def test_calculate_square_area(): assert calculate_area(Shape.SQUARE, side=4) == 16 def test_calculate_rectangle_area(): assert calculate_area(Shape.RECTANGLE, l...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from enum import Enum\nimport math\n\nclass Shape(Enum):\n SQUARE = {\"sides\": 1}\n CIRCLE = {\"sides\": 0}\n RECTANGLE = {\"sides\": 2}\n TRIANGLE = {\"sides\": 2}\n\ndef calcula...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016634", "row_id": 16634, "seed_ids": "['Llama-3.3-70B-Instruct_42360']" }
0.604923
Filter_16634
I
[ "calculate_circle_area", "calculate_square_area", "calculate_rectangle_area", "calculate_triangle_area", "calculate_area" ]
5
[ [ "calculate_area", "calculate_circle_area" ], [ "calculate_area", "calculate_rectangle_area" ], [ "calculate_area", "calculate_square_area" ], [ "calculate_area", "calculate_triangle_area" ] ]
4
[]
false
[ "Shape" ]
true
pytest
true
[]
true
0327ed17adff25d7d3d260e7d8bfb62d36786642
fcb63f4d01aa7cbd3198d460c1d74553dc14ef35
v1.0
instruct
Filter
Filter_16638_I
You've been asked to implement a function that counts the number of prime numbers in a given list of integers. Describe how you would approach this task and provide a sample implementation in Python.
def is_prime(n): """ Determine if a number is a prime number. Args: n (int): Number to check if it is a prime. Returns: bool: True if n is a prime number, False otherwise. """ if n <= 1: return False elif n <= 3: return True elif n % 2 == 0 or n % 3 == 0...
from solution import is_prime, count_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(29) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-1) == False ...
[ { "docstring": "Determine if a number is a prime number.\n\nArgs:\nn (int): Number to check if it is a prime.\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": ...
[ 1, 0, 1 ]
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 Helper function to check if a number is a prime.\n Returns True if n is a prime, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n fo...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016638", "row_id": 16638, "seed_ids": "['Llama-3.3-70B-Instruct_42367']" }
0.76979
Filter_16638
I
[ "is_prime", "count_primes" ]
2
[ [ "count_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a74acd8c3d37c88e9c8d8e03bf155b1841336344
7fd60d86b16eff0ae4fa53ba74a5e27673d8d0b0
v1.0
instruct
Filter
Filter_16645_I
I have a system that generates random words. I want the first word of every group of 3 words to be one of 3 specific words: 'apple', 'banana', or 'cherry'. The words in between (second and third) should be any other word. I would you like you to generate a group of 9 words, following the rules defined above. I would ...
import random class SystemWordGenerator: def generate_word(self): words = ["house", "car", "tree", "dog", "pen", "paper", "book", "desk", "pencil", "phone"] return random.choice(words) def get_specific_word(): """Returns one of the three specific words""" return random.choice(['apple', 'ba...
from solution import SystemWordGenerator, get_specific_word, generate_group_of_words def test_get_specific_word(): specific_words = {'apple', 'banana', 'cherry'} assert get_specific_word() in specific_words def test_generate_group_of_words_length(): words = generate_group_of_words() assert len(words) ...
[]
[ 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\nclass SystemWordGenerator:\n def generate_word(self):\n # This is a mock implementation of your system\n # In a real scenario, this would be replaced with you...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016645", "row_id": 16645, "seed_ids": "['Llama-3.3-70B-Instruct_42389']" }
0.606767
Filter_16645
I
[ "get_specific_word", "generate_group_of_words" ]
2
[ [ "generate_group_of_words", "get_specific_word" ] ]
1
[]
false
[ "SystemWordGenerator" ]
true
pytest
true
[]
true
c9b5993698a1ca700e57136c95c9f88e87511bd7
51a72a1345b5e45d0557adc961787d96f91be6bc
v1.0
instruct
Filter
Filter_16695_I
I have written a code and now I want to add a UNIQUE identifier for each uploaded image. I have a requirement where there are 10 types of uploads - (Report, Presentation, Image, Video, Document, Audio, Spreadsheet, Pdf, Zip, Other), I want to store the type of file as well in the database along with the unique identi...
import uuid import os from flask import Flask, request from werkzeug.utils import secure_filename app = Flask(__name__) upload_folder = '/path/to/upload/folder' file_info = { 'Report': {'count': 0, 'files': []}, 'Presentation': {'count': 0, 'files': []}, 'Image': {'count': 0, 'files': []}, 'Video': {'...
import pytest import os from solution import get_file_type, create_file_info def test_get_file_type(): class FileMock: def __init__(self, filename): self.filename = filename assert get_file_type(FileMock('example.jpg')) == 'Image' assert get_file_type(FileMock('example.jpeg')) == 'Imag...
[ { "docstring": null, "function_declaration": "def get_file_type(file):", "function_name": "get_file_type", "parameter_list": "(file)" }, { "docstring": null, "function_declaration": "def create_file_info(file, file_id, file_type, upload_folder):", "function_name": "create_file_info",...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\nimport uuid\nfrom flask import Flask, request\nfrom werkzeug.utils import secure_filename\n\napp = Flask(__name__)\nupload_folder = './uploads'\n\nfile_info = {\n 'Report': {'cou...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00016695", "row_id": 16695, "seed_ids": "['Llama-3.3-70B-Instruct_42496']" }
0.458243
Filter_16695
I
[ "get_file_type", "create_file_info", "upload_file" ]
3
[ [ "upload_file", "create_file_info" ], [ "upload_file", "get_file_type" ] ]
2
[]
false
[]
false
pytest
true
[ "flask", "werkzeug" ]
false
cf32d6f5eb6a1f0ebf7195a798fa498466a14953
942753bd1c8a50751d19674a886809f3528ed633
v1.0
instruct
Filter
Filter_16707_I
Here is the Python code to generate a random binary tree: ``` import random class Node: def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right def generate_random_tree(n): if n == 0: return None node = Node(random.randint(0, 100))...
import random class Node: def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right def generate_balanced_tree(n): if n == 0: return None node = Node(random.randint(0, 100)) if n == 1: return node left_size = (n - 1) ...
from solution import Node, generate_balanced_tree, get_height, is_balanced def test_generate_balanced_tree_size(): for n in range(10): tree = generate_balanced_tree(n) assert count_nodes(tree) == n, f"Failed for n={n}" def test_generate_balanced_tree_balanced(): for n in range(10): tre...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\nclass Node:\n def __init__(self, val, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef generate_balanced_tree(n)...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016707", "row_id": 16707, "seed_ids": "['Llama-3.3-70B-Instruct_42525']" }
0.680095
Filter_16707
I
[ "generate_balanced_tree", "get_height", "is_balanced" ]
3
[ [ "is_balanced", "get_height" ] ]
1
[]
false
[ "Node" ]
true
pytest
true
[]
true
fa0df13cac9894a99265687593a0f97478b2b130
357c10cafda72aa4cfdafd5bf1bcfdd94fa436b5
v1.0
instruct
Filter
Filter_16712_I
I have two functions, `func1` and `func2`, and I want to implement a third function, `func3`, such that `func3` adds behavior to `func1` and `func2` without changing their original implementation. Function `func3` should print a message before and after the execution of `func1` and `func2`. Here is my current impleme...
def func1(): print("func1 executed") def func2(): print("func2 executed") def func3(func): def wrapper(): print("Starting function execution") func() print("Ending function execution") return wrapper # Making func3 work as a decorator @func3 def func1_decorated(): func...
def test_func1_decorated(capfd): func1_decorated() captured = capfd.readouterr() assert captured.out == "Starting function execution\nfunc1 executed\nEnding function execution\n" def test_func2_decorated(capfd): func2_decorated() captured = capfd.readouterr() assert captured.out == "Starting fu...
[ { "docstring": null, "function_declaration": "def func1():", "function_name": "func1", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def func2():", "function_name": "func2", "parameter_list": "()" }, { "docstring": null, "function_declaration...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def func1():\n print(\"func1 executed\")\n\ndef func2():\n print(\"func2 executed\")\n\ndef log_execution(func):\n \"\"\"\n Decorator that adds logging behavior before and after\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016712", "row_id": 16712, "seed_ids": "['Llama-3.3-70B-Instruct_42531']" }
0.47463
Filter_16712
I
[ "func1", "func2", "func3", "func1_decorated", "func2_decorated" ]
5
[ [ "func1_decorated", "func1" ], [ "func2_decorated", "func2" ] ]
2
[]
false
[]
false
pytest
false
[]
true
3602b288f65aa45018d18f1adf849a8ff48bf233
d79f0366418e1b8fa7e66dbe71688b089557417b
v1.0
instruct
Filter
Filter_16719_I
I am trying to generate the Fibonacci sequence up to a given number n. I am using a for loop but it's not working. Can you show me how to generate the Fibonacci sequence using a for loop and also provide an alternate method using recursion. Here is my attempt so far: ```python def generate_fibonacci(n): fib_seque...
def generate_fibonacci(n): """ Generates the Fibonacci sequence up to the nth number using a for loop. """ if n <= 0: return [] elif n == 1: return [0] elif n == 2: return [0, 1] fib_sequence = [0, 1] for i in range(2, n): next_value = fib_sequence[-1...
from solution import generate_fibonacci, generate_fibonacci_recursive def test_generate_fibonacci(): assert generate_fibonacci(0) == [] assert generate_fibonacci(1) == [0] assert generate_fibonacci(2) == [0, 1] assert generate_fibonacci(5) == [0, 1, 1, 2, 3] assert generate_fibonacci(10) == [0, 1, ...
[ { "docstring": "Generates the Fibonacci sequence up to the nth number using a for loop.", "function_declaration": "def generate_fibonacci(n):", "function_name": "generate_fibonacci", "parameter_list": "(n)" }, { "docstring": "Helper function for the recursive approach to generate the nth Fib...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "# Corrected For Loop Based Fibonacci Sequence Generator\ndef generate_fibonacci(n):\n \"\"\"\n Generate the Fibonacci sequence up to the n-th element using a for loop.\n \"\"\"\n i...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016719", "row_id": 16719, "seed_ids": "['Llama-3.3-70B-Instruct_42551']" }
0.679091
Filter_16719
I
[ "generate_fibonacci", "recursive_fibonacci", "generate_fibonacci_recursive" ]
3
[ [ "generate_fibonacci_recursive", "recursive_fibonacci" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dbd2c3cde16e1dfca0117eab364e4af2d9f1f439
1b4304ce66225bef88be884e01e12faccedb0b67
v1.0
instruct
Filter
Filter_16720_I
I'm trying to solve a problem where I need to create a fractal using recursion. I'm using Python and have a basic understanding of the language. Can you help guide me through creating a fractal using Python?
import matplotlib.pyplot as plt import numpy as np def sierpinski(order, triangle): if order == 0: # Draw the triangle - base case plt.fill(triangle[:, 0], triangle[:, 1], 'b') else: # Calculate the midpoints of each side of the triangle midpoints = [(triangle[i] + triangle[(i +...
from solution import draw_sierpinski def test_sierpinski_order_0(): # Testing base case visually draw_sierpinski(0) assert True # If it runs without error, it's correct def test_sierpinski_order_1(): # Testing first recursion order visually draw_sierpinski(1) assert True # If it runs without...
[ { "docstring": null, "function_declaration": "def sierpinski(order, triangle):", "function_name": "sierpinski", "parameter_list": "(order, triangle)" }, { "docstring": null, "function_declaration": "def draw_sierpinski(order):", "function_name": "draw_sierpinski", "parameter_list...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import turtle\n\ndef sierpinski_triangle(t, order, size):\n \"\"\"\n Draws a Sierpinski Triangle using recursion.\n \n Parameters:\n t (turtle.Turtle): The turtle used for drawi...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016720", "row_id": 16720, "seed_ids": "['Llama-3.3-70B-Instruct_42554']" }
0.385332
Filter_16720
I
[ "sierpinski", "draw_sierpinski" ]
2
[ [ "draw_sierpinski", "sierpinski" ] ]
1
[]
false
[]
false
pytest
true
[ "matplotlib", "numpy" ]
false
40ed1a3fd705e1210a0292ed0856fd78da4efe58
96f63c769788ceaa5f4ea0037ebf0c7fb068591f
v1.0
instruct
Filter
Filter_16749_I
I have been trying to learn Python and have come across some confusing concepts like decorators, generators, and asynchronous programming. Can you provide an example of how you would use these concepts together in a real-world scenario?
import asyncio from functools import wraps def log_execution(func): """ A decorator that logs the execution of a function """ @wraps(func) async def wrapper(*args, **kwargs): print(f"Executing {func.__name__}...") result = await func(*args, **kwargs) print(f"{func.__name__} ...
import pytest import asyncio from solution import log_execution, async_generator, process_numbers @pytest.mark.asyncio async def test_log_execution_decorator(): """ Tests if log_execution decorator logs messages correctly """ @log_execution async def sample_func(): return "test complete" ...
[ { "docstring": "A decorator that logs the execution of a function", "function_declaration": "def log_execution(func):", "function_name": "log_execution", "parameter_list": "(func)" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import asyncio\nimport time\nfrom functools import wraps\n\n# Decorator to measure execution time of a function\ndef measure_time(func):\n @wraps(func)\n async def wrapper(*args, **kwarg...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016749", "row_id": 16749, "seed_ids": "['Llama-3.3-70B-Instruct_42625']" }
0.323091
Filter_16749
I
[ "log_execution", "async_generator", "process_numbers" ]
3
[ [ "process_numbers", "async_generator" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d246a100dab87b7cce54d4f813f607ed818eed8d
978039451045db69eea0a7a351c70c96d5973db3
v1.0
instruct
Filter
Filter_16755_I
### Information # Project 1:8 Queens Problem # Author: [Your Name] # Description: This program solves the 8-Queens problem using backtracking. # The 8-Queens problem is a classic problem where you have 8 queens on a chessboard # and you need to place them such that no two queens attack each other. # Backtracking algor...
def is_safe(board, row, col): """ Checks if a queen can be placed at position (row, col) on the board. Args: board (list): A 2D list representing the chessboard. row (int): The row index of the position. col (int): The column index of the position. Returns: bool: True if the qu...
from solution import is_safe, solve_n_queens, eight_queens_solution, print_board def test_is_safe(): board = [ [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], ...
[ { "docstring": "Checks if a queen can be placed at position (row, col) on the board.\n\nArgs:\nboard (list): A 2D list representing the chessboard.\nrow (int): The row index of the position.\ncol (int): The column index of the position.\n\nReturns:\nbool: True if the queen can be placed, False otherwise.", ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_safe(board, row, col):\n \"\"\"\n Checks if a queen can be placed at position (row, col) on the board.\n \n Args:\n board (list): A 2D list representing the chessboard.\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016755", "row_id": 16755, "seed_ids": "['Llama-3.3-70B-Instruct_42640']" }
0.569905
Filter_16755
I
[ "is_safe", "solve_n_queens", "eight_queens_solution", "print_board" ]
4
[ [ "eight_queens_solution", "solve_n_queens" ], [ "solve_n_queens", "is_safe" ] ]
2
[]
false
[]
false
pytest
true
[]
true
1ebef4f09b15a912cfa394a04cc47160c783009b
c7431f833801b6d7115a48869ca28951d86574a2
v1.0
instruct
Filter
Filter_16823_I
### Description A well-known result in game theory, known as the "Prisoner's Dilemma", is a fundamental concept which shows why cooperation is often not the best strategy in a non-cooperative game involving two players. In the classic version of this game, two prisoners, A and B, are arrested and imprisoned. Each priso...
import random def get_computer_choice(): """ This function simulates the choice of Prisoner B (computer) in the Prisoner's Dilemma. Prisoner B (computer) will randomly choose between 'confess' and 'remain silent'. """ return random.choice(["confess", "remain silent"]) def get_sentence(user_action,...
import pytest from io import StringIO from unittest.mock import patch from solution import get_computer_choice, get_sentence def test_get_computer_choice(): choices = [get_computer_choice() for _ in range(1000)] assert all(choice in ["confess", "remain silent"] for choice in choices) def test_get_sentence(): ...
[ { "docstring": "This function simulates the choice of Prisoner B (computer) in the Prisoner's Dilemma.\nPrisoner B (computer) will randomly choose between 'confess' and 'remain silent'.", "function_declaration": "def get_computer_choice():", "function_name": "get_computer_choice", "parameter_list": ...
[ 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 get_computer_choice():\n \"\"\"\n This function simulates the choice of Prisoner B (computer) in the Prisoner's Dilemma.\n Prisoner B (computer) will randomly cho...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00016823", "row_id": 16823, "seed_ids": "['Llama-3.3-70B-Instruct_42789']" }
0.6021
Filter_16823
I
[ "get_computer_choice", "get_sentence", "prisoners_dilemma" ]
3
[ [ "prisoners_dilemma", "get_computer_choice" ], [ "prisoners_dilemma", "get_sentence" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0df9ac0f96497c0dcae9358b13d86eadb4e8a79f
e07e516936dc83fab67d33bc1c5230fbde64d16a
v1.0
instruct
Filter
Filter_16861_I
### Algorithm Description The algorithm described here is intended to generate the next date in a sequence of increasing dates. The algorithm operates on dates in the Gregorian calendar and considers only the year, month, and day. The algorithm should handle dates ranging from 1/1/1 to 12/31/9999. ### Algorithm Requir...
def is_leap_year(year): """ Checks if a given year is a leap year. Args: year (int): The year to check. Returns: bool: True if the year is a leap year, False otherwise. """ if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0): return True return False...
from solution import next_date def test_next_date_end_of_month(): assert next_date("31/01/2023") == "01/02/2023" assert next_date("28/02/2023") == "01/03/2023" assert next_date("30/04/2023") == "01/05/2023" def test_next_date_end_of_leap_february(): assert next_date("28/02/2024") == "29/02/2024" a...
[ { "docstring": "Checks if a given year is a leap year.\n\nArgs:\n year (int): The year to check.\n\nReturns:\n bool: True if the year is a leap year, False otherwise.", "function_declaration": "def is_leap_year(year):", "function_name": "is_leap_year", "parameter_list": "(year)" }, { "...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_leap_year(year):\n \"\"\"\n Check if a given year is a leap year.\n \n Args:\n year (int): The year to check.\n \n Returns:\n bool: True if the year is a...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016861", "row_id": 16861, "seed_ids": "['Llama-3.3-70B-Instruct_42914']" }
0.650512
Filter_16861
I
[ "is_leap_year", "next_date" ]
2
[ [ "next_date", "is_leap_year" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3a012b0b3fcd942a99164329c75f89fd5f183fb5
3ffc59f0140fa9726763c10864320cd704c75c1c
v1.0
instruct
Filter
Filter_16865_I
Here is the code for a simple chatbot that takes in user input and responds to basic greetings and farewells: ```python def greet(name): """Prints a personalized greeting message.""" print(f"Hello, {name}!") def goodbye(name): """Prints a personalized farewell message.""" print(f"Goodbye, {name}!") de...
import random def greet(name): """Prints a personalized greeting message.""" print(f"Hello, {name}!") def goodbye(name): """Prints a personalized farewell message.""" print(f"Goodbye, {name}!") def number_guessing_game(): """Plays a number guessing game with the user.""" number = random.randi...
# We'll mock the input and output to test the chatbot functionality from unittest.mock import patch from io import StringIO from solution import greet, goodbye, number_guessing_game, rock_paper_scissors, chatbot def test_greet(capsys): greet("Alice") captured = capsys.readouterr() assert captured.out == ...
[ { "docstring": "Prints a personalized greeting message.", "function_declaration": "def greet(name):", "function_name": "greet", "parameter_list": "(name)" }, { "docstring": "Prints a personalized farewell message.", "function_declaration": "def goodbye(name):", "function_name": "good...
[ 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 greet(name):\n \"\"\"Prints a personalized greeting message.\"\"\"\n print(f\"Hello, {name}!\")\n\ndef goodbye(name):\n \"\"\"Prints a personalized farewell messa...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016865", "row_id": 16865, "seed_ids": "['Llama-3.3-70B-Instruct_42923']" }
0.401156
Filter_16865
I
[ "greet", "goodbye", "number_guessing_game", "rock_paper_scissors", "chatbot" ]
5
[ [ "chatbot", "goodbye" ], [ "chatbot", "greet" ], [ "chatbot", "number_guessing_game" ], [ "chatbot", "rock_paper_scissors" ] ]
4
[]
false
[]
false
pytest
true
[]
true
4feac0732e60914e594729c39115a973a1dee98d
8e5a563022d44bf9bfa1a81630fdfb57ff1714dd
v1.0
instruct
Filter
Filter_16903_I
I'm working with a series of non-negative integers and I'm trying to write a program to find the first prime number in that series. How can I do that? ### Problem Requirements 1. The input is a list of non-negative integers. 2. The function should return the first prime number in the list. 3. If no prime number is fou...
def is_prime(n): """Check if a number is prime.""" if n < 2: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True def find_first_prime(numbers): """Find the first prime number in a list of numbers.""" for num in numbers: ...
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(1) == False assert is_prime(0) == False def test_find_first_prime(): assert find_first_prime([4, 6, 8, 9, 11, 12]) == 11 assert find_first_p...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Find the first prime number in a list of numbers.", "function_declaration": "def find_first_prime(numbers):", "function_na...
[ 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 \"\"\"Check if a number is prime.\"\"\"\n if n < 2:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016903", "row_id": 16903, "seed_ids": "['Llama-3.3-70B-Instruct_43014']" }
0.702715
Filter_16903
I
[ "is_prime", "find_first_prime" ]
2
[ [ "find_first_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
false
[]
true
b75541494d4d882c11664b009f35ce6c2c50e111
a6badc73c4728812ff80baf6d9d9aa7f305758af
v1.0
instruct
Filter
Filter_16974_I
### Loops and Conditional Statements #### Exercise 6.3 Write a program that will print all the prime numbers in a user-specified range.
def is_prime(n): """ Checks 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 prime_numbers_in_range(start, end): """ Returns a list of all prime numbers in the user-spec...
from solution import is_prime, prime_numbers_in_range 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(-5) == False assert is_prime(0) == False assert is_prime(...
[ { "docstring": "Checks if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of all prime numbers in the user-specified range [start, end].", "function_declaration": "def prime_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 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": "00016974", "row_id": 16974, "seed_ids": "['Llama-3.3-70B-Instruct_43207']" }
0.574658
Filter_16974
I
[ "is_prime", "prime_numbers_in_range" ]
2
[ [ "prime_numbers_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f0574c4b68ae6bc8914ed98edc44598c10858326
be0f999d29e6f12f81988c4944d22f6277d12b48
v1.0
instruct
Filter
Filter_16986_I
Since he's a secret agent, Jack's boss has given him a coded message to decipher. The message is: `GUR PENML XRL VF ZL FRPERG`. He's managed to figure out that it's a simple substitution cipher where each letter has been shifted by a fixed number of positions in the alphabet. Help Jack decipher the coded message by wri...
def caesar_cipher_decrypt(message, shift): """ Deciphers the given message shifted by a fixed number of positions in the alphabet. Parameters: message (str): The encoded message to be deciphered. shift (int): The number of positions each letter in the message has been shifted. ...
from solution import caesar_cipher_decrypt, decode_jack_message def test_caesar_cipher_decrypt(): assert caesar_cipher_decrypt("GUR PENML XRL VF ZL FRPERG", 13) == "THE CRAZY KEY IS MY SECRET" assert caesar_cipher_decrypt("URYYB", 13) == "HELLO" assert caesar_cipher_decrypt("GUR DHVPX OEBJA SBK WHZCF BIRE ...
[ { "docstring": "Deciphers the given message shifted by a fixed number of positions in the alphabet.\n\nParameters:\n message (str): The encoded message to be deciphered.\n shift (int): The number of positions each letter in the message has been shifted.\n \nReturns:\n str: The deciphered message.", ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def caesar_cipher_decrypt(message, shift):\n \"\"\"\n Deciphers the given message using a Caesar Cipher with the given shift.\n \n Parameters:\n message (str): The message to de...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00016986", "row_id": 16986, "seed_ids": "['Llama-3.3-70B-Instruct_43233']" }
0.653665
Filter_16986
I
[ "caesar_cipher_decrypt", "decode_jack_message" ]
2
[ [ "decode_jack_message", "caesar_cipher_decrypt" ] ]
1
[]
false
[]
false
pytest
true
[]
true
02ccb40930d6793c2f2b5008107a86350d86a1cc
4818882bb70dbf62e408555202bd835ce920479d
v1.0
instruct
Filter
Filter_17001_I
I know that `python -m http.server` can start a simple HTTP server in Python, but I want to know the code or library behind this server. The `http.server` module in Python's standard library provides a simple HTTP server. Can you give me some insights into how it is implemented, and how you might go about writing your...
import socket from datetime import datetime def handle_request(request): """ Handles incoming HTTP requests and returns a response. """ headers = [ 'HTTP/1.1 200 OK', 'Content-Type: text/plain; charset=utf-8', 'Connection: close', ] body = f"Hello, World! The time is {datetime.n...
import pytest from socket import socket, AF_INET, SOCK_STREAM from threading import Thread import time import requests from solution import handle_request, run_server def test_handle_request(): request = "GET / HTTP/1.1\r\nHost: localhost\r\n\r\n" response = handle_request(request).decode('utf-8') assert "...
[ { "docstring": "Handles incoming HTTP requests and returns a response. ", "function_declaration": "def handle_request(request):", "function_name": "handle_request", "parameter_list": "(request)" }, { "docstring": "Runs a simple HTTP server. ", "function_declaration": "def run_server(host...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import socket\nfrom datetime import datetime\n\ndef handle_request(request):\n \"\"\" Handles incoming HTTP requests and returns a response. \"\"\"\n headers = [\n 'HTTP/1.1 200 O...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00017001", "row_id": 17001, "seed_ids": "['Llama-3.3-70B-Instruct_43257']" }
0.541364
Filter_17001
I
[ "handle_request", "run_server" ]
2
[ [ "run_server", "handle_request" ] ]
1
[]
false
[]
false
pytest
true
[ "requests" ]
false
b452c05454bfa274e880efe2537344303e75ab41
b2f5987ca9f5ef23be1b1e9c9986f887afb18d49
v1.0
instruct
Filter
Filter_17002_I
I have a relatively high interest rate on my credit card. I would like to pay off the outstanding amount as quickly as possible. To achieve this goal, I have decided to make monthly repayments of £250. In each month, 1.5% interest is applied to the outstanding amount at the start of the month, then my £250 repayment i...
def calculate_interest(outstanding_amount): return outstanding_amount * 0.015 def calculate_outstanding_balance(outstanding_amount, interest, repayment): return outstanding_amount + interest - repayment def model_credit_card_payment(outstanding_amount, repayment, interest_rate): month = 1 while outsta...
def test_calculate_interest(): assert calculate_interest(2000) == 30.0 assert calculate_interest(1000) == 15.0 assert calculate_interest(0) == 0.0 def test_calculate_outstanding_balance(): assert calculate_outstanding_balance(2000, 30.0, 250) == 1780.0 assert calculate_outstanding_balance(1000, 15....
[ { "docstring": null, "function_declaration": "def calculate_interest(outstanding_amount):", "function_name": "calculate_interest", "parameter_list": "(outstanding_amount)" }, { "docstring": null, "function_declaration": "def calculate_outstanding_balance(outstanding_amount, interest, rep...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "Magpie-Filter-89K_sanitized_prepared1_results_combined.jsonl", "solution_code": "def calculate_interest(outstanding_amount):\n \"\"\"\n Calculate the interest for the given outstanding amount based on a 1.5% interest rate.\n \"\"\"\n re...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017002", "row_id": 17002, "seed_ids": "['Llama-3.3-70B-Instruct_43259']" }
0.458342
Filter_17002
I
[ "calculate_interest", "calculate_outstanding_balance", "model_credit_card_payment" ]
3
[ [ "model_credit_card_payment", "calculate_interest" ], [ "model_credit_card_payment", "calculate_outstanding_balance" ] ]
2
[]
false
[]
false
pytest
false
[]
true
d137f0479af2e37454402c7b5b06741b8dfd598f
780bc537b1d23622e5ddd1dd578592bba6ad9b0f
v1.0
instruct
Filter
Filter_17015_I
You should build a simple rock-paper-scissors game in Python. The game should allow two players to play against each other, and it should also allow one player to play against the computer. ### Game Requirements 1. The game should be able to handle two players. 2. The game should be able to handle one player and the ...
import random def get_computer_choice(): """Returns the computer's random choice""" choices = ['rock', 'paper', 'scissors'] return random.choice(choices) def determine_winner(player1, player2): """Determines the winner of the game""" if player1 == player2: return "It's a tie!" if (play...
from solution import get_computer_choice, determine_winner, play_game_single, play_game_two_players, play_game_single_player_vs_computer def test_get_computer_choice(): for _ in range(100): choice = get_computer_choice() assert choice in ['rock', 'paper', 'scissors'] def test_determine_winner(): ...
[ { "docstring": "Returns the computer's random choice", "function_declaration": "def get_computer_choice():", "function_name": "get_computer_choice", "parameter_list": "()" }, { "docstring": "Determines the winner of the game", "function_declaration": "def determine_winner(player1, 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 get_computer_choice():\n \"\"\"Returns the computer's random choice\"\"\"\n choices = ['rock', 'paper', 'scissors']\n return random.choice(choices)\n\ndef determi...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00017015", "row_id": 17015, "seed_ids": "['Llama-3.3-70B-Instruct_43294']" }
0.458105
Filter_17015
I
[ "get_computer_choice", "determine_winner", "play_game_single", "play_game_two_players", "play_game_single_player_vs_computer" ]
5
[ [ "play_game_single", "determine_winner" ], [ "play_game_single", "get_computer_choice" ], [ "play_game_single_player_vs_computer", "determine_winner" ], [ "play_game_single_player_vs_computer", "get_computer_choice" ], [ "play_game_two_players", "determine_wi...
5
[]
false
[]
false
pytest
true
[]
true
50e4cc106534106f24fb12bd2450300987a2d992
1d04b78212fa689f3d72b204a3da7421de85a608
v1.0
instruct
Filter
Filter_17017_I
### Tip Calculator # Create a tip calculator. The program should ask the user for their total restaurant bill before tax and # calculate both 15% and 20% tips. The program should then provide the user with the total cost of the # meal, including the 15% and 20% tip. def main(): # Get the total cost of the meal bef...
def calculate_tip(cost, percentage): """ Calculates the tip based on the percentage of the cost. Args: cost (float): Total cost before tip. percentage (float): Tip percentage. Returns: float: The calculated tip amount. """ return cost * (percentage / 100.0) def calculate_t...
def test_calculate_tip(): assert calculate_tip(100, 15) == 15 assert calculate_tip(100, 20) == 20 assert calculate_tip(200, 10) == 20 def test_calculate_total_with_tip(): assert calculate_total_with_tip(100, 15) == 115 assert calculate_total_with_tip(100, 20) == 120 assert calculate_total_with_...
[ { "docstring": "Calculates the tip based on the percentage of the cost.\n\nArgs:\ncost (float): Total cost before tip.\npercentage (float): Tip percentage.\n\nReturns:\nfloat: The calculated tip amount.", "function_declaration": "def calculate_tip(cost, percentage):", "function_name": "calculate_tip", ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_tip(cost_before_tip, tip_percentage):\n \"\"\"\n Calculate the tip amount based on the cost and tip percentage.\n \n Args:\n cost_before_tip (float): The total res...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017017", "row_id": 17017, "seed_ids": "['Llama-3.3-70B-Instruct_43297']" }
0.4927
Filter_17017
I
[ "calculate_tip", "calculate_total_with_tip", "main" ]
3
[ [ "calculate_total_with_tip", "calculate_tip" ] ]
1
[]
false
[]
false
pytest
false
[]
true
c9b47920f772965d71770a68e57dbf1aa54d9663
9873fd3d889fc528417d45e85a3f67b52f40c8f7
v1.0
instruct
Filter
Filter_17035_I
I've been tasked with sorting an array of integers using my own implementation of the merge sort algorithm. However, I'm running into issues with the array not being properly sorted. I've tried debugging, but I'm having trouble identifying the problem. Here's my code: ```python def merge_sort(arr): # Base case: If...
def merge_sort(arr): # Base case: If the length of the array is 1, return the array if len(arr) <= 1: return arr # Split the array into two halves mid = len(arr) // 2 left_half = arr[:mid] right_half = arr[mid:] # Recursively sort the two halves left_half = merge_sort(left_half...
from solution import merge_sort def test_merge_sort_with_unsorted_array(): assert merge_sort([64, 34, 25, 12, 22, 11, 90]) == [11, 12, 22, 25, 34, 64, 90] def test_merge_sort_with_sorted_array(): assert merge_sort([1, 2, 3, 4, 5, 6]) == [1, 2, 3, 4, 5, 6] def test_merge_sort_with_negative_numbers(): asse...
[ { "docstring": null, "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def merge(left, right):", "function_name": "merge", "parameter_list": "(left, right)" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_sort(arr):\n \"\"\"\n Sorts an array of integers using the merge sort algorithm.\n \"\"\"\n # Base case: If the length of the array is 1 or empty, return the array\n i...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00017035", "row_id": 17035, "seed_ids": "['Llama-3.3-70B-Instruct_43352']" }
0.568319
Filter_17035
I
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f9b564a53e8de2f54605417ad4300b8df91f885c
d03288ff5522f67bdf31f0ea38fb278098ef7477
v1.0
instruct
Filter
Filter_17077_I
Below are two functions, `get_discipline_id` and `get_student_id_by_discipline`, that get student information from a database. I want to implement a new function that retrieves the student names for a given list of discipline ids. ```python def get_discipline_id(discipline_name): """Get discipline id for a given ...
def get_discipline_id(discipline_name): """Get discipline id for a given discipline name.""" discipline_ids = { 'Math': 1, 'Science': 2, 'History': 3 } return discipline_ids.get(discipline_name) def get_student_id_by_discipline(discipline_id): """Get a list of student ids fo...
from solution import get_student_names_by_discipline_ids def test_get_student_names_by_discipline_ids_single_discipline(): result = get_student_names_by_discipline_ids([1]) expected = { 1: 'John Doe', 2: 'Jane Doe', 3: 'Bob Smith' } assert result == expected def test_get_studen...
[ { "docstring": "Get discipline id for a given discipline name.", "function_declaration": "def get_discipline_id(discipline_name):", "function_name": "get_discipline_id", "parameter_list": "(discipline_name)" }, { "docstring": "Get a list of student ids for a given discipline id.", "funct...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def get_discipline_id(discipline_name):\n \"\"\"Get discipline id for a given discipline name.\"\"\"\n discipline_ids = {\n 'Math': 1,\n 'Science': 2,\n 'History': 3...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00017077", "row_id": 17077, "seed_ids": "['Llama-3.3-70B-Instruct_43456']" }
0.716067
Filter_17077
I
[ "get_discipline_id", "get_student_id_by_discipline", "get_student_names_by_discipline_ids" ]
3
[ [ "get_student_names_by_discipline_ids", "get_student_id_by_discipline" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c073cc8d72e48b1ad542052b2f38fbebc70f9638
52b87ead6fac250f0ff26143018dfd2f48674705
v1.0
instruct
Filter
Filter_17093_I
I am using the following Python code that uses numpy to create a 2D array of coordinates where x ranges from 0 to 90 degrees and y ranges from 0 to 90 degrees. The array is then used to calculate some value using a given formula (here a simple example formula, but in reality, it's more complex). ```python import numpy...
import numpy as np def calculate_value(x, y): return x + y def calculate_for_points(points): """ Applies the calculate_value function to a single point or a list of points. Args: points (tuple or list of tuples): A single tuple (x, y) or a list of tuples [(x1, y1), (x2, y2), ...] Returns: ...
from solution import calculate_for_points def test_calculate_for_single_point(): assert calculate_for_points((10, 15)) == 25 def test_calculate_for_multiple_points(): input_points = [(0, 0), (10, 20), (30, 40)] expected_result = [0, 30, 70] assert calculate_for_points(input_points) == expected_result ...
[ { "docstring": null, "function_declaration": "def calculate_value(x, y):", "function_name": "calculate_value", "parameter_list": "(x, y)" }, { "docstring": "Applies the calculate_value function to a single point or a list of points.\n\nArgs:\npoints (tuple or list of tuples): A single tuple ...
[ 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 calculate_value(x, y):\n return x + y\n\ndef calculate_for_points(points):\n \"\"\"\n Applies the calculate_value function to a single point or a list of poi...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00017093", "row_id": 17093, "seed_ids": "['Llama-3.3-70B-Instruct_43494']" }
0.481428
Filter_17093
I
[ "calculate_value", "calculate_for_points" ]
2
[ [ "calculate_for_points", "calculate_value" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
8167c1ea4b15ef4321445728561e8fd4fca40577
003ed6e0ea466a1c0610b102885bd24c1afff5dc
v1.0
instruct
Filter
Filter_17098_I
I have been tasked with creating a system for my organization that can effectively manage the availability of meeting rooms. I need a simple web application that can be used to reserve and manage rooms. I am thinking of building a meeting room management system using Python. Can't you provide some guidance on how to ...
from flask import Flask, request, jsonify from datetime import datetime app = Flask(__name__) rooms = { "Room A": [], "Room B": [], "Room C": [] } def is_conflict(existing_reservations, start_time, end_time): """ Checks if the new reservation slot conflicts with existing reservations. """ ...
import pytest from flask import Flask from solution import app, rooms from datetime import datetime @pytest.fixture def client(): with app.test_client() as client: yield client def test_get_rooms(client): response = client.get('/rooms') assert response.status_code == 200 assert response.json =...
[ { "docstring": "Checks if the new reservation slot conflicts with existing reservations.", "function_declaration": "def is_conflict(existing_reservations, start_time, end_time):", "function_name": "is_conflict", "parameter_list": "(existing_reservations, start_time, end_time)" }, { "docstrin...
[ 0, 0, 1 ]
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\nfrom datetime import datetime\n\napp = Flask(__name__)\n\n# Mock database\nrooms = [\n {\"id\": 1, \"name\": \"Conference Room A\", \"reservations...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017098", "row_id": 17098, "seed_ids": "['Llama-3.3-70B-Instruct_43505']" }
0.365998
Filter_17098
I
[ "is_conflict", "get_rooms", "reserve_room", "get_reservations" ]
4
[ [ "reserve_room", "is_conflict" ] ]
1
[]
false
[]
false
pytest
true
[ "flask" ]
false
cbee670ad8162f036b1b1a26625e5ccd7372e5b5
30fe076617d5c552179feb338eda22ba2d47a903
v1.0
instruct
Filter
Filter_17101_I
I have two Python functions: ```python def f(x): return x**2 def g(x): return 3*x + 1 ``` I want to compose these functions with each other. Function composition in mathematics is defined as `(f ∘ g)(x) = f(g(x))`, so I should be able to get `f ∘ g` and `g ∘ f` from these functions. How can I create `f ∘ g` a...
def f(x): return x**2 def g(x): return 3*x + 1 def compose_fg(x): return f(g(x)) def compose_gf(x): return g(f(x))
from solution import f, g, compose_fg, compose_gf def test_f_function(): assert f(2) == 4 assert f(-3) == 9 assert f(0) == 0 def test_g_function(): assert g(2) == 7 assert g(-3) == -8 assert g(0) == 1 def test_compose_fg(): assert compose_fg(2) == 49 # f(g(2)) = f(7) = 49 assert comp...
[ { "docstring": null, "function_declaration": "def f(x):", "function_name": "f", "parameter_list": "(x)" }, { "docstring": null, "function_declaration": "def g(x):", "function_name": "g", "parameter_list": "(x)" }, { "docstring": null, "function_declaration": "def comp...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def f(x):\n return x**2\n\ndef g(x):\n return 3*x + 1\n\ndef compose(f, g):\n \"\"\"\n Function composition of f and g, defined as f(g(x)).\n \"\"\"\n return lambda x: f(g(x)...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017101", "row_id": 17101, "seed_ids": "['Llama-3.3-70B-Instruct_43518']" }
0.434464
Filter_17101
I
[ "f", "g", "compose_fg", "compose_gf" ]
4
[ [ "compose_fg", "f" ], [ "compose_fg", "g" ], [ "compose_gf", "f" ], [ "compose_gf", "g" ] ]
4
[]
false
[]
false
pytest
true
[]
true
c29ce747bc1142e85bb5ec687c7c4d33d77d360c
5648fc55816743fb6e66388e0246a256adc7dce0
v1.0
instruct
Filter
Filter_17139_I
Here's the code I'm working on: ```python import pandas as pd def convert_dollar_to_cents(dollar_value): """Converts a dollar amount to cents (integer).""" return int(round(dollar_value * 100)) def convert_cents_to_dollar(cents_value): """Converts a cents amount to dollars (float).""" return cents_val...
import pandas as pd def convert_dollar_to_cents(dollar_value): """Converts a dollar amount to cents (integer).""" return int(round(dollar_value * 100)) def convert_cents_to_dollar(cents_value): """Converts a cents amount to dollars (float).""" return cents_value / 100 def add_price_cents_column(df): ...
import pytest import pandas as pd from solution import convert_dollar_to_cents, convert_cents_to_dollar, add_price_cents_column def test_convert_dollar_to_cents(): assert convert_dollar_to_cents(10.25) == 1025 assert convert_dollar_to_cents(0.99) == 99 assert convert_dollar_to_cents(1.00) == 100 assert...
[ { "docstring": "Converts a dollar amount to cents (integer).", "function_declaration": "def convert_dollar_to_cents(dollar_value):", "function_name": "convert_dollar_to_cents", "parameter_list": "(dollar_value)" }, { "docstring": "Converts a cents amount to dollars (float).", "function_d...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import pandas as pd\n\ndef convert_dollar_to_cents(dollar_value):\n \"\"\"Converts a dollar amount to cents (integer).\"\"\"\n return int(round(dollar_value * 100))\n\ndef convert_cents_...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017139", "row_id": 17139, "seed_ids": "['Llama-3.3-70B-Instruct_43622']" }
0.556002
Filter_17139
I
[ "convert_dollar_to_cents", "convert_cents_to_dollar", "add_price_cents_column" ]
3
[ [ "add_price_cents_column", "convert_dollar_to_cents" ] ]
1
[]
false
[]
false
pytest
true
[ "pandas" ]
false
bd165048cdea1c2c9f8b57f9bd6b0f7d3507c434
0af78a7ccd463d4ebfb663305d9b5259e775de23
v1.0
instruct
Filter
Filter_17146_I
I'll give you a list of numbers, and I'd like you to generate a program in any language that takes that list and outputs the list with all the numbers that are prime multiplied by 2. For example, if the list is [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], the output would be [1, 4, 6, 4, 10, 6, 14, 8, 9, 10]. I'll provide the l...
def is_prime(n): """ Checks if a number is prime. """ if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def process_list(input_list): """ Takes a list of numbers and returns a new list where all the prime numbe...
from solution import is_prime, process_list def test_is_prime(): assert is_prime(1) == False 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 def test_process_list(): assert process_list([1, 2, 3, 4, ...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Takes a list of numbers and returns a new list where all the prime numbers \nare multiplied by 2.", "function_declaration": "...
[ 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 if n < 2:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True\n\ndef multiply_primes_by_2(ls...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00017146", "row_id": 17146, "seed_ids": "['Llama-3.3-70B-Instruct_43640']" }
0.693156
Filter_17146
I
[ "is_prime", "process_list" ]
2
[ [ "process_list", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
501597e60186cd373748f6333dfe3b86d47a1168
e3f8d491c305fcb4b6c659ef264b58b82babc0b3
v1.0
instruct
Filter
Filter_17158_I
I'm working on a project to analyze and visualize some data regarding financial transactions, and I'd like to write a function that takes a date and calculates the next business day (Monday to Friday, excluding holidays). What's the best way to do this in Python?
from datetime import date, timedelta # Assuming holidays is a global list of date objects representing holidays holidays = [ date(2023, 1, 1), # New Year's Day date(2023, 12, 25) # Christmas ] def is_business_day(d): """ Checks if a given date is a business day. """ if d.weekday() >= 5 or d i...
from datetime import date from solution import next_business_day, is_business_day def test_is_business_day(): # Test weekdays assert is_business_day(date(2023, 9, 15)) == True # Friday assert is_business_day(date(2023, 9, 18)) == True # Monday assert is_business_day(date(2023, 12, 25)) == False # Chr...
[ { "docstring": "Checks if a given date is a business day.", "function_declaration": "def is_business_day(d):", "function_name": "is_business_day", "parameter_list": "(d)" }, { "docstring": "Takes a date object and returns the next business day (Monday to Friday, excluding holidays).", "f...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from datetime import datetime, timedelta\n\ndef next_business_day(date, holidays=None):\n \"\"\"\n Given a date, calculate the next business day (Monday to Friday, excluding holidays).\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017158", "row_id": 17158, "seed_ids": "['Llama-3.3-70B-Instruct_43663']" }
0.786751
Filter_17158
I
[ "is_business_day", "next_business_day" ]
2
[ [ "next_business_day", "is_business_day" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a500c65a81a1e605ea22f8dd1b775d88915c9c7c
cac41140c136ba2defd6089e6e11c366f527db86
v1.0
instruct
Filter
Filter_17159_I
Here is the problem: Write a program that will simulate the game show "Jeopardy." The host will think of a number of "categories" and a dollar amount per category. The program should then prompt the user to select a category and a dollar amount, and then the user will be given a "question." The user should then prov...
import random # Initialize categories and questions categories = { "Category 1": { "$100": "This is the capital of France.", "$200": "This is the largest planet in our solar system.", "$300": "This is the smallest country in the world.", "$400": "This is the largest living structure...
def test_ask_question(): q = ask_question("Category 1", "$100") assert q == "This is the capital of France." def test_check_answer_correct(): assert check_answer("Category 1", "$100", "What is Paris?") == True def test_check_answer_incorrect(): assert check_answer("Category 1", "$100", "What is London...
[ { "docstring": null, "function_declaration": "def ask_question(category, value):", "function_name": "ask_question", "parameter_list": "(category, value)" }, { "docstring": null, "function_declaration": "def check_answer(category, value, user_response):", "function_name": "check_answe...
[ 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\n# Initialize categories and questions\ncategories = {\n \"Category 1\": {\n \"$100\": \"This is the capital of France.\",\n \"$200\": \"This is the largest pl...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00017159", "row_id": 17159, "seed_ids": "['Llama-3.3-70B-Instruct_43664']" }
0.550351
Filter_17159
I
[ "ask_question", "check_answer", "play_game" ]
3
[ [ "play_game", "ask_question" ], [ "play_game", "check_answer" ] ]
2
[]
false
[]
false
pytest
false
[]
true
0b5b873da8dc8dac9594b26f3946963113a62c1b
11ce94d5532fa256fca743b62ac28e6a45bd7b1c
v1.0
instruct
Filter
Filter_17169_I
You've been tasked with building a small CLI (Command Line Interface) tool that can be used to quickly find the domain and username of email addresses in a text file. Here is an example of a text file that the tool will operate on: ``` John Doe, john.doe@example.com Jane Doe, jane.doe@example.com John Smith, john.smi...
import re def extract_emails_from_text(text): """ Given a text, extracts all email addresses. Args: text (str): The text from which to extract emails. Returns: list: A list containing all the email addresses found in the text. """ email_pattern = r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9...
import pytest from solution import extract_emails_from_text, extract_domain_and_username, process_emails, read_file def test_extract_emails_from_text(): text = "John Doe, john.doe@example.com\nJane Doe, jane.doe@example.com\n" emails = extract_emails_from_text(text) assert emails == ["john.doe@example.com"...
[ { "docstring": "Given a text, extracts all email addresses.\n\nArgs:\ntext (str): The text from which to extract emails.\n\nReturns:\nlist: A list containing all the email addresses found in the text.", "function_declaration": "def extract_emails_from_text(text):", "function_name": "extract_emails_from_...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def extract_emails(file_content):\n \"\"\"\n Extracts email addresses from the given text file content.\n \n Args:\n file_content (str): Text content of the file containing emai...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017169", "row_id": 17169, "seed_ids": "['Llama-3.3-70B-Instruct_43683']" }
0.454199
Filter_17169
I
[ "extract_emails_from_text", "extract_domain_and_username", "process_emails", "read_file" ]
4
[ [ "process_emails", "extract_domain_and_username" ], [ "process_emails", "extract_emails_from_text" ] ]
2
[]
false
[]
false
pytest
true
[]
true
7b1023dc615395fb65240e7c4876b94cbc3b9af4
8fd6f4bd5b9f21f01ef9f96cd59722a74b2bc9fc
v1.0
instruct
Filter
Filter_17173_I
I have two functions: ```python def index_of_first_occurrence(numbers, target): """ Helper function to find the index of first occurrence of target in a sorted list of numbers. :param numbers: A sorted list of numbers :param target: The target number to search for :return: The index of the first oc...
def frequency(numbers, target): """ Function to find the frequency of target in a sorted list of numbers. :param numbers: A sorted list of numbers :param target: The target number to search for :return: The frequency of the target number in the list. """ first_index = index_of_first_occurren...
import pytest from solution import index_of_first_occurrence, index_of_last_occurrence, frequency def test_index_of_first_occurrence(): assert index_of_first_occurrence([1, 2, 2, 2, 3], 2) == 1 assert index_of_first_occurrence([1, 2, 2, 2, 3], 3) == 4 assert index_of_first_occurrence([1, 2, 2, 2, 3], 1) ==...
[ { "docstring": "Function to find the frequency of target in a sorted list of numbers.\n:param numbers: A sorted list of numbers\n:param target: The target number to search for\n:return: The frequency of the target number in the list.", "function_declaration": "def frequency(numbers, target):", "function...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def frequency(numbers, target):\n \"\"\"\n Finds the frequency of target in a sorted list of numbers.\n :param numbers: A sorted list of numbers\n :param target: The target number ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017173", "row_id": 17173, "seed_ids": "['Llama-3.3-70B-Instruct_43691']" }
0.605591
Filter_17173
I
[ "frequency", "index_of_first_occurrence", "index_of_last_occurrence" ]
3
[ [ "frequency", "index_of_first_occurrence" ], [ "frequency", "index_of_last_occurrence" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5e2f82bc7183c1c10e3036419d65dc4304fc4006
603b525493b3168423d1c47c611eda302bd4fd39
v1.0
instruct
Filter
Filter_17193_I
I have many text files and each text file has many lines and each line contains some numbers. The task is to create a program that will read the text files in a directory, read each line of the file, and find all primes in the line, then add those primes to total primes. This is a Python program. I've tried some co...
import os def is_prime(n): """ Check if a number n 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 ...
import os import pytest from solution import is_prime, get_primes_from_dir, get_primes_from_file def test_is_prime(): assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert not is_prime(-7) assert not is_prime(0) assert not is_prime(1) def test_get_primes_fr...
[ { "docstring": "Check if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Get a set of prime numbers from a single file.", "function_declaration": "def get_primes_from_file(file_path):", "functi...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "Magpie-Filter-89K_sanitized_prepared1_results_combined.jsonl", "solution_code": "import os\n\ndef 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 return False\n i...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017193", "row_id": 17193, "seed_ids": "['Llama-3.3-70B-Instruct_43735']" }
0.579192
Filter_17193
I
[ "is_prime", "get_primes_from_file", "get_primes_from_dir" ]
3
[ [ "get_primes_from_dir", "get_primes_from_file" ], [ "get_primes_from_file", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
20ad6d608e822b4ff128d418d261b32a00ff6dd2
09e4518e8c1d185eeed26c30f3ca3503710a297e
v1.0
instruct
Filter
Filter_17198_I
I want to know how to make a simple layout for a text-based user interface like this: ``` +-------------------+ | Header | +-------------------+ | Sidebar | Main | | | | | | | +-----------+--------+ | Footer | +-------------------+ ``` To ...
def render_header(): return "+" + "-" * 19 + "+\n" + "| Header |\n" + "+" + "-" * 19 + "+\n" def render_sidebar(): return "| Sidebar |\n" + "| |\n" + "| |\n" def render_main(): return "| Main |\n" + "| |\n" + "| |\n" def render_footer(): return "+" + "...
from solution import render_header, render_sidebar, render_main, render_footer, render_layout def test_render_header(): expected = "+" + "-" * 19 + "+\n" + "| Header |\n" + "+" + "-" * 19 + "+\n" assert render_header() == expected def test_render_sidebar(): expected = "| Sidebar |\n" + "| ...
[ { "docstring": null, "function_declaration": "def render_header():", "function_name": "render_header", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def render_sidebar():", "function_name": "render_sidebar", "parameter_list": "()" }, { "docstring...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def render_header(width):\n return '+' + '-' * (width - 2) + '+\\n' + \\\n '|{:^{}}|\\n'.format('Header', width - 2) + \\\n '+' + '-' * (width - 2) + '+'\n\ndef render_f...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00017198", "row_id": 17198, "seed_ids": "['Llama-3.3-70B-Instruct_43745']" }
0.351646
Filter_17198
I
[ "render_header", "render_sidebar", "render_main", "render_footer", "render_layout" ]
5
[ [ "render_layout", "render_footer" ], [ "render_layout", "render_header" ], [ "render_layout", "render_main" ], [ "render_layout", "render_sidebar" ] ]
4
[]
false
[]
false
pytest
true
[]
true
d86f320af659bf6c9ecf48afd8a4b6ecd003e053
5d8fd5cc11505ffd9819fcd43622ef1da968cd8a
v1.0
instruct
Filter
Filter_17243_I
Can you write me a code to find the sum of all prime numbers up to n (inclusive) using Python?
def is_prime(num): """ Check 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 sum_of_primes(n): """ Returns the sum of all prime numbers up to n (inclusive). """ re...
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(18) == False def test_sum_of_primes(): assert sum_of_primes(10) == 17 # 2, 3, 5, 7 assert sum_of_...
[ { "docstring": "Check 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 up to n (inclusive).", "function_declaration": "def sum_of_primes(n):", "function...
[ 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 for i in range(2, int(num**0.5) + 1):\n if num % i == 0:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00017243", "row_id": 17243, "seed_ids": "['Llama-3.3-70B-Instruct_43845']" }
0.68327
Filter_17243
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b3a21c69672f78b63864f408bae4498b6e3d217a
f6778133b28272680a1786108580f6dce01ad775
v1.0
instruct
Filter
Filter_17244_I
I've been having a lot of trouble understanding how to write a simple program to handle different cases of inputs. For example, if I'm writing a program that converts units of measurement, I might have to handle different units (e.g., kilometers, miles, pounds, grams, etc.) and perform the correct conversions based on ...
def kilometers_to_miles(km): """ Converts kilometers to miles. """ return km * 0.621371 def miles_to_kilometers(miles): """ Converts miles to kilometers. """ return miles * 1.60934 def pounds_to_grams(pounds): """ Converts pounds to grams. """ return pounds * 453.592 d...
from solution import kilometers_to_miles, miles_to_kilometers, pounds_to_grams, grams_to_pounds def test_kilometers_to_miles(): assert kilometers_to_miles(1) == 0.621371 assert kilometers_to_miles(5) == 3.106855 assert kilometers_to_miles(0) == 0 def test_miles_to_kilometers(): assert miles_to_kilomet...
[ { "docstring": "Converts kilometers to miles.", "function_declaration": "def kilometers_to_miles(km):", "function_name": "kilometers_to_miles", "parameter_list": "(km)" }, { "docstring": "Converts miles to kilometers.", "function_declaration": "def miles_to_kilometers(miles):", "func...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def kilometers_to_miles(km):\n \"\"\"Convert kilometers to miles.\"\"\"\n return km * 0.621371\n\ndef miles_to_kilometers(miles):\n \"\"\"Convert miles to kilometers.\"\"\"\n retur...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00017244", "row_id": 17244, "seed_ids": "['Llama-3.3-70B-Instruct_43849']" }
0.43916
Filter_17244
I
[ "kilometers_to_miles", "miles_to_kilometers", "pounds_to_grams", "grams_to_pounds", "handle_conversion" ]
5
[ [ "handle_conversion", "grams_to_pounds" ], [ "handle_conversion", "kilometers_to_miles" ], [ "handle_conversion", "miles_to_kilometers" ], [ "handle_conversion", "pounds_to_grams" ] ]
4
[]
false
[]
false
pytest
true
[]
true
76be3a5a800a611250c7ed2942191dee970bf621
f13985ca68069d09d971f2465122e922189fa3fd
v1.0
instruct
Filter
Filter_17261_I
I have a basic understanding of blockchain and cryptocurrencies. I want to try my hand at building a simple blockchain from scratch. I am proficient in Python, so I would like to build it in Python. Can you walk me through the process of building a simple blockchain?
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, Blockchain, calculate_hash, create_genesis_block, create_new_block def test_create_genesis_block(): genesis_block = create_genesis_block() assert genesis_block.index == 0 assert genesis_block.previous_hash == "0" assert genesis_block.data == "Genesis Block" def test_create_...
[]
[ 1, 1, 1 ]
3
easy
1
{ "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_0
{ "original_instruction": "", "prompt_id": "00017261", "row_id": 17261, "seed_ids": "['Llama-3.3-70B-Instruct_43884']" }
0.29869
Filter_17261
I
[ "calculate_hash", "create_genesis_block", "create_new_block" ]
3
[ [ "create_genesis_block", "calculate_hash" ], [ "create_new_block", "calculate_hash" ] ]
2
[]
false
[ "Block", "Blockchain" ]
true
pytest
true
[]
true
b44db75470307d3456809446def8307f87ce8d7c
3d80d4d3eabe934d14c45c75c931614b6798cebd
v1.0
instruct
Filter
Filter_17280_I
I have a list of binary strings of varying lengths and I want to generate a list of complements for each string. Input: ['101', '110', '111', '10'] Output: ['010', '001', '000', '01'] The problem seems pretty straightforward: just iterate over each character in the string and flip it. However, I feel like I'm overcom...
def get_complement(bin_str): """ Returns the complement of a binary string. Each '1' is converted to '0' and each '0' is converted to '1'. """ return ''.join('1' if bit == '0' else '0' for bit in bin_str) def generate_complement_list(bin_str_list): """ Given a list of binary strings, return...
from solution import get_complement, generate_complement_list def test_get_complement(): assert get_complement('101') == '010' assert get_complement('110') == '001' assert get_complement('111') == '000' assert get_complement('10') == '01' assert get_complement('0') == '1' assert get_complement(...
[ { "docstring": "Returns the complement of a binary string.\nEach '1' is converted to '0' and each '0' is converted to '1'.", "function_declaration": "def get_complement(bin_str):", "function_name": "get_complement", "parameter_list": "(bin_str)" }, { "docstring": "Given a list of binary stri...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def get_complement(bin_str):\n \"\"\"\n Returns the complement of the binary string.\n Each '1' in the input is replaced with '0' and each '0' is replaced with '1'.\n \"\"\"\n r...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017280", "row_id": 17280, "seed_ids": "['Llama-3.3-70B-Instruct_43927']" }
0.594437
Filter_17280
I
[ "get_complement", "generate_complement_list" ]
2
[ [ "generate_complement_list", "get_complement" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a4266da11ce61158ca5dc8616f22bd9e87dbed70
73cf15d76762d8bf1427e0831df0b54b6d0d0e24
v1.0
instruct
Filter
Filter_17300_I
I've been working on a programming project for quite some time, and I've realized that I need to implement a feature to search for a specific string within a text. However, I'm having trouble figuring out how to do it efficiently. The text is quite large, and my current implementation is taking a lot of time to search...
def build_lps(pattern): """ Helper function to build the longest prefix suffix (lps) array used in KMP algorithm. """ length = 0 # length of the previous longest prefix suffix lps = [0] * len(pattern) i = 1 while i < len(pattern): if pattern[i] == pattern[length]: lengt...
def test_kmp_search(): text = "ababcabcabababd" pattern = "ababd" assert kmp_search(text, pattern) == 10 def test_kmp_search_pattern_not_in_text(): text = "ababcabcababab" pattern = "abcde" assert kmp_search(text, pattern) == -1 def test_kmp_search_empty_pattern(): text = "ababcabcababab" ...
[ { "docstring": "Helper function to build the longest prefix suffix (lps) array used in KMP algorithm.", "function_declaration": "def build_lps(pattern):", "function_name": "build_lps", "parameter_list": "(pattern)" }, { "docstring": "KMP algorithm to search for a pattern in a text.", "fu...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def build_lps(pattern):\n \"\"\"\n Helper function to build the longest prefix suffix (lps) array used in KMP algorithm.\n \"\"\"\n length = 0 # length of the previous longest pre...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00017300", "row_id": 17300, "seed_ids": "['Llama-3.3-70B-Instruct_43976']" }
0.570698
Filter_17300
I
[ "build_lps", "kmp_search" ]
2
[ [ "kmp_search", "build_lps" ] ]
1
[]
false
[]
false
pytest
false
[]
true
48eb615a0e37f772c7379339f57974c29a36b02f
2cf159ec2d4cc78c422d3e531b64a61c5eee3685
v1.0
instruct
Filter
Filter_17359_I
I see this issue in the code, but I don't know what is causing it. The program is supposed to find the closest pair of points in a set of points in n-dimensional space and return the pair of points and the distance between them. It looks like the issue is with the distance calculation. The code uses the Euclidean dis...
import math def euclidean_distance(point1, point2): """ Calculate the Euclidean distance between two points in n-dimensional space. """ return math.sqrt(sum((point1[k] - point2[k]) ** 2 for k in range(len(point1)))) def closest_pair(points): min_distance = float('inf') min_points = None ...
from solution import closest_pair def test_closest_pair_3d_points(): points = [(1, 2, 3), (4, 5, 6), (7, 8, 9)] result_points, distance = closest_pair(points) assert result_points == ((1, 2, 3), (4, 5, 6)) assert abs(distance - 5.196152422706632) < 1e-9 def test_closest_pair_2d_points(): points = ...
[ { "docstring": "Calculate the Euclidean distance between two points in n-dimensional space.", "function_declaration": "def euclidean_distance(point1, point2):", "function_name": "euclidean_distance", "parameter_list": "(point1, point2)" }, { "docstring": null, "function_declaration": "de...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef closest_pair(points):\n min_distance = float('inf')\n min_points = None\n \n for i in range(len(points)):\n for j in range(i + 1, len(points)): # Correct...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017359", "row_id": 17359, "seed_ids": "['Llama-3.3-70B-Instruct_44100']" }
0.591751
Filter_17359
I
[ "euclidean_distance", "closest_pair" ]
2
[ [ "closest_pair", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
75f38e6f1c34838aa75df99cd6d0ca9472125861
c6b1a79876a3511c4a328c383532f848f5cd0009
v1.0
instruct
Filter
Filter_17384_I
Create a code for calculating the area and volume of a sphere with a given radius. The formulas used should be: - Area = 4 * π * r^2 - Volume = (4 / 3) * π * r^3 Where r is the radius of the sphere. You should include the following functions: 1. A function to calculate the area of the sphere. 2. A function to calcu...
import math def sphere_area(radius): """ Calculates the surface area of a sphere given its radius. Parameters: radius (float): The radius of the sphere Returns: float: The surface area of the sphere """ return 4 * math.pi * (radius ** 2) def sphere_volume(radius): """ ...
from solution import sphere_area, sphere_volume, sphere_area_volume def test_sphere_area(): assert round(sphere_area(1), 5) == round(4 * math.pi * (1 ** 2), 5) assert round(sphere_area(2), 5) == round(4 * math.pi * (2 ** 2), 5) def test_sphere_volume(): assert round(sphere_volume(1), 5) == round((4 / 3) *...
[ { "docstring": "Calculates the surface area of a sphere given its radius.\n\nParameters:\nradius (float): The radius of the sphere\n\nReturns:\nfloat: The surface area of the sphere", "function_declaration": "def sphere_area(radius):", "function_name": "sphere_area", "parameter_list": "(radius)" }...
[ 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 sphere_area(radius):\n \"\"\"\n Calculate the area of a sphere with a given radius.\n :param radius: The radius of the sphere\n :return: The area of the sphere\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017384", "row_id": 17384, "seed_ids": "['Llama-3.3-70B-Instruct_44144']" }
0.69455
Filter_17384
I
[ "sphere_area", "sphere_volume", "sphere_area_volume" ]
3
[ [ "sphere_area_volume", "sphere_area" ], [ "sphere_area_volume", "sphere_volume" ] ]
2
[]
false
[]
false
pytest
true
[]
true
472090a77dc584cabc34a8b0679d9736576a2f92
38ef7ec3dfcc9972539019cf40db5facc05abbe5
v1.0
instruct
Filter
Filter_17391_I
Create a simple shift cipher program using Python that can do both encryption and decryption.
def shift_cipher_encrypt(text, shift): """ Encrypts the text using a shift cipher with the specified shift. """ encrypted_text = "" for char in text: if char.isalpha(): shift_base = 65 if char.isupper() else 97 encrypted_text += chr((ord(char) - shift_base + shift) % ...
from solution import shift_cipher_encrypt, shift_cipher_decrypt def test_shift_cipher_encrypt(): assert shift_cipher_encrypt("ABCD", 1) == "BCDE" assert shift_cipher_encrypt("abcd", 1) == "bcde" assert shift_cipher_encrypt("XYZ", 2) == "ZAB" assert shift_cipher_encrypt("xyz", 2) == "zab" assert shi...
[ { "docstring": "Encrypts the text using a shift cipher with the specified shift.", "function_declaration": "def shift_cipher_encrypt(text, shift):", "function_name": "shift_cipher_encrypt", "parameter_list": "(text, shift)" }, { "docstring": "Decrypts the text using a shift cipher with the s...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def shift_cipher(text, shift, mode='encrypt'):\n \"\"\"\n Encrypts or decrypts the given text using a simple shift cipher.\n\n :param text: The input text to be encrypted or decrypted...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017391", "row_id": 17391, "seed_ids": "['Llama-3.3-70B-Instruct_44162']" }
0.6565
Filter_17391
I
[ "shift_cipher_encrypt", "shift_cipher_decrypt" ]
2
[ [ "shift_cipher_decrypt", "shift_cipher_encrypt" ] ]
1
[]
false
[]
false
pytest
true
[]
true
43a1ebfd5b4c459f13855bf61ab43674384d9beb
74ddf0eea4782d913c75145e306e03a170b1518d
v1.0
instruct
Filter
Filter_17392_I
I have a large number of uploaded files and I'd like to get the MD5 hashes of all of them. Is there a simple way to do this in Python?
import hashlib import os def get_md5_hash(file_path): """ Returns the MD5 hash of the file specified by file_path. """ hash_md5 = hashlib.md5() try: with open(file_path, "rb") as f: for chunk in iter(lambda: f.read(4096), b""): hash_md5.update(chunk) retu...
import os import pytest from solution import get_md5_hash, get_md5_hashes def test_get_md5_hash(): # Create a temporary file for testing temp_file_path = 'test_temp_file.txt' with open(temp_file_path, 'w') as f: f.write('Test content for MD5 hash.') expected_hash = hashlib.md5(b'Test content f...
[ { "docstring": "Returns the MD5 hash of the file specified by file_path.", "function_declaration": "def get_md5_hash(file_path):", "function_name": "get_md5_hash", "parameter_list": "(file_path)" }, { "docstring": "Returns a dictionary with filenames as keys and MD5 hashes as values\nfor all...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import hashlib\n\ndef get_md5_hash(file_path):\n \"\"\"\n Returns the MD5 hash of the file at the provided file path.\n \"\"\"\n hash_md5 = hashlib.md5()\n with open(file_path, ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017392", "row_id": 17392, "seed_ids": "['Llama-3.3-70B-Instruct_44165']" }
0.682235
Filter_17392
I
[ "get_md5_hash", "get_md5_hashes" ]
2
[ [ "get_md5_hashes", "get_md5_hash" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c3ac718c9e082b2bb3d3db4ddc4dda368a3dc69a
320cc024563a10b1ec594029ab02dba30947ab77
v1.0
instruct
Filter
Filter_17436_I
Can you write a code snippet that checks whether the account balance of a bank account is low (less than $100) and sends an email notification to the account owner if it is?
def check_and_notify_balance(account_balance, email_address, threshold=100): """ Checks if the account balance is below the threshold and sends an email notification if it is. Parameters: account_balance (float): The balance of the bank account. email_address (str): The email address of the acc...
from solution import check_and_notify_balance def test_check_and_notify_balance_high(): assert check_and_notify_balance(150.0, "test@example.com") == False def test_check_and_notify_balance_low(): assert check_and_notify_balance(50.0, "test@example.com") == True def test_check_and_notify_balance_threshold():...
[ { "docstring": "Checks if the account balance is below the threshold and sends an email notification if it is.\n\nParameters:\naccount_balance (float): The balance of the bank account.\nemail_address (str): The email address of the account owner.\nthreshold (float): The balance threshold to check against. Defau...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import smtplib\nfrom email.mime.text import MIMEText\nfrom email.mime.multipart import MIMEMultipart\n\ndef send_low_balance_email(account_owner_email, balance):\n \"\"\"\n Sends an emai...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00017436", "row_id": 17436, "seed_ids": "['Llama-3.3-70B-Instruct_44275']" }
0.445249
Filter_17436
I
[ "check_and_notify_balance", "send_email_notification" ]
2
[ [ "check_and_notify_balance", "send_email_notification" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bc0661468d5afdd10c06c1ffd68bb32c56c21cf7
a15e8965e4215af62783611a0ead007cb7a1871d
v1.0
instruct
Filter
Filter_17480_I
I have been working on a Python code for an exposure notification system. I want the user to be able to add their own exposure location and date. The code I have so far is: ```python import datetime def get_exposure_location(): return input("Enter the location of potential exposure (e.g., store, restaurant, etc....
import datetime def get_exposure_location(): return input("Enter the location of potential exposure (e.g., store, restaurant, etc.): ") def get_exposure_date(): while True: try: date = input("Enter the date of potential exposure (YYYY-MM-DD): ") datetime.datetime.strptime(date,...
import pytest from unittest.mock import patch from solution import add_exposure def test_add_exposure(): with patch('builtins.input', side_effect=['store', '2023-09-15']): exposure_info = add_exposure() assert exposure_info['location'] == 'store' assert exposure_info['date'] == '2023-09-15'...
[ { "docstring": null, "function_declaration": "def get_exposure_location():", "function_name": "get_exposure_location", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def get_exposure_date():", "function_name": "get_exposure_date", "parameter_list": "()" ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import datetime\n\ndef get_exposure_location():\n return input(\"Enter the location of potential exposure (e.g., store, restaurant, etc.): \")\n\ndef get_exposure_date():\n while True:\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017480", "row_id": 17480, "seed_ids": "['Llama-3.3-70B-Instruct_44379']" }
0.544296
Filter_17480
I
[ "get_exposure_location", "get_exposure_date", "add_exposure" ]
3
[ [ "add_exposure", "get_exposure_date" ], [ "add_exposure", "get_exposure_location" ] ]
2
[]
false
[]
false
pytest
true
[]
true
dab4264ed0a5d8b51c0ee447443899fb3ddbdcb5
d43d93de8c5089fbd0996718133354a46cd1831f
v1.0
instruct
Filter
Filter_17487_I
### Tic Tac Toe Game #### Game Overview The Tic Tac Toe game is a simple game where two players, X and O, take turns marking a square on a 3x3 grid. The first player to get three in a row (horizontally, vertically, or diagonally) wins the game. If all squares are filled and no player has won, the game is a draw. #### C...
def print_board(board): """Print the current state of the game board.""" print(f" {board[0][0]} | {board[0][1]} | {board[0][2]}") print(" ---------") print(f" {board[1][0]} | {board[1][1]} | {board[1][2]}") print(" ---------") print(f" {board[2][0]} | {board[2][1]} | {board[2][2]}") def check...
from solution import check_win, make_move def test_check_win_row(): board = [ ['X', 'X', 'X'], ['4', 'O', '6'], ['O', '8', '9'] ] assert check_win(board) == 'X' def test_check_win_column(): board = [ ['X', 'O', 'X'], ['X', 'O', '6'], ['X', '8', 'O'] ...
[ { "docstring": "Print the current state of the game board.", "function_declaration": "def print_board(board):", "function_name": "print_board", "parameter_list": "(board)" }, { "docstring": "Check if there is a winner.", "function_declaration": "def check_win(board):", "function_name...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def print_board(board):\n \"\"\"Print the current state of the game board.\"\"\"\n print(f\" {board[0][0]} | {board[0][1]} | {board[0][2]}\")\n print(\" ---------\")\n print(f\" {...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00017487", "row_id": 17487, "seed_ids": "['Llama-3.3-70B-Instruct_44393']" }
0.578177
Filter_17487
I
[ "print_board", "check_win", "make_move", "tic_tac_toe" ]
4
[ [ "tic_tac_toe", "check_win" ], [ "tic_tac_toe", "make_move" ], [ "tic_tac_toe", "print_board" ] ]
3
[]
false
[]
false
pytest
true
[]
true
7cb60aa7b601f73629131b401de5c88d68e1d94f
82b4b3fffcc2b68e8bbb1233eb4f62095fdc2de2
v1.0
instruct
Filter
Filter_17493_I
Here's the problem I'm facing: I'm trying to iterate through a list of data and perform some action on each item in the list, but the function that performs the action only accepts a single argument. Can help me figure out this issue? That is, the function only accepts one argument but the data i have is in list fo...
def print_square(num): """Print the square of the given number.""" print(num**2) def process_data_with_square(data): """ Process a list of tuples and prints the square of the first item in each tuple. Args: data (list of tuples): The list of tuples to process. Returns: ...
from solution import process_data_with_square def test_process_data_with_square(capsys): data = [(1, 2), (3, 4), (5, 6)] process_data_with_square(data) captured = capsys.readouterr() assert captured.out == "1\n9\n25\n" def test_empty_data(capsys): data = [] process_data_with_square(data) c...
[ { "docstring": "Print the square of the given number.", "function_declaration": "def print_square(num):", "function_name": "print_square", "parameter_list": "(num)" }, { "docstring": "Process a list of tuples and prints the square of the first item in each tuple.\n\nArgs:\n data (list of ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def print_square(num):\n print(num**2)\n\ndef process_data(data):\n \"\"\"\n Processes the data by passing the first element of each tuple\n to the print_square function.\n \"\"...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00017493", "row_id": 17493, "seed_ids": "['Llama-3.3-70B-Instruct_44410']" }
0.492915
Filter_17493
I
[ "print_square", "process_data_with_square" ]
2
[ [ "process_data_with_square", "print_square" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4320ad09fb97beb9645c3bcfadb454b107e83934
83519d54b2c0a5f55d1ee7ba899dd79a1ccfdef0
v1.0
instruct
Filter
Filter_17506_I
### Sort a Binary Search Tree (BST) by modifying the tree in-place #### Problem Statement Given a binary search tree, sort it in-place, so that the value of every node in the left subtree of a node should be less than the node and the value of every node in the right subtree should be greater than the node. However, th...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def inorder_traversal(root): res = [] if root: res += inorder_traversal(root.left) res.append(root.val) res += inorder_traversal(root.right) return res def sorted_arra...
from solution import TreeNode, sort_BST, inorder_traversal def test_sort_BST_example1(): root = TreeNode(3) root.left = TreeNode(1) root.right = TreeNode(4) root.left.left = TreeNode(0) root.left.right = TreeNode(2) root.right.right = TreeNode(5) new_root = sort_BST(root) assert in...
[]
[ 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, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef inorder_traversal(root):\n res = []\n if root:\n res ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017506", "row_id": 17506, "seed_ids": "['Llama-3.3-70B-Instruct_44434']" }
0.54648
Filter_17506
I
[ "inorder_traversal", "sorted_array_to_bst", "sort_BST" ]
3
[ [ "sort_BST", "inorder_traversal" ], [ "sort_BST", "sorted_array_to_bst" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
8ca7a3c015adb3771ce3b855efecd86c788a7d1d
a36e04eff9103f793bcbfec41cea225bec7bdab5
v1.0
instruct
Filter
Filter_17538_I
Code a simple Blackjack game in Python. The game should be able to track the player's and the dealer's score and display the result at the end of the game. ```python import random def get_card_value(card): """Return the value of a card.""" suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] ranks = ['2', '3...
import random def get_card_value(card): """Return the value of a card.""" suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King', 'Ace'] values = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, 'Jack': ...
from solution import get_card_value, calculate_score, deal_cards def test_get_card_value(): assert get_card_value('2 of Hearts') == 2 assert get_card_value('10 of Diamonds') == 10 assert get_card_value('Jack of Clubs') == 10 assert get_card_value('Ace of Spades') == 11 def test_calculate_score(): ...
[ { "docstring": "Return the value of a card.", "function_declaration": "def get_card_value(card):", "function_name": "get_card_value", "parameter_list": "(card)" }, { "docstring": "Calculate the score of a hand of cards.", "function_declaration": "def calculate_score(hand):", "functio...
[ 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 get_card_value(card):\n \"\"\"Return the value of a card.\"\"\"\n values = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, 'Jack': 10, 'Qu...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00017538", "row_id": 17538, "seed_ids": "['Llama-3.3-70B-Instruct_44524']" }
0.617715
Filter_17538
I
[ "get_card_value", "calculate_score", "deal_cards", "game" ]
4
[ [ "calculate_score", "get_card_value" ], [ "game", "calculate_score" ], [ "game", "deal_cards" ] ]
3
[]
false
[]
false
pytest
true
[]
true
beebbf14f1ff2a2805613d64f1d9db5cd1b3fe46
94c70a3f44934a81674c04bc3fff74c728c352e9
v1.0
instruct
Filter
Filter_17551_I
I want to write a program that prints out all the prime numbers up to a given number. Once the program starts, it asks for the user for a number. It also gives the user the option to either print out the prime numbers using a for loop, or using recursion.
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 for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def primes_up_to_for_loop(n): ...
from solution import primes_up_to_for_loop, primes_up_to_recursive def test_is_prime(): from solution import is_prime assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True def test_primes_up_to_for_loop_with_10(): assert primes_up_to_for_l...
[ { "docstring": "Checks if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers up to n using a for loop.", "function_declaration": "def primes_up_to_for_loop(n):", "f...
[ 0, 1, 1 ]
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 Determines 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_1
{ "original_instruction": "", "prompt_id": "00017551", "row_id": 17551, "seed_ids": "['Llama-3.3-70B-Instruct_44559']" }
0.624198
Filter_17551
I
[ "is_prime", "primes_up_to_for_loop", "primes_up_to_recursive" ]
3
[ [ "primes_up_to_for_loop", "is_prime" ], [ "primes_up_to_recursive", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a76b5971005eba8b5e3acbbe261bf9da58486721
8fe1a5053ee4754557ed5516e0ce6bac6380c728
v1.0
instruct
Filter
Filter_17563_I
### Accepting User Input in Python ## Introduction to Input Function The built-in `input()` function in Python is used to accept user input. By default, it accepts user input as a string. ### Example 1: Accepting String Input ```python # Accepting user input user_input = input("Please enter your name: ") # Printing t...
# Define a function to add two numbers def add(num1, num2): return num1 + num2 # Define a function to subtract two numbers def subtract(num1, num2): return num1 - num2 # Define a function to multiply two numbers def multiply(num1, num2): return num1 * num2 # Define a function to divide two numbers def di...
from solution import add, subtract, multiply, divide, modulus, calculator def test_add(): assert add(3, 4) == 7 assert add(0, 0) == 0 assert add(-1, 1) == 0 def test_subtract(): assert subtract(10, 5) == 5 assert subtract(0, 0) == 0 assert subtract(-1, -1) == 0 def test_multiply(): assert...
[ { "docstring": null, "function_declaration": "def add(num1, num2):", "function_name": "add", "parameter_list": "(num1, num2)" }, { "docstring": null, "function_declaration": "def subtract(num1, num2):", "function_name": "subtract", "parameter_list": "(num1, num2)" }, { "d...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "# Define a function to add two numbers\ndef add(num1, num2):\n return num1 + num2\n\n# Define a function to subtract two numbers\ndef subtract(num1, num2):\n return num1 - num2\n\n# Defi...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00017563", "row_id": 17563, "seed_ids": "['Llama-3.3-70B-Instruct_44588']" }
0.529252
Filter_17563
I
[ "add", "subtract", "multiply", "divide", "modulus", "calculator" ]
6
[ [ "calculator", "add" ], [ "calculator", "divide" ], [ "calculator", "modulus" ], [ "calculator", "multiply" ], [ "calculator", "subtract" ] ]
5
[]
false
[]
false
pytest
true
[]
true
06dc74fd97839dbedd7d995213a848c4b4c4e3fd
fc9a60066e756519800d22d4129fe6b0d8b45234
v1.0
instruct
Filter
Filter_17564_I
I have a helper function `get_remainder` that takes an input value and returns the remainder when divided by 5. I want to process a list of integers and generate a new list containing the remainders of each integer in the list when divided by 5. Here's my helper function: ```python def get_remainder(value): retur...
def process_list(numbers): """ Given a list of integers, returns a new list containing the remainders of each integer when divided by 5. """ return [get_remainder(num) for num in numbers] def get_remainder(value): """ Helper function that returns the remainder when value is divided by 5. ...
from solution import process_list, get_remainder def test_process_list_with_positive_numbers(): assert process_list([10, 15, 22, 3, 7]) == [0, 0, 2, 3, 2] def test_process_list_with_negative_numbers(): assert process_list([-10, -4, -8, -15]) == [0, 1, 2, 0] def test_process_list_with_mixed_sign_numbers(): ...
[ { "docstring": "Given a list of integers, returns a new list containing the remainders \nof each integer when divided by 5.", "function_declaration": "def process_list(numbers):", "function_name": "process_list", "parameter_list": "(numbers)" }, { "docstring": "Helper function that returns t...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def get_remainder(value):\n return value % 5\n\ndef get_remainders_list(int_list):\n \"\"\"\n Takes a list of integers and returns a list of their remainders when divided by 5.\n \...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017564", "row_id": 17564, "seed_ids": "['Llama-3.3-70B-Instruct_44589']" }
0.523232
Filter_17564
I
[ "process_list", "get_remainder" ]
2
[ [ "process_list", "get_remainder" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ae748ba160d2ef7fae9f5118e86b589c2d582bab
00c8e873d48e79c95f201e2e934af9eb0e095054
v1.0
instruct
Filter
Filter_17593_I
### Creating a Simple Chatbot Using Python The following is a basic example of a chatbot that you can create in Python: ```python # Import the required libraries import random # Define a dictionary with intents and responses intents = { 'greeting': { 'patterns': ['Hi', 'Hello', 'Hey'], 'responses'...
import random # Define a dictionary with intents and responses intents = { 'greeting': { 'patterns': ['Hi', 'Hello', 'Hey'], 'responses': ['Hello!', 'Hi, how are you?', 'Hey, what\'s up?'] }, 'goodbye': { 'patterns': ['Bye', 'See you later', 'Goodbye'], 'responses': ['See yo...
from solution import match_intent, get_response, process_message def test_match_intent_greeting(): assert match_intent('Hi') == 'greeting' assert match_intent('Hello') == 'greeting' assert match_intent('Hey') == 'greeting' def test_match_intent_goodbye(): assert match_intent('Bye') == 'goodbye' as...
[ { "docstring": null, "function_declaration": "def match_intent(message):", "function_name": "match_intent", "parameter_list": "(message)" }, { "docstring": null, "function_declaration": "def get_response(intent):", "function_name": "get_response", "parameter_list": "(intent)" }...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\n# Define a dictionary with intents and responses\nintents = {\n 'greeting': {\n 'patterns': ['Hi', 'Hello', 'Hey'],\n 'responses': ['Hello!', 'Hi, how are you...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00017593", "row_id": 17593, "seed_ids": "['Llama-3.3-70B-Instruct_44654']" }
0.477288
Filter_17593
I
[ "match_intent", "get_response", "process_message" ]
3
[ [ "process_message", "get_response" ], [ "process_message", "match_intent" ] ]
2
[]
false
[]
false
pytest
true
[]
true
74c60ace9b291ddac7008c76063976c098dea57c
f3417c410f2c7455cc937848751cd9894fc1f516
v1.0
instruct
Filter
Filter_17597_I
I'm trying to set up a program to display a list of items with prices and then allow the user to add items to the inventory, remove items, and update the price. The program should store the data in a CSV file named "inventory.csv".
import csv CSV_FILE = "inventory.csv" def read_inventory(): """ Reads the inventory from the CSV file and returns it as a dictionary. """ inventory = {} try: with open(CSV_FILE, mode='r') as file: reader = csv.DictReader(file) for row in reader: inve...
from solution import read_inventory, write_inventory, add_item, remove_item, update_price def test_add_item(): add_item("apple", 1.00) inventory = read_inventory() assert inventory["apple"] == 1.00 remove_item("apple") # Cleanup def test_remove_item(): add_item("banana", 0.50) remove_item("ba...
[ { "docstring": "Reads the inventory from the CSV file and returns it as a dictionary.", "function_declaration": "def read_inventory():", "function_name": "read_inventory", "parameter_list": "()" }, { "docstring": "Writes the inventory dictionary to the CSV file.", "function_declaration":...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import csv\n\nCSV_FILE = \"inventory.csv\"\n\ndef read_inventory():\n \"\"\"\n Reads the inventory from the CSV file and returns it as a dictionary.\n \"\"\"\n inventory = {}\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00017597", "row_id": 17597, "seed_ids": "['Llama-3.3-70B-Instruct_44663']" }
0.450148
Filter_17597
I
[ "read_inventory", "write_inventory", "add_item", "remove_item", "update_price" ]
5
[ [ "add_item", "read_inventory" ], [ "add_item", "write_inventory" ], [ "remove_item", "read_inventory" ], [ "remove_item", "write_inventory" ], [ "update_price", "read_inventory" ], [ "update_price", "write_inventory" ] ]
6
[]
false
[]
false
pytest
true
[]
true
be1176a7d67c4b8766a501508bb6395349f3b10e
1d58e01946dbe2067d4d1b65743d6a8167ddd94d
v1.0
instruct
Filter
Filter_17611_I
Here's a problem I'm working on: I need to implement a system that can take in a list of scheduled events, sort them by date, and then generate a schedule. The schedule should include the date, time, and a brief description of the event. The events are represented as instances of a custom Event class. Here's what I...
from datetime import datetime class Event: def __init__(self, date, time, description): self.date = datetime.strptime(date, "%Y-%m-%d").date() self.time = datetime.strptime(time, "%H:%M").time() self.description = description def schedule_events(events): events.sort(key=lambda x: (x.da...
from datetime import datetime from solution import Event, schedule_events, generate_schedule def test_event_creation(): event = Event("2023-10-01", "14:00", "Doctor's appointment") assert event.date == datetime.strptime("2023-10-01", "%Y-%m-%d").date() assert event.time == datetime.strptime("14:00", "%H:%M...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from datetime import datetime\n\nclass Event:\n def __init__(self, date, time, description):\n self.date = datetime.strptime(date, \"%Y-%m-%d\").date()\n self.time = datetime....
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017611", "row_id": 17611, "seed_ids": "['Llama-3.3-70B-Instruct_44692']" }
0.553087
Filter_17611
I
[ "schedule_events", "generate_schedule" ]
2
[ [ "generate_schedule", "schedule_events" ] ]
1
[]
false
[ "Event" ]
true
pytest
true
[]
true
d65c0ccc044d1cc740c0ca8f02eb953271915796
a93ec275fb6a43ba9e350aa1e9709ef391ebe8a4
v1.0
instruct
Filter
Filter_17612_I
Hello! I'm trying to solve a problem where I need to find the closest pair of cities to each other, given a dictionary with city names as keys and their corresponding latitude and longitude coordinates as values. Here's what I have so far: ``` import math def distance(city1, city2): # Radius of the Earth in kilom...
import math def distance(city1, city2): """ Calculates the Haversine distance between two cities given their coordinates (latitude and longitude). """ R = 6371.0 # Radius of the Earth in kilometers # Coordinates lat1, lon1 = city1['lat'], city1['lon'] lat2, lon2 = city2['lat'], city2['lon...
from solution import distance, closest_cities def test_distance(): city1 = {'lat': 40.7128, 'lon': -74.0060} # New York city2 = {'lat': 41.8781, 'lon': -87.6298} # Chicago assert abs(distance(city1, city2) - 1144.291) < 1 # Distance should be close to ~1144 km def test_closest_cities(): city_dict =...
[ { "docstring": "Calculates the Haversine distance between two cities given their coordinates (latitude and longitude).", "function_declaration": "def distance(city1, city2):", "function_name": "distance", "parameter_list": "(city1, city2)" }, { "docstring": "Finds the closest pair of cities ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef distance(city1, city2):\n \"\"\"\n Calculate the haversine distance between two cities.\n Each city should be a dictionary with keys 'lat' and 'lon'.\n \"\"\"\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00017612", "row_id": 17612, "seed_ids": "['Llama-3.3-70B-Instruct_44693']" }
0.673656
Filter_17612
I
[ "distance", "closest_cities" ]
2
[ [ "closest_cities", "distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d54e4fcfd7e3acd8a322b04da676b583fdd672c9
6fcbf3ecd79298e238380d16d42aa8b12f38f858
v1.0
instruct
Filter
Filter_17664_I
Ok, I need to test a car's GPS system. Throughout the day, it will make requests to the server to get the location and status of a vehicle. The server will respond with the location and status of the vehicle. The server's response will be in the form of a JSON object, which will have the following structure: ``` { "l...
import json import random def generate_server_response(lat, long, status): """ Generates a JSON object representing the server response with location and status. """ response = { "location": { "lat": lat, "long": long }, "status": status } return ...
from solution import generate_server_response, generate_random_coordinates, simulate_response_for_cities import json def test_generate_server_response(): response = generate_server_response(45.5236, -122.6750, "available") response_dict = json.loads(response) assert response_dict["location"]["lat"] == 45.5...
[ { "docstring": "Generates a JSON object representing the server response with location and status.", "function_declaration": "def generate_server_response(lat, long, status):", "function_name": "generate_server_response", "parameter_list": "(lat, long, status)" }, { "docstring": "Generates r...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import json\nimport random\n\ndef get_server_response(lat, long, status):\n \"\"\"\n Returns a simulated server response with given latitude, longitude and status.\n \"\"\"\n respo...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017664", "row_id": 17664, "seed_ids": "['Llama-3.3-70B-Instruct_44827']" }
0.501885
Filter_17664
I
[ "generate_server_response", "generate_random_coordinates", "simulate_response_for_cities" ]
3
[ [ "simulate_response_for_cities", "generate_server_response" ] ]
1
[]
false
[]
false
pytest
true
[]
true
479e42d2b593ad64ef93d3f13db443f3f0529122
9f7100078ac17e7ec1d2d466452184f60b2cf21c
v1.0
instruct
Filter
Filter_17667_I
Here is the Python list: ``` [{"name": "John", "age": 30}, {"name": "Alice", "age": 25}, {"name": "Bob", "age": 40}, {"name": "Eve", "age": 35}] ``` I need a function to find all people who are older than 30. Here is what I came up with: ``` def find_older_than_30(people_list): result = [] for person in peop...
def is_valid_age(person): return "age" in person and isinstance(person["age"], (int, float)) def find_older_than_30(people_list): return [person for person in people_list if is_valid_age(person) and person["age"] > 30]
def test_find_older_than_30_valid_input(): people_list = [ {"name": "John", "age": 30}, {"name": "Alice", "age": 25}, {"name": "Bob", "age": 40}, {"name": "Eve", "age": 35} ] expected_output = [ {"name": "Bob", "age": 40}, {"name": "Eve", "age": 35} ] ...
[ { "docstring": null, "function_declaration": "def is_valid_age(person):", "function_name": "is_valid_age", "parameter_list": "(person)" }, { "docstring": null, "function_declaration": "def find_older_than_30(people_list):", "function_name": "find_older_than_30", "parameter_list":...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class Person:\n def __init__(self, name, age):\n self.name = name\n self.age = age\n\n def is_older_than_30(self):\n return self.age > 30\n\ndef find_older_than_30(p...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017667", "row_id": 17667, "seed_ids": "['Llama-3.3-70B-Instruct_44831']" }
0.585167
Filter_17667
I
[ "is_valid_age", "find_older_than_30" ]
2
[ [ "find_older_than_30", "is_valid_age" ] ]
1
[]
false
[]
false
pytest
false
[]
true
07dc0104ee8a792e10c4e668388bcc0c97e18fa9
7446553960f89c962a634978b8bf42f5742bb844
v1.0
instruct
Filter
Filter_17675_I
I have a feature in my game where I can "attend" a location. Locations are implemented as dictionaries with the following keys: - `identifier`: an unique identifier for the location - `name`: the name of the location - `description`: a short description of the location - `items`: a list of items that can be found at t...
def attend(location, player): """ Player attends a location, receiving details about it. Args: location (dict): The location the player is attending. player (Player): The player attending the location. """ print(f"You have arrived at the {location['name']}.") print(location['des...
from solution import attend, get_location def test_attend_with_items_and_npcs(capfd): location = { 'identifier': 'loc1', 'name': 'Old Library', 'description': 'A quiet place full of dusty books.', 'items': ['Ancient Book', 'Mystical Key'], 'exits': {'north': 'loc2', 'east': ...
[ { "docstring": "Player attends a location, receiving details about it.\n\nArgs:\n location (dict): The location the player is attending.\n player (Player): The player attending the location.", "function_declaration": "def attend(location, player):", "function_name": "attend", "parameter_list":...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def attend(location, player):\n \"\"\"\n Attend a location in the game. This function takes a location\n dictionary and a player dictionary, and prints information about\n the loca...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00017675", "row_id": 17675, "seed_ids": "['Llama-3.3-70B-Instruct_44846']" }
0.510972
Filter_17675
I
[ "attend", "get_location" ]
2
[ [ "attend", "get_location" ] ]
1
[]
false
[]
false
pytest
true
[]
true
925a9d59c074ab4affe94a8b3987e0198537d95f
820276c5ce1c1120095f9f4f74602192eace073f
v1.0
instruct
Filter
Filter_17689_I
You have been tasked with writing a Python function to process a list of positive integers. The function should return a new list containing only the prime numbers from the input list. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
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 filter_primes(numbers): """ Returns a list of prime numbers from the input list...
from solution import is_prime, filter_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(1) == False def test_filter_primes(): assert filter_primes([2, 3, 4, ...
[ { "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 a list of prime numbers from the input list of positive integers.", "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 is_prime(n):\n \"\"\"\n Returns True if n is a prime number, else False.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n % ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00017689", "row_id": 17689, "seed_ids": "['Llama-3.3-70B-Instruct_44879']" }
0.712321
Filter_17689
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
92577e7ea6397c91991285134e128000dfd15e7b
0bb94fbc237fc441d1afc8101c46b1f3594e771d
v1.0
instruct
Filter
Filter_17691_I
### Developer Story As a developer, I have a task to create a program that reads all numbers from a given CSV file and store them in a list, then calculates the sum, mean, and standard deviation of these numbers. I will use Python as the programming language.
import csv import math def read_numbers_from_csv(file_path): numbers = [] with open(file_path, mode='r') as file: csv_reader = csv.reader(file) for row in csv_reader: for value in row: try: numbers.append(float(value)) except Value...
def test_read_numbers_from_csv(tmp_path): d = tmp_path / "sub" d.mkdir() p = d / "numbers.csv" p.write_text("1.0, 2.0, 3.0\n4.0, 5.0, 6.0") from solution import read_numbers_from_csv numbers = read_numbers_from_csv(str(p)) assert numbers == [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] def test_...
[ { "docstring": null, "function_declaration": "def read_numbers_from_csv(file_path):", "function_name": "read_numbers_from_csv", "parameter_list": "(file_path)" }, { "docstring": null, "function_declaration": "def calculate_sum(numbers):", "function_name": "calculate_sum", "parame...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import csv\nimport math\n\ndef read_numbers_from_csv(file_path):\n \"\"\"\n Reads all numbers from the given CSV file and returns them as a list.\n \"\"\"\n numbers = []\n with ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017691", "row_id": 17691, "seed_ids": "['Llama-3.3-70B-Instruct_44881']" }
0.644905
Filter_17691
I
[ "read_numbers_from_csv", "calculate_sum", "calculate_mean", "calculate_standard_deviation" ]
4
[ [ "calculate_standard_deviation", "calculate_mean" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b2ee3f3fdb753dedcbcccb86864dc32a608bb8a7
a0b0a41a8caaaf549594c7c5592057968cc963fb
v1.0
instruct
Filter
Filter_17694_I
### Creating a Program to Read and Write Files #### Overview The following is an example of a Python program that reads from a file and writes to a file: ```python # read_write_file.py def read_file(file_path): """Reads the content of a file.""" try: with open(file_path, 'r') as file: conte...
import argparse import os VALID_EXTENSIONS = ['.txt', '.log', '.csv'] def validate_file_path(file_path): """Validates that the file path is not empty and has a valid extension.""" if not file_path or not os.path.splitext(file_path)[1] in VALID_EXTENSIONS: raise ValueError("Invalid file path or extensi...
import os import pytest from solution import read_file, write_file, append_file, create_file_with_content, validate_file_path @pytest.fixture def sample_file(): file_path = 'test.txt' with open(file_path, 'w') as f: f.write('Initial Content') yield file_path os.remove(file_path) def test_valid...
[ { "docstring": "Validates that the file path is not empty and has a valid extension.", "function_declaration": "def validate_file_path(file_path):", "function_name": "validate_file_path", "parameter_list": "(file_path)" }, { "docstring": "Reads the content of a file.", "function_declarat...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import argparse\nimport os\n\nVALID_EXTENSIONS = ['.txt', '.log', '.csv']\n\ndef validate_file_path(file_path):\n \"\"\"Validates that the file path is not empty and has a valid extension.\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00017694", "row_id": 17694, "seed_ids": "['Llama-3.3-70B-Instruct_44885']" }
0.545381
Filter_17694
I
[ "validate_file_path", "read_file", "write_file", "append_file", "create_file_with_content", "main" ]
6
[ [ "append_file", "write_file" ], [ "create_file_with_content", "write_file" ], [ "read_file", "validate_file_path" ], [ "write_file", "validate_file_path" ] ]
4
[]
false
[]
false
pytest
true
[]
true
2b0085302d41a8095b534d4ac8ae7872c0cbbf69
bff289523883b65dd02f7d8c77111e8daddbf6d6
v1.0
instruct
Filter
Filter_17707_I
I'm looking for a way to create a rough outline of a robot's design. Is there a way to use Python to create a simple 3D model of a robot using a graphical user interface (GUI)?
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d.art3d import Poly3DCollection def create_robot(): fig = plt.figure() ax = fig.add_subplot(111, projection='3d') # Define vertices for each part of the robot # Body vertices body_vertices = np.array([[-1, -1, -2],...
import pytest from solution import create_robot, draw_part def test_create_robot(): # This test will create a robot 3D model using matplotlib # This test is visual and manual. Check if the plot displays correctly with 4 parts. create_robot() # We cannot directly check the pyplot output in automated tes...
[ { "docstring": null, "function_declaration": "def create_robot():", "function_name": "create_robot", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def draw_part(ax, vertices):", "function_name": "draw_part", "parameter_list": "(ax, vertices)" } ]
[ 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\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d.art3d import Poly3DCollection\n\ndef create_robot():\n fig = plt.figure()\n ax = fig.add_subplot(111, proje...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00017707", "row_id": 17707, "seed_ids": "['Llama-3.3-70B-Instruct_44914']" }
0.271113
Filter_17707
I
[ "create_robot", "draw_part" ]
2
[ [ "create_robot", "draw_part" ] ]
1
[]
false
[]
false
pytest
true
[ "matplotlib", "mpl_toolkits", "numpy" ]
false
02cf7e431da2b2f3c579a565f6baf7887933b254
e346656b278e7df525e1cbb14b4aa812cadeeae4
v1.0
instruct
Filter
Filter_17716_I
I would like to create an ASCII art image of a cat, but I'm not sure how to get started. Can you guide me on the steps to create an ASCII art cat? Also, I would like to add some movement and life to the cat image. Is it possible to create an ASCII art animation of a cat? Finally, please provide some examples of sim...
import time import os def clear_console(): """ Clears the console for a new frame in the animation. """ os.system('cls' if os.name == 'nt' else 'clear') def print_cat_frame(frame_num): """ Prints the cat frame based on the frame number. """ frames = [ """ /\\_/\\ ...
def test_clear_console(): """ Test the clear_console function by checking if the command to clear the console was executed. Since it's a side-effect function, we check for exceptions. """ try: clear_console() except Exception as e: assert False, f"clear_console() raised an except...
[ { "docstring": "Clears the console for a new frame in the animation.", "function_declaration": "def clear_console():", "function_name": "clear_console", "parameter_list": "()" }, { "docstring": "Prints the cat frame based on the frame number.", "function_declaration": "def print_cat_fram...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import time\nimport os\n\ndef clear_screen():\n \"\"\"Helper function to clear the console screen.\"\"\"\n os.system('cls' if os.name == 'nt' else 'clear')\n\ndef print_frame(frame):\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00017716", "row_id": 17716, "seed_ids": "['Llama-3.3-70B-Instruct_44935']" }
0.412961
Filter_17716
I
[ "clear_console", "print_cat_frame", "cat_animation" ]
3
[ [ "cat_animation", "clear_console" ], [ "cat_animation", "print_cat_frame" ] ]
2
[]
false
[]
false
pytest
false
[]
true
73647cfb270f75cb041ccf70db978fa7ac3066d7
5649f808eeff46bad9c65be0f70cae41b25de428
v1.0
instruct
Filter
Filter_17749_I
Here are 2 functions, `f1` and `f2`: ```python def f1(n): return n + 1 def f2(n): return n - 2 ``` I'd like to create a decorator that takes a function `f` as input and returns a new function that applies `f1` and `f2` to the result of `f` **in this specific order**. This new function should also take 3 addi...
def f1(n): return n + 1 def f2(n): return n - 2 def my_decorator(func): def wrapper(a, b, x, y, z): result = func(a, b) result = f1(result) result = f2(result) return result return wrapper @my_decorator def f(a, b): return a + b
from solution import f def test_f_basic(): assert f(1, 2, 3, 4, 5) == 2 # (1 + 2) + 1 - 2 = 2 def test_f_negative(): assert f(-1, -2, 3, 4, 5) == -4 # (-1 + -2) + 1 - 2 = -4 def test_f_zero_and_positive(): assert f(0, 5, 3, 4, 5) == 4 # (0 + 5) + 1 - 2 = 4 def test_f_all_zero(): assert f(0, 0, 3,...
[ { "docstring": null, "function_declaration": "def f1(n):", "function_name": "f1", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def f2(n):", "function_name": "f2", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def f1(n):\n return n + 1\n\ndef f2(n):\n return n - 2\n\ndef my_decorator(f):\n def wrapper(a, b, x, y, z):\n result = f(a, b)\n result = f1(result)\n result = f...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00017749", "row_id": 17749, "seed_ids": "['Llama-3.3-70B-Instruct_45027']" }
0.471298
Filter_17749
I
[ "f1", "f2", "my_decorator", "f" ]
4
[ [ "my_decorator", "f1" ], [ "my_decorator", "f2" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a30cd38d029bac92a1a61a8c2a3a36cef8ea4b4f
f8f1923300c398739813f72d6b3f5cbe2b28db48
v1.0
instruct
Filter
Filter_17787_I
I have two vectors `a` and `b` of the same length `n` and I want to create a new vector `c` such that the i-th element of `c` is the result of a custom operation between the i-th elements of `a` and `b`. I am allowed to use any Python library. Can you show me how to vectorize such operations using the `numpy` library...
import numpy as np def custom_operation(a, b): """ Applies a custom operation element-wise to two vectors a and b. """ return a + b # This is an example, replace with any custom operation needed def vectorize_custom_operation(a, b): """ Vectorizes the custom operation using numpy. Args: ...
from solution import vectorize_custom_operation import numpy as np def test_vectorize_custom_operation_addition(): a = [1, 2, 3] b = [4, 5, 6] result = vectorize_custom_operation(a, b) expected = np.array([5, 7, 9]) assert np.array_equal(result, expected) def test_vectorize_custom_operation_with_z...
[ { "docstring": "Applies a custom operation element-wise to two vectors a and b.", "function_declaration": "def custom_operation(a, b):", "function_name": "custom_operation", "parameter_list": "(a, b)" }, { "docstring": "Vectorizes the custom operation using numpy.\n\nArgs:\na (np.ndarray): F...
[ 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\n\ndef vector_custom_operation(a, b, operation):\n \"\"\"\n Perform a custom operation element-wise on two vectors a and b using numpy.\n \n Parameters:\n a (...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017787", "row_id": 17787, "seed_ids": "['Llama-3.3-70B-Instruct_45111']" }
0.47169
Filter_17787
I
[ "custom_operation", "vectorize_custom_operation" ]
2
[ [ "vectorize_custom_operation", "custom_operation" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
1df7143fb80a7989c2b4569428578d7bcd9b9f8e
a5451dbde328ae2491795684145a4dd41f56dfe9
v1.0
instruct
Filter
Filter_17810_I
How do I get the send_email method to send an email using a template that was saved on my local disk, and specify the send_email method to load the template from a local file path?
import smtplib from email.mime.text import MIMEText def load_template(file_path): """ Loads the email template from the given file path. """ with open(file_path, 'r') as file: return file.read() def send_email(subject, recipient, template_path, **kwargs): """ Sends an email using the s...
from solution import load_template, send_email def test_load_template(tmp_path): # Create a temporary email template file template_content = "Dear {name},\n\nThis is a test email." template_path = tmp_path / "template.txt" template_path.write_text(template_content) # Load the template using th...
[ { "docstring": "Loads the email template from the given file path.", "function_declaration": "def load_template(file_path):", "function_name": "load_template", "parameter_list": "(file_path)" }, { "docstring": "Sends an email using the specified template located at the given file path.\n\nAr...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import smtplib\nfrom email.mime.text import MIMEText\nfrom email.mime.multipart import MIMEMultipart\n\ndef load_template(template_path):\n \"\"\"\n Load email template from a file.\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017810", "row_id": 17810, "seed_ids": "['Llama-3.3-70B-Instruct_45170']" }
0.556175
Filter_17810
I
[ "load_template", "send_email" ]
2
[ [ "send_email", "load_template" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8210e4654e33d019610bd954f206530e0193d761
71880a8fe7d95bccce23671c35e5abbcd9bf2024
v1.0
instruct
Filter
Filter_17813_I
You can perform at most two actions on a string: Insert a character, Delete a character, or Replace a character. Given two strings, write a function to check if they are one or zero edits away. Here is an example: Input: first = "pale" second = "ple" Output: True Input: first = "paling" second = "pang" Output: False ...
def oneAway(first, second): if len(first) == len(second): return oneEditReplace(first, second) elif len(first) + 1 == len(second): return oneEditInsert(first, second) elif len(second) + 1 == len(first): return oneEditInsert(second, first) return False def oneEditReplace(first, s...
def test_one_away(): assert oneAway("pale", "ple") == True assert oneAway("pales", "pale") == True assert oneAway("pale", "bale") == True assert oneAway("pale", "bake") == False assert oneAway("pale", "pall") == True assert oneAway("paling", "pang") == False assert oneAway("pal", "pale") == ...
[ { "docstring": null, "function_declaration": "def oneAway(first, second):", "function_name": "oneAway", "parameter_list": "(first, second)" }, { "docstring": null, "function_declaration": "def oneEditReplace(first, second):", "function_name": "oneEditReplace", "parameter_list": "...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def oneAway(first, second):\n if len(first) == len(second):\n return oneEditReplace(first, second)\n elif len(first) + 1 == len(second):\n return oneEditInsert(first, secon...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00017813", "row_id": 17813, "seed_ids": "['Llama-3.3-70B-Instruct_45174']" }
0.577075
Filter_17813
I
[ "oneAway", "oneEditReplace", "oneEditInsert" ]
3
[ [ "oneAway", "oneEditInsert" ], [ "oneAway", "oneEditReplace" ] ]
2
[]
false
[]
false
pytest
false
[]
true
f7bcf90f724934dedaeebf2979c2eb774c2c4861
f7837e6524ce9b697d139613d55ae85f7cacbf2a
v1.0
instruct
Filter
Filter_17829_I
Here is a list of the first 20 prime numbers: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71 Write a Python program that will take a given integer n and find the nth prime number. Example: input: 5 output: 11 input: 8 output: 19 Here is a basic function that checks whether a number...
def is_prime(num): if num < 2: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True def nth_prime(n): if n <= 0: raise ValueError("n must be a po...
from solution import nth_prime def test_nth_prime_fifth(): assert nth_prime(5) == 11 def test_nth_prime_eighth(): assert nth_prime(8) == 19 def test_nth_prime_first(): assert nth_prime(1) == 2 def test_nth_prime_twentieth(): assert nth_prime(20) == 71 def test_nth_prime_invalid_input(): try: ...
[ { "docstring": null, "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": null, "function_declaration": "def nth_prime(n):", "function_name": "nth_prime", "parameter_list": "(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(num):\n if num < 2:\n return False\n if num == 2:\n return True\n if num % 2 == 0:\n return False\n for i in range(3, int(num**0.5) + 1, 2):\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00017829", "row_id": 17829, "seed_ids": "['Llama-3.3-70B-Instruct_45212']" }
0.729011
Filter_17829
I
[ "is_prime", "nth_prime" ]
2
[ [ "nth_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b14e5b43d329c64ceb7869d2573298407537a568
2215ffadc402389ecdc5b4187dc9b1e83b49b936
v1.0
instruct
Filter
Filter_17837_I
I want to create a method that receives an array of strings and returns the string that has the highest number of vowels and no numerals. Can someone help me with example code?
def count_vowels(s): """ Counts the number of vowels in a given string. Parameters: s (str): The input string. Returns: int: The count of vowels in the input string. """ vowels = 'aeiouAEIOU' return sum(1 for char in s if char in vowels) def string_with_most_vowels(strings...
from solution import string_with_most_vowels def test_string_with_most_vowels(): assert string_with_most_vowels(["hello", "world", "aeiou", "123", "bcdfg"]) == "aeiou" assert string_with_most_vowels(["HELLO", "WORLD", "AEIOU", "12345", "PYTHON"]) == "AEIOU" assert string_with_most_vowels(["This", "is", "a"...
[ { "docstring": "Counts the number of vowels in a given string.\n\nParameters:\ns (str): The input string.\n\nReturns:\nint: The count of vowels in the input string.", "function_declaration": "def count_vowels(s):", "function_name": "count_vowels", "parameter_list": "(s)" }, { "docstring": "R...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def string_with_most_vowels_no_numerals(strings):\n \"\"\"\n Returns the string with the highest number of vowels and no numerals.\n \n Parameters:\n strings (list of str): List...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017837", "row_id": 17837, "seed_ids": "['Llama-3.3-70B-Instruct_45223']" }
0.592847
Filter_17837
I
[ "count_vowels", "string_with_most_vowels" ]
2
[ [ "string_with_most_vowels", "count_vowels" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f459daf6f3f73c500c51618bd49e46afd9ec7033
10aa3101964f0861be76c4c30de0a1a542562255
v1.0
instruct
Filter
Filter_17845_I
I've tried to implement a generator that produces prime numbers using memoization. Here's the code I've written: ```python def is_prime(n): """Check if a number is prime""" if n < 2: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True d...
def is_prime(n): """Check if a number is prime""" if n < 2: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True def prime_generator(): """Generator for prime numbers""" n = 2 while True: if is_prime(n): y...
from solution import is_prime, prime_generator def test_is_prime(): assert not is_prime(0) assert not is_prime(1) assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert not is_prime(9) assert is_prime(11) def test_prime_generator(): gen = prime_gener...
[ { "docstring": "Check if a number is prime", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generator for prime numbers", "function_declaration": "def prime_generator():", "function_name": "prime_generator", "pa...
[ 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 \"\"\"Check if a number is prime\"\"\"\n if n < 2:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n return False\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00017845", "row_id": 17845, "seed_ids": "['Llama-3.3-70B-Instruct_45244']" }
0.518951
Filter_17845
I
[ "is_prime", "prime_generator" ]
2
[ [ "prime_generator", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fa7d1730a12651f798394838176634b3c93e708b
6459106832aa2207c2e30f0c5178db65c3088494
v1.0
instruct
Filter
Filter_17860_I
You have a Python function `normalize` that takes a string as input and returns a normalized version of the string. The implementation of the `normalize` function is as follows: ```python def normalize(s): return s.replace(" ", "").lower() ``` This function removes all spaces from the input string and converts it t...
def normalize(s): return s.replace(" ", "").lower() def match_string(s1, s2): """ Returns True if the normalized versions of s1 and s2 are equal, otherwise False. """ return normalize(s1) == normalize(s2) # Example usage print(match_string("Hello World", "hello world")) # This should return True
from solution import match_string def test_match_string_identical(): assert match_string("Hello World", "Hello World") == True def test_match_string_case_insensitive(): assert match_string("Hello World", "hello world") == True def test_match_string_spaces_removed(): assert match_string("Hello World", "he...
[ { "docstring": null, "function_declaration": "def normalize(s):", "function_name": "normalize", "parameter_list": "(s)" }, { "docstring": "Returns True if the normalized versions of s1 and s2 are equal, otherwise False.", "function_declaration": "def match_string(s1, s2):", "function...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def normalize(s):\n return s.replace(\" \", \"\").lower()\n\ndef match_string(s1, s2):\n \"\"\"\n Returns True if the normalized versions of s1 and s2 are equal, else False.\n \"\"...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017860", "row_id": 17860, "seed_ids": "['Llama-3.3-70B-Instruct_45270']" }
0.710082
Filter_17860
I
[ "normalize", "match_string" ]
2
[ [ "match_string", "normalize" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0d4b413351c3caea10ac8e5331e26bade48979a4
c7f6dcfa4edc936227e6babf926d0b1593822ade
v1.0
instruct
Filter
Filter_17866_I
Testing related to BCD (Binary Coded Decimal) numbers, specifically: - Is a given number a valid BCD number? - Is a given number of the form "aBcD" or "abC" where a, b, c and d are BCD numbers? - Generate sample BCD numbers I'd like to answer these in Python, and would like to see example tests (unit tests) for these...
def is_valid_bcd(bcd_str): """ Check if a given string represents a valid BCD number. """ if len(bcd_str) % 4 != 0: return False for i in range(0, len(bcd_str), 4): digit = bcd_str[i:i+4] if int(digit, 2) > 9: return False return True def check_form_abcd_or_a...
from solution import is_valid_bcd, check_form_abcd_or_abc, generate_sample_bcd_numbers def test_is_valid_bcd(): assert is_valid_bcd('0000') == True assert is_valid_bcd('1001') == True assert is_valid_bcd('1010') == False # 1010 (10 in decimal) is not a valid BCD digit assert is_valid_bcd('00000') == F...
[ { "docstring": "Check if a given string represents a valid BCD number.", "function_declaration": "def is_valid_bcd(bcd_str):", "function_name": "is_valid_bcd", "parameter_list": "(bcd_str)" }, { "docstring": "Check if a given string is of the form 'aBcD' or 'abC' where a, b, c, d are valid B...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_bcd_digit(binary_str):\n \"\"\"\n Checks if a given 4-bit binary string is a valid BCD digit.\n A valid BCD digit is between '0000' (0) and '1001' (9).\n \"\"\"\n if len(...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017866", "row_id": 17866, "seed_ids": "['Llama-3.3-70B-Instruct_45292']" }
0.569073
Filter_17866
I
[ "is_valid_bcd", "check_form_abcd_or_abc", "generate_sample_bcd_numbers" ]
3
[ [ "check_form_abcd_or_abc", "is_valid_bcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0f6fe2d92b365c8ebc2dcb976134cd0118dbca4b
bab14c433872c9afefcbd916487c90a0fd474e81
v1.0
instruct
Filter
Filter_17909_I
I need to write a program that will collect data from an analog sensor that is connected to my Raspberry Pi. The sensor produces a value in the range 0-1023. My program will collect data from this sensor for 10 seconds, and then calculate the mean and standard deviation of the collected data.
import time import random import math def read_sensor(): """ Simulate reading a value from an analog sensor connected to a Raspberry Pi. The sensor produces a value in the range 0-1023. """ return random.randint(0, 1023) def collect_sensor_data(duration=10): """ Collect data from the senso...
from solution import calculate_mean, calculate_standard_deviation def test_calculate_mean(): data = [1, 2, 3, 4, 5] expected_mean = 3.0 assert calculate_mean(data) == expected_mean def test_calculate_standard_deviation(): data = [1, 2, 3, 4, 5] mean = calculate_mean(data) expected_std_dev = ma...
[ { "docstring": "Simulate reading a value from an analog sensor connected to a Raspberry Pi.\nThe sensor produces a value in the range 0-1023.", "function_declaration": "def read_sensor():", "function_name": "read_sensor", "parameter_list": "()" }, { "docstring": "Collect data from the sensor...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import time\nimport random\nimport statistics\n\ndef read_sensor():\n \"\"\"\n Simulate reading from an analog sensor. This function should return\n an integer value between 0 and 102...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00017909", "row_id": 17909, "seed_ids": "['Llama-3.3-70B-Instruct_45387']" }
0.529386
Filter_17909
I
[ "read_sensor", "collect_sensor_data", "calculate_mean", "calculate_standard_deviation", "main" ]
5
[ [ "collect_sensor_data", "read_sensor" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4615915368aec7596490e0e971a717c8088cda8f
a1bbf63a9bfc89ea52e8eefe6833778ff07d5219
v1.0
instruct
Filter
Filter_17940_I
I have a dict in Python with the following structure: `{str: Collection[Order]}` where `Order` is a custom class. How do I sort this dictionary by the total price of the orders in each collection?
from typing import List, Dict, Collection class Order: def __init__(self, price: float): self.price = price def get_total_price(orders: Collection[Order]) -> float: """ Returns the total price of all orders in the collection. """ return sum(order.price for order in orders) def sort_dict_b...
from solution import Order, get_total_price, sort_dict_by_total_price def test_get_total_price(): orders = [Order(10), Order(15), Order(5)] assert get_total_price(orders) == 30 def test_sort_dict_by_total_price(): orders_a = [Order(10), Order(15)] orders_b = [Order(5), Order(5)] orders_c = [Order(...
[]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import Collection\n\nclass Order:\n def __init__(self, price):\n self.price = price\n\ndef sort_dict_by_total_price(order_dict: dict[str, Collection[Order]]):\n \"\"\"...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00017940", "row_id": 17940, "seed_ids": "['Llama-3.3-70B-Instruct_45464']" }
0.611205
Filter_17940
I
[ "get_total_price", "sort_dict_by_total_price" ]
2
[ [ "sort_dict_by_total_price", "get_total_price" ] ]
1
[]
false
[ "Order" ]
true
pytest
true
[]
true
cb5faf52328d16dd041274164f5a5fac4e11323e
6f4b191f1e3889c8bc2f876dc0813d30183fafed
v1.0
instruct
Filter
Filter_18005_I
### Task 1: URL Shortener Service #### Problem Description: Create a URL shortener service. The service should have the following functionalities: - Receive a long URL as input and generate a unique shortened URL. - When a user accesses the shortened URL, the service should redirect them to the original long URL. - The...
from fastapi import FastAPI, HTTPException from pydantic import BaseModel import sqlite3 import uuid app = FastAPI() class URL(BaseModel): original_url: str # Create a connection to the SQLite database def create_connection(): conn = None try: conn = sqlite3.connect('url_shortener.db') re...
import pytest from fastapi.testclient import TestClient from solution import app, create_connection, create_table, insert_url client = TestClient(app) def setup_module(module): # Create tables before running tests conn = create_connection() create_table(conn) conn.close() def teardown_module(module):...
[]
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from fastapi import FastAPI, HTTPException\nfrom pydantic import BaseModel\nimport sqlite3\nimport uuid\n\napp = FastAPI()\n\nclass URL(BaseModel):\n original_url: str\n\n# Create a connect...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00018005", "row_id": 18005, "seed_ids": "['Llama-3.3-70B-Instruct_45616']" }
0.459308
Filter_18005
I
[ "create_connection", "create_table", "generate_shortened_url", "insert_url", "fetch_url", "startup", "shorten_url", "redirect_to_url" ]
8
[ [ "redirect_to_url", "create_connection" ], [ "redirect_to_url", "fetch_url" ], [ "shorten_url", "create_connection" ], [ "shorten_url", "generate_shortened_url" ], [ "shorten_url", "insert_url" ], [ "startup", "create_connection" ], [ "sta...
7
[]
false
[ "URL" ]
true
pytest
true
[ "fastapi", "pydantic" ]
false
eed4112298eb5399aaa1b72cb94b76212be05cbd
100ce28007fa6e4c62a8a1548105d6f0767c9b5a
v1.0
instruct
Filter
Filter_18039_I
Here is the code for a Caesar Cipher: ```python def caesar_cipher(text, shift): alphabet = 'abcdefghijklmnopqrstuvwxyz' shifted_text = "" for char in text: if char.isalpha(): index = alphabet.index(char.lower()) shifted_index = (index + shift) % 26 if char.isupper...
def caesar_decipher(text, shift): """ Decrypts the given text using a Caesar Cipher with the specified shift. """ return caesar_cipher(text, -shift) def caesar_cipher(text, shift): alphabet = 'abcdefghijklmnopqrstuvwxyz' shifted_text = "" for char in text: if char.isalpha(): ...
from solution import caesar_cipher, caesar_decipher def test_caesar_cipher(): assert caesar_cipher("Hello, World!", 5) == "Mjqqt, Btwqi!" assert caesar_cipher("abc", 2) == "cde" assert caesar_cipher("xyz", 3) == "abc" def test_caesar_decipher(): assert caesar_decipher("Mjqqt, Btwqi!", 5) == "Hello, Wo...
[ { "docstring": "Decrypts the given text using a Caesar Cipher with the specified shift.", "function_declaration": "def caesar_decipher(text, shift):", "function_name": "caesar_decipher", "parameter_list": "(text, shift)" }, { "docstring": null, "function_declaration": "def caesar_cipher(...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def caesar_cipher(text, shift):\n \"\"\"\n Encrypts the given text using Caesar Cipher with the given shift.\n \"\"\"\n alphabet = 'abcdefghijklmnopqrstuvwxyz'\n shifted_text = ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00018039", "row_id": 18039, "seed_ids": "['Llama-3.3-70B-Instruct_45728']" }
0.6658
Filter_18039
I
[ "caesar_decipher", "caesar_cipher" ]
2
[ [ "caesar_decipher", "caesar_cipher" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6bb4951e0dddf9a4ca7fddde1af63dddd9277440
b0acccc2ce1675465a3aee6f53b0fa8dfd24c75b
v1.0
instruct
Filter
Filter_18049_I
In this task, you will create a simple currency converter program. The conversion rates are as follows: 1 USD = 1.34 CAD, 1 USD = 0.87 EUR, 1 USD = 1.48 HKD. Your program should allow the user to convert USD to one of the target currencies (CAD, EUR, HKD) and vice versa. Here is a sample output: ``` Currency Conve...
def convert_currency(amount, rate, to_currency): """ Converts the given amount using the specified rate and prints the result in the target currency. """ converted_amount = amount * rate if to_currency else amount / rate return converted_amount def get_conversion_rate(currency, to_usd=True): ""...
def test_conversion_rate(): assert get_conversion_rate('CAD') == 1.34 assert get_conversion_rate('EUR') == 0.87 assert get_conversion_rate('HKD') == 1.48 assert get_conversion_rate('CAD', to_usd=False) == 1 / 1.34 assert get_conversion_rate('EUR', to_usd=False) == 1 / 0.87 assert get_conversion_...
[ { "docstring": "Converts the given amount using the specified rate and prints the result in the target currency.", "function_declaration": "def convert_currency(amount, rate, to_currency):", "function_name": "convert_currency", "parameter_list": "(amount, rate, to_currency)" }, { "docstring"...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def convert_currency(choice, amount):\n conversions_from_usd = {\n 1: (\"USD\", \"CAD\", 1.34),\n 2: (\"USD\", \"EUR\", 0.87),\n 3: (\"USD\", \"HKD\", 1.48)\n }\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00018049", "row_id": 18049, "seed_ids": "['Llama-3.3-70B-Instruct_45756']" }
0.635587
Filter_18049
I
[ "convert_currency", "get_conversion_rate", "convert_from_usd", "convert_to_usd", "main" ]
5
[ [ "convert_from_usd", "convert_currency" ], [ "convert_from_usd", "get_conversion_rate" ], [ "convert_to_usd", "convert_currency" ], [ "convert_to_usd", "get_conversion_rate" ] ]
4
[]
false
[]
false
pytest
false
[]
true
2cfdda5dcabc56d668bd0df332d919efebff0585
f08a9ab4774c4f3acf1a34bd7b826ee760d0b7ea
v1.0
instruct
Filter
Filter_18077_I
You have been tasked with writing a program that analyzes a log file and extracts the key-value pairs from it. The log file contains lines in the following format: `timestamp=YYYY-MM-DDTHH:MM:SS,target=log-target,level=level,message=message-content` Example log file content: `2021-01-01T12:00:00,target=stdout,level...
import re def parse_log_line(log_line): """ Extracts key-value pairs from a log line. """ log_pattern = re.compile( r'(?P<timestamp>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}),(?P<target>target=[^,]+),(?P<level>level=[^,]+),(?P<message>message=.*)' ) match = log_pattern.match(log_line) if ...
def test_parse_log_line(): log_line = "2021-01-01T12:00:00,target=stdout,level=INFO,message=This is an info message" expected_result = { 'timestamp': '2021-01-01T12:00:00', 'target': 'stdout', 'level': 'INFO', 'message': 'This is an info message' } assert parse_log_line(l...
[ { "docstring": "Extracts key-value pairs from a log line.", "function_declaration": "def parse_log_line(log_line):", "function_name": "parse_log_line", "parameter_list": "(log_line)" }, { "docstring": "Parses log file content and extracts key-value pairs for each line.", "function_declar...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef parse_log_line(line):\n \"\"\"\n Parses a log line and returns a dictionary of key-value pairs.\n \"\"\"\n log_pattern = re.compile(r\"\"\"\n timestamp=(?P<...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00018077", "row_id": 18077, "seed_ids": "['Llama-3.3-70B-Instruct_45817']" }
0.688206
Filter_18077
I
[ "parse_log_line", "parse_log_file" ]
2
[ [ "parse_log_file", "parse_log_line" ] ]
1
[]
false
[]
false
pytest
false
[]
true
c2908eefd3600a48d35db6030e4fb8a16737ee21
eca53ac9183ae24972e26d2a89ac03650c0053c3
v1.0
instruct
Filter
Filter_18078_I
1-Best Guess Code Explanation In a game of Hangman, a player makes an educated guess to a letter in a secret word. If the letter appears in the word, the game master fills in the corresponding blanks. If the letter does not appear in the word, the game master draws a part of a hangman’s gallows. The game continues unti...
import random def choose_word(word_list): """Randomly choose a word from a given list of words.""" return random.choice(word_list) def display_progress(word, guessed_letters): """Display the current progress of the guessed word with underscores for unguessed letters.""" return ''.join(letter if letter...
from solution import choose_word, display_progress, hangman def test_choose_word(): word_list = ['testing', 'game', 'hangman'] chosen_word = choose_word(word_list) assert chosen_word in word_list def test_display_progress(): assert display_progress('hangman', {'h', 'a'}) == 'ha___a_' assert displa...
[ { "docstring": "Randomly choose a word from a given list of words.", "function_declaration": "def choose_word(word_list):", "function_name": "choose_word", "parameter_list": "(word_list)" }, { "docstring": "Display the current progress of the guessed word with underscores for unguessed lette...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def hangman(secret_word, guesses):\n \"\"\"\n Simulates a game of Hangman. \n Parameters:\n - secret_word (str): The word to guess.\n - guesses (list): A list of guessed letters...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00018078", "row_id": 18078, "seed_ids": "['Llama-3.3-70B-Instruct_45818']" }
0.586464
Filter_18078
I
[ "choose_word", "display_progress", "hangman" ]
3
[ [ "hangman", "choose_word" ], [ "hangman", "display_progress" ] ]
2
[]
false
[]
false
pytest
true
[]
true
af3482bbe7ef366af8310d499f85b0a99f1a6a49
e61a979dde590b9392177355ed71c18a2afabe9f
v1.0
instruct
Filter
Filter_18085_I
I am trying to write a two-player text-based game. I have two issues with the game: 1. **Input validation for user inputs**: The players should not be able to enter anything other than the specified inputs. For example, if a player can choose between "rock," "paper," or "scissors," they should not be able to enter so...
def validate_input(prompt, valid_options): """ Prompt the user for input and validate it against the valid options. Args: prompt (str): The input prompt string. valid_options (list): A list of valid input options. Returns: str: A valid input string selected by the user. """ ...
from solution import validate_input import pytest import builtins # Mocking the input function for testing class MockInput: def __init__(self, inputs): self.inputs = inputs self.index = 0 def __call__(self, prompt): response = self.inputs[self.index] self.index += 1 ...
[ { "docstring": "Prompt the user for input and validate it against the valid options.\n\nArgs:\nprompt (str): The input prompt string.\nvalid_options (list): A list of valid input options.\n\nReturns:\nstr: A valid input string selected by the user.", "function_declaration": "def validate_input(prompt, valid...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def validate_input(choice, valid_choices):\n \"\"\"\n Validates that the input choice is one of the valid choices.\n \"\"\"\n return choice in valid_choices\n\ndef game():\n val...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00018085", "row_id": 18085, "seed_ids": "['Llama-3.3-70B-Instruct_45837']" }
0.439036
Filter_18085
I
[ "validate_input", "game" ]
2
[ [ "game", "validate_input" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ee2d16b4ec8bfdffdd9a9bd65c12e8c1e81ea080
09be08b05dc420f1edc7704794d6d26a867dade2
v1.0
instruct
Filter
Filter_18101_I
Let be 4 strings some of them potentially identical. Generate all permutations of them with 4 elements in every permutation maintaining the original order of equal elements if such exist. For example if input is (a, b, a, c) - the output must be (a, b, a, c) (a, a, b, c) is not valid because order of equal elements ...
from itertools import permutations def generate_permutations(str1, str2, str3, str4): """ Generates all valid permutations of 4 strings while maintaining the original order of identical elements. """ input_list = [str1, str2, str3, str4] all_perms = set(permutations(input_list)) valid_perm...
from solution import generate_permutations def test_generate_permutations(): str1, str2, str3, str4 = 'a', 'b', 'a', 'c' expected_permutations = { ('a', 'b', 'a', 'c'), ('a', 'b', 'c', 'a'), ('a', 'a', 'b', 'c'), ('b', 'a', 'a', 'c'), ('b', 'a', 'c', 'a'), ('a', 'c', 'a', 'b'), ('a', ...
[ { "docstring": "Generates all valid permutations of 4 strings while maintaining the original order of identical elements.", "function_declaration": "def generate_permutations(str1, str2, str3, str4):", "function_name": "generate_permutations", "parameter_list": "(str1, str2, str3, str4)" }, { ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import permutations\n\ndef generate_permutations_with_order(str1, str2, str3, str4):\n \"\"\"\n Generate all unique permutations of 4 strings maintaining the original \n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00018101", "row_id": 18101, "seed_ids": "['Llama-3.3-70B-Instruct_45877']" }
0.683884
Filter_18101
I
[ "generate_permutations", "is_valid_permutation" ]
2
[ [ "generate_permutations", "is_valid_permutation" ] ]
1
[]
false
[]
false
pytest
true
[]
true
04597fb5d51de92c6e243e6088621dd28cfff241
68ac86605ec01224b7fecf60d8c46060ced73b81
v1.0
instruct
Filter
Filter_18111_I
Can you create a short, simple Python function that takes a list of lists of integers and returns True if the list contains at least one sublist that contains at least one prime number, and returns False otherwise?
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def contains_prime_sublist(lst): """ Returns True if the list contains at least one sub...
from solution import is_prime, contains_prime_sublist 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(-1) == False assert is_prime(0) == False def test_contains_pri...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns True if the list contains at least one sublist with at least one prime number.\nReturns False otherwise...
[ 0, 1, 1 ]
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 Helper function to check if a number n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00018111", "row_id": 18111, "seed_ids": "['Llama-3.3-70B-Instruct_45899']" }
0.681726
Filter_18111
I
[ "is_prime", "contains_prime_sublist" ]
2
[ [ "contains_prime_sublist", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5e10452526e2bbeffc29cb30e319a9a41cb2f848
47caefc48d3a7df335cf36eb8270778dfa68381f
v1.0
instruct
Filter
Filter_18113_I
I'd like to create a simple "Word Game" where the words will be presented with some letters missing (e.g. w_r_d), and the player has to fill in the blanks. If the player fills in the blanks correctly, they earn a point. If they answer incorrectly, the computer gets a point. The game continues until one of the players r...
import random # Load words from file def load_words(filename): with open(filename, "r") as file: return file.read().splitlines() # Generate a word with random blanks def get_word_with_blanks(word): num_blanks = random.randint(1, len(word) - 1) indices_to_blank = random.sample(range(len(word)), num...
from solution import load_words, get_word_with_blanks, play_game def test_load_words(tmp_path): # Create a temporary file with words word_file = tmp_path / "word_data.txt" word_file.write_text("apple\nbanana\ncherry\ndate\nelderberry\n") # Test the load_words function word_list = load_words(wo...
[ { "docstring": null, "function_declaration": "def load_words(filename):", "function_name": "load_words", "parameter_list": "(filename)" }, { "docstring": null, "function_declaration": "def get_word_with_blanks(word):", "function_name": "get_word_with_blanks", "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 random\n\ndef load_words(filename):\n \"\"\"\n Load words from a file and return as a list of strings.\n \"\"\"\n with open(filename, \"r\") as file:\n return file.re...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00018113", "row_id": 18113, "seed_ids": "['Llama-3.3-70B-Instruct_45904']" }
0.5974
Filter_18113
I
[ "load_words", "get_word_with_blanks", "play_game", "main" ]
4
[ [ "play_game", "get_word_with_blanks" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9632c709135dfaacf7c5750881113c402bbbfe5b
67a5a21f5a538dd2333dc0eb68a5d5ddee0abb9f
v1.0
instruct
Filter
Filter_18116_I
Can you guide me through a simple program that will take an integer input, and then print out all the prime numbers up to that number?
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def primes_up_to(n): """ Ret...
from solution import is_prime, primes_up_to 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(-5) == False assert is_prime(0) == False assert is_prime(1) == Fals...
[ { "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 up to n.", "function_declaration": "def primes_up_to(n):", "function_name": "primes_up...
[ 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 Returns True if `n` is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00018116", "row_id": 18116, "seed_ids": "['Llama-3.3-70B-Instruct_45915']" }
0.623971
Filter_18116
I
[ "is_prime", "primes_up_to" ]
2
[ [ "primes_up_to", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fbab905a55c1eda4b8b2a982bbf9737e19c4f9ab
759f478783313aa13ae23b6cbf1d3fe62bbbfaa6
v1.0
instruct
Filter
Filter_18127_I
I have a list of files in a directory that follows a naming convention. The names are a combination of letters and numbers (but no other characters). I need to extract the numbers from the file names, sort them in ascending order, and then print them. Example: Directory "my_directory" contains the following files: x...
import os import re def extract_and_sort_numbers(dir_path): """ Extract the numbers from filenames in the given directory, sort them in ascending order, and return the sorted list of numbers as integers. """ numbers = [] for filename in os.listdir(dir_path): match = re.search(r'\d+', f...
import os import pytest from solution import extract_and_sort_numbers def setup_module(module): """ Prepares the environment by creating a test directory with some files. """ test_dir = 'test_directory' os.mkdir(test_dir) file_names = ['xyz123.txt', 'abc456.txt', 'def789.txt', 'ghi321.txt'] ...
[ { "docstring": "Extract the numbers from filenames in the given directory, sort them in ascending order, \nand return the sorted list of numbers as integers.", "function_declaration": "def extract_and_sort_numbers(dir_path):", "function_name": "extract_and_sort_numbers", "parameter_list": "(dir_path...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\nimport re\n\ndef extract_and_sort_numbers(dir_path):\n \"\"\"\n Extract the numbers from filenames in the given directory, sort them in ascending order, \n and return the s...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00018127", "row_id": 18127, "seed_ids": "['Llama-3.3-70B-Instruct_45949']" }
0.617083
Filter_18127
I
[ "extract_and_sort_numbers", "print_sorted_numbers" ]
2
[ [ "print_sorted_numbers", "extract_and_sort_numbers" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c9c63f3ec8258842716b244f3526f4749dd05a6b
accfcbbcf25fa89452041a08a986510fab5a588d
v1.0
instruct
Filter
Filter_18133_I
Here is a code challenge: write a program that takes an input string, checks if it is a palindrome, and if it is not, generates a next possible palindrome. To solve this, I have a plan: 1. Define a function that checks if a string is a palindrome. 2. Write an algorithm to generate the next possible palindrome from a...
def is_palindrome(s): """ Checks if a given string is a palindrome. Args: s (str): The string to be checked. Returns: bool: True if the string is a palindrome, False otherwise. """ return s == s[::-1] def increment_palindrome(s): """ Generates the next palindrome large...
from solution import is_palindrome, increment_palindrome def test_is_palindrome(): assert is_palindrome("racecar") == True assert is_palindrome("hello") == False assert is_palindrome("a") == True assert is_palindrome("abba") == True assert is_palindrome("abcba") == True def test_increment_palindro...
[ { "docstring": "Checks if a given string is a palindrome.\n\nArgs:\n s (str): The string to be checked.\n\nReturns:\n bool: True if the string is a palindrome, False otherwise.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, {...
[ 0, 1, 0 ]
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 Checks if a given string is a palindrome.\n\n Args:\n s (str): The string to be checked.\n\n Returns:\n bool: True if the string is a...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00018133", "row_id": 18133, "seed_ids": "['Llama-3.3-70B-Instruct_45963']" }
0.726555
Filter_18133
I
[ "is_palindrome", "increment_palindrome", "increment_string" ]
3
[ [ "increment_palindrome", "increment_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4d10d6937d34076500616a8efc93e22d9c6df851
2578717e83bf2fb2145aadabac228daa45b5ae6f
v1.0
instruct
Filter
Filter_18156_I
Kariye has been given a series of 5 numbers. Determine if at least one number is odd. Assuming we are using the Python programming language, can you help me determine if at least one number is odd by creating a function that checks if a number is odd, another function that checks if at least one number is odd in the ...
def is_odd(number): """ Determines if a number is odd. """ return number % 2 != 0 def at_least_one_odd(numbers): """ Determines if at least one number in the series is odd. """ for number in numbers: if is_odd(number): return True return False # Series of number...
from solution import is_odd, at_least_one_odd def test_is_odd(): assert is_odd(1) == True assert is_odd(2) == False assert is_odd(0) == False assert is_odd(-3) == True def test_at_least_one_odd(): assert at_least_one_odd([10, 7, 8, 35, 4]) == True assert at_least_one_odd([2, 4, 6, 8, 10]) == F...
[ { "docstring": "Determines if a number is odd.", "function_declaration": "def is_odd(number):", "function_name": "is_odd", "parameter_list": "(number)" }, { "docstring": "Determines if at least one number in the series is odd.", "function_declaration": "def at_least_one_odd(numbers):", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_odd(number):\n \"\"\"\n Returns True if the number is odd, False otherwise.\n \"\"\"\n return number % 2 != 0\n\ndef at_least_one_odd(numbers):\n \"\"\"\n Returns True...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00018156", "row_id": 18156, "seed_ids": "['Llama-3.3-70B-Instruct_46013']" }
0.638458
Filter_18156
I
[ "is_odd", "at_least_one_odd" ]
2
[ [ "at_least_one_odd", "is_odd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
02d65a4cacab9b8dd2b8f8839b49718e5e3bc234
13c311b9796fa94ab057a5d995d31e64852053ed
v1.0
instruct
Filter
Filter_18160_I
I have a CSV file containing contact information of individuals, with columns for name, email, phone number, and address. How can I write a Python program to read the CSV file, validate the email addresses, and then write the validated email addresses to a new CSV file?
import csv import re def validate_email(email): """ Validates an email address using regex. """ pattern = r'^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$' return re.match(pattern, email) is not None def read_and_validate_emails(input_csv, output_csv): """ Reads the input CSV file, valid...
import pytest from solution import validate_email, read_and_validate_emails import csv import os def test_validate_email_valid_cases(): assert validate_email("test@example.com") == True assert validate_email("user.name+tag+sorting@example.com") == True def test_validate_email_invalid_cases(): assert valid...
[ { "docstring": "Validates an email address using regex.", "function_declaration": "def validate_email(email):", "function_name": "validate_email", "parameter_list": "(email)" }, { "docstring": "Reads the input CSV file, validates the email addresses, and writes \nthe validated email addresse...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import csv\nimport re\n\ndef validate_email(email):\n \"\"\"\n Validates an email address using a regex pattern.\n Returns True if the email is valid, otherwise False.\n \"\"\"\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00018160", "row_id": 18160, "seed_ids": "['Llama-3.3-70B-Instruct_46021']" }
0.554572
Filter_18160
I
[ "validate_email", "read_and_validate_emails" ]
2
[ [ "read_and_validate_emails", "validate_email" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8f53c95f06add8a203482235023e6020145e1e92
b424648ef2f81e60523e9f01bab1ce2f4b91e918
v1.0
instruct
Filter
Filter_18168_I
I have two binary trees. I need to find if there is a node in the first tree that matches a node in the second tree. If a match is found, print the matching node's value. If no match is found, print "NO MATCHES". Here is my attempt so far: ``` class Node: def __init__(self, value): self.value = value ...
class Node: def __init__(self, value): self.value = value self.left = None self.right = None def collect_values(node, value_set): if node is None: return value_set.add(node.value) collect_values(node.left, value_set) collect_values(node.right, value_set) def find_ma...
from solution import Node, find_match def test_no_match(): tree1 = Node(1) tree1.left = Node(2) tree1.right = Node(3) tree2 = Node(4) tree2.left = Node(5) tree2.right = Node(6) assert find_match(tree1, tree2) == "NO MATCHES" def test_single_match(): tree1 = Node(1) tree1....
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class Node:\n def __init__(self, value):\n self.value = value\n self.left = None\n self.right = None\n\ndef collect_values(node, value_set):\n if node is None:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00018168", "row_id": 18168, "seed_ids": "['Llama-3.3-70B-Instruct_46042']" }
0.470438
Filter_18168
I
[ "collect_values", "find_match" ]
2
[ [ "find_match", "collect_values" ] ]
1
[]
false
[ "Node" ]
true
pytest
true
[]
true
bf3f265c541f49865288aeece8b657d13f884c47
83e788610d917646bde53cece3a29ac3f157086d
v1.0
instruct
Filter
Filter_18173_I
I have 3 functions f1, f2, f3. I want to create a new function that takes no arguments and returns the results of all 3 functions. ```python def f1(): # code that returns value1 def f2(): # code that returns value2 def f3(): # code that returns value3 ``` What would be the best way to do this?
def f1(): return "value1" def f2(): return "value2" def f3(): return "value3" def combined_function(): return f1(), f2(), f3()
from solution import f1, f2, f3, combined_function def test_f1(): assert f1() == "value1" def test_f2(): assert f2() == "value2" def test_f3(): assert f3() == "value3" def test_combined_function(): assert combined_function() == ("value1", "value2", "value3")
[ { "docstring": null, "function_declaration": "def f1():", "function_name": "f1", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def f2():", "function_name": "f2", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def f3()...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def f1():\n return \"value1\"\n\ndef f2():\n return \"value2\"\n\ndef f3():\n return \"value3\"\n\ndef combined_function():\n return f1(), f2(), f3()", "test_code": "from solut...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00018173", "row_id": 18173, "seed_ids": "['Llama-3.3-70B-Instruct_46058']" }
0.546233
Filter_18173
I
[ "f1", "f2", "f3", "combined_function" ]
4
[ [ "combined_function", "f1" ], [ "combined_function", "f2" ], [ "combined_function", "f3" ] ]
3
[]
false
[]
false
pytest
true
[]
true
7b4df6ea15f934b1a498db971f1e69abe8b2e64c
c3e5ffc4fc167d8f12867c8a721f9908da34cac9
v1.0
instruct
Filter
Filter_18180_I
I have a file called "page.html" with this content: ``` <!DOCTYPE html> <html> <head> <title>Page title</title> </head> <body> <p>This is a paragraph.</p> </body> </html> ``` I want two functions: `read_file` that reads the content of "page.html" and `print_file` that prints the content of "page.html". ...
def read_file(file_name): """Reads the content of a file and returns it.""" try: with open(file_name, 'r') as f: content = f.read() return content except FileNotFoundError: print(f"Sorry, the file {file_name} does not exist.") return None def print_file(file_...
import pytest from unittest.mock import mock_open, patch from solution import read_file, print_file, check_word_in_file # Test content mock_html_content = """<!DOCTYPE html> <html> <head> <title>Page title</title> </head> <body> <p>This is a paragraph.</p> </body> </html>""" def test_read_file_existi...
[ { "docstring": "Reads the content of a file and returns it.", "function_declaration": "def read_file(file_name):", "function_name": "read_file", "parameter_list": "(file_name)" }, { "docstring": "Prints the content of a file.", "function_declaration": "def print_file(file_name):", "f...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def read_file(file_name):\n \"\"\"\n Reads the content of a file and returns it.\n \n Parameters:\n file_name (str): The name of the file to be read.\n \n Returns:\n st...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00018180", "row_id": 18180, "seed_ids": "['Llama-3.3-70B-Instruct_46079']" }
0.440214
Filter_18180
I
[ "read_file", "print_file", "check_word_in_file" ]
3
[ [ "check_word_in_file", "read_file" ], [ "print_file", "read_file" ] ]
2
[]
false
[]
false
pytest
true
[]
true
def402edaad2b66743bd62e932fde85d18a28007
2b988bad9483fa59d99d06d63d823bbfb8b99db1
v1.0
instruct
Filter
Filter_18200_I
I have the following type of input data: {"name": "Boat", "number": 5, "price": 30} I want to create a function which creates an "invoice" with the receipt details, i.e: { "invoice_number": 12345, "date": "2023-01-01", "items": [ { "name": "Boat", "quantity": 5, "price": 30, "subtotal...
import datetime def get_invoice_number(): # This is a placeholder for the existing function which generates an invoice number return 12345 def create_invoice(item_data): """ Creates an invoice with the receipt details from the given item data. Args: item_data (dict): A dictionary containi...
from solution import create_invoice def test_create_invoice(): item_data = {"name": "Boat", "number": 5, "price": 30} invoice = create_invoice(item_data) # Check the invoice structure and values assert invoice["invoice_number"] == 12345 assert invoice["date"] == datetime.date.today().isoformat...
[ { "docstring": null, "function_declaration": "def get_invoice_number():", "function_name": "get_invoice_number", "parameter_list": "()" }, { "docstring": "Creates an invoice with the receipt details from the given item data.\n\nArgs:\nitem_data (dict): A dictionary containing 'name', 'number...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from datetime import datetime\n\ndef get_invoice_number():\n \"\"\"\n This is a mock function. Assume it generates a unique invoice number.\n \"\"\"\n return 12345\n\ndef create_in...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00018200", "row_id": 18200, "seed_ids": "['Llama-3.3-70B-Instruct_46140']" }
0.439113
Filter_18200
I
[ "get_invoice_number", "create_invoice" ]
2
[ [ "create_invoice", "get_invoice_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cc8f444a951c432dc05bc605cdd46f48a98dc033
7cfd4db723ea5a933669537debf31f8a1aaae62d
v1.0
instruct
Filter
Filter_18201_I
### Authentication and Authorization #### Overview In this exercise you will create a simple server that authenticates and authorizes users. #### Instructions Create a simple server that authenticates and authorizes users based on the following requirements: * The server should support both authentication and authoriz...
from flask import Flask, request, jsonify, abort import jwt import datetime from functools import wraps app = Flask(__name__) app.config['SECRET_KEY'] = 'secretkey' # Mock Data Storage users = {} user_id_counter = 1 # User roles and their permissions roles_permissions = { 'admin': ['create', 'read', 'update', 'd...
import pytest from solution import app, users, user_id_counter import json def test_register(): client = app.test_client() response = client.post('/register', data=json.dumps({ 'username': 'testuser', 'password': 'testpass', 'role': 'user' }), content_type='application/json') as...
[ { "docstring": null, "function_declaration": "def token_required(f):", "function_name": "token_required", "parameter_list": "(f)" }, { "docstring": null, "function_declaration": "def authorize_roles(allowed_roles):", "function_name": "authorize_roles", "parameter_list": "(allowed...
[ 1, 0, 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, abort\nimport jwt\nimport datetime\nfrom functools import wraps\n\napp = Flask(__name__)\napp.config['SECRET_KEY'] = 'secretkey'\n\n# Mock Data Stora...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00018201", "row_id": 18201, "seed_ids": "['Llama-3.3-70B-Instruct_46141']" }
0.429293
Filter_18201
I
[ "token_required", "authorize_roles", "register", "login", "get_all_users", "get_user", "update_user", "delete_user" ]
8
[ [ "delete_user", "authorize_roles" ], [ "get_all_users", "authorize_roles" ] ]
2
[]
false
[]
false
pytest
true
[ "flask", "jwt" ]
false
f26af82a8b11dd94b7cd81c07e1787ec8e4187b3
3b8ce72b1a092233eb8bbcbca2b7c2c13627ebf4
v1.0
instruct
Filter
Filter_18210_I
Here's a function that merges two sorted lists in Python: ``` import heapq def merge_sorted_lists(list1, list2): return list(heapq.merge(list1, list2)) ``` Can you explain what's happening under the hood here? Also, can you help me implement a merge sort algorithm from scratch, without relying on the heapq.merg...
def merge_sort(arr): """ A function that implements merge sort algorithm. """ if len(arr) <= 1: return arr # Split the list into halves mid = len(arr) // 2 left_half = merge_sort(arr[:mid]) right_half = merge_sort(arr[mid:]) # Merge the sorted halves return merge(left_h...
from solution import merge_sort def test_empty_list(): assert merge_sort([]) == [] def test_single_element_list(): assert merge_sort([1]) == [1] def test_sorted_list(): assert merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_reverse_sorted_list(): assert merge_sort([5, 4, 3, 2, 1]) == [1, 2, ...
[ { "docstring": "A function that implements merge sort algorithm.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": "Merges two sorted lists into one sorted list.", "function_declaration": "def merge(left, right):"...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_sort(arr):\n \"\"\"\n Sorts the list `arr` using the merge sort algorithm.\n \n Args:\n arr (list): The list to be sorted.\n \n Returns:\n list: A...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00018210", "row_id": 18210, "seed_ids": "['Llama-3.3-70B-Instruct_46155']" }
0.558694
Filter_18210
I
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5648ada86d457a80e3bb831b2413c349d983e66d
7cd6e9c99e95a98236b47fffa9457c82387e7ca6