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_24083_I
### Overview Here is a task to help you practice conditional statements in Python. You will be creating a simple magic 8-ball program. The magic 8-ball is a toy that generates random fortunes or predictions in response to yes or no questions. ### Task Create a Python program that simulates a magic 8-ball. The magic 8-...
import random def get_user_name(): """Gets the user's name.""" return input("What is your name? ") def get_user_question(): """Gets a yes or no question from the user.""" return input("What is your yes or no question? ") def get_random_response(): """Returns a random response.""" responses = ...
import pytest from unittest.mock import patch, MagicMock from solution import get_user_name, get_user_question, get_random_response, play_game def test_get_user_name(): with patch('builtins.input', return_value="John Doe"): assert get_user_name() == "John Doe" def test_get_user_question(): with patch...
[ { "docstring": "Gets the user's name.", "function_declaration": "def get_user_name():", "function_name": "get_user_name", "parameter_list": "()" }, { "docstring": "Gets a yes or no question from the user.", "function_declaration": "def get_user_question():", "function_name": "get_use...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef get_user_name():\n \"\"\"Gets the user's name.\"\"\"\n return input(\"What is your name? \")\n\ndef get_user_question():\n \"\"\"Gets a yes or no question from th...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00024083", "row_id": 24083, "seed_ids": "['Llama-3.3-70B-Instruct_59986']" }
0.516197
Filter_24083
I
[ "get_user_name", "get_user_question", "get_random_response", "play_game" ]
4
[ [ "play_game", "get_random_response" ], [ "play_game", "get_user_name" ], [ "play_game", "get_user_question" ] ]
3
[]
false
[]
false
pytest
true
[]
true
26793782ef90761a0ed19438014f6c78bfd14ded
90c24ee2335fe0060a4b69081f9a366e7c700c58
v1.0
instruct
Filter
Filter_24099_I
Create a simple rock-paper-scissors game for Singleplayer. The game should have the following functionalities: - The game should have three options: rock, paper, and scissors. - The user can choose any of the three options by typing 'rock,' 'paper,' or 'scissors.' - The computer should generate a random choice from ...
import random def get_computer_choice(choices): return random.choice(choices) def determine_winner(user_choice, computer_choice): if user_choice == computer_choice: return "It's a tie!" elif user_choice == "rock": if computer_choice == "scissors": return "Rock smashes scissors!...
from solution import get_computer_choice, determine_winner import pytest def test_get_computer_choice(): choices = ["rock", "paper", "scissors"] choice = get_computer_choice(choices) assert choice in choices @pytest.mark.parametrize("user_choice,computer_choice,expected", [ ("rock", "scissors", "Rock ...
[ { "docstring": null, "function_declaration": "def get_computer_choice(choices):", "function_name": "get_computer_choice", "parameter_list": "(choices)" }, { "docstring": null, "function_declaration": "def determine_winner(user_choice, computer_choice):", "function_name": "determine_w...
[ 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 possible_choices = [\"rock\", \"paper\", \"scissors\"]\n return random.choice(possible_choices)\n\ndef determine_winner(user_choice, compute...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00024099", "row_id": 24099, "seed_ids": "['Llama-3.3-70B-Instruct_60013']" }
0.529413
Filter_24099
I
[ "get_computer_choice", "determine_winner", "play_game" ]
3
[ [ "play_game", "determine_winner" ], [ "play_game", "get_computer_choice" ] ]
2
[]
false
[]
false
pytest
true
[]
true
135956ee414d97568f0574b56a9d81307ec609cf
271067f4727c691518442e237e84927e6973bf9f
v1.0
instruct
Filter
Filter_24107_I
Here's an example program that creates a grid, allows the user to input a starting point and target point on the grid, and then performs a breadth-first search (BFS) to find the shortest path between the starting and target points. Please provide comments and a main function for the better understanding of the code.
from collections import deque def is_valid_move(grid, x, y): """ Checks if the move is within the grid bounds and the cell is not an obstacle. """ if 0 <= x < len(grid) and 0 <= y < len(grid[0]) and grid[x][y] != 1: return True return False def bfs_shortest_path(grid, start, target): "...
from solution import bfs_shortest_path def test_bfs_shortest_path(): grid = [ [0, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [1, 1, 0, 0, 0] ] start = (0, 0) target = (4, 4) assert bfs_shortest_path(grid, start, target) == 8 def test_no_...
[ { "docstring": "Checks if the move is within the grid bounds and the cell is not an obstacle.", "function_declaration": "def is_valid_move(grid, x, y):", "function_name": "is_valid_move", "parameter_list": "(grid, x, y)" }, { "docstring": "Performs a BFS to find the shortest path from start ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef is_valid_move(grid, x, y):\n \"\"\"\n Checks if the move is within the grid bounds and the cell is not an obstacle.\n \"\"\"\n if 0 <= x < len(...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00024107", "row_id": 24107, "seed_ids": "['Llama-3.3-70B-Instruct_60036']" }
0.519474
Filter_24107
I
[ "is_valid_move", "bfs_shortest_path", "main" ]
3
[ [ "bfs_shortest_path", "is_valid_move" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9e626fe0efbf43cee855cc30bff34dd7643fa3fb
401b7cc6324d5015e2db787cebe32b6db6b17806
v1.0
instruct
Filter
Filter_24110_I
I try to calculate the simple harmonic motions using Euler's method with user-defined acceleration and position function for the damped and undamped systems. Here is my code: ```python import numpy as np def acceleration_damped(t, x, v, m, k, c): a = -(k * x + c * v)/m return a def acceleration_undamped(t,...
import numpy as np import matplotlib.pyplot as plt def acceleration_damped(t, x, v, m, k, c): a = -(k * x + c * v)/m return a def acceleration_undamped(t, x, v, m, k): a = -(k * x)/m return a def position_euler(x0, v0, m, k, c=None, dt=0.01, t_max=10): n_steps = int(t_max / dt) t = np.linspac...
import numpy as np from solution import acceleration_damped, acceleration_undamped, position_euler, plot_results def test_acceleration_undamped(): assert np.isclose(acceleration_undamped(0, 1, 0, 1, 10), -10) def test_acceleration_damped(): assert np.isclose(acceleration_damped(0, 1, 0, 1, 10, 0.5), -10) ...
[ { "docstring": null, "function_declaration": "def acceleration_damped(t, x, v, m, k, c):", "function_name": "acceleration_damped", "parameter_list": "(t, x, v, m, k, c)" }, { "docstring": null, "function_declaration": "def acceleration_undamped(t, x, v, m, k):", "function_name": "acc...
[ 0, 0, 1 ]
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\n\ndef acceleration_damped(t, x, v, m, k, c):\n a = -(k * x + c * v)/m\n return a\n\ndef acceleration_undamped(t, x, v, m, k):\n a ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024110", "row_id": 24110, "seed_ids": "['Llama-3.3-70B-Instruct_60039']" }
0.329442
Filter_24110
I
[ "acceleration_damped", "acceleration_undamped", "position_euler", "plot_results" ]
4
[ [ "position_euler", "acceleration_damped" ], [ "position_euler", "acceleration_undamped" ] ]
2
[]
false
[]
false
pytest
true
[ "matplotlib", "numpy" ]
false
9ae1ccd8f89fc3d7c850fbd92468c289add02f3d
89c5c3ec85514914f7b90b270b31ed032a19210e
v1.0
instruct
Filter
Filter_24120_I
### Shortify a URL Shortify a given URL and return the shortened URL. This should be include the original URL, a unique short code and the time of creation. ```python import hashlib import time import string from datetime import datetime from typing import Dict def shorten_url(original_url: str) -> str: """ ...
import hashlib import time from datetime import datetime from typing import Dict # Dictionary to store shortened URLs url_dict: Dict[str, Dict[str, str]] = {} def generate_shortcode(original_url: str) -> str: """ Generates a unique shortcode for the given URL using the hash function. """ return hashli...
from solution import shorten_url, url_dict def test_shorten_url_format(): url = "https://www.google.com" shortened_url = shorten_url(url) assert shortened_url.startswith("http://short.url/"), "Shortened URL does not have the correct format." def test_shorten_url_content(): url = "https://www.google.co...
[ { "docstring": "Generates a unique shortcode for the given URL using the hash function.", "function_declaration": "def generate_shortcode(original_url):", "function_name": "generate_shortcode", "parameter_list": "(original_url)" }, { "docstring": "This function takes in an original URL and s...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import hashlib\nimport time\nfrom datetime import datetime\nfrom typing import Dict\n\nurl_dict: Dict[str, Dict[str, str]] = {}\n\n\ndef generate_shortcode(original_url: str) -> str:\n \"\"...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00024120", "row_id": 24120, "seed_ids": "['Llama-3.3-70B-Instruct_60056']" }
0.530089
Filter_24120
I
[ "generate_shortcode", "shorten_url" ]
2
[ [ "shorten_url", "generate_shortcode" ] ]
1
[]
false
[]
false
pytest
true
[]
true
962dad1b4b57ba231e53b6421d6a8688ad0ac96b
cde1faf1b1418c22533e7a7a5874781bb81eca7c
v1.0
instruct
Filter
Filter_24123_I
I have a large number of images I need to share with a group of people, and I want to make sure that everyone gets a unique set of images. I've decided to create a set of collages, where each collage is made up of multiple images arranged in a grid. I'm planning to make each grid square, and I want to ensure that no tw...
from itertools import combinations from PIL import Image def create_collage(image_paths, grid_size): """ Creates a collage image from a list of image paths, arranged in a grid. :param image_paths: List of paths to images to be included in the collage. :param grid_size: Size of the collage grid (grid_s...
import pytest from solution import create_collage, generate_unique_collages from PIL import Image import tempfile import os def generate_dummy_images(num_images, size=(100, 100)): """ Generate dummy images for testing. :param num_images: Number of dummy images to generate. :param size: Size of each du...
[ { "docstring": "Creates a collage image from a list of image paths, arranged in a grid.\n\n:param image_paths: List of paths to images to be included in the collage.\n:param grid_size: Size of the collage grid (grid_size x grid_size).\n:return: A collage image.", "function_declaration": "def create_collage(...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from itertools import combinations\nfrom PIL import Image\n\ndef create_collage(image_paths, grid_size):\n \"\"\"\n Creates a collage image from a list of image paths, arranged in a grid...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00024123", "row_id": 24123, "seed_ids": "['Llama-3.3-70B-Instruct_60063']" }
0.441413
Filter_24123
I
[ "create_collage", "generate_unique_collages", "main" ]
3
[ [ "generate_unique_collages", "create_collage" ] ]
1
[]
false
[]
false
pytest
true
[ "PIL" ]
false
fea0a5ccadfae39afdde80e2d343fdb0edb174c1
96347bf75addde493fbdd10ff53215b6f04b2cc5
v1.0
instruct
Filter
Filter_24148_I
### Lesson 7: Yield from vs Return in Python Generators
def simple_generator(): """ A simple generator function that yields some values. """ yield 1 yield 2 yield 3 def yield_from_generator(): """ A generator function that uses 'yield from' to yield all values from another generator. """ yield from simple_generator() yield 4
from solution import simple_generator, yield_from_generator def test_simple_generator(): gen = simple_generator() assert next(gen) == 1 assert next(gen) == 2 assert next(gen) == 3 def test_yield_from_generator(): gen = yield_from_generator() assert next(gen) == 1 assert next(gen) == 2 ...
[ { "docstring": "A simple generator function that yields some values.", "function_declaration": "def simple_generator():", "function_name": "simple_generator", "parameter_list": "()" }, { "docstring": "A generator function that uses 'yield from' to yield all values from another generator.", ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generator_with_yield_from(iterable):\n \"\"\"\n A generator function that uses 'yield from' to yield values from the given iterable.\n \"\"\"\n yield from iterable\n\ndef gener...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024148", "row_id": 24148, "seed_ids": "['Llama-3.3-70B-Instruct_60108']" }
0.417602
Filter_24148
I
[ "simple_generator", "yield_from_generator" ]
2
[ [ "yield_from_generator", "simple_generator" ] ]
1
[]
false
[]
false
pytest
true
[]
true
30e415920bbb6057ab48a65ccf259411a07cab4e
61ab6f12599c177731db26d95280ae1abe88e84e
v1.0
instruct
Filter
Filter_24154_I
### Exercise: Guessing Game # 1. The computer will think of a number between 1 and 100, and the player will try to guess it. # 2. For each guess, the computer will respond with one of three messages: # * "too high" if the guess is greater than the number thought of # * "too low" if t...
import random def guessing_game(user_guess, number_to_guess): """ Function to handle the guessing game logic. Args: user_guess (int): The user's guess. number_to_guess (int): The number that the computer has thought of. Returns: str: A message indicating if the guess is too high, too low, ...
from solution import guessing_game def test_guessing_game_correct(): assert guessing_game(50, 50) == "correct" def test_guessing_game_too_high(): assert guessing_game(75, 50) == "too high" def test_guessing_game_too_low(): assert guessing_game(25, 50) == "too low" def test_guessing_game_edge_case_lower_...
[ { "docstring": "Function to handle the guessing game logic.\nArgs:\nuser_guess (int): The user's guess.\nnumber_to_guess (int): The number that the computer has thought of.\n\nReturns:\nstr: A message indicating if the guess is too high, too low, or correct.", "function_declaration": "def guessing_game(user...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef guessing_game(number_to_guess=None):\n \"\"\"\n A guessing game where the player has to guess a number between 1 and 100.\n\n Parameters:\n number_to_guess (in...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024154", "row_id": 24154, "seed_ids": "['Llama-3.3-70B-Instruct_60116']" }
0.628673
Filter_24154
I
[ "guessing_game", "game" ]
2
[ [ "game", "guessing_game" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cf546abbe96ec92a35f694004918d6d63c89f9d1
fbcdd49421a6d9a37f7b65dc994cec479c5d8d29
v1.0
instruct
Filter
Filter_24156_I
Please write a pseudo-code to find all possible subsets of a string. Let's assume the string can be empty or contain 1 or more characters, including empty spaces. ### Example: * Input: "abc" * Output: ["", "a", "b", "ab", "c", "ac", "bc", "abc"] * Note that the order of the subsets does not matter and it might not be...
def is_string(input_value): """ Checks if input_value is a string and raises TypeError if not. """ if not isinstance(input_value, str): raise TypeError("Input must be a string.") return True def get_subsets(input_str): """ Returns all possible subsets of the input string. """ ...
from solution import is_string, get_subsets def test_is_string(): assert is_string("test") == True assert is_string("") == True try: is_string(123) except TypeError as e: assert str(e) == "Input must be a string." def test_get_subsets(): assert set(get_subsets("")) == {""} ...
[ { "docstring": "Checks if input_value is a string and raises TypeError if not.", "function_declaration": "def is_string(input_value):", "function_name": "is_string", "parameter_list": "(input_value)" }, { "docstring": "Returns all possible subsets of the input string.", "function_declara...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_string(input_value):\n if not isinstance(input_value, str):\n raise TypeError(\"Input must be a string.\")\n return True\n\n\ndef get_subsets(input_str):\n \"\"\"\n R...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024156", "row_id": 24156, "seed_ids": "['Llama-3.3-70B-Instruct_60118']" }
0.565548
Filter_24156
I
[ "is_string", "get_subsets" ]
2
[ [ "get_subsets", "is_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2ff3c93cd944572bde85fc8ed59d58a5af824af6
017713e3166b90379c61edfe0e891ebdde84fc68
v1.0
instruct
Filter
Filter_24170_I
I've been experimenting with Python and thought about how I could use it to create a simple Newton's method calculator. However, I'd also like to visualize the function so I can see where the roots are, and also to better understand what the Newton's method is doing as it iterates through. Can I use Python to both ca...
import numpy as np import matplotlib.pyplot as plt def newtons_method(f, f_prime, x0, tol=1e-7, max_iter=100): """ Apply Newton's method to find root of f starting from x0. Parameters: f (function): The function for which we want to find the root f_prime (function): The derivative of the funct...
from solution import newtons_method, visualize_newtons_method, f, f_prime def test_newton_method_convergence(): root, approximations = newtons_method(f, f_prime, 3, tol=1e-7) assert abs(f(root)) < 1e-7 def test_newton_method_approximation_count(): _, approximations = newtons_method(f, f_prime, 3, tol=1e-7...
[ { "docstring": "Apply Newton's method to find root of f starting from x0.\n\nParameters:\nf (function): The function for which we want to find the root\nf_prime (function): The derivative of the function f\nx0 (float): Initial guess for the root\ntol (float): Tolerance for convergence\nmax_iter (int): Maximum n...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import matplotlib.pyplot as plt\nimport numpy as np\n\ndef newton_method(f, df, x0, tol=1e-5, max_iter=100):\n \"\"\"\n Perform Newton's method for finding roots of the function f with i...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00024170", "row_id": 24170, "seed_ids": "['Llama-3.3-70B-Instruct_60150']" }
0.437003
Filter_24170
I
[ "newtons_method", "visualize_newtons_method", "f", "f_prime" ]
4
[ [ "visualize_newtons_method", "newtons_method" ] ]
1
[]
false
[]
false
pytest
true
[ "matplotlib", "numpy" ]
false
f3187ca2bd551860304aa6ffb3ec0fd18656c8c2
4a844c340483a8e8bfd0b1ded80a37a568b59ebc
v1.0
instruct
Filter
Filter_24176_I
Here is a Python script to visualise the prime numbers using a modified version of the Sieve of Eratosthenes algorithm. But when you try to build a GUI from this, there might be an issue since updating a GUI in real time might be a resource intensive process. Here's what I'm trying to achieve in simple terms - 1. I h...
import tkinter as tk import time def is_prime(n, sieve): if sieve[n] == True: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def display_primes(canvas, limit): sieve = [False] * (limit + 1) for num in range(2, limit + 1): ...
from solution import is_prime def test_prime_number(): sieve = [False] * 51 # To check primes up to 50 assert is_prime(2, sieve) == True assert is_prime(3, sieve) == True assert is_prime(5, sieve) == True assert is_prime(7, sieve) == True assert is_prime(11, sieve) == True assert is_prime(...
[ { "docstring": null, "function_declaration": "def is_prime(n, sieve):", "function_name": "is_prime", "parameter_list": "(n, sieve)" }, { "docstring": null, "function_declaration": "def display_primes(canvas, limit):", "function_name": "display_primes", "parameter_list": "(canvas,...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import tkinter as tk\nimport time\n\ndef is_prime(n, sieve):\n if sieve[n] == True:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n retur...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00024176", "row_id": 24176, "seed_ids": "['Llama-3.3-70B-Instruct_60161']" }
0.380415
Filter_24176
I
[ "is_prime", "display_primes", "main" ]
3
[ [ "display_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c351c6f48d850d72f8db582218c519bd6444de5a
eda479dbe9f32d260fc7e0e8a316e3f477106cb7
v1.0
instruct
Filter
Filter_24177_I
I have a function `my_func` to process some data. This function has two parameters `x` and `y` and returns a value. If I want to apply this function on a numpy array in a way that the function is applied on each element of the array, consider that `x` and `y` parameters are two different arrays (both with the same sh...
import numpy as np def my_func(x, y): """ An example function that takes two arguments x and y and returns x + y. Adjust the operation as needed. """ return x + y def apply_func_vectorized(x, y): """ Applies my_func to each element of numpy arrays x and y in a vectorized manner. ""...
import numpy as np from solution import my_func, apply_func_vectorized def test_my_func(): assert my_func(1, 2) == 3 assert my_func(-1, 1) == 0 assert my_func(0, 0) == 0 def test_apply_func_vectorized(): x = np.array([1, 2, 3, 4, 5]) y = np.array([6, 7, 8, 9, 10]) result = apply_func_vectorize...
[ { "docstring": "An example function that takes two arguments x and y\nand returns x + y. Adjust the operation as needed.", "function_declaration": "def my_func(x, y):", "function_name": "my_func", "parameter_list": "(x, y)" }, { "docstring": "Applies my_func to each element of numpy arrays x...
[ 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 my_func(x, y):\n \"\"\"\n Custom function that processes two inputs x and y.\n This is a placeholder function and should be replaced with your actual logic.\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024177", "row_id": 24177, "seed_ids": "['Llama-3.3-70B-Instruct_60163']" }
0.499699
Filter_24177
I
[ "my_func", "apply_func_vectorized" ]
2
[ [ "apply_func_vectorized", "my_func" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
aaedd541dd8e59523e16293886f87e34540bfc87
5556498a5097ec3e1fa20cc5c6acdb4634016c13
v1.0
instruct
Filter
Filter_24198_I
I am creating a program that converts Celsius to Fahrenheit and vice versa. Can you provide a helper function for each temperature scale conversion and the main function to interact with the user?
def celsius_to_fahrenheit(celsius): """ Converts Celsius to Fahrenheit. :param celsius: Temperature in Celsius :return: Temperature in Fahrenheit """ return (celsius * 9/5) + 32 def fahrenheit_to_celsius(fahrenheit): """ Converts Fahrenheit to Celsius. :param fahrenheit: T...
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 assert celsius_to_fahrenheit(37) == 98.6 def test_fahrenh...
[ { "docstring": "Converts Celsius to Fahrenheit.\n\n:param celsius: Temperature in Celsius\n:return: Temperature in Fahrenheit", "function_declaration": "def celsius_to_fahrenheit(celsius):", "function_name": "celsius_to_fahrenheit", "parameter_list": "(celsius)" }, { "docstring": "Converts F...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def celsius_to_fahrenheit(celsius):\n \"\"\"\n Converts Celsius to Fahrenheit.\n \"\"\"\n return (celsius * 9/5) + 32\n\ndef fahrenheit_to_celsius(fahrenheit):\n \"\"\"\n Con...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00024198", "row_id": 24198, "seed_ids": "['Llama-3.3-70B-Instruct_60214']" }
0.470362
Filter_24198
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
187e67b31771939ec4b98d42cdc3ad65b3dcb7d6
b10b40306b58c8a1543fe08443ad13a55b9373e0
v1.0
instruct
Filter
Filter_24213_I
I have a little graph and I want to calculate its minimal spanning tree using Kruskal's algorithm. My graph is represented as an adjacency list, given by the following dictionary: ```python graph = { 'A': [('B', 3), ('C', 2), ('D', 1)], 'B': [('A', 3), ('D', 2), ('E', 4), ('F', 5)], 'C': [('A', 2), ('D', 4...
def find(parent, i): if parent[i] == i: return i return find(parent, parent[i]) def union(parent, rank, x, y): root_x = find(parent, x) root_y = find(parent, y) if rank[root_x] < rank[root_y]: parent[root_x] = root_y elif rank[root_x] > rank[root_y]: parent[root_y] = ro...
from solution import kruskal def test_kruskal_basic_graph(): graph = { 'A': [('B', 1), ('C', 3)], 'B': [('A', 1), ('C', 3)], 'C': [('A', 3), ('B', 3)] } expected_mst = {('A', 'B', 1), ('A', 'C', 3)} assert kruskal(graph) == expected_mst def test_kruskal_larger_graph(): grap...
[ { "docstring": null, "function_declaration": "def find(parent, i):", "function_name": "find", "parameter_list": "(parent, i)" }, { "docstring": null, "function_declaration": "def union(parent, rank, x, y):", "function_name": "union", "parameter_list": "(parent, rank, x, y)" }, ...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find(parent, i):\n if parent[i] == i:\n return i\n return find(parent, parent[i])\n\ndef union(parent, rank, x, y):\n root_x = find(parent, x)\n root_y = find(parent, y)...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00024213", "row_id": 24213, "seed_ids": "['Llama-3.3-70B-Instruct_60239']" }
0.553904
Filter_24213
I
[ "find", "union", "kruskal" ]
3
[ [ "kruskal", "find" ], [ "kruskal", "union" ], [ "union", "find" ] ]
3
[]
false
[]
false
pytest
true
[]
true
2ceaf5213d997f514f2cef55bc70039af68a9567
530f042bd1d311713d739953b7e4eb38f0b14a7b
v1.0
instruct
Filter
Filter_24223_I
In this exercise, we will implement a Python program that implements merge sort. I have helped by providing a basic implementation of the merge step of the algorithm, you need to implement the recursive merge sort itself Here is the implementation of the merge step: ```python def merge(left, right): merged = [] ...
def merge(left, right): merged = [] left_index = 0 right_index = 0 # Merge smaller elements first while left_index < len(left) and right_index < len(right): if left[left_index] < right[right_index]: merged.append(left[left_index]) left_index += 1 else: ...
from solution import merge_sort def test_empty_array(): assert merge_sort([]) == [] def test_single_element(): assert merge_sort([1]) == [1] def test_sorted_array(): assert merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_reverse_sorted_array(): assert merge_sort([5, 4, 3, 2, 1]) == [1, 2, 3,...
[ { "docstring": null, "function_declaration": "def merge(left, right):", "function_name": "merge", "parameter_list": "(left, right)" }, { "docstring": null, "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" } ]
[ 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 # Base case: If the array has 1 or 0 elements, it's already sorted\n if len(arr) <= 1:\n return arr\n \n # Find the middle point of the array\n mid...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00024223", "row_id": 24223, "seed_ids": "['Llama-3.3-70B-Instruct_60254']" }
0.635654
Filter_24223
I
[ "merge", "merge_sort" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fd2ecf7e539015ec0e0e5fe403c945e5395f626e
c5a18ba17d9271424d9264c7939d5e00356ee631
v1.0
instruct
Filter
Filter_24246_I
### Initial Setup This is a Python script that creates a game where the computer is the dealer and the player is a customer in a simplified version of the card game Blackjack. I need the guidance on how to implement the basic gameplay. ### Game Rules - The deck consists of 52 cards without jokers. - Number cards are w...
import random # Define card ranks and suits ranks = [_ for _ in range(2, 11)] + list('JQKA') suits = 'spades diamonds clubs hearts'.split() # Define card values values = {str(rank): rank if isinstance(rank, int) else 10 for rank in ranks} # Special case for Ace values['A'] = 11 class Card: def __init__(self, ra...
from solution import Card, Deck, Hand, setup_game def test_card_creation(): card = Card('A', 'spades') assert card.rank == 'A' assert card.suit == 'spades' assert str(card) == 'A of spades' def test_deck_creation(): deck = Deck() assert len(deck.cards) == 52 seen_cards = set() for card...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def hit(deck, hand):\n \"\"\"\n Add a card to the given hand from the deck.\n \"\"\"\n hand.add_card(deck.deal())\n\ndef play_game():\n deck = Deck()\n player_hand, dealer_ha...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024246", "row_id": 24246, "seed_ids": "['Llama-3.3-70B-Instruct_60296']" }
0.60793
Filter_24246
I
[ "setup_game", "play_game" ]
2
[ [ "play_game", "setup_game" ] ]
1
[]
false
[ "Card", "Deck", "Hand" ]
true
pytest
true
[]
true
97d11bf42257931ddb32c68335aa08c325e7e9fa
d212680ebd1b7915fe61f6020d9b7dfae28cb85c
v1.0
instruct
Filter
Filter_24257_I
My simulation gives me more particles in the solution than the number of particles I start with. I expect the simulation should end with fewer particles than initially started. I realize I have not implementing the collision between particles with each other. The implementation of such interaction between particles an...
class Particle: def __init__(self, x, y): self.x = x self.y = y self.alive = True class UniformGrid: def __init__(self, width, height, cell_size): self.cell_size = cell_size self.grid = {} self.width = width self.height = height def _hash(self, x, y)...
from solution import Particle, UniformGrid, simulate def test_no_collision(): particles = [Particle(0, 0), Particle(1, 1)] result = simulate(particles, 10, 10, 2) assert len(result) == 2 def test_collision(): particles = [Particle(0, 0), Particle(0, 0)] result = simulate(particles, 10, 10, 2) ...
[]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom collections import defaultdict\n\nclass Particle:\n def __init__(self, x, y):\n self.x = x\n self.y = y\n\nclass UniformGrid:\n def __init__(self, width, ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00024257", "row_id": 24257, "seed_ids": "['Llama-3.3-70B-Instruct_60319']" }
0.343813
Filter_24257
I
[ "check_collisions", "simulate" ]
2
[ [ "simulate", "check_collisions" ] ]
1
[]
false
[ "Particle", "UniformGrid" ]
true
pytest
true
[]
true
1e1923f06fc3af5757d284616ebd22f5f9907242
27161299590acf642e68c20ab0d603144b7fa331
v1.0
instruct
Filter
Filter_24273_I
Given an array of size n, write a Python function that counts the number of inversions of pairs of elements that are present in the modified Merge Sort algorithm.
def merge_and_count(arr, temp_arr, left, mid, right): """ Merge two halves of an array and count inversions. """ i = left # Starting index for left subarray j = mid + 1 # Starting index for right subarray k = left # Starting index to be sorted inv_count = 0 # Conditions are chec...
from solution import count_inversions def test_count_inversions_sorted_array(): assert count_inversions([1, 2, 3, 4, 5]) == 0 def test_count_inversions_reverse_sorted_array(): assert count_inversions([5, 4, 3, 2, 1]) == 10 def test_count_inversions_mixed_array(): assert count_inversions([1, 3, 2, 4, 5]) ...
[ { "docstring": "Merge two halves of an array and count inversions.", "function_declaration": "def merge_and_count(arr, temp_arr, left, mid, right):", "function_name": "merge_and_count", "parameter_list": "(arr, temp_arr, left, mid, right)" }, { "docstring": "Use Merge Sort algorithm to sort ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_inversions(arr):\n \"\"\"\n Returns the number of inversions in the array using a modified merge sort algorithm.\n \"\"\"\n return _merge_sort(arr, 0, len(arr) - 1)\n\nde...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024273", "row_id": 24273, "seed_ids": "['Llama-3.3-70B-Instruct_60366']" }
0.729669
Filter_24273
I
[ "merge_and_count", "merge_sort_and_count", "count_inversions" ]
3
[ [ "count_inversions", "merge_sort_and_count" ], [ "merge_sort_and_count", "merge_and_count" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5174f861ffe4cb79002a4d6b694d84abd9778c65
2070cc9a77fe24173b3ed55e2b4cda8f9ba05209
v1.0
instruct
Filter
Filter_24299_I
Write a D3.js implementation of the scatter plot example at http://bl.ocks.org/mbostock/3887118. As a Raspberry Pi Internet-of-Things project, assume the sensor data is grabbed from the Raspberry Pi’s GPIO pins, and analyze and visualize that data with D3.js on a web page.
def create_svg_element(svg_id: str, width: int, height: int): """ Creates a basic SVG container. Args: svg_id (str): The ID for the SVG element. width (int): The width of the SVG element. height (int): The height of the SVG element. Returns: str: An SVG container as a string. "...
def test_svg_element_creation(): svg = create_svg_element('scatterplot', 960, 500) assert svg == '<svg width="960" height="500" id="scatterplot"></svg>' def test_scatter_plot_structure(): data = [{'x': 2, 'y': 3}, {'x': 4, 'y': 5}] html = scatter_plot(data) assert '<svg width="960" height="500" id=...
[ { "docstring": "Creates a basic SVG container.\n\nArgs:\nsvg_id (str): The ID for the SVG element.\nwidth (int): The width of the SVG element.\nheight (int): The height of the SVG element.\n\nReturns:\nstr: An SVG container as a string.", "function_declaration": "def create_svg_element(svg_id, width, height...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def create_svg_element(svg_id: str, width: int, height: int):\n \"\"\"\n Creates a basic SVG container.\n\n Args:\n svg_id (str): The ID for the SVG element.\n width (int): The ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00024299", "row_id": 24299, "seed_ids": "['Llama-3.3-70B-Instruct_60423']" }
0.416811
Filter_24299
I
[ "create_svg_element", "scatter_plot" ]
2
[ [ "scatter_plot", "create_svg_element" ] ]
1
[]
false
[]
false
pytest
false
[]
true
3ece8b9a1b6935099c6626f6e5fec0c0062c849f
0dc74f074fd892c199899ccbb0acd403a99dbef9
v1.0
instruct
Filter
Filter_24301_I
You are the master of pythonic code. I need help with a generator that walks a tree like data structure, puts each unique node in a dictionary, and counts the frequency of each node. The tree nodes are represented by a nested list structure where each sublist can only contain a single element or another sublist. Here ...
def node_generator(tree): for node in tree: if isinstance(node, list): yield from node_generator(node) else: yield node def count_unique_nodes(tree): unique_node_dict = {} for node in node_generator(tree): unique_node_dict[node] = unique_node_dict.get(node, 0...
from solution import count_unique_nodes, sorted_node_dict, formatted_output def test_node_generator(): generator = node_generator([1, [2, [3, 4], 5], 6, [7, [8, 9]]]) assert list(generator) == [1, 2, 3, 4, 5, 6, 7, 8, 9] def test_count_unique_nodes(): test_case = [1, [2, [3, 4], 5], 6, [7, [8, 9]]] re...
[ { "docstring": null, "function_declaration": "def node_generator(tree):", "function_name": "node_generator", "parameter_list": "(tree)" }, { "docstring": null, "function_declaration": "def count_unique_nodes(tree):", "function_name": "count_unique_nodes", "parameter_list": "(tree...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def node_generator(tree):\n for node in tree:\n if isinstance(node, list):\n yield from node_generator(node)\n else:\n yield node\n\n\ndef count_unique_n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00024301", "row_id": 24301, "seed_ids": "['Llama-3.3-70B-Instruct_60432']" }
0.632761
Filter_24301
I
[ "node_generator", "count_unique_nodes", "sorted_node_dict", "formatted_output", "main" ]
5
[ [ "count_unique_nodes", "node_generator" ] ]
1
[]
false
[]
false
pytest
true
[]
true
61e7114ba7a51c224899a988be3f358014d6c72e
b3ada09e61dadb22d259cdb9a8f8133fc07c3c40
v1.0
instruct
Filter
Filter_24303_I
Based on the Vigenère cipher, write a code to encrypt and decrypt messages with it. **Language:** Python **Requirements:** - Use keyword to encrypt and decrypt messages. - Do not use built-in shift functions, to better understand the Vigenère cipher. - Make sure to take care about the keys provided. - Include some er...
def generate_table(): """Generate a table for mapping characters.""" table = [] for i in range(26): row = [] for j in range(26): row.append(chr(((i + j) % 26) + 65)) table.append(row) return table def encrypt(message, keyword): """Encrypt the message using the Vi...
from solution import encrypt, decrypt def test_encrypt_basic_case(): assert encrypt("HELLO", "KEY") == "RIJVS" def test_decrypt_basic_case(): assert decrypt("RIJVS", "KEY") == "HELLO" def test_encrypt_with_spaces(): assert encrypt("HELLO WORLD", "KEY") == "RIJVS UYVJN" def test_decrypt_with_spaces(): ...
[ { "docstring": "Generate a table for mapping characters.", "function_declaration": "def generate_table():", "function_name": "generate_table", "parameter_list": "()" }, { "docstring": "Encrypt the message using the Vigenère cipher.", "function_declaration": "def encrypt(message, keyword)...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_table():\n \"\"\"Generate a table for mapping characters.\"\"\"\n table = []\n for i in range(26):\n row = []\n for j in range(26):\n row.append(...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024303", "row_id": 24303, "seed_ids": "['Llama-3.3-70B-Instruct_60437']" }
0.666278
Filter_24303
I
[ "generate_table", "encrypt", "decrypt" ]
3
[ [ "decrypt", "generate_table" ], [ "encrypt", "generate_table" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c2c02ae3ac158df138848ee4ad715476d36f7f64
be4d0bc77daa241e84138e66c4d09e69fa0bf276
v1.0
instruct
Filter
Filter_24328_I
### SSL Certificate Expiration and Expiration Date At a given time, you've got of bunch of SSL certificates on a load balancer along with their expiration dates. You need to come up with an algorithm to determine which certificate has yet to expire (still valid) and which has already expired at a given time. ### Examp...
from datetime import datetime from typing import Dict def is_certificate_valid(date_string: str, expiration_date_string: str, date_format: str = "%Y-%m-%d") -> bool: try: date = datetime.strptime(date_string, date_format) expiration_date = datetime.strptime(expiration_date_string, date_format) ...
from solution import is_certificate_valid, get_valid_certificates def test_is_certificate_valid(): assert is_certificate_valid("2024-02-25", "2024-03-10") == True assert is_certificate_valid("2024-02-25", "2024-02-20") == False assert is_certificate_valid("2024-02-25", "2024-02-25") == False def test_is_c...
[ { "docstring": null, "function_declaration": "def is_certificate_valid(date_string, expiration_date_string, date_format='%Y-%m-%d'):", "function_name": "is_certificate_valid", "parameter_list": "(date_string, expiration_date_string, date_format='%Y-%m-%d')" }, { "docstring": "Returns a dicti...
[ 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\nfrom typing import Dict\n\ndef is_certificate_valid(date_string: str, expiration_date_string: str, date_format: str=\"%Y-%m-%d\") -> bool:\n \"\"\"\n Retur...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024328", "row_id": 24328, "seed_ids": "['Llama-3.3-70B-Instruct_60485']" }
0.635801
Filter_24328
I
[ "is_certificate_valid", "get_valid_certificates" ]
2
[ [ "get_valid_certificates", "is_certificate_valid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fad1a6b079be43a073a9e03e0e55955eacd7cba3
3f94ae1a470271d56d0847b8a14a30ff2785744b
v1.0
instruct
Filter
Filter_24339_I
I have a vector of vectors of length 2 which contains all unique pairs of vertices of a graph. Each vector of length 2 represents an edge of the graph. For example: ``` vec_of_vecs = [[1, 2], [3, 4], [1, 3], [2, 4], [1, 4]] ``` I would like to write a function `is_connected` that takes this vector of vectors as input a...
def convert_to_adj_list(vec_of_vecs): adj_list = {} for edge in vec_of_vecs: u, v = edge if u not in adj_list: adj_list[u] = [] if v not in adj_list: adj_list[v] = [] adj_list[u].append(v) adj_list[v].append(u) return adj_list def dfs(vertex, ...
def test_convert_to_adj_list(): vec_of_vecs = [[1, 2], [3, 4], [1, 3], [2, 4], [1, 4]] expected = { 1: [2, 3, 4], 2: [1, 4], 3: [4, 1], 4: [3, 2, 1] } assert convert_to_adj_list(vec_of_vecs) == expected def test_is_connected(): vec_of_vecs = [[1, 2], [3, 4], [1, 3], ...
[ { "docstring": null, "function_declaration": "def convert_to_adj_list(vec_of_vecs):", "function_name": "convert_to_adj_list", "parameter_list": "(vec_of_vecs)" }, { "docstring": null, "function_declaration": "def dfs(vertex, adj_list, visited):", "function_name": "dfs", "paramete...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_connected(vec_of_vecs):\n \"\"\"\n Determines if the graph represented by vec_of_vecs is connected.\n\n Parameters:\n vec_of_vecs (list of list of int): List of edges in the...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024339", "row_id": 24339, "seed_ids": "['Llama-3.3-70B-Instruct_60513']" }
0.48706
Filter_24339
I
[ "convert_to_adj_list", "dfs", "is_connected" ]
3
[ [ "is_connected", "convert_to_adj_list" ], [ "is_connected", "dfs" ] ]
2
[]
false
[]
false
pytest
false
[]
true
7b625b9ad66fbff078bac0d62d7885480a696dd1
77e1fed9a3b4fb11cc8ef952bd639705ece6aa94
v1.0
instruct
Filter
Filter_24345_I
You want the random_number method from main.py to have a call to a function called generate_number which will create the helper function random_integer with the provided seed. Can you provide some high-quality code for generate_number and random_integer, and use it in the main method?
import random def random_integer(seed): """ This function generates a random integer between 0 and 100 using the provided seed for reproducibility. """ random.seed(seed) return random.randint(0, 100) def generate_number(): """ This function generates a random integer using a helper fun...
from solution import random_integer, generate_number, random_number def test_random_integer(): # Testing with known seed assert random_integer(42) == 81 # Change the expected value based on the actual random output assert random_integer(0) == 49 # Change the expected value based on the actual random out...
[ { "docstring": "This function generates a random integer between 0 and 100\nusing the provided seed for reproducibility.", "function_declaration": "def random_integer(seed):", "function_name": "random_integer", "parameter_list": "(seed)" }, { "docstring": "This function generates a random in...
[ 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 generate_number(seed=None):\n \"\"\"\n Generates a random number generator function with an optional seed.\n\n :param seed: The seed for the random number generat...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00024345", "row_id": 24345, "seed_ids": "['Llama-3.3-70B-Instruct_60526']" }
0.534116
Filter_24345
I
[ "random_integer", "generate_number", "random_number" ]
3
[ [ "generate_number", "random_integer" ], [ "random_number", "generate_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9ee0521df313ff59472f39ccc8a170f6da5bb0ea
0bb89bb2232fd384d2d77f5993e424eaa0b7a82f
v1.0
instruct
Filter
Filter_24369_I
I am creating a simple remainders program in Python. It will require to have a file to store the notes. I need the program to keep asking the requested info until the file is filled with a predetermined amount. I would like the algorithm to have the following functionalities: - The file will have a specific name "rema...
import os FILENAME = "remainder.txt" MAX_NOTES = 5 SEPARATOR = ',' def get_note_and_date_from_file(filename): notes = {} if os.path.exists(filename): with open(filename, 'r') as file: for line in file: if line.strip(): # ignore empty lines date, descrip...
import os from solution import get_note_and_date_from_file, write_to_file, FILENAME, SEPARATOR def setup_module(module): """ setup any state specific to the execution of the given module.""" with open(FILENAME, 'w') as file: file.write("") def teardown_module(module): """ teardown any state that w...
[ { "docstring": null, "function_declaration": "def get_note_and_date_from_file(filename):", "function_name": "get_note_and_date_from_file", "parameter_list": "(filename)" }, { "docstring": null, "function_declaration": "def write_to_file(filename, date, description, notes):", "functio...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\n\ndef get_notes_from_file(filename):\n notes = {}\n try:\n with open(filename, 'r') as file:\n for line in file:\n if len(line.strip()) > 0: ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024369", "row_id": 24369, "seed_ids": "['Llama-3.3-70B-Instruct_60592']" }
0.50599
Filter_24369
I
[ "get_note_and_date_from_file", "write_to_file", "ask_for_info", "main" ]
4
[ [ "ask_for_info", "get_note_and_date_from_file" ], [ "ask_for_info", "write_to_file" ] ]
2
[]
false
[]
false
pytest
true
[]
true
06da6b258494a8a758cd020cd8a483764e6a1cb3
750d64fc18856f3d59cb62ac0522fceccc1b1a66
v1.0
instruct
Filter
Filter_24382_I
I would like to simulate a scenario in Python using only built-in libraries. If you have a sorting algorithm (originally for a list of integers) that already works for integers, but you'd also like to sort a list of lists (inner lists are not empty and all the same length). Can you show me some ways to make this sortin...
def bubble_sort(arr, key=lambda x: x): """ A generalized bubble sort that can sort based on a key function. Args: arr: list of elements to be sorted. key: a function to extract a comparison key from each element (default is identity function). Returns: A sorted list. """ n ...
from solution import bubble_sort, sort_list_of_lists def test_bubble_sort_basic(): assert bubble_sort([3, 1, 2]) == [1, 2, 3] def test_bubble_sort_with_key(): assert bubble_sort([[3, 1], [1, 2], [2, 3]], key=lambda x: x[0]) == [ [1, 2], [2, 3], [3, 1] ] def test_sort_list_of_lists(): input_li...
[ { "docstring": "A generalized bubble sort that can sort based on a key function.\n\nArgs:\narr: list of elements to be sorted.\nkey: a function to extract a comparison key from each element (default is identity function).\n\nReturns:\nA sorted list.", "function_declaration": "def bubble_sort(arr, key=lambda...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def bubble_sort(arr):\n n = len(arr)\n for i in range(n-1):\n for j in range(0, n-i-1):\n if arr[j] > arr[j+1]:\n arr[j], arr[j+1] = arr[j+1], arr[j]\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024382", "row_id": 24382, "seed_ids": "['Llama-3.3-70B-Instruct_60626']" }
0.655086
Filter_24382
I
[ "bubble_sort", "sort_list_of_lists" ]
2
[ [ "sort_list_of_lists", "bubble_sort" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1b9aa33461e4187981b2d7db4e354bf5e28f5f98
b04a51e35bfdaab95943ca27c00d1b2fb3befba4
v1.0
instruct
Filter
Filter_24415_I
Here is the problem: ObjectType: Control Name: DHPSystem_selector LCM: SingleSelectList� Isoreach: false uinactive: false adaystofix: 500 dequeue деньえ.. Repairshedule: [["2024-01-10","noselect","oreilly999"],["2024-02-05"," retvalthisone"," videogames:m IMGTheatreแฟ售edo.Search=rand spear.YX delve te Italis fatally...
import re def contains_number(name): """ Checks if a string contains any numbers. Args: name (str): The input string to check. Returns: bool: True if the string contains any numbers, False otherwise. """ return any(char.isdigit() for char in name) def evaluate_repair_schedule...
from solution import contains_number, evaluate_repair_schedule def test_contains_number(): assert contains_number("oreilly999") == True assert contains_number("noselect") == False assert contains_number("retvalthisone") == False assert contains_number("videogames") == False assert contains_number("...
[ { "docstring": "Checks if a string contains any numbers.\n\nArgs:\n name (str): The input string to check.\n\nReturns:\n bool: True if the string contains any numbers, False otherwise.", "function_declaration": "def contains_number(name):", "function_name": "contains_number", "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 contains_number(name):\n \"\"\"\n Checks if a string contains any numbers.\n\n Args:\n name (str): The input string to check.\n\n Returns:\n bool: True if the str...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024415", "row_id": 24415, "seed_ids": "['Llama-3.3-70B-Instruct_60704']" }
0.47748
Filter_24415
I
[ "contains_number", "evaluate_repair_schedule" ]
2
[ [ "evaluate_repair_schedule", "contains_number" ] ]
1
[]
false
[]
false
pytest
true
[]
true
25f9bb1e03cac661ada9c927b85ebfb76d70e14d
5962f0d4d8ded0ce8d6c0125935312a6232f7f1c
v1.0
instruct
Filter
Filter_24421_I
I've encountered a scenario where I need to generate random passwords for about 3000 employees, and these should be 12 characters long, contain a mix of characters, numbers, and special characters. I also have to make sure these generated passwords do not contain any employee's name, employee ID, or any other sensitive...
import random import string def generate_random_password(): """ Generates a 12-character long random password containing a mix of uppercase, lowercase letters, digits, and special characters. """ characters = string.ascii_letters + string.digits + string.punctuation password = ''.join(random.ch...
from solution import generate_random_password, is_safe_password, generate_passwords def test_generate_random_password(): password = generate_random_password() assert len(password) == 12 assert any(char.isdigit() for char in password) assert any(char.isupper() for char in password) assert any(char.i...
[ { "docstring": "Generates a 12-character long random password containing a mix of uppercase,\nlowercase letters, digits, and special characters.", "function_declaration": "def generate_random_password():", "function_name": "generate_random_password", "parameter_list": "()" }, { "docstring": ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport string\n\ndef generate_password(exclude_list):\n \"\"\"\n Generates a random 12-character password that does not contain any of the substrings in exclude_list.\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024421", "row_id": 24421, "seed_ids": "['Llama-3.3-70B-Instruct_60713']" }
0.668645
Filter_24421
I
[ "generate_random_password", "is_safe_password", "generate_passwords" ]
3
[ [ "generate_passwords", "generate_random_password" ], [ "generate_passwords", "is_safe_password" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a9ab19425981b08d5f697f640f97382ee96b1b23
8578c218860eadef02c5e5fcdb1935392bcd0c49
v1.0
instruct
Filter
Filter_24446_I
I want to write an extensive application to direct the customers of whom were stolen debit cards to the relevant banks and help them to report cases accordingly The python application will automate the UI in such a way that each bank has its dedicated form where entering just bank name would identify and match the vic...
from flask import Flask, render_template, request, redirect, url_for from werkzeug.utils import secure_filename import os import sqlite3 app = Flask(__name__) # Connecting to SQLite database conn = sqlite3.connect('customer.db') c = conn.cursor() # Create table c.execute("""CREATE TABLE IF NOT EXISTS customers ( ...
import pytest from solution import allowed_file def test_allowed_file(): assert allowed_file("test.jpg") == True assert allowed_file("test.png") == True assert allowed_file("test.jpeg") == True assert allowed_file("test.gif") == False assert allowed_file("test.txt") == False assert allowed_file...
[ { "docstring": null, "function_declaration": "def allowed_file(filename):", "function_name": "allowed_file", "parameter_list": "(filename)" }, { "docstring": null, "function_declaration": "def index():", "function_name": "index", "parameter_list": "()" }, { "docstring": n...
[ 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, render_template, request, redirect, url_for\nfrom werkzeug.utils import secure_filename\nimport os\nimport sqlite3\n\napp = Flask(__name__)\n\n# File upload config\nUP...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024446", "row_id": 24446, "seed_ids": "['Llama-3.3-70B-Instruct_60777']" }
0.532937
Filter_24446
I
[ "allowed_file", "index", "createprofile", "identify_bank", "report_form", "confirmation", "admin_dashboard" ]
7
[ [ "createprofile", "allowed_file" ] ]
1
[]
false
[]
false
pytest
true
[ "flask", "werkzeug" ]
false
0938351c7991c8c855c9d9e3fc30b0eb39f09377
2aa94de60779e42aa632763432db1dd6c9b270bf
v1.0
instruct
Filter
Filter_24451_I
Write code that solves the "Papers, Please" puzzle. The puzzle is to write a fictional passport application reader that takes a string input, extracts the required fields, and checks for potential security risks. The key fields in the string input are: - `dln` (driver's license number) - `hcl` (hair color) - `ecl` (e...
import re def validate_height(hgt): if hgt.endswith("cm"): value = int(hgt[:-2]) return 150 <= value <= 193 elif hgt.endswith("in"): value = int(hgt[:-2]) return 59 <= value <= 76 return False def validate_hair_color(hcl): return bool(re.match(r"^#[0-9a-f]{6}$", hcl)) ...
from solution import validate_passport def test_valid_passport(): data = "byr:2002 iyr:2012 eyr:2023 hgt:175cm hcl:#602927 ecl:brn pid:012345678 dln:1234567" assert validate_passport(data) == True def test_invalid_byr(): data = "byr:1919 iyr:2012 eyr:2023 hgt:175cm hcl:#602927 ecl:brn pid:012345678 dln:12...
[ { "docstring": null, "function_declaration": "def validate_height(hgt):", "function_name": "validate_height", "parameter_list": "(hgt)" }, { "docstring": null, "function_declaration": "def validate_hair_color(hcl):", "function_name": "validate_hair_color", "parameter_list": "(hcl...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef validate_height(hgt):\n if hgt.endswith(\"cm\"):\n value = int(hgt[:-2])\n return 150 <= value <= 193\n elif hgt.endswith(\"in\"):\n value = int(hgt...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00024451", "row_id": 24451, "seed_ids": "['Llama-3.3-70B-Instruct_60792']" }
0.486394
Filter_24451
I
[ "validate_height", "validate_hair_color", "validate_passport_id", "validate_passport" ]
4
[ [ "validate_passport", "validate_hair_color" ], [ "validate_passport", "validate_height" ], [ "validate_passport", "validate_passport_id" ] ]
3
[]
false
[]
false
pytest
true
[]
true
8072060a840ab4d3ecdf7035b709e6b4fe5c3686
015cffaf69d27ffd814343c4173051250028905f
v1.0
instruct
Filter
Filter_24456_I
Many special algorithmic techniques used in solving mathematical problems make it indeed true that the technique called divide-and-conquer is innovatively utilized to explicate countless problems within the realm of algorithms. Today, I want to propose a simple problem with a divide-and-conquer solution so that you can...
from collections import deque def counting_sort(arr, exp): n = len(arr) output = [0] * n count = [0] * 10 for i in range(n): index = arr[i] // exp count[index % 10] += 1 for i in range(1, 10): count[i] += count[i - 1] for i in range(n - 1, -1, -1): index = arr...
from solution import radix_sort_streaming def test_empty_input(): input_stream = [] assert radix_sort_streaming(input_stream) == [] def test_single_chunk(): input_stream = [[170, 45, 75, 90, 802, 24, 2, 66]] assert radix_sort_streaming(input_stream) == [2, 24, 45, 66, 75, 90, 170, 802] def test_multi...
[ { "docstring": null, "function_declaration": "def counting_sort(arr, exp):", "function_name": "counting_sort", "parameter_list": "(arr, exp)" }, { "docstring": null, "function_declaration": "def radix_sort_streaming(input_stream):", "function_name": "radix_sort_streaming", "param...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\n\ndef counting_sort_for_radix(input_list, exponent):\n n = len(input_list)\n output_list = [0] * n # output list to store the sorted order\n count = [0] * 10 # count arra...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024456", "row_id": 24456, "seed_ids": "['Llama-3.3-70B-Instruct_60806']" }
0.472356
Filter_24456
I
[ "counting_sort", "radix_sort_streaming" ]
2
[ [ "radix_sort_streaming", "counting_sort" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d607e2e59f3dbcb51568490eb91fcd2b94b8e440
28518c062c6010f95834670f3f2e36836adff160
v1.0
instruct
Filter
Filter_24485_I
Here's my code with metaprogramming concept: ```python def add_suffix(name, suffix): def decorator(func): def wrapper(*args, **kwargs): result = func(*args, **kwargs) return result wrapper.__name__ = name + suffix return wrapper return decorator @add_suffix("say_...
def add_suffix(name, suffix): def decorator(func): def wrapper(*args, **kwargs): result = func(*args, **kwargs) return result wrapper.__name__ = name + suffix return wrapper return decorator @add_suffix("say_", "_hello_world") def hello(): return 'hi' @add_s...
from solution import hello, world def test_hello_name(): assert hello.__name__ == "say__hello_world" def test_world_name(): assert world.__name__ == "test__olo_))" def test_hello_functionality(): assert hello() == "hi" def test_world_functionality(): assert world() == "hello"
[ { "docstring": null, "function_declaration": "def add_suffix(name, suffix):", "function_name": "add_suffix", "parameter_list": "(name, suffix)" }, { "docstring": null, "function_declaration": "def hello():", "function_name": "hello", "parameter_list": "()" }, { "docstring...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def add_suffix(name, suffix):\n def decorator(func):\n def wrapper(*args, **kwargs):\n result = func(*args, **kwargs)\n return result\n wrapper.__name__ ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024485", "row_id": 24485, "seed_ids": "['Llama-3.3-70B-Instruct_60889']" }
0.399133
Filter_24485
I
[ "add_suffix", "hello", "world" ]
3
[ [ "hello", "add_suffix" ], [ "world", "add_suffix" ] ]
2
[]
false
[]
false
pytest
true
[]
true
032c20635e4f11a5be8ab87bf6e7a9f964400a58
216984aed7abbb55996ddd5d22f78b21bd81e4c0
v1.0
instruct
Filter
Filter_24524_I
### Zip Multiple Files #### Problem Description You have 50 files with the same extension (`.csv`) in a directory, and you want to create a zip archive with all of them at once. #### Solution ```python import os import zipfile # Specify the directory path and the zip file name directory_path = '/path/to/your/director...
import os import zipfile def get_csv_files(directory_path): """ Returns a list of CSV files in the given directory. Args: directory_path (str): The path of the directory to search in. Returns: list: List of CSV file paths. """ return [os.path.join(directory_path, filename) for filenam...
import os import zipfile from solution import get_csv_files, create_zip_from_files, zip_csv_files def setup_test_directory(test_dir, filenames): os.makedirs(test_dir, exist_ok=True) for filename in filenames: open(os.path.join(test_dir, filename), 'w').close() def teardown_test_directory(test_dir): ...
[ { "docstring": "Returns a list of CSV files in the given directory.\n\nArgs:\ndirectory_path (str): The path of the directory to search in.\n\nReturns:\nlist: List of CSV file paths.", "function_declaration": "def get_csv_files(directory_path):", "function_name": "get_csv_files", "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 os\nimport zipfile\n\ndef create_zip_file(directory_path, zip_file_name, extension='.csv', exclusions=None):\n \"\"\"\n Creates a zip file containing all files with a specific ext...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00024524", "row_id": 24524, "seed_ids": "['Llama-3.3-70B-Instruct_60986']" }
0.726843
Filter_24524
I
[ "get_csv_files", "create_zip_from_files", "zip_csv_files" ]
3
[ [ "zip_csv_files", "create_zip_from_files" ], [ "zip_csv_files", "get_csv_files" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fc5240579850ca6ec7c052dfca9b63e5a3853fc6
9b4280949e5ceca9eb852f4004cdee03b80bd43b
v1.0
instruct
Filter
Filter_24528_I
Here is a recursive function to implement the insertion sort algorithm. It will sort a list of integers in ascending order, recursively. ```python def recursive_insertion_sort(lst): if len(lst) <= 1: return lst else: return insert(lst[:1], recursive_insertion_sort(lst[1:])) def insert(lst, so...
def recursive_insertion_sort(lst): if len(lst) <= 1: return lst else: return insert(lst[0], recursive_insertion_sort(lst[1:])) def insert(element, sorted_lst): if len(sorted_lst) == 0: return [element] elif element <= sorted_lst[0]: return [element] + sorted_lst else...
from solution import recursive_insertion_sort def test_recursive_insertion_sort_empty_list(): assert recursive_insertion_sort([]) == [] def test_recursive_insertion_sort_single_element(): assert recursive_insertion_sort([1]) == [1] def test_recursive_insertion_sort_sorted_list(): assert recursive_inserti...
[ { "docstring": null, "function_declaration": "def recursive_insertion_sort(lst):", "function_name": "recursive_insertion_sort", "parameter_list": "(lst)" }, { "docstring": null, "function_declaration": "def insert(element, sorted_lst):", "function_name": "insert", "parameter_list...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def recursive_insertion_sort(lst):\n if len(lst) <= 1:\n return lst\n else:\n first_element = lst[0]\n sorted_lst = recursive_insertion_sort(lst[1:])\n return...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024528", "row_id": 24528, "seed_ids": "['Llama-3.3-70B-Instruct_60996']" }
0.50989
Filter_24528
I
[ "recursive_insertion_sort", "insert" ]
2
[ [ "recursive_insertion_sort", "insert" ] ]
1
[]
false
[]
false
pytest
true
[]
true
acb17ba4310c6514f9e1d78992b9be22542455d8
c3eed2af7417bf74a37a7416ecc641c32c40ec7d
v1.0
instruct
Filter
Filter_24529_I
### Telegram Bot Setup #### Overview To set up a new Telegram bot for informing about cooling breaks, define a new Telegram bot using the BotFather bot. Choose a name and a username for the bot. Obtain the API token provided by BotFather. 1. Open Telegram and start a conversation with **BotFather**. 2. Send `/newbot` ...
import requests API_TOKEN = "YOUR_API_TOKEN" def send_message(chat_id, message): url = f"https://api.telegram.org/bot{API_TOKEN}/sendMessage" params = { "chat_id": chat_id, "text": message } response = requests.get(url, params=params) if response.status_code != 200: print(f...
from unittest.mock import patch from solution import notify_cooling_break, send_message @patch('solution.requests.get') def test_notify_cooling_break_success(mock_get): mock_get.return_value.status_code = 200 chat_ids = [12345, 67890] results = notify_cooling_break(chat_ids) assert results[12...
[ { "docstring": null, "function_declaration": "def send_message(chat_id, message):", "function_name": "send_message", "parameter_list": "(chat_id, message)" }, { "docstring": "Send a cooling break notification to all users in the chat_ids list.\n\nArgs:\nchat_ids (list): List of chat IDs to s...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import requests\n\ndef send_message(api_token, chat_id, message):\n \"\"\"\n Sends a message to a specific Telegram chat.\n\n Parameters:\n - api_token (str): The API token for the...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00024529", "row_id": 24529, "seed_ids": "['Llama-3.3-70B-Instruct_60999']" }
0.420413
Filter_24529
I
[ "send_message", "notify_cooling_break" ]
2
[ [ "notify_cooling_break", "send_message" ] ]
1
[]
false
[]
false
pytest
true
[ "requests" ]
false
d183767288327d3c5f8122630571c900a9a8c450
f31bc0b9960513cfb17cb7fd6c2e694fdc1fff7e
v1.0
instruct
Filter
Filter_24530_I
Here are the instructions you need to follow to create a code block: 1. Write a Python function that takes in a string with a format of the form XXX-XXX-XXXX and returns a string with every digit replaced with it's corresponding alphabetical index (A=1, B=2, C=3, etc.) - For example, if the input string is "123-456-789...
def get_stringMapped(input_string: str) -> str: """ Returns a string where every digit is replaced with its corresponding alphabetical index (A=1, B=2, C=3, etc.) :param input_string: string in the format XXX-XXX-XXXX :return: string with digits replaced by their corresponding alphabetical index ...
from solution import get_stringMapped, get_strings_mapped def test_get_stringMapped(): assert get_stringMapped("123-456-7890") == "ABC-DEF-GHIJ" assert get_stringMapped("111-222-3333") == "AAA-BBB-CCCC" assert get_stringMapped("987-654-3210") == "IHG-FED-CBAJ" def test_get_strings_mapped(): assert get...
[ { "docstring": "Returns a string where every digit is replaced with its corresponding alphabetical index (A=1, B=2, C=3, etc.)\n\n:param input_string: string in the format XXX-XXX-XXXX\n:return: string with digits replaced by their corresponding alphabetical index", "function_declaration": "def get_stringMa...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def get_stringMapped(input_string: str) -> str:\n char_map = {str(i): chr(64 + int(i)) for i in range(1, 10)}\n char_map['0'] = 'J'\n result = ''\n for char in input_string:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024530", "row_id": 24530, "seed_ids": "['Llama-3.3-70B-Instruct_61001']" }
0.568947
Filter_24530
I
[ "get_stringMapped", "get_strings_mapped" ]
2
[ [ "get_strings_mapped", "get_stringMapped" ] ]
1
[]
false
[]
false
pytest
true
[]
true
903045b741ada2cd087c50a6a2c9255735d1f9b9
78435508f18faa30b609d0f3bb3b9daa5ed6e152
v1.0
instruct
Filter
Filter_24541_I
I have a numerical computing project where I need to calculate the first 100 prime numbers. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. I am looking for a few different algorithms to achieve this. ### Algorithm 1: Simple Trial Division This algorithm will it...
import math # Algorithm 1: Simple Trial Division def first_100_primes_trial_division(): primes = [] num = 2 while len(primes) < 100: is_prime = True for i in range(2, int(math.sqrt(num)) + 1): if num % i == 0: is_prime = False break if is_...
from solution import first_100_primes_trial_division, first_100_primes_sieve_of_eratosthenes, first_100_primes_aks def test_first_100_primes_trial_division(): primes = first_100_primes_trial_division() assert len(primes) == 100 assert primes[0] == 2 assert primes[99] == 541 def test_first_100_primes_s...
[ { "docstring": null, "function_declaration": "def first_100_primes_trial_division():", "function_name": "first_100_primes_trial_division", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def first_100_primes_sieve_of_eratosthenes():", "function_name": "first_1...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\n# Algorithm 1: Simple Trial Division\ndef first_100_primes_trial_division():\n primes = []\n num = 2\n while len(primes) < 100:\n is_prime = True\n for i ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00024541", "row_id": 24541, "seed_ids": "['Llama-3.3-70B-Instruct_61021']" }
0.605529
Filter_24541
I
[ "first_100_primes_trial_division", "first_100_primes_sieve_of_eratosthenes", "is_prime_aks", "first_100_primes_aks" ]
4
[ [ "first_100_primes_aks", "is_prime_aks" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fe8d27a58a44a3540b0c7bcce833a13ca580446f
afea3ed26f4d6b186f2660958f07bc476d0c6eb7
v1.0
instruct
Filter
Filter_24591_I
Here are the rules for the game: The game is played with 128 teams. The game is played on a circular board with 128 slots, numbered 1-128. Each team is assigned a unique number from 1-128 and that number corresponds to the slot where the team will start the game. The game is played for a fixed number of rounds, let's s...
import random def roll_die(): return random.randint(1, 6) def play_game(num_teams=128, num_rounds=3): positions = {i: i for i in range(1, num_teams + 1)} active_teams = set(range(1, num_teams + 1)) for _ in range(num_rounds): new_positions = {} for team in list(active_teams): ...
from solution import play_game def test_initial_positions(): positions = {i: i for i in range(1, 129)} assert len(positions) == 128 assert positions[1] == 1 assert positions[128] == 128 def test_single_round(): results = play_game(num_rounds=1) assert isinstance(results, list) or isinstanc...
[ { "docstring": null, "function_declaration": "def roll_die():", "function_name": "roll_die", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def play_game(num_teams=128, num_rounds=3):", "function_name": "play_game", "parameter_list": "(num_teams=128, num_...
[ 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\nclass Game:\n def __init__(self, num_teams=128, num_slots=128):\n self.num_teams = num_teams\n self.num_slots = num_slots\n self.teams_positions = {i: ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00024591", "row_id": 24591, "seed_ids": "['Llama-3.3-70B-Instruct_61119']" }
0.559357
Filter_24591
I
[ "roll_die", "play_game", "simulate_gameplay" ]
3
[ [ "play_game", "roll_die" ], [ "simulate_gameplay", "play_game" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9a53c839daff5d0d3a3946ee65def48fa723f7ca
0000eded8a8bbd1acac7d3ee595b00f6a1bc6363
v1.0
instruct
Filter
Filter_24594_I
After loading features from all devices, change the color palette of the default skin to Light Coral (color id: #FFC67D) and use the Null Engine driver for audio. Expected output to the console: Loading features from device /dev/input/event0 Loading features from device /dev/input/event1 Loading features from dev...
import glob def load_device_features(device_pattern="/dev/input/event*"): """ Load features from input devices based on the device pattern. """ input_devices = glob.glob(device_pattern) for device in input_devices: print(f"Loading features from device {device}") print("Done loading fea...
import pytest import builtins from unittest.mock import patch, call from solution import load_device_features, change_color_palette, use_audio_driver, initialize_system def test_load_device_features(capsys, monkeypatch): mock_devices = ["/dev/input/event0", "/dev/input/event1", "/dev/input/event2"] def m...
[ { "docstring": "Load features from input devices based on the device pattern.", "function_declaration": "def load_device_features(device_pattern='/dev/input/event*'):", "function_name": "load_device_features", "parameter_list": "(device_pattern='/dev/input/event*')" }, { "docstring": "Change...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import glob\n\ndef load_device_features(device_pattern):\n input_devices = glob.glob(device_pattern)\n for device in input_devices:\n print(f\"Loading features from device {device...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00024594", "row_id": 24594, "seed_ids": "['Llama-3.3-70B-Instruct_61130']" }
0.376666
Filter_24594
I
[ "load_device_features", "change_color_palette", "use_audio_driver", "initialize_system" ]
4
[ [ "initialize_system", "change_color_palette" ], [ "initialize_system", "load_device_features" ], [ "initialize_system", "use_audio_driver" ] ]
3
[]
false
[]
false
pytest
true
[]
true
06500fe2cc208939f5bf3a1b720256bad5927764
700b54deeae7c75d12546020872a4d577323463c
v1.0
instruct
Filter
Filter_24627_I
I need a way to know when the date is a federal holiday in the US for the next 100 years. Here you have a and sample list of federal holidays in the US. ``` - New Year's Day: January 1 - Martin Luther King Jr. Day: Third Monday in January - Presidents' Day: Third Monday in February - Easter: Typically first Sund...
import datetime import calendar def nth_weekday(year, month, weekday, n): """ Returns the nth weekday date for a given year, month, and weekday. E.g., nth_weekday(2024, 1, 0, 3) returns the date for the 3rd Monday of January 2024. """ first_day_of_month = datetime.date(year, month, 1) first_wee...
import datetime from solution import federal_holiday def test_new_year(): assert federal_holiday(datetime.date(2024, 1, 1)) == 'New Year\'s Day' def test_mlk_day(): assert federal_holiday(datetime.date(2024, 1, 15)) == 'Martin Luther King Jr. Day' def test_presidents_day(): assert federal_holiday(datetim...
[ { "docstring": "Returns the nth weekday date for a given year, month, and weekday.\nE.g., nth_weekday(2024, 1, 0, 3) returns the date for the 3rd Monday of January 2024.", "function_declaration": "def nth_weekday(year, month, weekday, n):", "function_name": "nth_weekday", "parameter_list": "(year, m...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import datetime\nimport calendar\n\ndef nth_weekday(year, month, weekday, n):\n \"\"\"\n Returns the nth weekday date for a given year, month, and weekday.\n E.g., nth_weekday(2024, 1...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00024627", "row_id": 24627, "seed_ids": "['Llama-3.3-70B-Instruct_61192']" }
0.630056
Filter_24627
I
[ "nth_weekday", "last_weekday", "calculate_easter", "federal_holiday" ]
4
[ [ "federal_holiday", "calculate_easter" ], [ "federal_holiday", "last_weekday" ], [ "federal_holiday", "nth_weekday" ] ]
3
[]
false
[]
false
pytest
true
[]
true
5cb84524ceee021574d309688dbecba4b62d46a2
f57de470d4b6ded5a7b5964f2d5b5c09aa8f2d4b
v1.0
instruct
Filter
Filter_24644_I
The prime factorization of n! is a mathematical representation that shows which prime numbers are included in the product of all positive integers up to n. I need a program I can use to calculate the prime factorization of n! when given the input n. Here are some specifications: 1) Represent each prime factor with ...
def sieve_of_eratosthenes(n): """ Compute all prime numbers up to a given number n using the Sieve of Eratosthenes algorithm. """ is_prime = [True] * (n + 1) p = 2 while p * p <= n: if is_prime[p] == True: for i in range(p * p, n + 1, p): is_prime[i] = False ...
from solution import sieve_of_eratosthenes, prime_factorization_of_factorial def test_sieve_of_eratosthenes(): assert sieve_of_eratosthenes(10) == [2, 3, 5, 7] assert sieve_of_eratosthenes(1) == [] assert sieve_of_eratosthenes(2) == [2] assert sieve_of_eratosthenes(0) == [] def test_prime_factorizatio...
[ { "docstring": "Compute all prime numbers up to a given number n using the Sieve of Eratosthenes algorithm.", "function_declaration": "def sieve_of_eratosthenes(n):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(n)" }, { "docstring": "Returns the prime factorization of n! as...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def prime_factors_of_factorial(n):\n \"\"\"\n Returns a list of tuples representing the prime factors of n! and their exponents.\n The prime factors are returned in ascending order.\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024644", "row_id": 24644, "seed_ids": "['Llama-3.3-70B-Instruct_61232']" }
0.681304
Filter_24644
I
[ "sieve_of_eratosthenes", "prime_factorization_of_factorial" ]
2
[ [ "prime_factorization_of_factorial", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bcbc79cbf86af27079d2735316a71ec581f854e5
3b70a2e39e5255faa8c044aad8e3e9fedec0ade2
v1.0
instruct
Filter
Filter_24645_I
I wrote the code in another language, here's the pseudo-code and I need help implementing it. Here's the Pseudo-code: ``` PROGRAM circ digraph c: // initialize an empty collection FOR 문의 maxx те 10 read_from_database("circuits.txt", typename) c add typename FOR 맞게 PreparedStatement add Prepared...
def read_circuit_types(file_path): """ Reads circuit types from the given file and returns them as a list. :param file_path: The path to the file containing circuit types. :return: A list of circuit types. """ circuit_types = [] try: with open(file_path, 'r') as file: fo...
import pytest from solution import read_circuit_types, circ_digraph def test_read_circuit_types(): # Create a temporary file for testing file_path = 'test_circuits.txt' with open(file_path, 'w') as file: file.write("C1\nC2\nC3\n") circuit_types = read_circuit_types(file_path) assert ci...
[ { "docstring": "Reads circuit types from the given file and returns them as a list.\n\n:param file_path: The path to the file containing circuit types.\n:return: A list of circuit types.", "function_declaration": "def read_circuit_types(file_path):", "function_name": "read_circuit_types", "parameter...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def read_circuits_from_file(file_path):\n \"\"\"\n Reads circuit types from a file and returns a list of the circuit types.\n \n Args:\n file_path (str): The path to the file fr...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024645", "row_id": 24645, "seed_ids": "['Llama-3.3-70B-Instruct_61233']" }
0.428797
Filter_24645
I
[ "read_circuit_types", "circ_digraph" ]
2
[ [ "circ_digraph", "read_circuit_types" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7d7de8a5254e2b4677d384748380a922604168f4
7dd663751ec42e236150558c7612b1e077e4cc82
v1.0
instruct
Filter
Filter_24653_I
Design a Python function called `reroute` that takes two parameters: `inputs` and `boundaries`. `inputs` will be a list of tuples representing points (x, y) on a coordinate system, while `boundaries` will be a list of lists representing rectangles, where each rectangle is defined by two opposite corners: (x1, y1) and (...
def point_in_rectangle(point, rect): """ Check if the point (x, y) is inside the rectangle defined by rect((x1, y1), (x2, y2)). """ (x, y) = point (x1, y1), (x2, y2) = rect # Determine the min and max bounds of the rectangle min_x, max_x = min(x1, x2), max(x1, x2) min_y, max_y = min...
from solution import point_in_rectangle, reroute def test_point_in_rectangle(): assert point_in_rectangle((3, 3), ((2, 2), (4, 4))) == True assert point_in_rectangle((1, 1), ((2, 2), (4, 4))) == False assert point_in_rectangle((5, 5), ((2, 2), (4, 4))) == False assert point_in_rectangle((2, 3), ((2, 2)...
[ { "docstring": "Check if the point (x, y) is inside the rectangle defined by rect((x1, y1), (x2, y2)).", "function_declaration": "def point_in_rectangle(point, rect):", "function_name": "point_in_rectangle", "parameter_list": "(point, rect)" }, { "docstring": "Reroute the points that fall wi...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def reroute(inputs, boundaries):\n \"\"\"\n Returns a new list of points after rerouting them if they fall inside any of the rectangles defined by 'boundaries'.\n \n params:\n i...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00024653", "row_id": 24653, "seed_ids": "['Llama-3.3-70B-Instruct_61249']" }
0.511613
Filter_24653
I
[ "point_in_rectangle", "reroute" ]
2
[ [ "reroute", "point_in_rectangle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
93cf53ced9a6e604bf205bd78a119d0aff49f750
1b4a749a53b05b0755f52efaf2a41159c79ad19d
v1.0
instruct
Filter
Filter_24672_I
I wrote a program that generates a random set of board game pieces, including two character pieces and six dice. The code is partially written, but I'm having trouble with combining the data. Below is how the code looks: ```python import random # Generate character pieces def generate_character_pieces(): charac...
import random # Generate character pieces def generate_character_pieces(): characters = ["Warrior", "Mage", "Rogue"] return [random.choice(characters) for _ in range(2)] # Generate dice def generate_dice(): dice_sides = 6 return [random.randint(1, dice_sides) for _ in range(6)] # Main function to gen...
from solution import generate_board_game_pieces def test_generate_character_pieces_length(): result = generate_board_game_pieces() assert len(result["characters"]) == 2 def test_generate_dice_length(): result = generate_board_game_pieces() assert len(result["dice"]) == 6 def test_generate_character_p...
[ { "docstring": null, "function_declaration": "def generate_character_pieces():", "function_name": "generate_character_pieces", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def generate_dice():", "function_name": "generate_dice", "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 random\n\n# Generate character pieces\ndef generate_character_pieces():\n characters = [\"Warrior\", \"Mage\", \"Rogue\"]\n return [random.choice(characters) for _ in range(2)]\n\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024672", "row_id": 24672, "seed_ids": "['Llama-3.3-70B-Instruct_61290']" }
0.473216
Filter_24672
I
[ "generate_character_pieces", "generate_dice", "generate_board_game_pieces" ]
3
[ [ "generate_board_game_pieces", "generate_character_pieces" ], [ "generate_board_game_pieces", "generate_dice" ] ]
2
[]
false
[]
false
pytest
true
[]
true
4edbc6936723fc7fe759a1453ebd59259d1686b7
38fa69d9ee924b6ea57c5cd98b25c5736b8cfeb0
v1.0
instruct
Filter
Filter_24698_I
I hope this isn't too basic, but I'm having trouble getting a subtraction function to work. Here's what I need to happen: I have "a" and "would" function which takes (or accepts) two arguments. Each argument that "would" accepts can be assumed to only be a dollar amount. The implementation of the function should be m...
def would(a, b): """ Returns the result of subtracting the length of string `b` from the value `a`. """ return a - len(b) def calculate_new_balance(starting_balance, value1, value2): """ Calculates the new balance after performing the required operations. `starting_balance` is the initial a...
from solution import would, calculate_new_balance def test_would(): assert would(50, "hello world") == 50 - 11 assert would(20, "a") == 20 - 1 assert would(10, "abc") == 10 - 3 def test_calculate_new_balance(): assert calculate_new_balance(100, 50, "hello world") == 61 assert calculate_new_balance...
[ { "docstring": "Returns the result of subtracting the length of string `b` from the value `a`.", "function_declaration": "def would(a, b):", "function_name": "would", "parameter_list": "(a, b)" }, { "docstring": "Calculates the new balance after performing the required operations.\n`starting...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def would(a, b):\n \"\"\"\n Returns the result of subtracting the length of string `b` from the value `a`.\n \"\"\"\n return a - len(b)\n\ndef calculate_new_balance(starting_balanc...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00024698", "row_id": 24698, "seed_ids": "['Llama-3.3-70B-Instruct_61353']" }
0.446611
Filter_24698
I
[ "would", "calculate_new_balance" ]
2
[ [ "calculate_new_balance", "would" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ecd81c9c06ff88d9809f8ce359bd139182e56ea7
87a17f99f10838344efb63ac0509014de4e96582
v1.0
instruct
Filter
Filter_24730_I
### Build a Rock, Paper, Scissors Game #### Overview Create a Rock, Paper, Scissors game that can be played between two people, or a single player against the computer. #### Game Rules * The game is played best two out of three. * If a player wins two games in a row, they win the match. #### Functionality * The game ...
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 a single game round""" if player1 == player2: return None if (pl...
def test_get_computer_choice(): choices = ['Rock', 'Paper', 'Scissors'] assert get_computer_choice() in choices def test_determine_winner(): assert determine_winner('Rock', 'Scissors') == 'player1' # Rock crushes Scissors assert determine_winner('Paper', 'Rock') == 'player1' # Paper covers Rock a...
[ { "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 a single game round", "function_declaration": "def determine_winner(play...
[ 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 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": "00024730", "row_id": 24730, "seed_ids": "['Llama-3.3-70B-Instruct_61422']" }
0.579692
Filter_24730
I
[ "get_computer_choice", "determine_winner", "game" ]
3
[ [ "game", "determine_winner" ], [ "game", "get_computer_choice" ] ]
2
[]
false
[]
false
pytest
false
[]
true
40a369867e9e34bafd3b2762f734890ba6948df3
42e25505a2ca08bdbaf51fbcd34958801accc4f8
v1.0
instruct
Filter
Filter_24754_I
I have a binary tree where each node has a character, and the integers representing parent and left and right child of the node. Here is a small sample data structure: ```python data = [ {"char": "A", "parent": -1, "left": -1, "right": -1}, {"char": "B", "parent": 0, "left": -1, "right": -1}, {"char": "C"...
class Node: def __init__(self, char): self.char = char self.left = None self.right = None def build_tree(data): nodes = [Node(d["char"]) for d in data] for i, d in enumerate(data): if d["parent"] != -1: parent = nodes[d["parent"]] if not parent.left: ...
from solution import build_tree, generate_traversal_strings, strict_phylogenetic_check, laxer_phylogenetic_check, check_incorrect_tree # Sample test data data = [ {"char": "A", "parent": -1, "left": -1, "right": -1}, {"char": "B", "parent": 0, "left": -1, "right": -1}, {"char": "C", "parent": 0, "left": -1...
[]
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class Node:\n def __init__(self, char):\n self.char = char\n self.left = None\n self.right = None\n\ndef build_tree(data):\n nodes = [Node(d[\"char\"]) for d in data...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00024754", "row_id": 24754, "seed_ids": "['Llama-3.3-70B-Instruct_61476']" }
0.5987
Filter_24754
I
[ "build_tree", "preorder_traversal", "inorder_traversal", "strict_phylogenetic_check", "laxer_phylogenetic_check", "check_incorrect_tree", "generate_traversal_strings" ]
7
[ [ "generate_traversal_strings", "inorder_traversal" ], [ "generate_traversal_strings", "preorder_traversal" ] ]
2
[]
false
[ "Node" ]
true
pytest
true
[]
true
8746d5d0385b9391bbd257599cca530d3300ae44
ba7f417ba9600cefe2532e66fe695a0d2c6ed55e
v1.0
instruct
Filter
Filter_24757_I
### Algorithms #### 1.1 Slide 41: Depth-First Search Depth-first search (DFS) is an algorithm for searching a graph or tree data structure. The algorithm starts at the root node (selecting some arbitrary node as the root node in the case of a graph) and explores as far as possible along each branch before backtracking....
def DFS_All_Nodes(graph): """ Perform DFS to visit all nodes in a graph, even if it consists of multiple disconnected components. :param graph: Dictionary representing the graph where each key is a node and its value is a set of connected nodes. :return: A set of all visited nodes. """ visited =...
from solution import DFS_All_Nodes def test_DFS_disconnected_graph(): graph = { 'A': {'B'}, 'B': {'A', 'D'}, 'C': {'E'}, 'D': {'B'}, 'E': {'C'}, 'F': {} } visited = DFS_All_Nodes(graph) assert visited == {'A', 'B', 'D', 'C', 'E', 'F'} def test_DFS_connec...
[ { "docstring": "Perform DFS to visit all nodes in a graph, even if it consists of multiple disconnected components.\n:param graph: Dictionary representing the graph where each key is a node and its value is a set of connected nodes.\n:return: A set of all visited nodes.", "function_declaration": "def DFS_Al...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def DFS(graph, start):\n \"\"\"\n Perform depth-first search (DFS) starting from the given node in the graph.\n \n Args:\n graph (dict): The graph represented as an adjacency li...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024757", "row_id": 24757, "seed_ids": "['Llama-3.3-70B-Instruct_61484']" }
0.559886
Filter_24757
I
[ "DFS_All_Nodes", "DFS_Util" ]
2
[ [ "DFS_All_Nodes", "DFS_Util" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cd894c00aef5a65ff8c010fddca7252ecedfe122
75c383c74346595b6cd02ce3309eec96f9319537
v1.0
instruct
Filter
Filter_24764_I
I have a wonder about decorators in Python. I think decorators can now provide the ability to *partially apply* functions, and partially apply curried functions, *by adding in argument(s) in a decorator* Let me demonstrate an example of this concept. ``` import functools def decorator_curry_arg(arg1): def real_...
import functools def decorator_curry_arg(arg1): def real_decorator(func): @functools.wraps(func) def wrapper(*args, **kwargs): return func(arg1, *args, **kwargs) return wrapper return real_decorator @decorator_curry_arg('Jeong') def introduce(name, country, **other_info): ...
def test_introduce_only_required(): assert introduce("Korea") == "Jeong from Korea" def test_introduce_with_additional_info(): assert introduce("Korea", age=30, hobby='reading') == "Jeong from Korea, age: 30, hobby: reading" def test_introduce_with_multiple_keywords(): assert introduce("USA", profession="...
[ { "docstring": null, "function_declaration": "def decorator_curry_arg(arg1):", "function_name": "decorator_curry_arg", "parameter_list": "(arg1)" }, { "docstring": null, "function_declaration": "def introduce(name, country, **other_info):", "function_name": "introduce", "paramete...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import functools\n\ndef decorator_curry_arg(arg1):\n def real_decorator(func):\n @functools.wraps(func)\n def wrapper(*args, **kwargs):\n return func(arg1, *args, *...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00024764", "row_id": 24764, "seed_ids": "['Llama-3.3-70B-Instruct_61501']" }
0.409239
Filter_24764
I
[ "decorator_curry_arg", "introduce" ]
2
[ [ "introduce", "decorator_curry_arg" ] ]
1
[]
false
[]
false
pytest
false
[]
true
5457d2a4ea5d6a11f99832a07829c0ff62d4c61d
7f840e5441e52ec2b3d1213b51304aabc592e528
v1.0
instruct
Filter
Filter_24766_I
Below is my code that prints out a list of names based on the day of the week. I created three functions: create roaster, randomize, and print_roaster. The names section is a mock section that simulates a real database. ```python import random import calendar # Mock database of names for testing purposes names = ["Jo...
import random # Mock database of names for testing purposes names = ["John", "Jim", "Jake", "David","Brendan","Ben", "William", "Tommy", "Ryan"] def create_roster(): roster = [] for name in names: roster.append({'Name': name, 'Days': []}) return roster def randomize(): roster = create_roster(...
import random from solution import create_roster, randomize, print_roster def test_roster_length(): roster = randomize() assert len(roster) == len(names) def test_no_duplicate_assignments_per_day(): roster = randomize() weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday...
[ { "docstring": null, "function_declaration": "def create_roster():", "function_name": "create_roster", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def randomize():", "function_name": "randomize", "parameter_list": "()" }, { "docstring": null, ...
[ 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\n# Mock database of names for testing purposes\nnames = [\"John\", \"Jim\", \"Jake\", \"David\",\"Brendan\",\"Ben\", \"William\", \"Tommy\", \"Ryan\"]\n\ndef create_roster():\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00024766", "row_id": 24766, "seed_ids": "['Llama-3.3-70B-Instruct_61505']" }
0.609503
Filter_24766
I
[ "create_roster", "randomize", "print_roster", "main" ]
4
[ [ "randomize", "create_roster" ] ]
1
[]
false
[]
false
pytest
true
[]
true
63d1e68e757735ce92fbc5892b8b9d0a836aee4f
61eefdffd3436f7ce8a4db08156891ba23523aa3
v1.0
instruct
Filter
Filter_24767_I
Ok, I'm currently working on a course on graph theory. I am supposed to create an unweighted graph with random edges and perform some operations on the graph to analyze it. I'm stuck on implementing an efficient algorithm to check whether the graph is a tree. My current approach is by checking the number of edges *pe...
import random from collections import defaultdict class Graph: def __init__(self, num_vertices): self.num_vertices = num_vertices self.adj_list = defaultdict(list) def add_edge(self, u, v): self.adj_list[u].append(v) self.adj_list[v].append(u) def generate_random_graph(num...
import pytest from solution import Graph, generate_random_graph, is_tree def test_tree_with_valid_input(): num_vertices = 5 num_edges = 4 graph = generate_random_graph(num_vertices, num_edges) assert is_tree(graph) == True def test_tree_with_too_many_edges(): num_vertices = 5 num_edges = 6 ...
[]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nfrom collections import defaultdict, deque\n\nclass Graph:\n def __init__(self, vertices):\n self.vertices = vertices\n self.graph = defaultdict(list)\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00024767", "row_id": 24767, "seed_ids": "['Llama-3.3-70B-Instruct_61507']" }
0.553756
Filter_24767
I
[ "generate_random_graph", "is_connected", "has_no_cycles", "is_tree" ]
4
[ [ "is_tree", "has_no_cycles" ], [ "is_tree", "is_connected" ] ]
2
[]
false
[ "Graph" ]
true
pytest
true
[]
true
ff20d90bc1362a32a74214020a9898f49e5d2a4f
ea06cc16581952a941cc14e9a4fca01e00df9943
v1.0
instruct
Filter
Filter_24777_I
### Building a High Score List Consider an array of integers representing the scores earned by different players in a game. Write a program to build a high score list that displays the top 5 scores. The high score list should be sorted in descending order. #### Implementation Details The program should NOT use Python'...
def bubble_sort_descending(arr): n = len(arr) # Traverse through all array elements for i in range(n): # Last i elements are already in place for j in range(0, n-i-1): # Traverse the array from 0 to n-i-1 # Swap if the element found is less than the next element ...
from solution import build_high_score_list, bubble_sort_descending def test_build_high_score_list(): high_scores = build_high_score_list() assert high_scores == [95, 92, 91, 90, 89] def test_bubble_sort_descending(): scores = [50, 40, 60, 30, 90] bubble_sort_descending(scores) assert scores == [90...
[ { "docstring": null, "function_declaration": "def bubble_sort_descending(arr):", "function_name": "bubble_sort_descending", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def build_high_score_list():", "function_name": "build_high_score_list", "paramet...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def bubble_sort_descending(arr):\n \"\"\"\n Sorts the array in descending order using Bubble Sort algorithm.\n \"\"\"\n n = len(arr)\n for i in range(n):\n for j in range...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00024777", "row_id": 24777, "seed_ids": "['Llama-3.3-70B-Instruct_61533']" }
0.594688
Filter_24777
I
[ "bubble_sort_descending", "build_high_score_list" ]
2
[ [ "build_high_score_list", "bubble_sort_descending" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7f28a066db6f7f128ff612b573daf1ec31bd8c10
e521f94e673255786e7c54d73c46619df4403f0f
v1.0
instruct
Filter
Filter_24779_I
To determine if a number is prime, you can divide it by all the numbers less than it, and if none of them divide evenly, then it's prime. However, you only need to check up to the square root of the number. Can you write a simple function in Python that checks whether a given number is prime, and prints out the pri...
import math def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 ...
from solution import is_prime, print_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(19) == True assert is_prime(1) == False assert is_prime(0) == False...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Print all prime numbers up to a given limit.", "function_declaration": "def print_primes(limit):", "function_name": "print...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00024779", "row_id": 24779, "seed_ids": "['Llama-3.3-70B-Instruct_61536']" }
0.773686
Filter_24779
I
[ "is_prime", "print_primes" ]
2
[ [ "print_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
35237fcabe2398115b97423ab78ac29bea0c91e4
0b9c2f91751b9d1613571b7e8262d58a6bb615b7
v1.0
instruct
Filter
Filter_24799_I
I made a robot and can control its functions using clicks, but I want a more natural interface. How can I take the current program and rework it into a natural language interface (NLI) for my robot using Python?
import re def move_forward(): print("Robot is moving forward") def turn_left(): print("Robot is turning left") def turn_right(): print("Robot is turning right") def stop(): print("Robot is stopping") def parse_command(command): """ Parses a natural language command and executes the correspo...
import pytest from solution import parse_command def test_move_forward(capsys): parse_command("move forward") captured = capsys.readouterr() assert "Robot is moving forward" in captured.out def test_turn_left(capsys): parse_command("turn left") captured = capsys.readouterr() assert "Robot is t...
[ { "docstring": null, "function_declaration": "def move_forward():", "function_name": "move_forward", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def turn_left():", "function_name": "turn_left", "parameter_list": "()" }, { "docstring": null, ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef move(direction, steps):\n \"\"\"\n Simulates moving the robot in the specified direction by a certain number of steps.\n \"\"\"\n return f\"Moving {direction} by {...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024799", "row_id": 24799, "seed_ids": "['Llama-3.3-70B-Instruct_61564']" }
0.356418
Filter_24799
I
[ "move_forward", "turn_left", "turn_right", "stop", "parse_command" ]
5
[ [ "parse_command", "move_forward" ], [ "parse_command", "stop" ], [ "parse_command", "turn_left" ], [ "parse_command", "turn_right" ] ]
4
[]
false
[]
false
pytest
true
[]
true
a30f7ec58ff1c00aec59383866f4ecfaaa78daf3
d3b522e38012560e4db3c78ac8b9e496eed1af66
v1.0
instruct
Filter
Filter_24808_I
Here are the Times Square celebrities this year ------ * Andy Serkis * Arjen Robben * Tony Hawk * Rohingya girl_____ I'd like to get the "(number)th" suffixes for each of those names if I indicate their order, such as: If the order is just that order (Andy is 1st, Arjen is 2nd etc.,) I get: * Andy Serkis (1st) * Arjen...
def get_suffix(num): """ Returns the appropriate suffix for a given number. """ if 11 <= abs(num) % 100 <= 13: return 'th' else: last_digit = abs(num) % 10 if last_digit == 1: return 'st' elif last_digit == 2: return 'nd' elif last_digi...
from solution import get_suffix, generate_labels def test_get_suffix(): assert get_suffix(1) == 'st' assert get_suffix(2) == 'nd' assert get_suffix(3) == 'rd' assert get_suffix(4) == 'th' assert get_suffix(11) == 'th' assert get_suffix(21) == 'st' assert get_suffix(22) == 'nd' assert ge...
[ { "docstring": "Returns the appropriate suffix for a given number.", "function_declaration": "def get_suffix(num):", "function_name": "get_suffix", "parameter_list": "(num)" }, { "docstring": "Generates labels with suffixes for the given list of names based on the order.", "function_decl...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def get_suffix(num):\n \"\"\"\n Returns the appropriate suffix for a given number.\n \"\"\"\n if 11 <= abs(num) % 100 <= 13:\n return 'th'\n else:\n last_digit = a...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00024808", "row_id": 24808, "seed_ids": "['Llama-3.3-70B-Instruct_61585']" }
0.52574
Filter_24808
I
[ "get_suffix", "generate_labels" ]
2
[ [ "generate_labels", "get_suffix" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2045e91ca686e08ec20dbd1304dc293b9b3d6dc5
508fd2ad94b2ae462c8d7f4684d7920da28dbc08
v1.0
instruct
Filter
Filter_24815_I
### Objective Write a simple license plate game for two players. The goal is to come up with words that can be created using the letters of a randomly generated license plate. ### Game Requirements * Two players * Generate a random license plate with 6 letters * Players take turns to think of words that can be create...
import random import string def generate_license_plate(size=6): """Generate a random license plate with 6 letters.""" return ''.join(random.choice(string.ascii_uppercase) for _ in range(size)) def get_player_word(plate, player_used_words, other_used_words): """Get a valid word from the player.""" whil...
from solution import generate_license_plate, get_player_word def test_generate_license_plate(): plate = generate_license_plate() assert len(plate) == 6 assert all(letter.isupper() for letter in plate) def test_get_player_word(monkeypatch): # Mock input to simulate player input inputs = iter(["tea"...
[ { "docstring": "Generate a random license plate with 6 letters.", "function_declaration": "def generate_license_plate(size=6):", "function_name": "generate_license_plate", "parameter_list": "(size=6)" }, { "docstring": "Get a valid word from the player.", "function_declaration": "def get...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport string\n\ndef generate_license_plate(size=6):\n \"\"\"\n Generate a random license plate with 6 letters.\n \"\"\"\n return ''.join(random.choice(string.ascii_...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024815", "row_id": 24815, "seed_ids": "['Llama-3.3-70B-Instruct_61604']" }
0.591478
Filter_24815
I
[ "generate_license_plate", "get_player_word", "play_game" ]
3
[ [ "play_game", "generate_license_plate" ], [ "play_game", "get_player_word" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b43ef3b57ead20c2de74795fc3671eff5c077c04
57543b3e693eea1944461d802429eed81fc0d268
v1.0
instruct
Filter
Filter_24828_I
I can perform math operations like addition, subtraction, multiplication, and division only using bit manipulation. I'd like to add, subtract, multiply, and divide unsigned 8-bit integers. Here are the details of how I can manipulate bits. I can do the following: - left shift: Shift the bits of the number to the lef...
def add(a, b): """ Returns the sum of a and b using bit manipulation. """ while b != 0: carry = a & b a = a ^ b b = carry << 1 return a def subtract(a, b): """ Returns the result of a - b using bit manipulation. """ while b != 0: borrow = (~a...
def test_add(): assert add(0, 0) == 0 assert add(1, 2) == 3 assert add(255, 0) == 255 assert add(200, 55) == 255 def test_subtract(): assert subtract(5, 3) == 2 assert subtract(10, 5) == 5 assert subtract(0, 0) == 0 assert subtract(255, 55) == 200 def test_multiply(): assert multip...
[ { "docstring": "Returns the sum of a and b using bit manipulation.", "function_declaration": "def add(a, b):", "function_name": "add", "parameter_list": "(a, b)" }, { "docstring": "Returns the result of a - b using bit manipulation.", "function_declaration": "def subtract(a, b):", "f...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def add(a, b):\n while b != 0:\n carry = a & b\n a = a ^ b\n b = carry << 1\n return a & 0xFF\n\ndef subtract(a, b):\n while b != 0:\n borrow = (~a) & b\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024828", "row_id": 24828, "seed_ids": "['Llama-3.3-70B-Instruct_61645']" }
0.550171
Filter_24828
I
[ "add", "subtract", "multiply", "divide" ]
4
[ [ "multiply", "add" ] ]
1
[]
false
[]
false
pytest
false
[]
true
571d0c1d856db3661883a734ab91ce412923410d
a7b7d56a23a4b32231e9ea0855086fcdd6dece6d
v1.0
instruct
Filter
Filter_24863_I
### Re-Engineer Furnace Runtime Monitoring #### Problem Description You are a software engineer tasked with implementing a monitoring system to track furnace runtime. The system will store the number of hours the furnace has been running each day. The system will track the number of days in a month, up to 31, and will ...
def validate_input(runtime): """ Validate the runtime input list. Ensure it has 31 days and each day's runtime is between 0 and 1439 minutes. Args: runtime (list): List of integers representing furnace runtime in minutes for each day. Returns: bool: True if the input is valid, Fals...
from solution import validate_input, calculate_total_runtime def test_validate_input_valid(): valid_runtime = [0] * 31 assert validate_input(valid_runtime) == True def test_validate_input_invalid_length(): invalid_runtime = [0] * 30 # Less than 31 days assert validate_input(invalid_runtime) == False ...
[ { "docstring": "Validate the runtime input list.\nEnsure it has 31 days and each day's runtime is between 0 and 1439 minutes.\n\nArgs:\nruntime (list): List of integers representing furnace runtime in minutes for each day.\n\nReturns:\nbool: True if the input is valid, False otherwise.", "function_declarati...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_total_runtime(runtime):\n \"\"\"\n Calculate total runtime in minutes for each day and the entire month.\n\n Parameters:\n runtime (list of int): List of runtime in m...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024863", "row_id": 24863, "seed_ids": "['Llama-3.3-70B-Instruct_61723']" }
0.564548
Filter_24863
I
[ "validate_input", "calculate_total_runtime" ]
2
[ [ "calculate_total_runtime", "validate_input" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a8321b1cd3a2c2e8dc021ba1cd4d161f2863f895
94b9f7d07dc5aa244033891c71944d90acec2661
v1.0
instruct
Filter
Filter_24868_I
Here's a problem regarding prime numbers. I have an implementation that checks if a number is a prime number, but I'd rather have a user prompt and wait for input. Here is the current implementation: ```python import time import math def is_prime(n): if n <= 1: return False if n == 2: return...
import time import math def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(math.sqrt(n)) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False return True def check_prime_numbers...
from solution import is_prime def test_is_prime_single_digit(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(1) == False assert is_prime(0) == False def test_is_prime_double_digits(): assert is_prime(11) == Tru...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def check_prime_numbers():", "function_name": "check_prime_numbers", "parameter_list": "()" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import time\nimport math\n\ndef is_prime(n):\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n max_divisor = int(math.sq...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00024868", "row_id": 24868, "seed_ids": "['Llama-3.3-70B-Instruct_61730']" }
0.579458
Filter_24868
I
[ "is_prime", "check_prime_numbers" ]
2
[ [ "check_prime_numbers", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a442d2e85b8cfc5808494c557016226ff7002ab1
e240c5d2c831c9763d573fc3b4ee290d55258481
v1.0
instruct
Filter
Filter_24878_I
Here is a Python script that uses OpenCV to stream a webcam video in real time, and it applies some basic editing to the video feed, such as converting it to grayscale, applying a Gaussian blur, and recording the output. However, I want to apply some custom operations on the frames of the video. For that purpose, I h...
import cv2 def custom_func1(frame): """ Apply a custom operation to the frame. For example, let's invert the colors in the frame. """ return cv2.bitwise_not(frame) def custom_func2(frame): """ Apply another custom operation to the frame. For example, let's draw a rectangle on the frame...
import numpy as np import cv2 from solution import custom_func1, custom_func2, process_frame def test_custom_func1(): # Create a dummy frame (black image) frame = np.zeros((100, 100, 3), dtype=np.uint8) # Apply custom_func1 (invert colors) result = custom_func1(frame) # Check if the resul...
[ { "docstring": "Apply a custom operation to the frame.\nFor example, let's invert the colors in the frame.", "function_declaration": "def custom_func1(frame):", "function_name": "custom_func1", "parameter_list": "(frame)" }, { "docstring": "Apply another custom operation to the frame.\nFor e...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import cv2\n\ndef apply_custom_operations(frame, operations):\n \"\"\"\n Applies a list of custom operations to the input frame.\n \n Parameters:\n frame (numpy.array): The inpu...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00024878", "row_id": 24878, "seed_ids": "['Llama-3.3-70B-Instruct_61746']" }
0.450353
Filter_24878
I
[ "custom_func1", "custom_func2", "process_frame", "main" ]
4
[ [ "process_frame", "custom_func1" ], [ "process_frame", "custom_func2" ] ]
2
[]
false
[]
false
pytest
true
[ "cv2", "numpy" ]
false
7e63e66af0db5c68b38048ed89fd142d47e33b27
50af8cead467e034ffea65878ef48d1d63640ed8
v1.0
instruct
Filter
Filter_24902_I
I have a Python list of strings called columnList where all the elements are queries returning specific subsets of data i.e ['"#getsetSize>3"', '"#getSameGroup"', '"#distinctNames"'] I have a function that takes a single query and calculates the size of the subset of data it defines Unfortunately the function is set u...
def returnSubsetDataLength(query): # This is a placeholder function. Assume the real implementation is elsewhere. # Normally, this function would interact with a data source and return the length of the subset. if query == '"#getsetSize>3"': return 10 elif query == '"#getSameGroup"': ret...
import pytest from solution import returnSubsetDataLength, returnLengthsOfSubsetData def test_returnSubsetDataLength(): assert returnSubsetDataLength('"#getsetSize>3"') == 10 assert returnSubsetDataLength('"#getSameGroup"') == 5 assert returnSubsetDataLength('"#distinctNames"') == 7 assert returnSubset...
[ { "docstring": null, "function_declaration": "def returnSubsetDataLength(query):", "function_name": "returnSubsetDataLength", "parameter_list": "(query)" }, { "docstring": "Given a list of queries, returns the lengths of the corresponding subsets defined by each query.\n\n:param columnList: ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def returnLengthsOfSubsetData(columnList):\n \"\"\"\n Takes a list of query strings and returns a list of lengths of the resulting subsets\n as calculated by the returnSubsetDataLengt...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024902", "row_id": 24902, "seed_ids": "['Llama-3.3-70B-Instruct_61798']" }
0.627332
Filter_24902
I
[ "returnSubsetDataLength", "returnLengthsOfSubsetData" ]
2
[ [ "returnLengthsOfSubsetData", "returnSubsetDataLength" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7aaea12c3870afa72523861c2bc1a3e4933a8867
4cec5e265c4a11d514fc2af025f7f08e40211e5d
v1.0
instruct
Filter
Filter_24915_I
Create a long procedural generated dungeon crawler for a text-based game. I'm hoping to use this in a chat-based platform where users can interact with the dungeon using commands. I don directions set up, so PLEASE use n, s, e, w as direction indicators. Let's set some parameters: - Maximum of 20 rooms - The dunge...
import random # Define the possible room types room_types = ["empty", "treasure", "health", "enemy"] # Function to create a randomized dungeon def create_dungeon(): # Create a list to store the rooms rooms = [] # Create 15 rooms with random types (excluding treasure) for _ in range(15): rooms...
from solution import create_dungeon, describe_room, move, player_inventory def test_create_dungeon(): rooms = create_dungeon() assert len(rooms) == 20 assert rooms.count("treasure") == 5 def test_describe_room_empty(capsys): # Test an empty room player_inventory['room'] = 0 player_inventory['h...
[ { "docstring": null, "function_declaration": "def create_dungeon():", "function_name": "create_dungeon", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def describe_room(rooms):", "function_name": "describe_room", "parameter_list": "(rooms)" }, { ...
[ 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# Define the possible room types\nroom_types = [\"empty\", \"treasure\", \"health\", \"enemy\"]\n\n# Function to create a randomized dungeon\ndef create_dungeon():\n # Crea...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00024915", "row_id": 24915, "seed_ids": "['Llama-3.3-70B-Instruct_61820']" }
0.543963
Filter_24915
I
[ "create_dungeon", "describe_room", "move", "game_loop" ]
4
[ [ "game_loop", "move" ], [ "move", "describe_room" ] ]
2
[]
false
[]
false
pytest
true
[]
true
d962ebe87056e48be12d630112a7b390941d1d89
059fa9d80298d2c204d0f628637f39b27b0d44d9
v1.0
instruct
Filter
Filter_24938_I
A Palindrome is a number that remains the same when its digits are reversed. For example, 12321 is a palindrome number. Given a number n, write a function that prints all the palindromic numbers between 1 and n. платы cellspacing="0" align="left">Example: Input: `5` Output: `[1, 2, 3, 4, 5]` Explanation: These five ...
def is_palindrome(num): """ Helper function to check if a given number is a palindrome. """ return str(num) == str(num)[::-1] def palindromes_upto_n(n): """ Function to return a list of all palindromic numbers from 1 to n. """ return [i for i in range(1, n+1) if is_palindrome(i)]
from solution import is_palindrome, palindromes_upto_n def test_is_palindrome(): assert is_palindrome(1) == True assert is_palindrome(121) == True assert is_palindrome(12321) == True assert is_palindrome(123) == False assert is_palindrome(10) == False def test_palindromes_upto_5(): assert pali...
[ { "docstring": "Helper function to check if a given number is a palindrome.", "function_declaration": "def is_palindrome(num):", "function_name": "is_palindrome", "parameter_list": "(num)" }, { "docstring": "Function to return a list of all palindromic numbers from 1 to n.", "function_de...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n \"\"\"\n Helper function to check if a number is a palindrome.\n \"\"\"\n return str(n) == str(n)[::-1]\n\ndef palindrome_numbers(n):\n \"\"\"\n Retur...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024938", "row_id": 24938, "seed_ids": "['Llama-3.3-70B-Instruct_61860']" }
0.726808
Filter_24938
I
[ "is_palindrome", "palindromes_upto_n" ]
2
[ [ "palindromes_upto_n", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c02a2a71b68bdbd6a0d37ab8522153ed8d6c9e78
f59e49554f4d099a669ce6201865964fa6bbce8f
v1.0
instruct
Filter
Filter_24968_I
I wrote a simple color detection algorithm in Python that detects red and blue pixels in an RGB image. How can I display the detected colors in their respective colors?
import cv2 import numpy as np def detect_colors(image): """ Detect red and blue pixels in an RGB image and display them in their respective colors (red and blue). """ # Create masks for red and blue colors red_mask = (image[:, :, 2] > 150) & (image[:, :, 0] < 100) & (image[:, :, 1] < 100) b...
import cv2 import numpy as np from solution import detect_colors def test_detect_colors_red(): # Create a simple red image red_image = np.zeros((100, 100, 3), dtype=np.uint8) red_image[:] = [0, 0, 255] # Red color in BGR detected_image = detect_colors(red_image) # Verify the red color is dete...
[ { "docstring": "Detect red and blue pixels in an RGB image and display them\nin their respective colors (red and blue).", "function_declaration": "def detect_colors(image):", "function_name": "detect_colors", "parameter_list": "(image)" }, { "docstring": null, "function_declaration": "de...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nimport cv2\nimport matplotlib.pyplot as plt\n\ndef detect_red_blue_colors(image_path):\n \"\"\"\n Detects red and blue pixels in an RGB image and displays them in the...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024968", "row_id": 24968, "seed_ids": "['Llama-3.3-70B-Instruct_61921']" }
0.377926
Filter_24968
I
[ "detect_colors", "display_image" ]
2
[ [ "display_image", "detect_colors" ] ]
1
[]
false
[]
false
pytest
true
[ "cv2", "numpy" ]
false
b10588320e83567e2b5f5d7e5ce5aa7d09d31cf1
60a434abc1d078d0feddeeee7603eb39c50eee5b
v1.0
instruct
Filter
Filter_24972_I
I wrote my own implementation of merge sort, but I call the merge_sort function twice to finish the discussion about how to revise it to accept more input or not. The exercise wants the function being called only once at the end. ```python def merge_sort(arr): ''' This function takes in a single array as a...
def merge_sort(arr): ''' This function takes in a single array as an input and returns it in ascending order >> merge_sort([3, 7, 10, 5, 2, 9]) [2, 3, 5, 7, 9, 10] ''' if len(arr) <= 1: return arr mid = len(arr) // 2 first_half = merge_sort(arr[:mid]) second_half ...
from solution import merge_sort, merge_sort_multiple def test_merge_sort_single_array(): assert merge_sort([3, 7, 10, 5, 2, 9]) == [2, 3, 5, 7, 9, 10] def test_merge_sort_multiple_arrays(): inputs = [ [3, 7, 10, 5, 2, 9], [10, 40, 30, 60, 50, 20], [1, 3, 5, 7, 9, 2, 4, 6, 8, 0] ] ...
[ { "docstring": "This function takes in a single array as an input and returns it in ascending order\n>> merge_sort([3, 7, 10, 5, 2, 9])\n[2, 3, 5, 7, 9, 10]", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": "Implement...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_sort(arrays):\n \"\"\"\n This function takes in a list of arrays as an input and converts each into an ascending array.\n >> merge_sort([[3, 7, 10, 5, 2, 9], [10, 40, 30, 60...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024972", "row_id": 24972, "seed_ids": "['Llama-3.3-70B-Instruct_61933']" }
0.49604
Filter_24972
I
[ "merge_sort", "merge", "merge_sort_multiple" ]
3
[ [ "merge_sort", "merge" ], [ "merge_sort_multiple", "merge_sort" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c03b3886f84da4cf67a5e72de925e3dd4175d066
3b266081cdfdfc892de2527ef82d6a24b9db46ad
v1.0
instruct
Filter
Filter_24986_I
I would like to implement a function that, when called, recursively generates combinations of times in a day with a cycle that adds one minute and also includes the seconds, down to one second intervals. For example, when starting at 00:00:00: the next time generated would be 00:00:01, next after that 00:00:02 and so...
def time_incrementer(current_time): """ Increments the given time (HH:MM:SS) by one second. Args: current_time (str): Starting time in "HH:MM:SS" format. Returns: str: New time incremented by one second in "HH:MM:SS" format. """ time_parts = current_time.split(':') ...
from solution import time_incrementer, time_iterator import pytest def test_time_incrementer(): assert time_incrementer("00:00:00") == "00:00:01" assert time_incrementer("00:00:59") == "00:01:00" assert time_incrementer("00:59:59") == "01:00:00" assert time_incrementer("23:59:59") == "00:00:00" ass...
[ { "docstring": "Increments the given time (HH:MM:SS) by one second.\n\nArgs:\n current_time (str): Starting time in \"HH:MM:SS\" format.\n \nReturns:\n str: New time incremented by one second in \"HH:MM:SS\" format.", "function_declaration": "def time_incrementer(current_time):", "function_name...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def time_incrementer(current_time):\n time_parts = list(map(int, current_time.split(':')))\n hours, minutes, seconds = time_parts[0], time_parts[1], time_parts[2]\n \n seconds += 1...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00024986", "row_id": 24986, "seed_ids": "['Llama-3.3-70B-Instruct_61962']" }
0.526615
Filter_24986
I
[ "time_incrementer", "time_iterator" ]
2
[ [ "time_iterator", "time_incrementer" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e047ad3ae40639a64a4d6c08a2fde7255ac9ecc8
d17ba4dccf59a6fbb0383f73d96bad5a25d58c87
v1.0
instruct
Filter
Filter_24987_I
import random # list of first names first_names = ["John", "Emma", "Michael", "Sophia", "William", "Olivia", "James", "Ava", "George", "Isabella"] # list of last names last_names = ["Smith", "Johnson", "Williams", "Jones", "Brown", "Davis", "Miller", "Wilson", "Moore", "Taylor"] # combine first and last names into a...
import random # list of first names first_names = ["John", "Emma", "Michael", "Sophia", "William", "Olivia", "James", "Ava", "George", "Isabella"] # list of last names last_names = ["Smith", "Johnson", "Williams", "Jones", "Brown", "Davis", "Miller", "Wilson", "Moore", "Taylor"] # list of occupations occupations = [...
from solution import generate_random_age, generate_random_occupation, generate_random_name, generate_person, generate_random_individuals def test_generate_random_age(): ages = [generate_random_age() for _ in range(100)] for age in ages: assert 18 <= age <= 65 def test_generate_random_occupation(): ...
[ { "docstring": null, "function_declaration": "def generate_random_age():", "function_name": "generate_random_age", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def generate_random_occupation():", "function_name": "generate_random_occupation", "parameter...
[ 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# list of first names\nfirst_names = [\"John\", \"Emma\", \"Michael\", \"Sophia\", \"William\", \"Olivia\", \"James\", \"Ava\", \"George\", \"Isabella\"]\n\n# list of last nam...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00024987", "row_id": 24987, "seed_ids": "['Llama-3.3-70B-Instruct_61963']" }
0.64577
Filter_24987
I
[ "generate_random_age", "generate_random_occupation", "generate_random_name", "generate_person", "generate_random_individuals" ]
5
[ [ "generate_person", "generate_random_age" ], [ "generate_person", "generate_random_name" ], [ "generate_person", "generate_random_occupation" ], [ "generate_random_individuals", "generate_person" ] ]
4
[]
false
[]
false
pytest
true
[]
true
df423f928968933341583f1ab217c3923ab929c4
0505f8d758b5e00939c913cd8034f363fb26a7ae
v1.0
instruct
Filter
Filter_24990_I
I am working on a mosaic art project where I am creating an image out of small tiles. The image is made up of a group of squares with different colors and the squares are made up of smaller tiles. I can draw the image by calling functions that take in parameters for position and color. For example, drawing a red squa...
def draw_square(x, y, color): """ Draws a square at (x, y) with the specified color. This function is a placeholder for the actual implementation. """ print(f"Drawing square at ({x}, {y}) with color {color}") def get_tile_color(x, y): """ Determines the color of the tile at position (x, y) ...
from solution import draw_square, get_tile_color, draw_image def mock_draw_square(x, y, color): """ Mock function to replace draw_square for testing. It captures the calls for assertions. """ mock_draw_square.calls.append((x, y, color)) mock_draw_square.calls = [] def test_get_tile_color(): #...
[ { "docstring": "Draws a square at (x, y) with the specified color.\nThis function is a placeholder for the actual implementation.", "function_declaration": "def draw_square(x, y, color):", "function_name": "draw_square", "parameter_list": "(x, y, color)" }, { "docstring": "Determines the col...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def draw_square(x, y, color):\n \"\"\"\n Draws a square at (x, y) with the specified color.\n This function is a placeholder for the actual implementation.\n \"\"\"\n print(f\"D...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00024990", "row_id": 24990, "seed_ids": "['Llama-3.3-70B-Instruct_61972']" }
0.491319
Filter_24990
I
[ "draw_square", "get_tile_color", "draw_image" ]
3
[ [ "draw_image", "draw_square" ], [ "draw_image", "get_tile_color" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f89cd500214160439b467b0eaa57d9e9350404ad
994e59921df6e70e3ed90b9919ad34e596416112
v1.0
instruct
Filter
Filter_25018_I
### Blackjack ================ ## Step-by-step analysis of the problem: The problem is to create a Blackjack game. Here is the step-by-step analysis: - Create a deck of 52 cards. - Deal 2 cards to the player. - Deal 2 cards to the dealer. - Calculate the total value of the player's hand and the dealer's hand using th...
import random class Card: def __init__(self, suit, value): self.suit = suit self.value = value def __repr__(self): return f"{self.value} of {self.suit}" class Deck: def __init__(self): self.cards = [] self.suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] s...
def test_calculate_hand_value(): hand = [Card('Hearts', '5'), Card('Diamonds', 'Ace')] assert calculate_hand_value(hand) == 16 hand = [Card('Hearts', 'King'), Card('Diamonds', 'Ace')] assert calculate_hand_value(hand) == 21 hand = [Card('Hearts', 'King'), Card('Diamonds', 'Ace'), Card('Clu...
[]
[ 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 class for Card\nclass Card:\n def __init__(self, suit, value):\n self.suit = suit\n self.value = value\n\n def __repr__(self):\n return f...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00025018", "row_id": 25018, "seed_ids": "['Llama-3.3-70B-Instruct_62028']" }
0.60387
Filter_25018
I
[ "calculate_hand_value", "play_game" ]
2
[ [ "play_game", "calculate_hand_value" ] ]
1
[]
false
[ "Card", "Deck" ]
true
pytest
false
[]
true
43953af3fb5bd1e0c65e7104c911eb3aaa7b4019
e6a10e08870548787b47d53e8a2b0b6677c99565
v1.0
instruct
Filter
Filter_25024_I
# Additional Templates for Hypermodern Python's` elliotttf` Repository ===================================================== Experimental approach to using the bookmarks widget to allow easier identification of repository dependencies Endpoints --------- The bookmarks widget includes a new `'dependencies'` tab allow...
def check_dependencies(): """ Retrieve and report project dependencies, returning them as a parallel list. Returns: list: A nested list where each sublist contains a dependency name and its stage. """ # Mocked example of retrieving dependencies (this should be replaced with actual code)...
from solution import check_dependencies def mocked_retrieve_dependencies(): """ Mock function to simulate retrieving dependencies. """ return [ {"name": "dep1", "lang": "Python", "stage": "production"}, {"name": "dep2", "lang": "Python", "stage": "development"}, {"name": "dep3",...
[ { "docstring": "Retrieve and report project dependencies, returning them as a parallel list.\n\nReturns:\n list: A nested list where each sublist contains a dependency name and its stage.", "function_declaration": "def check_dependencies():", "function_name": "check_dependencies", "parameter_list...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def check_dependencies():\n \"\"\"\n Retrieve and report project dependencies, returning them as a parallel list.\n \n Returns:\n list: A nested list where each sublist cont...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00025024", "row_id": 25024, "seed_ids": "['Llama-3.3-70B-Instruct_62039']" }
0.44273
Filter_25024
I
[ "check_dependencies", "retrieve_dependencies", "group_by_stage" ]
3
[ [ "check_dependencies", "group_by_stage" ], [ "check_dependencies", "retrieve_dependencies" ] ]
2
[]
false
[]
false
pytest
true
[]
true
13799b0c475e397ed91c955df006e3847d08e89f
837fe0b6e724c4d07366b8a63e7bf8631cfd5e46
v1.0
instruct
Filter
Filter_25045_I
You've been tasked with combining two sorted arrays into a single sorted array. For instance, if you have [1, 3, 5] and [2, 4, 6], the output should be [1, 2, 3, 4, 5, 6]. Your function should be able to handle arrays of different lengths. Write a testable code with two functions: one to merge sorted arrays and ano...
def mergeSortedArrays(arr1, arr2): """ Merges two sorted arrays into one sorted array. """ merged_array = [] while arr1 and arr2: if arr1[0] < arr2[0]: merged_array.append(arr1.pop(0)) else: merged_array.append(arr2.pop(0)) merged_array += arr1 merged_...
from solution import mergeSortedArrays, mergedArraysValueTest def test_merge_sorted_arrays(): assert mergedArraysValueTest([1, 3, 5], [2, 4, 6], [1, 2, 3, 4, 5, 6]) assert mergedArraysValueTest([], [2, 4, 6], [2, 4, 6]) assert mergedArraysValueTest([1, 3, 5], [], [1, 3, 5]) assert mergedArraysValueTest...
[ { "docstring": "Merges two sorted arrays into one sorted array.", "function_declaration": "def mergeSortedArrays(arr1, arr2):", "function_name": "mergeSortedArrays", "parameter_list": "(arr1, arr2)" }, { "docstring": "Verifies that the merged array is as expected.", "function_declaration...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "Magpie-Filter-89K_sanitized_prepared1_results_combined.jsonl", "solution_code": "def mergeSortedArrays(arr1, arr2):\n \"\"\"\n Merges two sorted arrays into one sorted array.\n\n :param arr1: List[int], first sorted array\n :param arr2:...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00025045", "row_id": 25045, "seed_ids": "['Llama-3.3-70B-Instruct_62090']" }
0.594337
Filter_25045
I
[ "mergeSortedArrays", "mergedArraysValueTest" ]
2
[ [ "mergedArraysValueTest", "mergeSortedArrays" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f0da1782dedaed9ff909d5292b76b72198498318
391f59cf24081a2d052efc96f4d145def8f29180
v1.0
instruct
Filter
Filter_25061_I
Create an interactive menu-based sorting program in Python that uses the merge sort algorithm to sort a list of numbers. The user can choose to add numbers to the list, view the list, sort the list, or quit the program.
def merge_sort(arr): if len(arr) > 1: mid = len(arr) // 2 left_half = arr[:mid] right_half = arr[mid:] merge_sort(left_half) merge_sort(right_half) i = j = k = 0 while i < len(left_half) and j < len(right_half): if left_half[i] < right_half[j]: ...
from solution import merge_sort def test_empty_list(): arr = [] merge_sort(arr) assert arr == [] def test_single_element_list(): arr = [1] merge_sort(arr) assert arr == [1] def test_two_element_list(): arr = [2, 1] merge_sort(arr) assert arr == [1, 2] def test_multiple_elements()...
[ { "docstring": null, "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def menu():", "function_name": "menu", "parameter_list": "()" } ]
[ 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 using merge sort algorithm.\n \"\"\"\n if len(arr) <= 1:\n return arr\n\n mid = len(arr) // 2\n left = arr[:mid]\n ri...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00025061", "row_id": 25061, "seed_ids": "['Llama-3.3-70B-Instruct_62127']" }
0.579192
Filter_25061
I
[ "merge_sort", "menu" ]
2
[ [ "menu", "merge_sort" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1404e132cdbab6eecdc81e93c686b743b0816b05
69bceb72bad67c671b5f3b947839c1dd11a30276
v1.0
instruct
Filter
Filter_25067_I
The daytime mood of a person is very much influenced by the number of hours of sleep they get each night. Write a program in python that models the relationship between hours slept and daytime mood (1-5, from unhappy to happy). In addition, create a cohort of 12 persons and assign moods to them after a random number of...
import random def calculate_mood(hours_slept): """ Calculate the mood based on hours slept. More hours generally correspond to a better mood. """ if hours_slept < 4: return 1 # Very unhappy elif 4 <= hours_slept < 6: return 2 # Unhappy elif 6 <= hours_slept < 7: re...
from solution import calculate_mood, average_daytime_mood def test_calculate_mood(): assert calculate_mood(3) == 1 assert calculate_mood(5) == 2 assert calculate_mood(6.5) == 3 assert calculate_mood(8) == 4 assert calculate_mood(9) == 5 assert calculate_mood(10) == 5 def test_average_daytime_m...
[ { "docstring": "Calculate the mood based on hours slept.\nMore hours generally correspond to a better mood.", "function_declaration": "def calculate_mood(hours_slept):", "function_name": "calculate_mood", "parameter_list": "(hours_slept)" }, { "docstring": "Generate random sleep hours for a ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef calculate_mood(hours_slept):\n \"\"\"\n Calculate the mood based on hours slept.\n More hours generally correspond to a better mood.\n \"\"\"\n if hours_sle...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00025067", "row_id": 25067, "seed_ids": "['Llama-3.3-70B-Instruct_62142']" }
0.496098
Filter_25067
I
[ "calculate_mood", "average_daytime_mood" ]
2
[ [ "average_daytime_mood", "calculate_mood" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bfe52271a1457d8511ba650a7da4b86f07460637
87b9b098dd431a363fb3ab7d4ab36f3dbc97f8b0
v1.0
instruct
Filter
Filter_25070_I
I have a Python script I've written that generates, prints and saves rig vectors to a file, each vector on a new line with the vecx, vecy and vecz components separated by spaces. The scripts also supports optional scaling of the vectors.
import random def generate_vector(): """ Generates a vector with components (vecx, vecy, vecz) where each component is a random float. """ vecx = random.uniform(-1.0, 1.0) vecy = random.uniform(-1.0, 1.0) vecz = random.uniform(-1.0, 1.0) return (vecx, vecy, vecz) def scale_vector(vector, s...
import os from solution import generate_vector, scale_vector, save_vector_to_file, generate_and_save_vectors def test_generate_vector(): vec = generate_vector() assert len(vec) == 3 assert all(-1.0 <= component <= 1.0 for component in vec) def test_scale_vector(): vec = (1, 2, 3) scale = 2 sca...
[ { "docstring": "Generates a vector with components (vecx, vecy, vecz) where each component is a random float.", "function_declaration": "def generate_vector():", "function_name": "generate_vector", "parameter_list": "()" }, { "docstring": "Scales the given vector by the given scale factor.",...
[ 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 generate_and_save_vectors(filename, num_vectors, scale=1.0):\n \"\"\"\n Generates `num_vectors` vectors, prints them, and saves them to `filename`.\n Each vector ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00025070", "row_id": 25070, "seed_ids": "['Llama-3.3-70B-Instruct_62147']" }
0.318084
Filter_25070
I
[ "generate_vector", "scale_vector", "save_vector_to_file", "generate_and_save_vectors" ]
4
[ [ "generate_and_save_vectors", "generate_vector" ], [ "generate_and_save_vectors", "save_vector_to_file" ], [ "generate_and_save_vectors", "scale_vector" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e4dcdcafe20089878eea9d25faab2ad5500af790
e3b273d4ec932706856c07f827cc3b0ea9822f6d
v1.0
instruct
Filter
Filter_25076_I
### Task 1: Generate a Python list of all Ford Mustang models through the years, from the first generation in 1964 to the 6th generation in 2014. ### Task 2: Write a function that filters this list to only include years when the car had an V8 engine. ### Task 3: Filter the list to only include models that were both ...
# Task 1: Generate a Python list of all Ford Mustang models through the years. mustang_years = list(range(1964, 2022)) # Task 2: Function to filter years when the Mustang had a V8 engine. # Assuming the Ford Mustang had a V8 engine available every year since its inception up to 2022. def filter_v8_years(years): "...
from solution import filter_v8_years, filter_years_1969_v8 def test_filter_v8_years_all(): all_years = list(range(1964, 2022)) expected_years = list(range(1964, 2022)) assert filter_v8_years(all_years) == expected_years def test_filter_v8_years_subset(): subset_years = list(range(1980, 1990)) expe...
[ { "docstring": "Filters the list of years to return only those where the Ford Mustang had a V8 engine option.\n\nArgs:\nyears (list): List of years of Mustang models.\n\nReturns:\nlist: List of years where V8 engine was available.", "function_declaration": "def filter_v8_years(years):", "function_name":...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "# List of Ford Mustang models through the years\nmustang_models = [\n {\"year\": 1964, \"engine\": \"V6\"},\n {\"year\": 1965, \"engine\": \"V8\"},\n {\"year\": 1966, \"engine\": \"V8...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00025076", "row_id": 25076, "seed_ids": "['Llama-3.3-70B-Instruct_62156']" }
0.471141
Filter_25076
I
[ "filter_v8_years", "filter_years_1969_v8" ]
2
[ [ "filter_years_1969_v8", "filter_v8_years" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a36407f1a48f98c445b908dd07166846c213425e
0a98741c4c843e07b9b764849594c3853f048aaf
v1.0
instruct
Filter
Filter_25078_I
I would like to implement network flow algorithms to find the maximum flow in a flow network. I will be implementing it using Python. Could you please guide me through the steps and also explain the algorithms you would recommend for this task?
from collections import deque def bfs(residual_graph, source, sink, parent): """ Perform BFS on the residual graph to find a path from source to sink. Returns True if there is a path from source to sink, else False. Updates the parent list to store path information. """ visited = [False] * len...
def test_edmonds_karp(): # Graph definition based on adjacency matrix graph = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0] ] source = 0 sink = 5 expected_max_flow = 2...
[ { "docstring": "Perform BFS on the residual graph to find a path from source to sink. \nReturns True if there is a path from source to sink, else False.\nUpdates the parent list to store path information.", "function_declaration": "def bfs(residual_graph, source, sink, parent):", "function_name": "bfs",...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import deque\n\ndef bfs(residual_graph, source, sink, parent):\n \"\"\"\n Perform BFS on the residual graph to find a path from source to sink. \n Returns True if the...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00025078", "row_id": 25078, "seed_ids": "['Llama-3.3-70B-Instruct_62160']" }
0.340149
Filter_25078
I
[ "bfs", "edmonds_karp" ]
2
[ [ "edmonds_karp", "bfs" ] ]
1
[]
false
[]
false
pytest
false
[]
true
ec3d7d4d4a3d5d93081346128375f8b080f22cc8
b396bd25c3fcfb8e9358b72838004f9d9bb8ecbc
v1.0
instruct
Filter
Filter_25081_I
Write a Decentralized Data Storage Solution using peer-to-peer networking to Store and Retrieve Data Blocks. We will use the bitcoin's blockchain as the distributed ledger technology to keep track of the transactions (data blocks) and the ipfs (InterPlanetary File System) as the underlying storage for storing the actu...
import hashlib def gen_hash(data): """ Generates a SHA-256 hash for the given data. """ sha256_hash = hashlib.sha256() sha256_hash.update(data.encode('utf-8')) return sha256_hash.hexdigest() def generate_transaction_id(data): """ Generates a transaction ID for the given data block. ...
def test_gen_hash(): assert gen_hash('test') == '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08' def test_generate_transaction_id(): assert generate_transaction_id('test') == '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08' def test_reed_solomon_encode_decode(): data = ...
[ { "docstring": "Generates a SHA-256 hash for the given data.", "function_declaration": "def gen_hash(data):", "function_name": "gen_hash", "parameter_list": "(data)" }, { "docstring": "Generates a transaction ID for the given data block.", "function_declaration": "def generate_transactio...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import hashlib\n\ndef gen_hash(data):\n \"\"\"\n Generates a SHA-256 hash for the given data.\n \"\"\"\n sha256_hash = hashlib.sha256()\n sha256_hash.update(data.encode('utf-8')...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00025081", "row_id": 25081, "seed_ids": "['Llama-3.3-70B-Instruct_62166']" }
0.351472
Filter_25081
I
[ "gen_hash", "generate_transaction_id", "reed_solomon_encode", "reed_solomon_decode", "ipfs_add", "ipfs_get", "bitcoin_send", "bitcoin_get", "request_nearest_triangle", "reconstruct_block", "restore_data_block", "test_restore_data_block" ]
12
[ [ "bitcoin_send", "generate_transaction_id" ], [ "generate_transaction_id", "gen_hash" ], [ "ipfs_add", "gen_hash" ], [ "restore_data_block", "ipfs_get" ], [ "restore_data_block", "reconstruct_block" ], [ "restore_data_block", "request_nearest_tria...
10
[]
false
[]
false
pytest
false
[]
true
b8e4c92def1012ece1c23267709defde606f15b8
86b1de7ad59479182cd4069193d25a2ea84d2f6f
v1.0
instruct
Filter
Filter_25119_I
Given a sorted array of positive integers, find the smallest number in the array that is not in the range of 1 to N where N is the length of the array. Similarly, find the smallest number that is greater than the maximum value in the array. The first part of the task is a well-known problem, often referred to as the "...
def first_missing_positive(nums): """ Finds the smallest number in the array nums that is not in the range of 1 to N where N is the length of the array. If all numbers from 1 to N are found, returns None. """ # Create a set from the list num_set = set(num for num in nums if 1 <= num <= len(nums)...
from solution import solve def test_solve_all_numbers_present(): # No missing numbers in range 1 to 6 assert solve([1, 2, 3, 4, 5, 6]) == (None, 7) def test_solve_with_missing_number(): # Missing 1 and 6 in range 1 to 6 assert solve([2, 3, 4, 5, 7, 8]) == (1, 9) def test_solve_single_element(): ...
[ { "docstring": "Finds the smallest number in the array nums that is not in the range of 1 to N where N is the length of the array.\nIf all numbers from 1 to N are found, returns None.", "function_declaration": "def first_missing_positive(nums):", "function_name": "first_missing_positive", "parameter...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def first_missing_positive(nums):\n \"\"\"\n Finds the smallest number in the array nums that is not in the range of 1 to N where N is the length of the array.\n If all numbers from 1...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00025119", "row_id": 25119, "seed_ids": "['Llama-3.3-70B-Instruct_62253']" }
0.657405
Filter_25119
I
[ "first_missing_positive", "smallest_greater_than_max", "solve" ]
3
[ [ "solve", "first_missing_positive" ], [ "solve", "smallest_greater_than_max" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9d497a246b8b5517f2d200532e9e14702f52e8fd
a687e6dfba4a15fa5e1eec0ab5388b3f6e616fc1
v1.0
instruct
Filter
Filter_25127_I
I have a sequenced genome and a list of gene annotations. I want to write a Python script to get the maximum GC content of coding regions. First, let's assume we have an initialized dictionary of sequences, seqs, where keys are gene names and values are sequences. We also have a list of gene annotations, anns, where e...
def gc_content(seq): """ Calculate the GC content of a given DNA sequence. """ g_c_count = seq.count('G') + seq.count('C') return (g_c_count / len(seq)) * 100 if len(seq) > 0 else 0 def max_gc_content_of_coding_regions(seqs, anns): """ Calculate the maximum GC content of coding regions (CDS...
from solution import gc_content, max_gc_content_of_coding_regions def test_gc_content(): assert gc_content("ATCG") == 50.0 assert gc_content("GGGG") == 100.0 assert gc_content("AAAA") == 0.0 assert gc_content("") == 0.0 def test_max_gc_content_of_coding_regions(): seqs = { "gene1": "ATCGAT...
[ { "docstring": "Calculate the GC content of a given DNA sequence.", "function_declaration": "def gc_content(seq):", "function_name": "gc_content", "parameter_list": "(seq)" }, { "docstring": "Calculate the maximum GC content of coding regions (CDS) from a list of annotations and sequences.\n...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def gc_content(sequence):\n \"\"\"\n Calculate the GC content of a given sequence.\n GC content is the percentage of nucleotides in a DNA or RNA molecule that are either G (guanine) o...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00025127", "row_id": 25127, "seed_ids": "['Llama-3.3-70B-Instruct_62267']" }
0.449195
Filter_25127
I
[ "gc_content", "max_gc_content_of_coding_regions" ]
2
[ [ "max_gc_content_of_coding_regions", "gc_content" ] ]
1
[]
false
[]
false
pytest
true
[]
true
97f237d3f75a9432afee69d237311a49c452db37
2116f5345224245cd36a1442a647aefdfeae7203
v1.0
instruct
Filter
Filter_25142_I
You've been tasked with creating a function `/login` that takes in a request object, processes it, and then calls another function `process_request` to handle the logic related to the login functionality. The problem is that `process_request` function expects two parameters: `username` and `password`. But the `request`...
def login(request): """ Extract the necessary information from the request object and pass it to the process_request function. """ username = request.get('username') password = request.get('password') if username is None or password is None: return "Error: Missing username or p...
from solution import login, process_request def test_login_success(): request = {'username': 'admin', 'password': 'admin'} assert login(request) == "Login successful" def test_login_invalid_credentials(): request = {'username': 'user', 'password': 'wrongpassword'} assert login(request) == "Invalid cre...
[ { "docstring": "Extract the necessary information from the request object and \npass it to the process_request function.", "function_declaration": "def login(request):", "function_name": "login", "parameter_list": "(request)" }, { "docstring": "Mock function to simulate processing a login re...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def process_request(username, password):\n \"\"\"\n Dummy function to process username and password.\n \"\"\"\n if username == \"admin\" and password == \"secret\":\n return...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00025142", "row_id": 25142, "seed_ids": "['Llama-3.3-70B-Instruct_62298']" }
0.367989
Filter_25142
I
[ "login", "process_request" ]
2
[ [ "login", "process_request" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0f4d1f15ae3e37d07a8fb7afd476baa6d8c916e5
94165f275a2299d6776e9fc75501f13e200df846
v1.0
instruct
Filter
Filter_25165_I
### Task - Develop a basic, 6-player, console-based game where players take individual turns attempting to guess the number between 1 and 100 that the game master has randomly generated.
import random def initialize_game(): """ Initializes the game by selecting a random number for the players to guess. """ return random.randint(1, 100) def guess_number(secret_number, player_guess): """ Compares player's guess with the secret number and gives feedback. Args: secret_numb...
from solution import initialize_game, guess_number, take_turn def test_initialize_game(): secret_number = initialize_game() assert 1 <= secret_number <= 100 def test_guess_number(): secret_number = 50 assert guess_number(secret_number, 25) == "too low" assert guess_number(secret_number, 75) == "to...
[ { "docstring": "Initializes the game by selecting a random number for the players to guess.", "function_declaration": "def initialize_game():", "function_name": "initialize_game", "parameter_list": "()" }, { "docstring": "Compares player's guess with the secret number and gives feedback.\nAr...
[ 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 game_master():\n \"\"\"\n Function to create a random number between 1 and 100 for players to guess.\n \"\"\"\n return random.randint(1, 100)\n\ndef play_game(...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00025165", "row_id": 25165, "seed_ids": "['Llama-3.3-70B-Instruct_62345']" }
0.486273
Filter_25165
I
[ "initialize_game", "guess_number", "take_turn", "play_game" ]
4
[ [ "play_game", "initialize_game" ], [ "play_game", "take_turn" ], [ "take_turn", "guess_number" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e16488bae292950ca4e9a3375fbe4a36dbf966f6
d8cf1ff28771f9870143e8bd33066a33450232d9
v1.0
instruct
Filter
Filter_25185_I
I see what you did there with the travel recommendations. Too bad I didn't ask for travel recommendations. The task is to implement "Existence Check" on two vectors, say `vectorA` and `vectorB`. Given the vectors are of different sizes and dimensions, ensure that the inferred algorithm is dimension and size-agnostic....
def existenceCheck(vectorA, vectorB): """ Checks if at least one element from vectorB exists in vectorA. Handles vectors of varying sizes and dimensions. Parameters: vectorA (list): First input vector (can be nested). vectorB (list): Second input vector (can be nested). Returns: ...
from solution import existenceCheck def test_existenceCheck_with_1d_vectors(): assert existenceCheck([1, 2, 3, 4, 5], [4, 6, 7]) == True assert existenceCheck([1, 2, 3], [4, 5, 6]) == False def test_existenceCheck_with_2d_vectors(): assert existenceCheck([[1, 2], [3, 4], [5, 6]], [[3, 4], [7, 8]]) == True...
[ { "docstring": "Checks if at least one element from vectorB exists in vectorA.\nHandles vectors of varying sizes and dimensions.\n\nParameters:\nvectorA (list): First input vector (can be nested).\nvectorB (list): Second input vector (can be nested).\n\nReturns:\nbool: True if any element of vectorB is found in...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def existenceCheck(vectorA, vectorB):\n \"\"\"\n Checks if at least one element from `vectorB` exists in `vectorA`.\n \n Parameters:\n vectorA (list): The vector to search withi...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00025185", "row_id": 25185, "seed_ids": "['Llama-3.3-70B-Instruct_62379']" }
0.568067
Filter_25185
I
[ "existenceCheck", "flatten" ]
2
[ [ "existenceCheck", "flatten" ] ]
1
[]
false
[]
false
pytest
true
[]
true
46b9f47f9f3a1bbc8c02b0867db476ea5fcfb8d3
298fb20bfc2847b1486e5f1d69ea31ec56fe1e32
v1.0
instruct
Filter
Filter_25188_I
Given s1 and s2 as input strings, design an algorithm that determines if s2 data can be obtained from s1 with ONLY ROT13 substitution (ROT13 cancels itself), and implements either ROT13 or its inverse to get the desired s2 from s1. Algorithm: - Take 2 input strings - For each character in the strings, apply the ROT13...
def rot13(text): """ Apply ROT13 substitution cipher to the input text. """ result = "" for char in text: if char.isalpha(): ascii_offset = 97 if char.islower() else 65 result += chr((ord(char) - ascii_offset + 13) % 26 + ascii_offset) else: result...
from solution import rot13, can_transform_with_rot13 def test_rot13(): assert rot13('abc') == 'nop' assert rot13('nop') == 'abc' assert rot13('ABCDEFGHIJKLMNOPQRSTUVWXYZ') == 'NOPQRSTUVWXYZABCDEFGHIJKLM' assert rot13('nopqrstuvwxyz') == 'abcdefghijklm' assert rot13('Hello, World!') == 'Uryyb, Jbeyq...
[ { "docstring": "Apply ROT13 substitution cipher to the input text.", "function_declaration": "def rot13(text):", "function_name": "rot13", "parameter_list": "(text)" }, { "docstring": "Determine if s2 can be obtained from s1 using ROT13 substitution.\n\nReturns True if s2 can be obtained by ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def rot13(text):\n \"\"\"\n Applies ROT13 cipher to the input text.\n \"\"\"\n result = \"\"\n\n for char in text:\n if char.isalpha():\n ascii_offset = 97 if ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00025188", "row_id": 25188, "seed_ids": "['Llama-3.3-70B-Instruct_62391']" }
0.58603
Filter_25188
I
[ "rot13", "can_transform_with_rot13" ]
2
[ [ "can_transform_with_rot13", "rot13" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2ebc7935d0f4700221b80eaa3d0b7d1f0d056d1c
13436f3fe1002cacff935258bfd5a6ed80df8c23
v1.0
instruct
Filter
Filter_25205_I
### Word Chain In a word chain, the last letter of a word is the first letter of the next word. For example, "cat" and "turtle" form a chain because t is the last letter of "cat" and is also the first letter of "turtle". Your task is to write a function that plays a word chain game. The player inputs the name of a cat...
def get_words(category): """ Fetch all words from a predefined list for a given category. Args: category (str): The category of words. Returns: List[str]: List of words for the given category. """ word_dict = { "animals": ["cat", "turtle", "elephant", "tiger", "rhin...
from solution import get_words, word_chain_game def test_get_words_valid_category(): assert get_words("animals") == ["cat", "turtle", "elephant", "tiger", "rhino", "ostrich"] assert get_words("countries") == ["spain", "nigeria", "australia", "argentina", "afghanistan"] assert get_words("foods") == ["pizza"...
[ { "docstring": "Fetch all words from a predefined list for a given category.\n\nArgs:\n category (str): The category of words.\n\nReturns:\n List[str]: List of words for the given category.", "function_declaration": "def get_words(category):", "function_name": "get_words", "parameter_list": "(...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def get_words(category):\n \"\"\"\n Fetch all words from a predefined list for a given category.\n \n Args:\n category (str): The category of words.\n\n Returns:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00025205", "row_id": 25205, "seed_ids": "['Llama-3.3-70B-Instruct_62420']" }
0.585138
Filter_25205
I
[ "get_words", "word_chain_game" ]
2
[ [ "word_chain_game", "get_words" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1668653af13b2c4f9902046765e6e47e54e487ca
03da9e4a744e3cfcc6ad9b3451aacbc915d6131b
v1.0
instruct
Filter
Filter_25215_I
I have been logging Excel Issues (specifically Cells that cause issues). My dataset contains a Spreadsheet filename, a row number and a column letter. I would like to write a python tool to add a button that links to the correct cell in the specified worksheet. See example below. Example of Logs | SpreadsheetFilename...
import pandas as pd def generate_open_cell_link(spreadsheet_filename, sheet_name, row_number, column_letter): """ Generates an HTML link to open the specified cell in Excel. Parameters: - spreadsheet_filename: Name of the spreadsheet file - sheet_name: Name of the sheet (if empty, defaults to ...
from solution import generate_open_cell_link, add_open_cell_links import pandas as pd def test_generate_open_cell_link_with_sheet_name(): assert generate_open_cell_link("Example1.xlsx", "Sheet1", 5, "A") == '<a href="excel:///C:/Example1.xlsx::Sheet1!A5">Open in Excel</a>' def test_generate_open_cell_link_without...
[ { "docstring": "Generates an HTML link to open the specified cell in Excel.\n\nParameters:\n- spreadsheet_filename: Name of the spreadsheet file\n- sheet_name: Name of the sheet (if empty, defaults to \"Sheet1\")\n- row_number: Row number of the cell\n- column_letter: Column letter of the cell\n\nReturns:\nA st...
[ 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 generate_open_cell_link(spreadsheet_filename, sheet_name, row_number, column_letter):\n \"\"\"\n Generates a HTML link to open a specific cell in an Excel file...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00025215", "row_id": 25215, "seed_ids": "['Llama-3.3-70B-Instruct_62442']" }
0.540826
Filter_25215
I
[ "generate_open_cell_link", "add_open_cell_links" ]
2
[ [ "add_open_cell_links", "generate_open_cell_link" ] ]
1
[]
false
[]
false
pytest
true
[ "pandas" ]
false
1798a8f9fae548a17dd8c0c5a0045ca673fbb17d
3182cfb3ee47935b983ba5d716987a76bb55bea1
v1.0
instruct
Filter
Filter_25216_I
I am trying to create a simple game and I am having trouble with collision detection for rectangles and circles. Can you explain how this works and provide some sample code in Python? ### Collision Detection Overview Here's a brief explanation of how collision detection works for rectangles and circles: 1. **Rectangl...
import math class Rectangle: def __init__(self, x, y, width, height): self.x = x self.y = y self.width = width self.height = height class Circle: def __init__(self, x, y, radius): self.x = x self.y = y self.radius = radius def check_rectangle_collision(...
from solution import ( Rectangle, Circle, check_rectangle_collision, check_circle_collision, check_rectangle_circle_collision ) def test_check_rectangle_collision(): r1 = Rectangle(0, 0, 10, 10) r2 = Rectangle(5, 5, 10, 10) assert check_rectangle_collision(r1, r2) == True r1 = Rectangl...
[]
[ 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\nclass Rectangle:\n def __init__(self, x, y, width, height):\n self.x = x\n self.y = y\n self.width = width\n self.height = height\n\nclass Circle:...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00025216", "row_id": 25216, "seed_ids": "['Llama-3.3-70B-Instruct_62446']" }
0.571496
Filter_25216
I
[ "check_rectangle_collision", "check_circle_collision", "closest_point_on_rectangle", "check_rectangle_circle_collision" ]
4
[ [ "check_rectangle_circle_collision", "closest_point_on_rectangle" ] ]
1
[]
false
[ "Rectangle", "Circle" ]
true
pytest
true
[]
true
2b7a60dc7194c32ab7446ad219ad64051a3f9881
0b14ce586d18d52283128d2b5ea6a66ea6ebe8d5
v1.0
instruct
Filter
Filter_25219_I
Consider the differential equation: $y''+y=0$, with initial conditions $y(0)=1$ and $y'(0)=0$, I need to solve it using Python. First I am going to define the model, which is the function $f(y',y,t) = -y$, and then use `scipy` library to solve the system of equations. Here is a way to perform it, ```python import nu...
import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt # Function to define the system of differential equations def model(u, t, a, b): """ Returns the system of equations for y''(t) + a*y'(t) + b*y(t) = 0. u[0] = y u[1] = y' """ dydt = [u[1], -a * u[1] - b * u[0]...
from solution import solve_ode import numpy as np def test_solve_ode_ys_zeros_a1_b1(): t = np.linspace(0, 10, 100) a = 1 b = 1 u0 = [0, 0] u = solve_ode(a, b, u0, t) # Check if all y values are zero assert np.allclose(u[:, 0], 0) # Check if all y' values are zero assert np.allclose(...
[ { "docstring": "Returns the system of equations for y''(t) + a*y'(t) + b*y(t) = 0.\nu[0] = y\nu[1] = y'", "function_declaration": "def model(u, t, a, b):", "function_name": "model", "parameter_list": "(u, t, a, b)" }, { "docstring": "Solves the ODE y'' + a*y' + b*y = 0 and returns the soluti...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nfrom scipy.integrate import odeint\nimport matplotlib.pyplot as plt\n\ndef model(u, t, a, b):\n \"\"\"\n Defines the system of differential equations.\n u[0] = y\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00025219", "row_id": 25219, "seed_ids": "['Llama-3.3-70B-Instruct_62453']" }
0.433731
Filter_25219
I
[ "model", "solve_ode" ]
2
[ [ "solve_ode", "model" ] ]
1
[]
false
[]
false
pytest
true
[ "matplotlib", "numpy", "scipy" ]
false
d01ea4c2474bafd568b965c14b2d91ce6ae04e42
b1ab7354ab920c4aa624556b40b1385947a9cfe3
v1.0
instruct
Filter
Filter_25223_I
I have a piece of code that is working fine so far with numpy and scipy. However, I need a function that could give me all permutations of a list and then I try all the permutations in the function. However, I need it to be as efficient as possible, since I might need to use lists with up to 6-9 elements in the future....
import numpy as np def all_permutations(lst): """ Given a list, returns all permutations of it using numpy. """ n = len(lst) # Create an array with repeated values of the input list repeated_values = np.tile(lst, (n ** n, 1)) # Generate all indices combinations as Cartesian product ...
from solution import all_permutations def test_all_permutations_length_3(): myList = [0, 1, 2] result = all_permutations(myList) expected_length = 3 ** 3 assert result.shape == (expected_length, 3) def test_all_permutations_length_2(): myList = [0, 1] result = all_permutations(myList) expe...
[ { "docstring": "Given a list, returns all permutations of it using numpy.", "function_declaration": "def all_permutations(lst):", "function_name": "all_permutations", "parameter_list": "(lst)" }, { "docstring": null, "function_declaration": "def display_permutations(lst):", "function...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\n\ndef generate_permutations(myList):\n \"\"\"\n Generate all permutations of a given list and return them in an order \n similar to the Cartesian product.\n \n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00025223", "row_id": 25223, "seed_ids": "['Llama-3.3-70B-Instruct_62464']" }
0.627148
Filter_25223
I
[ "all_permutations", "display_permutations" ]
2
[ [ "display_permutations", "all_permutations" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
9dda900ac020e425f86b37ddd3b761cedd649e90
d8bbc87a6289fa1bb9077105fc39321c1dd0909c
v1.0
instruct
Filter
Filter_25232_I
Here is an updated version of the code snippet you requested: ```python import numpy as np def longest_common_subsequence_memoization(sequence_1, sequence_2, m, n, memo): if m == 0 or n == 0: return 0 if (m, n) in memo: return memo[(m, n)] if sequence_1[m-1] == sequence_2[n-1]: ...
def longest_common_subsequence_memoization(sequence_1, sequence_2, m, n, memo): """ Helper function to compute the LCS using memoization. Args: sequence_1 (str): First sequence. sequence_2 (str): Second sequence. m (int): Length of the first sequence. n (int): Length of the second sequence. ...
import pytest from solution import longest_common_subsequence def test_longest_common_subsequence(): assert longest_common_subsequence("abcde", "ace") == 3 assert longest_common_subsequence("abc", "abc") == 3 assert longest_common_subsequence("abc", "def") == 0 assert longest_common_subsequence("abcdef...
[ { "docstring": "Helper function to compute the LCS using memoization.\nArgs:\nsequence_1 (str): First sequence.\nsequence_2 (str): Second sequence.\nm (int): Length of the first sequence.\nn (int): Length of the second sequence.\nmemo (dict): Dictionary to store the results of subproblems.\n\nReturns:\nint: Len...
[ 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 longest_common_subsequence_memoization(sequence_1, sequence_2, m, n, memo):\n if m == 0 or n == 0:\n return 0\n \n if (m, n) in memo:\n return ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00025232", "row_id": 25232, "seed_ids": "['Llama-3.3-70B-Instruct_62487']" }
0.627079
Filter_25232
I
[ "longest_common_subsequence_memoization", "longest_common_subsequence" ]
2
[ [ "longest_common_subsequence", "longest_common_subsequence_memoization" ] ]
1
[]
false
[]
false
pytest
true
[]
true
79c86db66efa05198ce031b826a44c94120b9250
3128868a4f8b49ea54099827a78572d9f5945d00
v1.0
instruct
Filter
Filter_25240_I
I need help with writing a python program that will find the probability that a random function will end with a certain byte value. Specifically I will be taking a random string and hashing it with SHA-256. The goal is to determine the probability of the resulting hash ending with a certain byte or certain byte values...
import hashlib import secrets import string def hash_string(input_string): return hashlib.sha256(input_string.encode()).digest() def estimate_probability(target_byte, sample_size): matches = 0 for _ in range(sample_size): random_string = ''.join(secrets.choice(string.ascii_letters) for _ in range(...
from solution import hash_string, estimate_probability def test_hash_string(): # SHA-256 of an empty string assert hash_string("") == bytes.fromhex( "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" ) # SHA-256 of "test" assert hash_string("test") == bytes.fromhex( ...
[ { "docstring": null, "function_declaration": "def hash_string(input_string):", "function_name": "hash_string", "parameter_list": "(input_string)" }, { "docstring": null, "function_declaration": "def estimate_probability(target_byte, sample_size):", "function_name": "estimate_probabil...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import hashlib\nimport secrets\nimport string\n\ndef hash_string(input_string):\n return hashlib.sha256(input_string.encode()).digest()\n\ndef estimate_probability(target_byte, sample_size)...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00025240", "row_id": 25240, "seed_ids": "['Llama-3.3-70B-Instruct_62504']" }
0.628345
Filter_25240
I
[ "hash_string", "estimate_probability" ]
2
[ [ "estimate_probability", "hash_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e2caf980ce95359cbab9a24829238ebc1090c7ce
9194b6b553d3db11b9b16e830a2f533350d7e808
v1.0
instruct
Filter
Filter_25243_I
In the following Python code implementation of the QuickSort algorithm, the `partition` method is incorrectly implemented. Describe the steps to correctly implement the `partition` method for a QuickSort algorithm.
def quicksort(arr, low, high): if low < high: pi = partition(arr, low, high) quicksort(arr, low, pi - 1) quicksort(arr, pi + 1, high) def partition(arr, low, high): pivot = arr[high] i = low - 1 for j in range(low, high): if arr[j] <= pivot: i = i + 1 ...
from solution import quicksort def test_partition(): arr = [10, 80, 30, 90, 40, 50, 70] quicksort(arr, 0, len(arr) - 1) assert arr == [10, 30, 40, 50, 70, 80, 90] def test_sorted_array(): arr = [1, 2, 3, 4, 5] quicksort(arr, 0, len(arr) - 1) assert arr == [1, 2, 3, 4, 5] def test_reverse_sort...
[ { "docstring": null, "function_declaration": "def quicksort(arr, low, high):", "function_name": "quicksort", "parameter_list": "(arr, low, high)" }, { "docstring": null, "function_declaration": "def partition(arr, low, high):", "function_name": "partition", "parameter_list": "(ar...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def quicksort(arr):\n \"\"\"\n Sorts an array using the QuickSort algorithm.\n \"\"\"\n def _quicksort(arr, low, high):\n if low < high:\n pi = partition(arr, low...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00025243", "row_id": 25243, "seed_ids": "['Llama-3.3-70B-Instruct_62508']" }
0.47426
Filter_25243
I
[ "quicksort", "partition" ]
2
[ [ "quicksort", "partition" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dee31f75f571d93ea350f94927c16e30c7f17976
2dc2619e3e4a37a2364c555ddf01e88581006960
v1.0
instruct
Filter
Filter_25248_I
I want to implement a digital coin flip game where two players can take turns and the winner of each round is announced. This is what my game should do: 1. The game should continue until one player reaches a score of 10. 2. The winner of each round should be determined by a random coin flip. 3. The scores should b...
import random def coin_flip(): """Simulates a coin flip, returning either 'Heads' or 'Tails'.""" return 'Heads' if random.random() < 0.5 else 'Tails' def game(): player1_score = 0 player2_score = 0 round_number = 0 scores = [] while player1_score < 10 and player2_score < 10: round...
import pytest from solution import coin_flip, game def test_coin_flip(): """ Test the coin_flip function to ensure it returns either 'Heads' or 'Tails'. """ results = {coin_flip() for _ in range(100)} assert results == {'Heads', 'Tails'} def test_game_execution(): """ Test the game fun...
[ { "docstring": "Simulates a coin flip, returning either 'Heads' or 'Tails'.", "function_declaration": "def coin_flip():", "function_name": "coin_flip", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def game():", "function_name": "game", "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 coin_flip():\n \"\"\"Simulates a coin flip, returning either 'Heads' or 'Tails'\"\"\"\n return 'Heads' if random.random() < 0.5 else 'Tails'\n\ndef game():\n play...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00025248", "row_id": 25248, "seed_ids": "['Llama-3.3-70B-Instruct_62535']" }
0.531493
Filter_25248
I
[ "coin_flip", "game" ]
2
[ [ "game", "coin_flip" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4e3484897bd130b65bbf74d4521182e96f5a3bdc
0ce6dedaafc55fc271ec4a6dde080e20fdce9ce5
v1.0
instruct
Filter
Filter_25267_I
### Description Create a function that will calculate the bonus for a given employee based on their role and years of service. The bonus calculation rules are as follows: - All employees with less than 5 years of service receive a 5% bonus. - All employees with 5 years of service or more but less than 10 years of servi...
def calculate_bonus(years_of_service, employee_role): """ Calculate the bonus for an employee based on their role and years of service. Parameters: years_of_service (int): The number of years the employee has worked for the company. employee_role (str): The role of the employee. Can be 'manager...
from solution import calculate_bonus, print_employee_bonuses def test_calculate_bonus_employee(): assert calculate_bonus(3, 'employee') == 0.05 assert calculate_bonus(7, 'employee') == 0.07 assert calculate_bonus(12, 'employee') == 0.10 def test_calculate_bonus_manager(): assert calculate_bonus(3, 'ma...
[ { "docstring": "Calculate the bonus for an employee based on their role and years of service.\n\nParameters:\nyears_of_service (int): The number of years the employee has worked for the company.\nemployee_role (str): The role of the employee. Can be 'manager', 'executive', or 'employee'.\n\nReturns:\nbonus (flo...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_bonus(years_of_service, employee_role):\n \"\"\"\n Calculate the bonus for an employee based on their role and years of service.\n \n Parameters:\n years_of_servic...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00025267", "row_id": 25267, "seed_ids": "['Llama-3.3-70B-Instruct_62566']" }
0.59753
Filter_25267
I
[ "calculate_bonus", "print_employee_bonuses" ]
2
[ [ "print_employee_bonuses", "calculate_bonus" ] ]
1
[]
false
[]
false
pytest
true
[]
true
064ea98ad04da04a413b2f75d5dd3319623daf96
f6b592661f5423b69e99ab258afc1372c255402c
v1.0
instruct
Filter
Filter_25271_I
We have a binary tree and we want to check if it's a binary search tree (BST) or not. A binary tree is considered a BST if for each node, all elements in its left child are less than the node and all elements in its right child are greater than the node. Here is a code to check if a binary tree is a BST: ```python def...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def is_bst_and_get_min_max(node): """ This function checks if the tree is a BST and simultaneously finds the minimum and maximum values in the tree. Returns a tup...
from solution import TreeNode, is_bst, get_min_max_values def test_is_bst(): # Test case 1: A valid BST root = TreeNode(2) root.left = TreeNode(1) root.right = TreeNode(3) assert is_bst(root) == True # Test case 2: Not a BST because 4 is on the left of 3 root = TreeNode(3) root.left = ...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef is_bst_and_get_min_max(node):\n d...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00025271", "row_id": 25271, "seed_ids": "['Llama-3.3-70B-Instruct_62571']" }
0.558043
Filter_25271
I
[ "is_bst_and_get_min_max", "is_bst", "get_min_max_values" ]
3
[ [ "get_min_max_values", "is_bst_and_get_min_max" ], [ "is_bst", "is_bst_and_get_min_max" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
3332d7fcde05c1853567f74fdadb9527afb3da59
0b27f4839bd15b73cecb9f89cb3671aaa62ad324
v1.0
instruct
Filter
Filter_25282_I
Here is the code for a naive implementation of insertion sort: ```python def insertion_sort(arr): for i in range(1, len(arr)): key = arr[i] j = i - 1 while j >= 0 and key < arr[j]: arr[j + 1] = arr[j] j -= 1 arr[j + 1] = key return arr numbers = [4, 3, 2,...
def merge_sort(arr): if len(arr) <= 1: return arr mid = len(arr) // 2 left = merge_sort(arr[:mid]) right = merge_sort(arr[mid:]) return merge(left, right) def merge(left, right): merged = [] left_index = right_index = 0 while left_index < len(left) and right_index...
from solution import merge_sort def test_merge_sort_with_unsorted_list(): assert merge_sort([4, 3, 2, 10, 12, 1, 5, 6]) == [1, 2, 3, 4, 5, 6, 10, 12] def test_merge_sort_with_sorted_list(): assert merge_sort([1, 2, 3, 4, 5, 6, 7, 8]) == [1, 2, 3, 4, 5, 6, 7, 8] def test_merge_sort_with_reverse_sorted_list():...
[ { "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 if len(arr) <= 1:\n return arr\n mid = (0 + len(arr)) // 2\n left = merge_sort(arr[:mid])\n right = merge_sort(arr[mid:])\n return merge(left, righ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00025282", "row_id": 25282, "seed_ids": "['Llama-3.3-70B-Instruct_62593']" }
0.527328
Filter_25282
I
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5a67c5abd26d597827f62b848b4d3ff328e6e0d5
801a1c5d1155eec70538999243c80be46492a2d2
v1.0
instruct
Filter
Filter_25286_I
Given a matrix of size N x N, containing random integers, write a Python function to find the maximum sum of all the possible submatrices within this matrix.
def max_submatrix_sum(matrix): """ Finds the maximum sum of all possible submatrices within the given matrix. Args: - matrix (list of list of int): The input N x N matrix. Returns: - int: The maximum submatrix sum. """ n = len(matrix) max_sum = float('-inf') # Prec...
from solution import max_submatrix_sum def test_max_submatrix_sum_1(): matrix = [ [1, 2, -1, -4, -20], [-8, -3, 4, 2, 1], [3, 8, 10, 1, 3], [-4, -1, 1, 7, -6] ] assert max_submatrix_sum(matrix) == 29 def test_max_submatrix_sum_2(): matrix = [ [1, -2, 1], ...
[ { "docstring": "Finds the maximum sum of all possible submatrices within the given matrix.\n\nArgs:\n- matrix (list of list of int): The input N x N matrix.\n\nReturns:\n- int: The maximum submatrix sum.", "function_declaration": "def max_submatrix_sum(matrix):", "function_name": "max_submatrix_sum", ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_submatrix_sum(matrix):\n \"\"\"\n Finds the maximum sum of all possible submatrices within the given matrix.\n \n Args:\n - matrix (list of list of int): The input N x N...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00025286", "row_id": 25286, "seed_ids": "['Llama-3.3-70B-Instruct_62599']" }
0.61452
Filter_25286
I
[ "max_submatrix_sum", "kadane" ]
2
[ [ "max_submatrix_sum", "kadane" ] ]
1
[]
false
[]
false
pytest
true
[]
true
87ac177e58bd0f8d67bc64ed9d1199d9d57c2f77
feb3731a608b95e89db61e3300284fe74bf7c8ee
v1.0
instruct
Filter
Filter_25302_I
It's sometimes a good idea to create an ECC (Error Checking and Correcting) code to detect and correct data. Let's say we write a program that writes a number, along with a calculated checksum digit, for later verification. The function write_with_checksum takes two parameters: number and file_object (an open, writabl...
def calculate_checksum(number): def digit_sum(n): return sum(int(digit) for digit in str(n)) checksum = digit_sum(number) while checksum >= 10: checksum = digit_sum(checksum) return checksum def write_with_checksum(number, file_object): checksum = calculate_checksum(number...
import io from solution import calculate_checksum, write_with_checksum def test_calculate_checksum_single_digit(): assert calculate_checksum(4) == 4 def test_calculate_checksum_multiple_digits(): assert calculate_checksum(12345) == 6 # 1+2+3+4+5 = 15 -> 1+5 = 6 assert calculate_checksum(9876) == 3 #...
[ { "docstring": null, "function_declaration": "def calculate_checksum(number):", "function_name": "calculate_checksum", "parameter_list": "(number)" }, { "docstring": null, "function_declaration": "def write_with_checksum(number, file_object):", "function_name": "write_with_checksum",...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_checksum(number):\n def digit_sum(n):\n return sum(int(digit) for digit in str(n))\n \n checksum = digit_sum(number)\n while checksum >= 10:\n checksum ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00025302", "row_id": 25302, "seed_ids": "['Llama-3.3-70B-Instruct_62638']" }
0.463269
Filter_25302
I
[ "calculate_checksum", "write_with_checksum" ]
2
[ [ "write_with_checksum", "calculate_checksum" ] ]
1
[]
false
[]
false
pytest
true
[]
true
323d7ea77c9cf335843f3011494266571ca983b9
828091be7f54c185c23747c1a3950a5056db8042
v1.0
instruct
Filter
Filter_25312_I
Write a script to print all the prime numbers from 2 to 1000 using Python
def is_prime(n): """ Check if a number is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 re...
from solution import is_prime, print_primes_up_to_1000 def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(0) == False assert is_prime(1) == False assert is_prime(13) == True assert is_prime(17...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Print all prime numbers from 2 to 1000.", "function_declaration": "def print_primes_up_to_1000():", "function_nam...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n re...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00025312", "row_id": 25312, "seed_ids": "['Llama-3.3-70B-Instruct_62666']" }
0.625018
Filter_25312
I
[ "is_prime", "print_primes_up_to_1000" ]
2
[ [ "print_primes_up_to_1000", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
09c6807426a1e21cc920493b908c9c04aa537c0b
f994bbc631b38d97840ba7085332dcbfbf19a183
v1.0
instruct
Filter
Filter_25315_I
Create a fully executable code (no dependencies) for a multithreaded mergesort algorithm in Python. ```python import threading import random # Create a fake data fake_data = [random.randint(0, 100) for _ in range(10)] ``` I require the code with all necessary comments and instructions to execute it. **What is the ...
import threading def merge_sort(arr): """ Sorts an array using a multithreaded mergesort algorithm. """ if len(arr) > 1: mid = len(arr) // 2 # Finding the middle of the array left_half = arr[:mid] # Dividing the array elements into 2 halves right_half = arr[mid:] # Cr...
from solution import merge_sort def test_merge_sort_empty(): arr = [] merge_sort(arr) assert arr == [] def test_merge_sort_single_element(): arr = [1] merge_sort(arr) assert arr == [1] def test_merge_sort_sorted_array(): arr = [1, 2, 3, 4, 5] merge_sort(arr) assert arr == [1, 2, 3...
[ { "docstring": "Sorts an array using a multithreaded mergesort algorithm.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": "Merges two halves in a sorted manner.", "function_declaration": "def merge(arr, left_hal...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import threading\n\ndef merge(left, right):\n \"\"\"\n Merges two sorted lists into a single sorted list.\n \"\"\"\n result = []\n i = j = 0\n \n # Merge the two sorted ar...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00025315", "row_id": 25315, "seed_ids": "['Llama-3.3-70B-Instruct_62671']" }
0.46352
Filter_25315
I
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8daa0d420c67cac8936558b04e12941b04304dea
230199cbb4b5fb92024ead93d50863b1f1ef836b
v1.0
instruct
Filter
Filter_25369_I
Identify the programming language used in the following code snippet and explain why you think it is that language. Also, modify the code to add a function that returns a list of prime numbers up to the argument provided to the `loop_function`. Your solution should utilize an optimized algorithm to check for prime numb...
# The provided code snippet is written in Python def loop_function(n): result = [] for i in range(n): result.append(i * i) return result # Adding a function that returns a list of prime numbers up to the argument provided to `loop_function`. def is_prime(number): """ Returns True if numbe...
from solution import loop_function, is_prime, prime_numbers_up_to def test_loop_function(): assert loop_function(5) == [0, 1, 4, 9, 16] assert loop_function(0) == [] assert loop_function(1) == [0] def test_is_prime(): assert is_prime(2) is True assert is_prime(3) is True assert is_prime(4) is ...
[ { "docstring": null, "function_declaration": "def loop_function(n):", "function_name": "loop_function", "parameter_list": "(n)" }, { "docstring": "Returns True if number is a prime, else False.", "function_declaration": "def is_prime(number):", "function_name": "is_prime", "param...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def loop_function(n):\n for i in range(n):\n print(i)", "test_code": "from solution import loop_function, is_prime, primes_up_to\n\ndef test_is_prime():\n assert is_prime(2) =...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00025369", "row_id": 25369, "seed_ids": "['Qwen2-72B-Instruct_62810']" }
0.66645
Filter_25369
I
[ "loop_function", "is_prime", "prime_numbers_up_to" ]
3
[ [ "prime_numbers_up_to", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
364186ec1ab19ce3bb698081c55df66394bc9f91
17d474e046dd227aec896e1df504e25ce22c76e5