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_13237_I
### Programming Challenge: Word Scramble #### Problem Description Create a word scrambler program that takes a list of words as input and generates a scrambled version of each word. #### Requirements * The scrambled version of each word should have all the same letters as the original word, but in a different order....
import random def scramble_word(word): """ Scrambles a single word such that the first and last letters remain the same, while the letters in between are randomly shuffled. """ word_list = list(word) # If the word has less than 3 characters, return it as is if len(word_list) <= 2: ...
import pytest from solution import scramble_word, scramble_words def test_scramble_word_example_case(): scrambled = scramble_word("hello") assert scrambled[0] == "h" and scrambled[-1] == "o" and set(scrambled) == set("hello") def test_scramble_single_letter(): assert scramble_word("a") == "a" def test_sc...
[ { "docstring": "Scrambles a single word such that the first and last letters remain the same,\nwhile the letters in between are randomly shuffled.", "function_declaration": "def scramble_word(word):", "function_name": "scramble_word", "parameter_list": "(word)" }, { "docstring": "Takes a lis...
[ 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 scramble_word(word):\n if len(word) <= 2:\n return word\n\n # Convert the word to a list so we can shuffle it\n word_list = list(word)\n\n # Remove the ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013237", "row_id": 13237, "seed_ids": "['Llama-3.3-70B-Instruct_34327']" }
0.734522
Filter_13237
I
[ "scramble_word", "scramble_words" ]
2
[ [ "scramble_words", "scramble_word" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ea997df7fd3243226623d3077da883e4d6babff8
af3874f9896f0711def0b1da2d5d2755f4524a2d
v1.0
instruct
Filter
Filter_13238_I
I've been working on this project for a long time now, and I still don't know how to implement this one specific thing. I've tried looking at examples online, but I could use some extra help. I want to create a command-line interface for my server. I have the following specifications and requirements: My CLI tool sho...
import click import getpass import json import requests # Sample URL of the server SERVER_URL = "http://example.com/api" # Authenticate user def authenticate_user(username, password): response = requests.post(f"{SERVER_URL}/auth/login", json={"username": username, "password": password}) if response.status_cod...
import requests from click.testing import CliRunner from solution import cli # Mock Responses def test_help_command(): runner = CliRunner() result = runner.invoke(cli, ['--help']) assert result.exit_code == 0 assert 'Commands' in result.output def test_login_success(monkeypatch): def mock_post(url...
[ { "docstring": null, "function_declaration": "def authenticate_user(username, password):", "function_name": "authenticate_user", "parameter_list": "(username, password)" }, { "docstring": null, "function_declaration": "def cli(ctx):", "function_name": "cli", "parameter_list": "(c...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import click\nimport getpass\nimport json\nimport requests\n\n# Sample URL of the server\nSERVER_URL = \"http://example.com/api\"\n\n# Authenticate user\ndef authenticate_user(username, passwo...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00013238", "row_id": 13238, "seed_ids": "['Llama-3.3-70B-Instruct_34330']" }
0.354414
Filter_13238
I
[ "authenticate_user", "cli", "login", "list_users", "create_user", "update_user", "delete_user" ]
7
[ [ "login", "authenticate_user" ] ]
1
[]
false
[]
false
pytest
true
[ "click", "requests" ]
false
2ebc6f92b9a92dfe7b353a9d5b8b39e5f2d19d1f
190d7d415156187b0ee1253873118af2adfa6f7d
v1.0
instruct
Filter
Filter_13255_I
### Prompt We've been given a list of intervals where each interval is a list of two integers representing a start and end time. The intervals are not guaranteed to be sorted by their start time, and the intervals may or may not overlap. The task is to merge all overlapping intervals into one interval. ### Example Inp...
class IntervalNode: def __init__(self, start, end): self.start = start self.end = end self.left = None self.right = None def insert_interval(root, interval): if root is None: return IntervalNode(interval[0], interval[1]) if interval[0] <= root.start: roo...
from solution import merge_intervals def test_merge_intervals_basic(): assert merge_intervals([(1, 3), (2, 6), (8, 10), (15, 18)]) == [(1, 6), (8, 10), (15, 18)] def test_merge_intervals_overlapping(): assert merge_intervals([(1, 4), (4, 5)]) == [(1, 5)] def test_merge_intervals_multiple_overlapping(): a...
[]
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class IntervalTree:\n def __init__(self, intervals):\n # Initialize tree by sorting intervals and VEB nodes\n self.root = self.build_tree(sorted(intervals, key=lambda x: x[0])...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00013255", "row_id": 13255, "seed_ids": "['Llama-3.3-70B-Instruct_34384']" }
0.612792
Filter_13255
I
[ "insert_interval", "merge_intervals_with_root", "in_order_traversal", "merge_intervals" ]
4
[ [ "insert_interval", "merge_intervals_with_root" ], [ "merge_intervals", "in_order_traversal" ], [ "merge_intervals", "insert_interval" ] ]
3
[]
false
[ "IntervalNode" ]
true
pytest
true
[]
true
80bd0e5abf239be9e3d911c45e7c44b967fb7f29
7c9eecea986be6f710906168ad83d100d4c54072
v1.0
instruct
Filter
Filter_13264_I
Can you guide me through creating a simple neural network using PyTorch, including data loading and training?
import torch import torch.nn as nn import torch.optim as optim from torch.utils.data import DataLoader, TensorDataset # Step 1: Define the neural network architecture class SimpleNN(nn.Module): def __init__(self, input_size, hidden_size, output_size): super(SimpleNN, self).__init__() self.fc1 = nn....
import pytest from solution import SimpleNN, generate_dummy_data, create_dataloader, train_model, train_simple_nn import torch.nn as nn import torch.optim as optim import torch def test_simple_nn_structure(): model = SimpleNN(10, 5, 1) assert len(list(model.parameters())) == 4 assert list(model.children())...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import torch\nimport torch.nn as nn\nimport torch.optim as optim\nfrom torch.utils.data import DataLoader, Dataset\nfrom torchvision import transforms, datasets\n\n# 1. Define a simple neural ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013264", "row_id": 13264, "seed_ids": "['Llama-3.3-70B-Instruct_34411']" }
0.33711
Filter_13264
I
[ "generate_dummy_data", "create_dataloader", "train_model", "train_simple_nn" ]
4
[ [ "train_simple_nn", "create_dataloader" ], [ "train_simple_nn", "generate_dummy_data" ], [ "train_simple_nn", "train_model" ] ]
3
[]
false
[ "SimpleNN" ]
true
pytest
true
[ "torch" ]
false
45ed1e148572afab38931c540c09ccf6a84dde26
68950907b70eac28fda133484055168b68e0970d
v1.0
instruct
Filter
Filter_13277_I
I know that in Python, you can define a function with the same name as an existing function or method, which can lead to shadowing. However, if the function has a different signature, you cannot use the shadowed function anymore. However, I think there is a more nuanced case. When the shadowed function takes a variab...
# Example of shadowing the print function with a new definition def print(*args, **kwargs): return "Shadowed print function called" def demo_print_shadowing(): # Attempt to call the newly defined print result = print("Hello, World!") return result
from solution import demo_print_shadowing def test_demo_print_shadowing(): assert demo_print_shadowing() == "Shadowed print function called" import builtins def test_original_print_restored(): saved_print = builtins.print # Save the original built-in print def mock_print(*args, **kwargs): re...
[ { "docstring": null, "function_declaration": "def print(*args, **kwargs):", "function_name": "print", "parameter_list": "(*args, **kwargs)" }, { "docstring": null, "function_declaration": "def demo_print_shadowing():", "function_name": "demo_print_shadowing", "parameter_list": "(...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def func(*args):\n print(\"Original function called with\", args)\n\n# Call the original function\nfunc(1, 2, 3)\n\n# Shadowing the original function with the same name and same signature\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00013277", "row_id": 13277, "seed_ids": "['Llama-3.3-70B-Instruct_34449']" }
0.350693
Filter_13277
I
[ "print", "demo_print_shadowing" ]
2
[ [ "demo_print_shadowing", "print" ] ]
1
[]
false
[]
false
pytest
true
[]
true
23d68db55246b805f7400817c6a9382799745450
da642381e5c9e72e1e681edf6fcd8ccff2e2cb53
v1.0
instruct
Filter
Filter_13278_I
Can I make a function (in Python) that takes an integer `n` as an input and returns a list of all prime numbers up to `n`?
def is_prime(number): """ Helper function to check if a number is prime. """ if number <= 1: return False if number <= 3: return True if number % 2 == 0 or number % 3 == 0: return False i = 5 while i * i <= number: if number % i == 0 or number % (i + 2) ==...
from solution import primes_up_to def test_primes_up_to_10(): assert primes_up_to(10) == [2, 3, 5, 7] def test_primes_up_to_20(): assert primes_up_to(20) == [2, 3, 5, 7, 11, 13, 17, 19] def test_primes_up_to_1(): assert primes_up_to(1) == [] def test_primes_up_to_2(): assert primes_up_to(2) == [2] ...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(number):", "function_name": "is_prime", "parameter_list": "(number)" }, { "docstring": "Returns a list of all prime numbers up to n (inclusive).", "function_declaration": "def primes_up...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Helper function to determine if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if num % ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00013278", "row_id": 13278, "seed_ids": "['Llama-3.3-70B-Instruct_34452']" }
0.727791
Filter_13278
I
[ "is_prime", "primes_up_to" ]
2
[ [ "primes_up_to", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c8e80bc640383ef74c61705328498dd8dc3d00bc
114b4cfc992c2a6f43e80a0d415343433510f348
v1.0
instruct
Filter
Filter_13310_I
I have two binary trees, a and b, and I want to check if one is a subtree of the other. Here is my solution: ```python class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def are_identical(a, b): if a is None and b is None: return True if...
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None def are_identical(a, b): if not a and not b: return True if not a or not b: return False if a.val != b.val: return False return are_identical(a.left, b.left) and ar...
from solution import TreeNode, are_identical, is_subtree def test_are_identical(): tree_a = TreeNode(1) tree_a.left = TreeNode(2) tree_a.right = TreeNode(3) tree_b = TreeNode(1) tree_b.left = TreeNode(2) tree_b.right = TreeNode(3) assert are_identical(tree_a, tree_b) == True tree_c =...
[]
[ 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, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef are_identical(a, b):\n \"\"\"\n Checks if two binary trees a...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013310", "row_id": 13310, "seed_ids": "['Llama-3.3-70B-Instruct_34531']" }
0.501309
Filter_13310
I
[ "are_identical", "is_subtree" ]
2
[ [ "is_subtree", "are_identical" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
3e068bf32779ad2c9e9e694c0fb9aae2d7252901
81a596ee30055939cd8e27a6a19b2f72c78c144a
v1.0
instruct
Filter
Filter_13352_I
I am trying to create a program that takes in a list of words and then creates a new list with the first and last character of each word. For example, if the input list is ["apple", "banana", "cherry"], the output list should be [["a", "e"], ["b", "a"], ["c", "y"]]. Here is my code: ``` def get_first_last(word): ...
def get_first_last(word): """ Returns a list containing the first and last character of the given word. """ return [word[0], word[-1]] if word else [] def first_last_chars(word_list): """ Takes a list of words and returns a new list with the first and last character of each word. Param...
from solution import first_last_chars def test_first_last_chars_with_words(): assert first_last_chars(["apple", "banana", "cherry"]) == [['a', 'e'], ['b', 'a'], ['c', 'y']] def test_first_last_chars_with_empty_list(): assert first_last_chars([]) == [] def test_first_last_chars_with_single_letter_words(): ...
[ { "docstring": "Returns a list containing the first and last character of the given word.", "function_declaration": "def get_first_last(word):", "function_name": "get_first_last", "parameter_list": "(word)" }, { "docstring": "Takes a list of words and returns a new list with the first and la...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def get_first_last(word):\n \"\"\"\n Returns a list containing the first and last character of the given word.\n \"\"\"\n return [word[0], word[-1]]\n\ndef first_last_chars(word_li...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013352", "row_id": 13352, "seed_ids": "['Llama-3.3-70B-Instruct_34623']" }
0.629171
Filter_13352
I
[ "get_first_last", "first_last_chars" ]
2
[ [ "first_last_chars", "get_first_last" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a114ee67fac8d2ef9705daf01a1383c30363dfb9
e052a03acac767a6d3b1d8d5a4988104ee32aa4c
v1.0
instruct
Filter
Filter_13354_I
I have a version of a spell-checking program that checks the spelling of a sentence by comparing it to a dictionary. However, this version only handles single-character edits (insertions, deletions, or substitutions) and it has a limitation that it only checks the edits up to 3 words away from the initial misspelling. ...
def levenshtein_distance(word1, word2): """ Helper function to compute the Levenshtein distance between two words. """ len_word1 = len(word1) + 1 len_word2 = len(word2) + 1 # Create a matrix (len_word1 x len_word2) matrix = [[0] * len_word2 for _ in range(len_word1)] # Initialize the f...
from solution import levenshtein_distance, spell_checker def test_levenshtein_distance(): assert levenshtein_distance("kitten", "sitting") == 3 assert levenshtein_distance("flaw", "lawn") == 2 assert levenshtein_distance("gumbo", "gambol") == 2 assert levenshtein_distance("book", "back") == 2 asser...
[ { "docstring": "Helper function to compute the Levenshtein distance between two words.", "function_declaration": "def levenshtein_distance(word1, word2):", "function_name": "levenshtein_distance", "parameter_list": "(word1, word2)" }, { "docstring": "Enhanced spell-checker that handles multi...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import itertools\n\ndef generate_edits(word):\n \"\"\"\n Generate possible edits that are one edit away from the given word.\n \"\"\"\n letters = 'abcdefghijklmnopqrstuvwxyz'\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00013354", "row_id": 13354, "seed_ids": "['Llama-3.3-70B-Instruct_34627']" }
0.379893
Filter_13354
I
[ "levenshtein_distance", "spell_checker" ]
2
[ [ "spell_checker", "levenshtein_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f6b200befe7a54020886f6008b801684f22672bc
23401a106853fe72530a57f296b7b7db68928be1
v1.0
instruct
Filter
Filter_13356_I
Here is the problem: Given an array of integers, write a function that returns a new array with all elements in ascending order, and also returns the number of inversions in the array. An inversion is a pair of elements in the sorted array that were in a different order in the original array.
def merge_sort_and_count(arr): """ Function to use merge sort to sort an array and count inversions. """ if len(arr) <= 1: return arr, 0 mid = len(arr) // 2 left, left_inv = merge_sort_and_count(arr[:mid]) right, right_inv = merge_sort_and_count(arr[mid:]) merged, split_inv = m...
from solution import sort_and_count_inversions def test_sort_and_count_inversions_no_inversion(): assert sort_and_count_inversions([1, 2, 3, 4, 5]) == ([1, 2, 3, 4, 5], 0) def test_sort_and_count_inversions_one_inversion(): assert sort_and_count_inversions([2, 1, 3, 4, 5]) == ([1, 2, 3, 4, 5], 1) def test_so...
[ { "docstring": "Function to use merge sort to sort an array and count inversions.", "function_declaration": "def merge_sort_and_count(arr):", "function_name": "merge_sort_and_count", "parameter_list": "(arr)" }, { "docstring": "Merge two sorted arrays and count split inversions.", "funct...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_and_count(arr, temp_arr, left, mid, right):\n inv_count = 0\n i = left # Starting index for left subarray\n j = mid + 1 # Starting index for right subarray\n k = left ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013356", "row_id": 13356, "seed_ids": "['Llama-3.3-70B-Instruct_34631']" }
0.804652
Filter_13356
I
[ "merge_sort_and_count", "merge_and_count_split_inv", "sort_and_count_inversions" ]
3
[ [ "merge_sort_and_count", "merge_and_count_split_inv" ], [ "sort_and_count_inversions", "merge_sort_and_count" ] ]
2
[]
false
[]
false
pytest
true
[]
true
3f70262661f19891485777b831a5192bc3136b32
bb133ed12ae0b8c60504442810a84af445e74c22
v1.0
instruct
Filter
Filter_13373_I
Your task is to create a Tic Tac Toe game for console in Python programming language. Here's a brief description of how the game should work: - The game should be played on a 3x3 grid. - Two players play the game: X and O. - The players play one after the other. - The first player is X and the second player is O. - Th...
def print_board(board): print(f"{board[0]} | {board[1]} | {board[2]}") print("--+---+--") print(f"{board[3]} | {board[4]} | {board[5]}") print("--+---+--") print(f"{board[6]} | {board[7]} | {board[8]}") def check_winner(board): winning_combos = [(0, 1, 2), (3, 4, 5), (6, 7, 8), (0, 3, 6), (1, 4...
from solution import check_winner, play_game def test_check_winner_no_winner(): board = ["X", "O", "X", "X", "O", "X", "O", "X", "O"] result = check_winner(board) assert result == "Tie" def test_check_winner_x_wins(): board = ["X", "X", "X", "O", "O", " ", " ", " ", " "] result = check_winner(boar...
[ { "docstring": null, "function_declaration": "def print_board(board):", "function_name": "print_board", "parameter_list": "(board)" }, { "docstring": null, "function_declaration": "def check_winner(board):", "function_name": "check_winner", "parameter_list": "(board)" }, { ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def print_board(board):\n print(\"\\n\")\n print(f\"{board[0]} | {board[1]} | {board[2]}\")\n print(\"--+---+--\")\n print(f\"{board[3]} | {board[4]} | {board[5]}\")\n print(\"-...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00013373", "row_id": 13373, "seed_ids": "['Llama-3.3-70B-Instruct_34664']" }
0.505269
Filter_13373
I
[ "print_board", "check_winner", "play_game", "main" ]
4
[ [ "play_game", "check_winner" ], [ "play_game", "print_board" ] ]
2
[]
false
[]
false
pytest
true
[]
true
e0175e00020670116dbc9dffb355f90e2e730930
cd64281b0702dce65100104f09ca30306adf2dce
v1.0
instruct
Filter
Filter_13374_I
### Creating a Simple Game Create a simple game where the player has to guess a number between 1 and 100. #### The Game Rules * The player is given a limited number of guesses (6 attempts). * After each guess, the game tells the player if their guess is higher or lower than the number to be guessed. * If the player gu...
import random def get_user_guess(): while True: try: guess = int(input("Enter your guess (between 1 and 100): ")) if 1 <= guess <= 100: return guess else: print("Please enter a number between 1 and 100.") except ValueError: ...
import pytest from unittest import mock from solution import get_user_guess, check_guess, play_again def test_get_user_guess_valid_input(): with mock.patch('builtins.input', return_value='50'): assert get_user_guess() == 50 def test_get_user_guess_invalid_input(): with mock.patch('builtins.input', sid...
[ { "docstring": null, "function_declaration": "def get_user_guess():", "function_name": "get_user_guess", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def check_guess(secret_number, guess):", "function_name": "check_guess", "parameter_list": "(secret_num...
[ 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_guess():\n while True:\n try:\n guess = int(input(\"Enter your guess (between 1 and 100): \"))\n if 1 <= guess <= 100:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00013374", "row_id": 13374, "seed_ids": "['Llama-3.3-70B-Instruct_34666']" }
0.579193
Filter_13374
I
[ "get_user_guess", "check_guess", "play_again", "game" ]
4
[ [ "game", "check_guess" ], [ "game", "get_user_guess" ], [ "game", "play_again" ] ]
3
[]
false
[]
false
pytest
true
[]
true
0ffa23fd91624375cb40a5dd8a990259abc4a07a
cfeb3eddc6fbbff0f8227f3b0d1ed0729eef0fae
v1.0
instruct
Filter
Filter_13381_I
I have a neural network with layers of different sizes: input layer with n neurons, hidden layer with m neurons and output layer with k neurons. I want to implement backpropagation to train this network. Can you provide a step-by-step guide on how to do this? I will provide you the following information: - The learnin...
import numpy as np def sigmoid(x): return 1 / (1 + np.exp(-x)) def sigmoid_derivative(x): return x * (1 - x) def initialize_weights_biases(n, m, k): np.random.seed(42) # for reproducible results w1 = np.random.randn(n, m) * 0.01 b1 = np.zeros((1, m)) w2 = np.random.randn(m, k) * 0.01 b2 ...
import numpy as np from solution import initialize_weights_biases, forward_pass, backward_pass, update_weights_biases, train_network, compute_loss def test_initialize_weights_biases(): n, m, k = 2, 3, 1 w1, b1, w2, b2 = initialize_weights_biases(n, m, k) assert w1.shape == (n, m) assert b1.shape == (1,...
[ { "docstring": null, "function_declaration": "def sigmoid(x):", "function_name": "sigmoid", "parameter_list": "(x)" }, { "docstring": null, "function_declaration": "def sigmoid_derivative(x):", "function_name": "sigmoid_derivative", "parameter_list": "(x)" }, { "docstring...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\n\ndef sigmoid(x):\n return 1 / (1 + np.exp(-x))\n\ndef sigmoid_derivative(x):\n return x * (1 - x)\n\ndef initialize_weights_biases(n, m, k):\n np.random.seed(42) ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00013381", "row_id": 13381, "seed_ids": "['Llama-3.3-70B-Instruct_34688']" }
0.428299
Filter_13381
I
[ "sigmoid", "sigmoid_derivative", "initialize_weights_biases", "forward_pass", "compute_loss", "backward_pass", "update_weights_biases", "train_network" ]
8
[ [ "backward_pass", "sigmoid_derivative" ], [ "forward_pass", "sigmoid" ], [ "train_network", "backward_pass" ], [ "train_network", "compute_loss" ], [ "train_network", "forward_pass" ], [ "train_network", "initialize_weights_biases" ], [ "t...
7
[]
false
[]
false
pytest
true
[ "numpy" ]
false
c96642f66644439849f93bdcbe1541762ce56fce
8fd3da1a262e0d1f04413e13230b1aafc39259a4
v1.0
instruct
Filter
Filter_13385_I
### Function to Update Version and Build Number We want to update the version and build number of our application. Here is an example of how you could do this in bash: ```bash #!/bin/bash VERSION_FILE="version.sh" VERSION_PATTERN="VERSION=([0-9]+)\.([0-9]+)\.([0-9]+)" BUILD_PATTERN="BUILD=([0-9]+)" update_version...
import re def update_version(version): """ Update the patch version by incrementing it by 1. Args: version (str): The version string in the format "VERSION=x.y.z" Returns: str: The updated version string. Raises: ValueError: If the version string is not in the valid forma...
import pytest from solution import update_version, update_build def test_update_version(): assert update_version("VERSION=1.2.3") == "VERSION=1.2.4" assert update_version("VERSION=0.0.0") == "VERSION=0.0.1" assert update_version("VERSION=9.9.9") == "VERSION=9.9.10" with pytest.raises(ValueError, match...
[ { "docstring": "Update the patch version by incrementing it by 1.\n\nArgs:\nversion (str): The version string in the format \"VERSION=x.y.z\"\n\nReturns:\nstr: The updated version string.\n\nRaises:\nValueError: If the version string is not in the valid format.", "function_declaration": "def update_version(...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef update_version(version):\n \"\"\"\n Update the patch version by incrementing it by 1.\n \n Args:\n version (str): The version string in the format \"VERSION=x.y...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00013385", "row_id": 13385, "seed_ids": "['Llama-3.3-70B-Instruct_34695']" }
0.542265
Filter_13385
I
[ "update_version", "update_build", "update_version_file" ]
3
[ [ "update_version_file", "update_build" ], [ "update_version_file", "update_version" ] ]
2
[]
false
[]
false
pytest
true
[]
true
18548a7a80fb7024f54fa9920b2cab0d4041f285
5e1e0b060c4eb190efd4a44145a6d33f4a59f50a
v1.0
instruct
Filter
Filter_13388_I
Can you write a code snippet to convert an integer to hexadecimal and then use it to calculate the sum of two hexadecimal numbers?
def int_to_hex(num): """ Converts an integer to its hexadecimal representation. """ return hex(num)[2:] # Remove the '0x' prefix def sum_hex_numbers(num1, num2): """ Sums two integers, converts them to hexadecimal, and returns the sum. """ hex1 = int_to_hex(num1) hex2 = int_to_hex(...
from solution import int_to_hex, sum_hex_numbers def test_int_to_hex(): assert int_to_hex(10) == 'a' assert int_to_hex(255) == 'ff' assert int_to_hex(0) == '0' assert int_to_hex(16) == '10' def test_sum_hex_numbers(): assert sum_hex_numbers(10, 5) == 'f' # 10 in hex is 'a', 5 in hex is '5', sum...
[ { "docstring": "Converts an integer to its hexadecimal representation.", "function_declaration": "def int_to_hex(num):", "function_name": "int_to_hex", "parameter_list": "(num)" }, { "docstring": "Sums two integers, converts them to hexadecimal, and returns the sum.", "function_declarati...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def int_to_hex(n):\n \"\"\"\n Converts an integer to its hexadecimal representation.\n \"\"\"\n return hex(n)[2:]\n\ndef hex_sum(hex1, hex2):\n \"\"\"\n Calculates the sum of...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00013388", "row_id": 13388, "seed_ids": "['Llama-3.3-70B-Instruct_34708']" }
0.57461
Filter_13388
I
[ "int_to_hex", "sum_hex_numbers" ]
2
[ [ "sum_hex_numbers", "int_to_hex" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b448bac0ef45a40baf9fe5f3b2d0ebc0abd8cff1
ce89ec0a0879631f3ea09165d09439a8d612fa5a
v1.0
instruct
Filter
Filter_13439_I
### AWS Lambda Function for Alexa I am building an Alexa skill. I need some help with the AWS Lambda function that will process the Alexa requests and respond accordingly. Here is the function I have so far: ```python import boto3 import json # Intent Schemes INTENT.refs = "refs" INTENT.tips = "tips" INTENT.get_quot...
import boto3 import json import logging # Configure logging logging.basicConfig(level=logging.INFO) # Intent Schemes INTENTS = { "refs": "handle_refs", "tips": "handle_tips", "get_quote": "handle_get_quote" } def lambda_handler(event, context): logging.info(f"Event: {json.dumps(event)}") int...
import pytest from solution import lambda_handler def test_handle_refs(): event = { 'request': { 'intent': { 'name': 'refs' } } } response = lambda_handler(event, {}) assert response['response']['outputSpeech']['text'] == 'You have reached the ref...
[ { "docstring": null, "function_declaration": "def lambda_handler(event, context):", "function_name": "lambda_handler", "parameter_list": "(event, context)" }, { "docstring": null, "function_declaration": "def get_intent_name(event):", "function_name": "get_intent_name", "paramete...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import boto3\nimport json\n\n# Intent Schemas\nINTENT_REFS = \"refs\"\nINTENT_TIPS = \"tips\"\nINTENT_GET_QUOTE = \"get_quote\"\n\ndef lambda_handler(event, context):\n \"\"\"\n Main han...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013439", "row_id": 13439, "seed_ids": "['Llama-3.3-70B-Instruct_34835']" }
0.467683
Filter_13439
I
[ "lambda_handler", "get_intent_name", "handle_refs", "handle_tips", "handle_get_quote", "handle_default" ]
6
[ [ "lambda_handler", "get_intent_name" ], [ "lambda_handler", "handle_default" ] ]
2
[]
false
[]
false
pytest
true
[ "boto3" ]
false
72c663ffc3920bdb15d97d11deed95b9f6d5b6cd
ce302a5b73bf1a28e17adfe28be867b4e43ca421
v1.0
instruct
Filter
Filter_13495_I
I have a list of strings where each string is a math expression. I want to evaluate these expressions and get their results. ```python import re expressions = [ "2 + 3", "4 * 5", "7 - 2", "10 / 2", "2 ** 3", "2 + 3 * 5", "10 / (2 + 3)", "10 + (2 * 3)" ] def evaluate_expressions(expre...
import operator import re # Define operator precedence and mapping operators = { '+': (1, operator.add), '-': (1, operator.sub), '*': (2, operator.mul), '/': (2, operator.truediv), '**': (3, operator.pow), } def parse_expression(expression): tokens = re.findall(r'\d+|\*\*|[+*/()-]', expression...
from solution import evaluate_expressions def test_evaluate_simple_addition(): assert evaluate_expressions(["2 + 3"]) == [5] def test_evaluate_simple_multiplication(): assert evaluate_expressions(["4 * 5"]) == [20] def test_evaluate_simple_subtraction(): assert evaluate_expressions(["7 - 2"]) == [5] def...
[ { "docstring": null, "function_declaration": "def parse_expression(expression):", "function_name": "parse_expression", "parameter_list": "(expression)" }, { "docstring": null, "function_declaration": "def infix_to_postfix(tokens):", "function_name": "infix_to_postfix", "parameter...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import operator\nimport re\n\n# Define operator precedence and operations\nOPERATORS = {\n '+': (1, operator.add),\n '-': (1, operator.sub),\n '*': (2, operator.mul),\n '/': (2, op...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00013495", "row_id": 13495, "seed_ids": "['Llama-3.3-70B-Instruct_34982']" }
0.52048
Filter_13495
I
[ "parse_expression", "infix_to_postfix", "evaluate_postfix", "evaluate_expressions" ]
4
[ [ "evaluate_expressions", "evaluate_postfix" ], [ "evaluate_expressions", "infix_to_postfix" ], [ "evaluate_expressions", "parse_expression" ] ]
3
[]
false
[]
false
pytest
true
[]
true
326431e1728ccdf294e0ff63da6ef0bfec535d91
2ba7484f82c6f7af5b33406d5f260c79a44fdd09
v1.0
instruct
Filter
Filter_13499_I
Create a 2D list of size 5x5 and fill it with all the prime numbers between 1 and 25. Use the helper function is_prime() to check if a number is prime. Implement this in Python.
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def prime_2d_list(): """ Create a 2D list of size 5x5 and fill it with all the ...
from solution import is_prime, prime_2d_list 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(25) == False def test_prime_2d_list_structure(): matrix = prime_2d_list() assert len(matrix) == 5 ...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Create a 2D list of size 5x5 and fill it with all the prime numbers\nbetween 1 and 25.", "function_decl...
[ 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": "00013499", "row_id": 13499, "seed_ids": "['Llama-3.3-70B-Instruct_34993']" }
0.636182
Filter_13499
I
[ "is_prime", "prime_2d_list" ]
2
[ [ "prime_2d_list", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f125aa3bdf3be7aee92a5ca17f84857620e71936
a56d11ae1ec628e6e3b8bed4384d85e4eaf38396
v1.0
instruct
Filter
Filter_13512_I
### Fastest Turing Machine for 3-coloring The 3-coloring problem is a well-known problem in computer science where you are given a graph and asked to determine if the nodes can be colored with 3 colors such that no two adjacent nodes have the same color. We can use a Turing machine to solve this problem. A Turing mach...
def is_valid_coloring(node, color, graph, colors): """ Helper function to check if the current coloring is valid. """ for neighbor in graph[node]: if colors[neighbor] == color: return False return True def solve_3_coloring(graph, colors, node, num_nodes): """ Function to...
from solution import three_coloring def test_three_coloring_possible(): input_str = "0:1,2\n1:0,3\n2:0\n3:1" assert three_coloring(input_str) == "YES" def test_three_coloring_impossible(): input_str = "0:1,2,3\n1:0,2,3\n2:0,1,3\n3:0,1,2" assert three_coloring(input_str) == "NO" def test_single_node()...
[ { "docstring": "Helper function to check if the current coloring is valid.", "function_declaration": "def is_valid_coloring(node, color, graph, colors):", "function_name": "is_valid_coloring", "parameter_list": "(node, color, graph, colors)" }, { "docstring": "Function to perform the 3-color...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid_coloring(node, color, graph, colors):\n \"\"\"\n Helper function to check if the current coloring is valid.\n \"\"\"\n for neighbor in graph[node]:\n if colors[...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00013512", "row_id": 13512, "seed_ids": "['Llama-3.3-70B-Instruct_35024']" }
0.489086
Filter_13512
I
[ "is_valid_coloring", "solve_3_coloring", "parse_input", "three_coloring" ]
4
[ [ "solve_3_coloring", "is_valid_coloring" ], [ "three_coloring", "parse_input" ], [ "three_coloring", "solve_3_coloring" ] ]
3
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
48681e1e98e8294ddb1cdce4fcb328121bdf8a14
3b59adc3e3effd57d7f00e21a713efa3b33f1fce
v1.0
instruct
Filter
Filter_13535_I
### Overview When a user interacts with an application, they create a digital footprint that can be collected and analyzed. This footprint can be used to generate a unique identifier, which can then be used to track the user across multiple platforms and devices. **Task:** Design a system that can generate and manage ...
import secrets import threading from flask import Flask, request, jsonify app = Flask(__name__) # Lock object to ensure thread safety lock = threading.Lock() # Initialize the Identifier Generator def generate_identifier(): with lock: # Use a cryptographically secure pseudorandom number generator (CSPRNG)...
import pytest from solution import generate_identifier, app def test_generate_identifier(): identifier = generate_identifier() assert isinstance(identifier, str) assert len(identifier) > 0 def test_unique_identifiers(): identifiers = {generate_identifier() for _ in range(1000)} assert len(iden...
[ { "docstring": null, "function_declaration": "def generate_identifier():", "function_name": "generate_identifier", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def generate():", "function_name": "generate", "parameter_list": "()" }, { "docstring...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import secrets\nimport threading\nfrom flask import Flask, request, jsonify\n\napp = Flask(__name__)\n\n# Lock object to ensure thread safety\nlock = threading.Lock()\n\n# Initialize the Ident...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00013535", "row_id": 13535, "seed_ids": "['Llama-3.3-70B-Instruct_35078']" }
0.340529
Filter_13535
I
[ "generate_identifier", "generate", "retrieve" ]
3
[ [ "generate", "generate_identifier" ] ]
1
[]
false
[]
false
pytest
true
[ "flask" ]
false
7a8b1eb276cc5b104289546416776c72b435e0a2
6c1be4d18491cbbdef7327b6ad5c7eb989936f5a
v1.0
instruct
Filter
Filter_13573_I
### Task Create a Python program that generates and prints the first 10 rows of Pascal's triangle.
def generate_pascals_triangle(num_rows): """ Generate Pascal's Triangle up to num_rows. """ if num_rows <= 0: return [] triangle = [[1]] for i in range(1, num_rows): row = [1] for j in range(1, i): row.append(triangle[i-1][j-1] + triangle[i-1][j]) row....
from solution import generate_pascals_triangle, print_pascals_triangle def test_generate_pascals_triangle(): assert generate_pascals_triangle(1) == [[1]] assert generate_pascals_triangle(2) == [[1], [1, 1]] assert generate_pascals_triangle(3) == [[1], [1, 1], [1, 2, 1]] assert generate_pascals_triangle...
[ { "docstring": "Generate Pascal's Triangle up to num_rows.", "function_declaration": "def generate_pascals_triangle(num_rows):", "function_name": "generate_pascals_triangle", "parameter_list": "(num_rows)" }, { "docstring": "Print Pascal's Triangle up to num_rows.", "function_declaration...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_pascals_triangle(num_rows):\n \"\"\"\n Generates the first num_rows of Pascal's triangle.\n \n :param num_rows: The number of rows to generate\n :return: A list of ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00013573", "row_id": 13573, "seed_ids": "['Llama-3.3-70B-Instruct_35175']" }
0.493761
Filter_13573
I
[ "generate_pascals_triangle", "print_pascals_triangle" ]
2
[ [ "print_pascals_triangle", "generate_pascals_triangle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
55589d1a105ad8e0a2b01790f426a39b51838945
748d07db78e65de3a90fbe82a15a3262bd5684b1
v1.0
instruct
Filter
Filter_13591_I
Your task is to write a simple Python code snippet that prints out all prime numbers within a given range, including the endpoints, using a function called `is_prime` to check for primality. The function `print_primes` should take two arguments, `start` and `end`, and print out all prime numbers within the given range....
from math import sqrt def is_prime(num): """ Checks if a number is prime. """ if num < 2: return False for i in range(2, int(sqrt(num)) + 1): if num % i == 0: return False return True def print_primes(start, end): """ Prints all prime numbers within the rang...
from io import StringIO import sys 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(1) == False assert is_prime(0) == Fa...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Prints all prime numbers within the range [start, end] inclusive.", "function_declaration": "def print_primes(start, end)...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from math import sqrt\n\ndef is_prime(num):\n \"\"\"\n Returns True if num is a prime number, otherwise False.\n \"\"\"\n if num < 2:\n return False\n for i in range(2, i...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013591", "row_id": 13591, "seed_ids": "['Llama-3.3-70B-Instruct_35216']" }
0.706036
Filter_13591
I
[ "is_prime", "print_primes" ]
2
[ [ "print_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
159e6509cdfaf964afce6a5c2ebe024d630fe418
5d0fd0ea25036febadb1a447e580fa2ad7fd94e8
v1.0
instruct
Filter
Filter_13597_I
### Card Game BlackJack #### Game Description The game of BlackJack is played with a deck of cards, without jokers. The cards from 2 to 10 are worth their face value. Jacks, queens and kings are worth 10 points each. An ace can be worth either 1 or 11 points, whichever is more beneficial to the player. The objective of...
import random # Function to deal a card def deal_card(): """Returns a random card from 1 to 10""" return random.randint(1, 10) # Function to calculate the hand value def calculate_hand_value(hand): """Calculates the total value of a hand""" # Initialize total value and aces count total_value = 0 ...
from solution import deal_card, calculate_hand_value, determine_result, dealer_play def test_deal_card(): card = deal_card() assert 1 <= card <= 10 def test_calculate_hand_value(): assert calculate_hand_value([1, 10]) == 21 assert calculate_hand_value([1, 1, 8]) == 20 assert calculate_hand_value([...
[ { "docstring": "Returns a random card from 1 to 10", "function_declaration": "def deal_card():", "function_name": "deal_card", "parameter_list": "()" }, { "docstring": "Calculates the total value of a hand", "function_declaration": "def calculate_hand_value(hand):", "function_name": ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\n# Function to deal a card\ndef deal_card():\n \"\"\"Returns a random card from 1 to 10\"\"\"\n return random.randint(1, 10)\n\n# Function to calculate the hand value\nde...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013597", "row_id": 13597, "seed_ids": "['Llama-3.3-70B-Instruct_35227']" }
0.611114
Filter_13597
I
[ "deal_card", "calculate_hand_value", "determine_result", "dealer_play", "play_game" ]
5
[ [ "dealer_play", "calculate_hand_value" ], [ "dealer_play", "deal_card" ], [ "determine_result", "calculate_hand_value" ], [ "play_game", "calculate_hand_value" ], [ "play_game", "deal_card" ], [ "play_game", "dealer_play" ], [ "play_game",...
7
[]
false
[]
false
pytest
true
[]
true
018fdf70462d2798404389f95990ba1c12d37562
f4244b5297bc81cd0c3b8e2b23bdbabbd8d492a8
v1.0
instruct
Filter
Filter_13609_I
Here is the code to create a silly chatbot that will answer random questions. Here is the code: ``` import random def get_response(user_input): responses = { 'hello': 'Hey, how are you?', 'hi': 'Hello! How can I help you today?', 'how are you': 'I\'m doing great, thanks for asking! How abo...
import random def get_response(user_input): responses = { 'hello': ['Hey, how are you?', 'Hello there!'], 'hi': ['Hello! How can I help you today?', 'Hi! What do you want to know?'], 'how are you': ['I\'m doing great, thanks for asking! How about you?', 'I\'m just a bunch of code, but I\'m ...
from solution import get_response def test_get_response_known_inputs(): assert get_response('hello') in ['Hey, how are you?', 'Hello there!'] assert get_response('hi') in ['Hello! How can I help you today?', 'Hi! What do you want to know?'] assert get_response('how are you') in ['I\'m doing great, thanks f...
[ { "docstring": null, "function_declaration": "def get_response(user_input):", "function_name": "get_response", "parameter_list": "(user_input)" }, { "docstring": null, "function_declaration": "def chat():", "function_name": "chat", "parameter_list": "()" } ]
[ 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_response(user_input):\n responses = {\n 'hello': ['Hey, how are you?', 'Hello there!'],\n 'hi': ['Hello! How can I help you today?', 'Hi! What do you ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00013609", "row_id": 13609, "seed_ids": "['Llama-3.3-70B-Instruct_35254']" }
0.534481
Filter_13609
I
[ "get_response", "chat" ]
2
[ [ "chat", "get_response" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b8688259bfea1b826d04dc51e2e109258a614745
c99d64ca713483922b3695156dfe55864eb2c5a0
v1.0
instruct
Filter
Filter_13638_I
I need a program to solve a nonlinear least squares problem. But before I start coding, I need to be sure that my data and objective function are correct. I'd like to visualize the curve I get when minimizing the sum of the squared errors between my data and the function. I'd like to plot this curve for a given set o...
import numpy as np import matplotlib.pyplot as plt def poly_func(x, coeffs): """ Evaluate a polynomial function with given coefficients. Parameters: x : np.array Input values. coeffs : list List of coefficients [a, b, c, ...] for the polynomial. Returns: np.array O...
from solution import poly_func, plot_polynomial_and_data import numpy as np import matplotlib.pyplot as plt def test_poly_func(): x = np.array([0, 1, 2, 3]) coeffs = [1, 2, 3] # Represents y = 3x^2 + 2x + 1 y_expected = np.array([1, 6, 17, 34]) y_computed = poly_func(x, coeffs) assert np.allclose(...
[ { "docstring": "Evaluate a polynomial function with given coefficients.\n\nParameters:\nx : np.array\n Input values.\ncoeffs : list\n List of coefficients [a, b, c, ...] for the polynomial.\n\nReturns:\nnp.array\n Output values after evaluating the polynomial.", "function_declaration": "def poly_fu...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nimport matplotlib.pyplot as plt\n\n# Define the function which can handle any number of parameters\ndef func(x, *params):\n y = np.zeros_like(x)\n for i, param in enu...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00013638", "row_id": 13638, "seed_ids": "['Llama-3.3-70B-Instruct_35333']" }
0.693979
Filter_13638
I
[ "poly_func", "plot_polynomial_and_data" ]
2
[ [ "plot_polynomial_and_data", "poly_func" ] ]
1
[]
false
[]
false
pytest
true
[ "matplotlib", "numpy" ]
false
9045ce4f289ac1fb2e03e4e72db88c6a675301fa
5320f90d562eb8a1e8b0fe028ae405feee34a3ec
v1.0
instruct
Filter
Filter_13661_I
High card is a simple card game where the player challenges the computer to see who has the highest card. Create and explain a high card game using python. ### Example of game: ``` 1. Game starts 2. Player and computer are each delt a card 3. The player is shown their card 4. The player is asked for their bet 5....
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...
from solution import Card, Deck, get_card_value def test_card_creation(): card = Card("Hearts", "Ace") assert card.suit == "Hearts" assert card.value == "Ace" assert str(card) == "Ace of Hearts" def test_deck_creation(): deck = Deck() assert len(deck.cards) == 52 suits = set(card.suit for ...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\nclass Card:\n def __init__(self, suit, value):\n self.suit = suit\n self.value = value\n\n def __repr__(self):\n return f\"{self.value} of {self.sui...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00013661", "row_id": 13661, "seed_ids": "['Llama-3.3-70B-Instruct_35383']" }
0.573871
Filter_13661
I
[ "get_card_value", "play_game" ]
2
[ [ "play_game", "get_card_value" ] ]
1
[]
false
[ "Card", "Deck" ]
true
pytest
true
[]
true
292bce0cd4e9ec23fc31bcf3a0096607906f5236
e7f7ded43e43ee8b9617e2c9d66955bc38c7c1b5
v1.0
instruct
Filter
Filter_13662_I
I have a set of points on a 2D plane and I want to implement a function to find the closest pair of points. The algorithm should be able to handle N points in O(N log N) time complexity. Here is a my brute force approach: ``` def closest_pair(points): min_distance = float('inf') closest_points = None for...
import math def euclidean_distance(p1, p2): return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) def closest_pair_util(points_sorted_x, points_sorted_y): n = len(points_sorted_x) # Base case: if there are 2 or 3 points, use the brute force method if n <= 3: min_distance = float('...
def test_euclidean_distance(): assert euclidean_distance((0, 0), (3, 4)) == 5 assert euclidean_distance((1, 1), (4, 5)) == 5 assert euclidean_distance((1, 1), (1, 1)) == 0 def test_closest_pair_small_sample(): points = [(0, 0), (3, 4), (3, 3)] (p1, p2), distance = closest_pair(points) assert p1...
[ { "docstring": null, "function_declaration": "def euclidean_distance(p1, p2):", "function_name": "euclidean_distance", "parameter_list": "(p1, p2)" }, { "docstring": null, "function_declaration": "def closest_pair_util(points_sorted_x, points_sorted_y):", "function_name": "closest_pa...
[ 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 euclidean_distance(p1, p2):\n return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2)\n\ndef closest_pair_util(points_sorted_x, points_sorted_y):\n n = len(point...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00013662", "row_id": 13662, "seed_ids": "['Llama-3.3-70B-Instruct_35385']" }
0.547464
Filter_13662
I
[ "euclidean_distance", "closest_pair_util", "closest_pair" ]
3
[ [ "closest_pair", "closest_pair_util" ], [ "closest_pair_util", "euclidean_distance" ] ]
2
[]
false
[]
false
pytest
false
[]
true
720a5c413c9161a2c9e64ad28e123c4b016ef646
d9060576fb5cc9f299731fb79086ec102827f34e
v1.0
instruct
Filter
Filter_13681_I
I have two files. File A has test questions and file B has the corresponding answers. A and B are in same directory. I want to create a quiz from this. How can I do this using Python?
import os def load_file(file_path): """ Loads the content of the given file. Args: file_path (str): The path to the file. Returns: list: A list of strings representing the lines in the file. """ if not os.path.exists(file_path): raise FileNotFoundError(f"The file {file_pat...
from solution import load_file, generate_quiz import os # Helper function to create temporary test files def create_temp_file(file_name, content): with open(file_name, 'w') as file: file.write("\n".join(content)) def test_load_file(): file_name = 'test_questions.txt' content = ['What is the capita...
[ { "docstring": "Loads the content of the given file.\n\nArgs:\nfile_path (str): The path to the file.\n\nReturns:\nlist: A list of strings representing the lines in the file.", "function_declaration": "def load_file(file_path):", "function_name": "load_file", "parameter_list": "(file_path)" }, {...
[ 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 read_file(file_path):\n \"\"\"\n Reads the content of a given file and returns it as a list of lines.\n \"\"\"\n with open(file_path, 'r') as file:\n lines ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013681", "row_id": 13681, "seed_ids": "['Llama-3.3-70B-Instruct_35428']" }
0.414012
Filter_13681
I
[ "load_file", "generate_quiz" ]
2
[ [ "generate_quiz", "load_file" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3e84fe4184161d5943de2a6a1f2573496e3ca1c9
beaf478574cc894198b9f31c9adc5e0595235967
v1.0
instruct
Filter
Filter_13689_I
I have a list of methods that I want to fill in. I want to apply the `auth` decorator to each one of these methods. Is there a way to define the decorator in a way that it can be used later to decorate any method without having to use the `@auth` syntax?
def auth(func): """ A decorator that checks for authentication before calling the actual function. """ def wrapper(*args, **kwargs): # Authentication logic goes here # For illustration, we assume authentication always passes print("Authentication successful") return func(...
from solution import auth, add_auth_decorator_to_methods def dummy_method(): return "Method executed" @auth def decorated_method(): return "Decorated Method executed" def test_direct_decorator(): assert decorated_method() == "Decorated Method executed" def test_auth_with_add_auth_decorator(): method...
[ { "docstring": "A decorator that checks for authentication before calling the actual function.", "function_declaration": "def auth(func):", "function_name": "auth", "parameter_list": "(func)" }, { "docstring": "Adds the auth decorator to each method in the list.", "function_declaration":...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def auth(func):\n \"\"\"\n A decorator that prints \"Authenticated\" before calling the actual function.\n \"\"\"\n def wrapper(*args, **kwargs):\n print(\"Authenticated\")\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013689", "row_id": 13689, "seed_ids": "['Llama-3.3-70B-Instruct_35447']" }
0.268864
Filter_13689
I
[ "auth", "add_auth_decorator_to_methods" ]
2
[ [ "add_auth_decorator_to_methods", "auth" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7a814d5d5167015608dcf39e8345070cdad82819
479bef6175aaacba2def219b6c879e0984496d1e
v1.0
instruct
Filter
Filter_13690_I
I have a partially filled-in Sudoku grid, and I would like to fill in the rest of the cells. However, I want to write a function that will do this for me. I only have access to standard libraries in Python, so I'd like the functionality of the following function to be accomplished using only built-in data types and fun...
def is_valid(board, row, col, num): """ Check if it's valid to place num on board[row][col]. """ # Check the row for x in range(9): if board[row][x] == num: return False # Check the column for x in range(9): if board[x][col] == num: return False ...
from solution import is_valid, solve_sudoku def test_is_valid(): board = [ [5, 3, 0, 0, 7, 0, 0, 0, 0], [6, 0, 0, 1, 9, 5, 0, 0, 0], [0, 9, 8, 0, 0, 0, 0, 6, 0], [8, 0, 0, 0, 6, 0, 0, 0, 3], [4, 0, 0, 8, 0, 3, 0, 0, 1], [7, 0, 0, 0, 2, 0, 0, 0, 6], [0, 6, 0, ...
[ { "docstring": "Check if it's valid to place num on board[row][col].", "function_declaration": "def is_valid(board, row, col, num):", "function_name": "is_valid", "parameter_list": "(board, row, col, num)" }, { "docstring": "Solves the Sudoku puzzle by filling the board.\nReturns True if a s...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def solve_sudoku(board):\n \"\"\"\n Solves a Sudoku puzzle by filling the empty cells.\n The input board is a list of lists representing a 9x9 Sudoku grid.\n Empty cells are repres...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013690", "row_id": 13690, "seed_ids": "['Llama-3.3-70B-Instruct_35449']" }
0.457992
Filter_13690
I
[ "is_valid", "solve_sudoku" ]
2
[ [ "solve_sudoku", "is_valid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3c36c24a131669d678840b18bee8816c535eca12
2032aa598c3990f22506194c6619589ca1682c8b
v1.0
instruct
Filter
Filter_13692_I
Can you develop a program to simulate a simple calculator using only addition operation and provide an explanation of how it works?
def add(a, b): """ Returns the sum of a and b. """ return a + b def subtract(a, b): """ Returns the difference of a and b using addition. """ return add(a, -b) def multiply(a, b): """ Returns the product of a and b using addition. """ result = 0 for _ in range(abs(b...
from solution import add, subtract, multiply, divide def test_add(): assert add(3, 2) == 5 assert add(-1, -1) == -2 assert add(-1, 1) == 0 assert add(0, 0) == 0 def test_subtract(): assert subtract(3, 2) == 1 assert subtract(5, -2) == 7 assert subtract(-1, -1) == 0 assert subtract(0, 0...
[ { "docstring": "Returns the sum of a and b.", "function_declaration": "def add(a, b):", "function_name": "add", "parameter_list": "(a, b)" }, { "docstring": "Returns the difference of a and b using addition.", "function_declaration": "def subtract(a, b):", "function_name": "subtract"...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def add(a, b):\n \"\"\"\n Returns the sum of a and b.\n \"\"\"\n return a + b\n\ndef subtract(a, b):\n \"\"\"\n Returns the result of subtracting b from a using addition.\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00013692", "row_id": 13692, "seed_ids": "['Llama-3.3-70B-Instruct_35461']" }
0.508919
Filter_13692
I
[ "add", "subtract", "multiply", "divide" ]
4
[ [ "divide", "add" ], [ "divide", "subtract" ], [ "multiply", "add" ], [ "subtract", "add" ] ]
4
[]
false
[]
false
pytest
true
[]
true
04c5db6bbf4bcc64f348d7ddf86052955d993b8b
8b6a00ceb44fbdafbfd2230edae799c9d07241b8
v1.0
instruct
Filter
Filter_13704_I
Here is a model that takes in a string input and returns an integer output. There are two functions: `preprocess_text` and `predict`. The `preprocess_text` function cleans and tokenizes the text, and the `predict` function uses the preprocessed text to make an integer prediction.
def preprocess_text(text): """ Preprocess the text by converting it to lowercase, removing punctuation, and splitting it into words. """ import re text = text.lower() text = re.sub(r'[^\w\s]', '', text) words = text.split() return words def predict(text): """ Predict the out...
from solution import preprocess_text, predict def test_preprocess_text(): assert preprocess_text("Hello, World!") == ["hello", "world"] assert preprocess_text("This is a test.") == ["this", "is", "a", "test"] assert preprocess_text("Python 3.8, it's great!") == ["python", "38", "its", "great"] assert p...
[ { "docstring": "Preprocess the text by converting it to lowercase, removing punctuation,\nand splitting it into words.", "function_declaration": "def preprocess_text(text):", "function_name": "preprocess_text", "parameter_list": "(text)" }, { "docstring": "Predict the output integer based on...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def preprocess_text(text):\n \"\"\"\n Cleans and tokenizes the input text.\n \"\"\"\n # Convert text to lowercase\n text = text.lower()\n \n # Remove punctuation\n impo...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013704", "row_id": 13704, "seed_ids": "['Llama-3.3-70B-Instruct_35493']" }
0.45869
Filter_13704
I
[ "preprocess_text", "predict" ]
2
[ [ "predict", "preprocess_text" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fc6c057d637037f6ced152980b744d0980b5afb2
f8cc8877d5b75907c649bff127667df5073b0ae9
v1.0
instruct
Filter
Filter_13758_I
Can you create and explain a program written in python to simulate the effect of gravitational forces on the motion of two objects?
import math G = 6.67430e-11 # Gravitational constant def calculate_gravitational_force(m1, m2, r): """ Calculate the gravitational force between two objects. Parameters: - m1: Mass of the first object (kg) - m2: Mass of the second object (kg) - r: Distance between the two objects (m) ...
import pytest from solution import calculate_gravitational_force, update_velocity, update_position, simulate_motion # Test Gravitational Force Calculation def test_calculate_gravitational_force(): m1 = 5.97e24 # Earth mass (kg) m2 = 7.35e22 # Moon mass (kg) r = 3.84e8 # Distance between Earth and Moon...
[ { "docstring": "Calculate the gravitational force between two objects.\n\nParameters:\n- m1: Mass of the first object (kg)\n- m2: Mass of the second object (kg)\n- r: Distance between the two objects (m)\n\nReturns:\n- Force between the two objects (N)", "function_declaration": "def calculate_gravitational_...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef calculate_gravitational_force(m1, m2, r):\n \"\"\"\n Calculates the gravitational force between two masses m1 and m2 separated by distance r.\n \"\"\"\n G = 6.67...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00013758", "row_id": 13758, "seed_ids": "['Llama-3.3-70B-Instruct_35637']" }
0.432977
Filter_13758
I
[ "calculate_gravitational_force", "update_velocity", "update_position", "simulate_motion" ]
4
[ [ "simulate_motion", "calculate_gravitational_force" ], [ "simulate_motion", "update_position" ], [ "simulate_motion", "update_velocity" ] ]
3
[]
false
[]
false
pytest
true
[]
true
614a5771d90b91ff3c645e091e2739baf7b793c3
7e201c44fb8b4e9dcb128d4ffaf1504b6bd30f2e
v1.0
instruct
Filter
Filter_13761_I
I have a 20x20 grid, in which I randomly place 2 or more silver balls and a headless chicken. - The headless chicken moves randomly in one of the 4 main directions in the grid (up, down, left, right) - When the headless chicken hits a silver ball, it disappears and the headless chicken gets "stuck" and cannot move an...
import random def simulate_chicken(grid_size=20, ball_count=2): # Initialize the grid grid = [[0 for _ in range(grid_size)] for _ in range(grid_size)] # Place silver balls randomly balls = set() while len(balls) < ball_count: x, y = random.randint(0, grid_size - 1), random.randint(0, grid_...
from solution import simulate_chicken, calculate_probability def test_simulate_chicken(): result = simulate_chicken(grid_size=20, ball_count=2) assert isinstance(result, bool), "The simulate_chicken function should return a boolean value." def test_calculate_probability_values(): probability = calculate_p...
[ { "docstring": null, "function_declaration": "def simulate_chicken(grid_size=20, ball_count=2):", "function_name": "simulate_chicken", "parameter_list": "(grid_size=20, ball_count=2)" }, { "docstring": null, "function_declaration": "def calculate_probability(simulations=10000, grid_size=...
[ 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 simulate_game(grid_size=20, num_silver_balls=2):\n # Initialize the grid\n grid = [[0 for _ in range(grid_size)] for _ in range(grid_size)]\n \n # Place the si...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013761", "row_id": 13761, "seed_ids": "['Llama-3.3-70B-Instruct_35645']" }
0.448129
Filter_13761
I
[ "simulate_chicken", "calculate_probability" ]
2
[ [ "calculate_probability", "simulate_chicken" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1ee22b485b8917846c220beb6c9b2a5bf2f51f49
a32d965878bc974c29a2b905eeae7ab290f2f627
v1.0
instruct
Filter
Filter_13762_I
I've been tasked by my school with recreating the Caesar cipher as a programming project. I've never done any programming before, so I want to make sure I get this right. So, I've been told that the Caesar cipher is a simple encryption technique where each letter in the plaintext is 'shifted' a certain number of plac...
def caesar_cipher(text, shift): """ Encrypts the text using Caesar cipher with the given shift. """ result = "" for char in text: if char.isalpha(): ascii_offset = 65 if char.isupper() else 97 result += chr((ord(char) - ascii_offset + shift) % 26 + ascii_offset) ...
from solution import caesar_cipher, caesar_decipher def test_caesar_cipher_with_positive_shift(): assert caesar_cipher("ABCD", 1) == "BCDE" assert caesar_cipher("abcd", 1) == "bcde" assert caesar_cipher("AbCd", 1) == "BcDe" def test_caesar_cipher_with_negative_shift(): assert caesar_cipher("BCDE", -1)...
[ { "docstring": "Encrypts the text using Caesar cipher with the given shift.", "function_declaration": "def caesar_cipher(text, shift):", "function_name": "caesar_cipher", "parameter_list": "(text, shift)" }, { "docstring": "Decrypts the Caesar cipher text with the given shift.", "functio...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def caesar_cipher(text, shift):\n \"\"\"\n Encrypts the given text using Caesar cipher with the specified shift.\n \"\"\"\n result = \"\"\n\n for char in text:\n if char....
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013762", "row_id": 13762, "seed_ids": "['Llama-3.3-70B-Instruct_35646']" }
0.631127
Filter_13762
I
[ "caesar_cipher", "caesar_decipher" ]
2
[ [ "caesar_decipher", "caesar_cipher" ] ]
1
[]
false
[]
false
pytest
true
[]
true
27b0da2b54f12d2f9698dabc145656cb1aa36641
f80b57b04ea38ff680fce842ea75c055aa28e2c6
v1.0
instruct
Filter
Filter_13792_I
I want to implement my own Caesar Cipher program in Python. I can do the encryption, but I'm having trouble figuring out how to do the decryption. Here is my current code: ```python def caesar_cipher(text, shift): result = "" for char in text: # Check if character is a letter if char.isalpha...
def caesar_cipher(text, shift): """ Encrypts the given text using a Caesar Cipher with the specified shift. """ result = "" for char in text: if char.isalpha(): ascii_offset = 65 if char.isupper() else 97 result += chr((ord(char) - ascii_offset + shift) % 26 + ascii_...
from solution import caesar_cipher, caesar_decipher def test_encryption(): assert caesar_cipher("HELLO", 3) == "KHOOR" assert caesar_cipher("hello", 3) == "khoor" assert caesar_cipher("Hello, World!", 3) == "Khoor, Zruog!" def test_decryption(): assert caesar_decipher("KHOOR", 3) == "HELLO" assert...
[ { "docstring": "Encrypts the given text using a Caesar Cipher with the specified shift.", "function_declaration": "def caesar_cipher(text, shift):", "function_name": "caesar_cipher", "parameter_list": "(text, shift)" }, { "docstring": "Decrypts a text that was encrypted using a Caesar Cipher...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def caesar_cipher_decryption(text, shift):\n \"\"\"\n Decrypts the text which was encrypted using a Caesar cipher with the given shift.\n \"\"\"\n return caesar_cipher(text, -shift...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013792", "row_id": 13792, "seed_ids": "['Llama-3.3-70B-Instruct_35710']" }
0.661517
Filter_13792
I
[ "caesar_cipher", "caesar_decipher" ]
2
[ [ "caesar_decipher", "caesar_cipher" ] ]
1
[]
false
[]
false
pytest
true
[]
true
35b35a7e367968490d85298f2887ae80d2dd6182
ace1cdcd5a79a9f402242e19270d38c5e1874094
v1.0
instruct
Filter
Filter_13794_I
I have an array of integers and I want to make a binary search tree out of it. I want to make sure it's a valid binary search tree, not just any binary tree. What are steps I can take to achieve this goal?
class TreeNode: def __init__(self, key): self.left = None self.right = None self.val = key def sorted_array_to_bst(nums): def helper(left, right): if left > right: return None mid = (left + right) // 2 node = TreeNode(nums[mid]) node.left = he...
import pytest from solution import array_to_bst, TreeNode def inorder_traversal(root): return inorder_traversal(root.left) + [root.val] + inorder_traversal(root.right) if root else [] def test_empty_array(): assert array_to_bst([]) == None def test_single_element_array(): bst = array_to_bst([1]) asse...
[]
[ 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, key):\n self.left = None\n self.right = None\n self.value = key\n\ndef insert_node(root, key):\n \"\"\"\n Inserts a node into...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013794", "row_id": 13794, "seed_ids": "['Llama-3.3-70B-Instruct_35715']" }
0.53302
Filter_13794
I
[ "sorted_array_to_bst", "array_to_bst" ]
2
[ [ "array_to_bst", "sorted_array_to_bst" ] ]
1
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
edeb1ae9ef4e148fe311a5e1c8bae70ac8c48668
d6a83d213dd4222da06723f4c942d15541e7581f
v1.0
instruct
Filter
Filter_13816_I
Here is the Python code for the traveling salesman problem using the brute force method: ```python from itertools import permutations import math def distance(p1, p2): return math.sqrt((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2) def total_distance(points, path): total = 0 for i in range(len(path)-1): ...
from itertools import permutations import math def distance(p1, p2): return math.sqrt((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2) def total_distance(points, path): total = 0 for i in range(len(path)-1): total += distance(points[path[i]], points[path[i+1]]) total += distance(points[path[-1]], poin...
from solution import distance, total_distance, traveling_salesman, two_opt def test_distance(): assert math.isclose(distance((0, 0), (3, 4)), 5.0) def test_total_distance(): points = [(0, 0), (0, 1), (1, 1), (1, 0)] path = [0, 1, 2, 3] assert math.isclose(total_distance(points, path), 4.0) def test_t...
[ { "docstring": null, "function_declaration": "def distance(p1, p2):", "function_name": "distance", "parameter_list": "(p1, p2)" }, { "docstring": null, "function_declaration": "def total_distance(points, path):", "function_name": "total_distance", "parameter_list": "(points, path...
[ 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 permutations\nimport math\n\ndef distance(p1, p2):\n return math.sqrt((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)\n\ndef total_distance(points, path):\n total = 0\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00013816", "row_id": 13816, "seed_ids": "['Llama-3.3-70B-Instruct_35769']" }
0.504516
Filter_13816
I
[ "distance", "total_distance", "traveling_salesman", "two_opt", "main" ]
5
[ [ "total_distance", "distance" ], [ "traveling_salesman", "total_distance" ], [ "two_opt", "total_distance" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e621fe7a7a24d2d83588b47c6af85a56845763e5
af8e56838fdc54fe16e21bdbfe17bdc053356e38
v1.0
instruct
Filter
Filter_13826_I
I am a computer science student and I'm working on a project that involves converting the probability of an event from one form to another (odds, probability, decimal, and fractional odds). I need help with implementing the conversion between these forms. Here is a basic structure for how I envision the functions to l...
def decimal_to_probability(decimal_odds): """ Converts decimal odds to probability """ return 1 / decimal_odds def decimal_to_fractional(decimal_odds): """ Converts decimal odds to fractional odds """ decimal_odds -= 1 numerator = int(decimal_odds * 100) denominator = 100 # ...
from solution import * def test_decimal_to_probability(): assert decimal_to_probability(2) == 0.5 assert decimal_to_probability(1.5) == 0.6666666666666666 def test_decimal_to_fractional(): assert decimal_to_fractional(2) == "1/1" assert decimal_to_fractional(2.5) == "3/2" def test_decimal_to_odds(): ...
[ { "docstring": "Converts decimal odds to probability", "function_declaration": "def decimal_to_probability(decimal_odds):", "function_name": "decimal_to_probability", "parameter_list": "(decimal_odds)" }, { "docstring": "Converts decimal odds to fractional odds", "function_declaration": ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def decimal_to_probability(decimal_odds):\n \"\"\"\n Converts decimal odds to probability.\n \"\"\"\n return 1 / decimal_odds\n\ndef decimal_to_fractional(decimal_odds):\n \"\"\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013826", "row_id": 13826, "seed_ids": "['Llama-3.3-70B-Instruct_35789']" }
0.486054
Filter_13826
I
[ "decimal_to_probability", "decimal_to_fractional", "decimal_to_odds", "fractional_to_decimal", "fractional_to_probability", "fractional_to_odds", "odds_to_decimal", "odds_to_fractional", "odds_to_probability", "probability_to_decimal", "probability_to_fractional", "probability_to_odds" ]
12
[ [ "decimal_to_odds", "decimal_to_fractional" ], [ "odds_to_decimal", "fractional_to_decimal" ], [ "odds_to_probability", "fractional_to_probability" ], [ "probability_to_fractional", "decimal_to_fractional" ], [ "probability_to_fractional", "probability_to_dec...
7
[]
false
[]
false
pytest
true
[]
true
d74f63b0e76215b19f7867f14e9a3889c0977618
783fda4442e6c1cca0862c4b2a252453dcc11290
v1.0
instruct
Filter
Filter_13837_I
### Basic Arithmetic Operations In this task, you will create a Python program that performs addition, subtraction, multiplication, and division. #### Problem Statement The program should ask the user for two numbers and an operator. The program will then perform the specified operation on the numbers and print the re...
def perform_operation(first_number, operator, second_number): """ Performs the specified arithmetic operation on the two numbers. Parameters: first_number (float): The first number. operator (str): The operator ('+', '-', '*', '/'). second_number (float): The second number. Returns...
from solution import calculator def test_addition(): assert calculator(10, '+', 5) == "The result is: 15" def test_subtraction(): assert calculator(10, '-', 5) == "The result is: 5" def test_multiplication(): assert calculator(10, '*', 5) == "The result is: 50" def test_division(): assert calculator...
[ { "docstring": "Performs the specified arithmetic operation on the two numbers.\n\nParameters:\nfirst_number (float): The first number.\noperator (str): The operator ('+', '-', '*', '/').\nsecond_number (float): The second number.\n\nReturns:\nfloat: The result of the operation.\nstr: Error message if invalid o...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def perform_operation(first_number, operator, second_number):\n \"\"\"\n Performs a basic arithmetic operation on two numbers.\n \n Args:\n first_number (float): The first numbe...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013837", "row_id": 13837, "seed_ids": "['Llama-3.3-70B-Instruct_35811']" }
0.724629
Filter_13837
I
[ "perform_operation", "calculator" ]
2
[ [ "calculator", "perform_operation" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f45b9efce1cf03f616e39bb4a54d4d66af6e1910
51dc0f74b574e5c1c76b923ef08ce4904641663d
v1.0
instruct
Filter
Filter_13860_I
### Programming Concepts: Combinatorial Algorithms #### Problem: Finding the Closest Pair of Points Given a set of points in a two-dimensional space, find the closest pair of points.
import math def distance(p1, p2): """Calculate the Euclidean distance between two points.""" return math.sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) def closest_pair(points): """Find the closest pair of points using a divide-and-conquer approach. Args: points (list of tuples): A list of...
from solution import closest_pair def test_closest_pair_1(): points = [(0, 0), (1, 1), (4, 5), (1, 2)] assert closest_pair(points)[1] == 1.0 def test_closest_pair_2(): points = [(0, 0), (-1, -1), (-4, -5), (1, 2)] assert closest_pair(points)[1] == math.sqrt(2) def test_closest_pair_3(): points = ...
[ { "docstring": "Calculate the Euclidean distance between two points.", "function_declaration": "def distance(p1, p2):", "function_name": "distance", "parameter_list": "(p1, p2)" }, { "docstring": "Find the closest pair of points using a divide-and-conquer approach.\n\nArgs:\n points (list...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom itertools import combinations\n\ndef distance(point1, point2):\n \"\"\"\n Calculate the Euclidean distance between two points.\n \"\"\"\n return math.sqrt((point1...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013860", "row_id": 13860, "seed_ids": "['Llama-3.3-70B-Instruct_35854']" }
0.672356
Filter_13860
I
[ "distance", "closest_pair" ]
2
[ [ "closest_pair", "distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ef8b0aa93e2ad44523450b4ae57c4e8453c3c509
bd2589367afb8335512ad7793f72d48932bd22a4
v1.0
instruct
Filter
Filter_13862_I
I've been trying to implement merge sort in python. I was wondering if you could help me debug it and provide feedback. Here's my current implementation: ```python def merge(left, right): """Merge two sorted lists into one sorted list""" result = [] while len(left) > 0 and len(right) > 0: if left[0...
def merge(left, right): """Merge two sorted lists into one sorted list""" result = [] i = j = 0 while i < len(left) and j < len(right): if left[i] < right[j]: result.append(left[i]) i += 1 else: result.append(right[j]) j += 1 result.e...
from solution import merge_sort def test_merge_sort_empty(): assert merge_sort([]) == [] def test_merge_sort_single_element(): assert merge_sort([1]) == [1] def test_merge_sort_sorted(): assert merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_merge_sort_reverse_sorted(): assert merge_sort([5,...
[ { "docstring": "Merge two sorted lists into one sorted list", "function_declaration": "def merge(left, right):", "function_name": "merge", "parameter_list": "(left, right)" }, { "docstring": "Sorts an array using the merge sort algorithm", "function_declaration": "def merge_sort(arr):", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge(left, right):\n \"\"\"Merge two sorted lists into one sorted list\"\"\"\n result = []\n i, j = 0, 0\n while i < len(left) and j < len(right):\n if left[i] < right[...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013862", "row_id": 13862, "seed_ids": "['Llama-3.3-70B-Instruct_35856']" }
0.558412
Filter_13862
I
[ "merge", "merge_sort" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
477adfa20b02f5c4da30fef59c3ce6f83ce30963
e61aa6745e934c533e9c676d085ded2e79209805
v1.0
instruct
Filter
Filter_13864_I
I want to create a simple rock, paper, scissors game using Python and want to get the user's name and generate a random choice for the computer. Here is my code so far: ``` import random # define a dictionary with rock paper and scissors choices = { "rock": "scissors", "paper": "rock", "scissors": "paper"...
import random choices = { "rock": "scissors", "paper": "rock", "scissors": "paper" } def get_computer_choice(): return random.choice(list(choices.keys())) def get_user_choice(): user_name = input("Please enter your name: ") user_choice = input("Please enter a choice (rock, paper, scissors): "...
from solution import determine_winner def test_determine_winner_tie(): assert determine_winner("rock", "rock") == "It's a tie!" assert determine_winner("paper", "paper") == "It's a tie!" assert determine_winner("scissors", "scissors") == "It's a tie!" def test_determine_winner_user_wins(): assert dete...
[ { "docstring": null, "function_declaration": "def get_computer_choice():", "function_name": "get_computer_choice", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def get_user_choice():", "function_name": "get_user_choice", "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\nchoices = {\n \"rock\": \"scissors\",\n \"paper\": \"rock\",\n \"scissors\": \"paper\"\n}\n\ndef get_computer_choice():\n return random.choice(list(choices.keys())...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013864", "row_id": 13864, "seed_ids": "['Llama-3.3-70B-Instruct_35858']" }
0.476953
Filter_13864
I
[ "get_computer_choice", "get_user_choice", "determine_winner", "game" ]
4
[ [ "game", "determine_winner" ], [ "game", "get_computer_choice" ], [ "game", "get_user_choice" ] ]
3
[]
false
[]
false
pytest
true
[]
true
9ecd951bf88d2f31e258d4bcddf08852f2be3aa6
a29cc95e812211e1e6808cad935b46f3fd813159
v1.0
instruct
Filter
Filter_13865_I
Based on the Mad Libs game, I'd like to create a story with 7 words that are user input. So, the user will input 7 words and the program will create a funny story with those words. Here is the sample story with the blank spaces for the user's input: "Yesterday, I saw a _______________ (adjective) elephant eating a ...
def get_valid_input(prompt): while True: user_input = input(prompt) if user_input.strip() != "": return user_input else: print("Input cannot be empty. Please try again.") def create_story(): print("Welcome to the Mad Libs game!") print("Please provide the fol...
from unittest.mock import patch import builtins import pytest from solution import get_valid_input, create_story def test_get_valid_input_non_empty(): with patch.object(builtins, 'input', lambda _: 'valid input'): assert get_valid_input("Enter something: ") == 'valid input' def test_get_valid_input_empty...
[ { "docstring": null, "function_declaration": "def get_valid_input(prompt):", "function_name": "get_valid_input", "parameter_list": "(prompt)" }, { "docstring": null, "function_declaration": "def create_story():", "function_name": "create_story", "parameter_list": "()" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def get_valid_input(prompt):\n while True:\n user_input = input(prompt)\n if user_input.strip() != \"\":\n return user_input\n else:\n print(\"Inp...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00013865", "row_id": 13865, "seed_ids": "['Llama-3.3-70B-Instruct_35864']" }
0.563451
Filter_13865
I
[ "get_valid_input", "create_story" ]
2
[ [ "create_story", "get_valid_input" ] ]
1
[]
false
[]
false
pytest
true
[]
true
db973322a071150de766ee44b769b24e28125571
b55a1b735d2a022ffde33e20c5232c3ccc74c63b
v1.0
instruct
Filter
Filter_13883_I
Okay, so I want to make a 2D fighting game, and I have a few questions regarding some of the features and mechanics I want to include. To begin with, I want the game to have a "just frame" or "1-frame" system, where the player can cancel certain moves into other moves at the exact frame where the move becomes cancella...
class Move: def __init__(self, name, total_frames, cancellable_frame): self.name = name self.total_frames = total_frames self.cancellable_frame = cancellable_frame self.current_frame = 0 self.is_finished = False def update(self): """ Update the state of t...
from solution import Move, Fighter, perform_move, try_cancel_move def test_perform_and_cancel_move(): fighter = Fighter("Test Fighter") move1 = Move("Punch", total_frames=30, cancellable_frame=15) move2 = Move("Kick", total_frames=20, cancellable_frame=10) perform_move(fighter, move1) for...
[]
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class Move:\n def __init__(self, name, frames_duration, cancel_frame):\n self.name = name\n self.frames_duration = frames_duration\n self.cancel_frame = cancel_frame\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013883", "row_id": 13883, "seed_ids": "['Llama-3.3-70B-Instruct_35894']" }
0.274693
Filter_13883
I
[ "perform_move", "try_cancel_move" ]
2
[ [ "try_cancel_move", "perform_move" ] ]
1
[]
false
[ "Move", "Fighter" ]
true
pytest
true
[]
true
08c500a34825ef3b36c7ad81f1ff92eac2e530cd
6e72a2b50583f4bb41e755fdf329c1d11fb340c5
v1.0
instruct
Filter
Filter_13911_I
I'm trying to create a route from a list of gps coordinates, but the coordinates are in a string format like this: "12.3456,-34.5678". How can I convert this string into a tuple of floats, and then use it to create a route on a map?
def convert_gps_string_to_tuple(gps_string): """ Converts a GPS coordinate string to a tuple of floats. Parameters: gps_string (str): A GPS coordinate string in the format "latitude,longitude". Returns: tuple: A tuple of floats representing the latitude and longitude. """ latit...
from solution import convert_gps_string_to_tuple, create_route def test_convert_gps_string_to_tuple(): assert convert_gps_string_to_tuple("12.3456,-34.5678") == (12.3456, -34.5678) assert convert_gps_string_to_tuple("0.0,-1.0") == (0.0, -1.0) assert convert_gps_string_to_tuple("45.6789,123.4567") == (45.67...
[ { "docstring": "Converts a GPS coordinate string to a tuple of floats.\n\nParameters:\ngps_string (str): A GPS coordinate string in the format \"latitude,longitude\".\n\nReturns:\ntuple: A tuple of floats representing the latitude and longitude.", "function_declaration": "def convert_gps_string_to_tuple(gps...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def string_to_tuple(coord_str):\n \"\"\"\n Converts a string of GPS coordinates into a tuple of floats.\n \n Parameters:\n coord_str (str): A string representing GPS coordinates...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013911", "row_id": 13911, "seed_ids": "['Llama-3.3-70B-Instruct_35967']" }
0.58322
Filter_13911
I
[ "convert_gps_string_to_tuple", "create_route" ]
2
[ [ "create_route", "convert_gps_string_to_tuple" ] ]
1
[]
false
[]
false
pytest
true
[]
true
91ec8b205db570b7dce545a460a85bde51d58256
17db45e19db84200c6a672ab0d97683cfbacf329
v1.0
instruct
Filter
Filter_13915_I
I am trying to create a program that can solve a specific type of puzzle, where a given word is mixed up, and the goal is to unscramble it to form as many valid words as possible. I have a list of valid English words that I can use to check the generated words. Here are some requirements for the program: 1. **Genera...
import itertools def generate_permutations(word): """ Generate all unique permutations of the input word. """ # Use a set to ensure uniqueness perms = set([''.join(p) for p in itertools.permutations(word)]) return perms def filter_valid_words(perms, valid_words): """ Filter out invalid...
from solution import generate_permutations, filter_valid_words, unscramble_word def test_generate_permutations(): perms = generate_permutations("abc") expected_perms = {"abc", "acb", "bac", "bca", "cab", "cba"} assert perms == expected_perms def test_filter_valid_words(): perms = {"abc", "acb", "bac",...
[ { "docstring": "Generate all unique permutations of the input word.", "function_declaration": "def generate_permutations(word):", "function_name": "generate_permutations", "parameter_list": "(word)" }, { "docstring": "Filter out invalid words from the list of permutations.", "function_de...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import itertools\n\ndef generate_permutations(word):\n \"\"\"\n Generate all unique permutations of the input word.\n \"\"\"\n # Use a set to ensure uniqueness\n perms = set([''...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00013915", "row_id": 13915, "seed_ids": "['Llama-3.3-70B-Instruct_35973']" }
0.62891
Filter_13915
I
[ "generate_permutations", "filter_valid_words", "unscramble_word" ]
3
[ [ "unscramble_word", "filter_valid_words" ], [ "unscramble_word", "generate_permutations" ] ]
2
[]
false
[]
false
pytest
true
[]
true
d1a1c747a1277288f9fa3d7774d06f5e23ce951c
c746c8d6b93bf9db01de3dfdf897d676e0a49757
v1.0
instruct
Filter
Filter_13931_I
I've written an algorithm to calculate the nth Fibonacci number using dynamic programming in Python. However, my code only works for positive numbers. How can I enhance it so that it will continue working for negative integers as well?
def fibonacci(n): """ Returns the nth Fibonacci number, handling both positive and negative indices. """ if n == 0: return 0 elif n > 0: return fibonacci_positive(n) else: return fibonacci_negative(n) def fibonacci_positive(n): """ Helper function to calc...
from solution import fibonacci def test_fibonacci_positive_numbers(): assert fibonacci(0) == 0 assert fibonacci(1) == 1 assert fibonacci(2) == 1 assert fibonacci(3) == 2 assert fibonacci(10) == 55 def test_fibonacci_negative_numbers(): assert fibonacci(-1) == 1 assert fibonacci(-2) == -1 ...
[ { "docstring": "Returns the nth Fibonacci number, handling both positive and negative indices.", "function_declaration": "def fibonacci(n):", "function_name": "fibonacci", "parameter_list": "(n)" }, { "docstring": "Helper function to calculate the nth Fibonacci number for positive n using dy...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def fibonacci(n):\n \"\"\"\n Returns the nth Fibonacci number. \n Works for positive and negative indices.\n \"\"\"\n if n == 0:\n return 0\n elif n == 1 or n == -1:\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013931", "row_id": 13931, "seed_ids": "['Llama-3.3-70B-Instruct_36009']" }
0.586059
Filter_13931
I
[ "fibonacci", "fibonacci_positive", "fibonacci_negative" ]
3
[ [ "fibonacci", "fibonacci_negative" ], [ "fibonacci", "fibonacci_positive" ], [ "fibonacci_negative", "fibonacci_positive" ] ]
3
[]
false
[]
false
pytest
true
[]
true
a58fc3c751f7950d28ae214cf73f2062e2355c51
61cd99505f4c78d382168c2eb7c4a9d8371fde10
v1.0
instruct
Filter
Filter_13936_I
Can you demonstrate the usage of the `yield from` statement in Python?
def generator_1(): """ A generator that yields numbers from 1 to 3. """ yield 1 yield 2 yield 3 def generator_2(): """ A generator that uses 'yield from' to yield all values from generator_1 and then yields the values 4 and 5. """ yield from generator_1() yield 4 yie...
from solution import generator_1, generator_2 def test_generator_1(): assert list(generator_1()) == [1, 2, 3] def test_generator_2(): assert list(generator_2()) == [1, 2, 3, 4, 5]
[ { "docstring": "A generator that yields numbers from 1 to 3.", "function_declaration": "def generator_1():", "function_name": "generator_1", "parameter_list": "()" }, { "docstring": "A generator that uses 'yield from' to yield all values from generator_1\nand then yields the values 4 and 5."...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generator1():\n \"\"\"\n A simple generator that yields numbers 1, 2, 3\n \"\"\"\n yield 1\n yield 2\n yield 3\n\ndef generator2():\n \"\"\"\n A generator that yiel...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013936", "row_id": 13936, "seed_ids": "['Llama-3.3-70B-Instruct_36022']" }
0.429278
Filter_13936
I
[ "generator_1", "generator_2" ]
2
[ [ "generator_2", "generator_1" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5a525491b73ab01209e8f20bbeabc5c7fd49b01d
865882ec925ed87f862eada142ef5c6112e5da54
v1.0
instruct
Filter
Filter_13959_I
I have this function that takes an integer and prints the first n Fibonacci numbers. I want to add a second function that asks the user to input a number n, and uses the first function to print the first n Fibonacci numbers. Here is my current code: ```python def print_fib(n): """ Prints the first n Fibonacc...
def print_fib(n): """ Prints the first n Fibonacci numbers. """ fib_sequence = [0, 1] while len(fib_sequence) < n: fib_sequence.append(fib_sequence[-1] + fib_sequence[-2]) print(*fib_sequence[:n]) def ask_and_print_fib(): """ Asks the user to input a number, and prints the first...
from solution import print_fib, ask_and_print_fib import pytest from io import StringIO import sys def test_print_fib(): # Test for different lengths of the Fibonacci sequence captured_output = StringIO() sys.stdout = captured_output print_fib(5) sys.stdout = sys.__stdout__ assert captured_outp...
[ { "docstring": "Prints the first n Fibonacci numbers.", "function_declaration": "def print_fib(n):", "function_name": "print_fib", "parameter_list": "(n)" }, { "docstring": "Asks the user to input a number, and prints the first n Fibonacci numbers.", "function_declaration": "def ask_and_...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def print_fib(n):\n \"\"\"\n Prints the first n Fibonacci numbers.\n \"\"\"\n fib_sequence = [0, 1]\n while len(fib_sequence) < n:\n fib_sequence.append(fib_sequence[-1] ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00013959", "row_id": 13959, "seed_ids": "['Llama-3.3-70B-Instruct_36071']" }
0.646952
Filter_13959
I
[ "print_fib", "ask_and_print_fib" ]
2
[ [ "ask_and_print_fib", "print_fib" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3926fa96d5a8b510a909c45cbd7134a5345cedd4
96f43d426ca7efb0cf0feee64a948eeb9d8ba00e
v1.0
instruct
Filter
Filter_13976_I
How do I use Python to find the first 10 prime numbers?
def is_prime(n): """ Determines if a number n is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 retu...
from solution import first_10_primes, is_prime, first_n_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-3) == False def test_fir...
[ { "docstring": "Determines if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the first n prime numbers.", "function_declaration": "def first_n_primes(n):", "function_name": "first_n_pr...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determines if a number n is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00013976", "row_id": 13976, "seed_ids": "['Llama-3.3-70B-Instruct_36111']" }
0.621134
Filter_13976
I
[ "is_prime", "first_n_primes", "first_10_primes" ]
3
[ [ "first_10_primes", "first_n_primes" ], [ "first_n_primes", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
87dfbdcc01e6eedc79b57ce9bdd95abda4cfa4c4
bb5c5f8bb96b99c71a476e41976046087bdbd173
v1.0
instruct
Filter
Filter_13984_I
Write a fully executable Scala program to simulate the rock-paper-scissors game. Below is an example of a rock-paper-scissors game in Python, which we will be basing our program off of. ```python import random while True: user_choice = input("Enter a choice (rock, paper, scissors): ") possible_choices = ["r...
import random def get_winner(user_choice, computer_choice): """ Determines the winner of a rock-paper-scissors game. Returns "tie", "user", or "computer". """ if user_choice == computer_choice: return "tie" elif user_choice == "rock": return "user" if computer_choice == "scissor...
from solution import get_winner, simulate_game def test_get_winner_tie(): assert get_winner("rock", "rock") == "tie" assert get_winner("paper", "paper") == "tie" assert get_winner("scissors", "scissors") == "tie" def test_get_winner_user_wins(): assert get_winner("rock", "scissors") == "user" asse...
[ { "docstring": "Determines the winner of a rock-paper-scissors game.\nReturns \"tie\", \"user\", or \"computer\".", "function_declaration": "def get_winner(user_choice, computer_choice):", "function_name": "get_winner", "parameter_list": "(user_choice, computer_choice)" }, { "docstring": "Si...
[ 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 get_game_result(user_choice, computer...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00013984", "row_id": 13984, "seed_ids": "['Llama-3.3-70B-Instruct_36130']" }
0.502997
Filter_13984
I
[ "get_winner", "simulate_game" ]
2
[ [ "simulate_game", "get_winner" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0a996ec2dbace0eab60720acaee97085e996cdaa
700e896f669fe26d88b6b7f65cd6fe920f8b9c89
v1.0
instruct
Filter
Filter_13994_I
Here is a Python program that takes a series of "transactions" (e.g., 'Buy 3000 shares of XYZ stock at $10.50') and outputs the "portfolio". The current portfolio shows each transaction separately. I would like the program to accumulate the shares and cost for each stock so that the portfolio only shows each stock on...
def parse_transactions(transactions): portfolio = {} for t in transactions: # Parse the transaction ty, quantity, symbol, price = parse_transaction(t) # Add or subtract the shares and cost accordingly if ty == 'Buy': if symbol not in portfolio: ...
from solution import parse_transactions def test_single_transaction(): transactions = ['Buy 3000 shares of XYZ stock at $10.50'] result = parse_transactions(transactions) assert result == [{'symbol': 'XYZ', 'quantity': 3000, 'average_price': 10.50}] def test_multiple_buy_transactions_same_stock(): tra...
[ { "docstring": null, "function_declaration": "def parse_transactions(transactions):", "function_name": "parse_transactions", "parameter_list": "(transactions)" }, { "docstring": null, "function_declaration": "def parse_transaction(t):", "function_name": "parse_transaction", "para...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def parse_transactions(transactions):\n portfolio = {}\n for t in transactions:\n ty, quantity, symbol, price = parse_transaction(t)\n quantity = int(quantity)\n pri...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00013994", "row_id": 13994, "seed_ids": "['Llama-3.3-70B-Instruct_36154']" }
0.451064
Filter_13994
I
[ "parse_transactions", "parse_transaction" ]
2
[ [ "parse_transactions", "parse_transaction" ] ]
1
[]
false
[]
false
pytest
true
[]
true
91a41fbfe3e9443117c76130cd84aa3c693e3335
16785c08f112c7e96e29a4d4d74a0307739ab65e
v1.0
instruct
Filter
Filter_14025_I
I provide a check if it is valid for a provided country. The country requires all checks to be written in a specific numeric format, but the bank will only cash it if there is an exact match with the amount in both numeric and written forms. For example, if the amount is $23, the written form should be "Twenty-Three"...
def number_to_words(n): below_20 = ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen'] tens = ['Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety'] ...
from solution import check_writer def test_check_writer_zero(): assert check_writer(0.0) == "Zero" def test_check_writer_one_cent(): assert check_writer(0.01) == "One Cent" def test_check_writer_one_dollar(): assert check_writer(1.00) == "One Dollar" def test_check_writer_one_dollar_one_cent(): asse...
[ { "docstring": null, "function_declaration": "def number_to_words(n):", "function_name": "number_to_words", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def check_writer(amount):", "function_name": "check_writer", "parameter_list": "(amount)" } ]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def check_writer(amount):\n # Dictionaries for number to words conversion\n num_to_words_units = {\n 0: \"Zero\", 1: \"One\", 2: \"Two\", 3: \"Three\", 4: \"Four\",\n 5: \"...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014025", "row_id": 14025, "seed_ids": "['Llama-3.3-70B-Instruct_36217']" }
0.523763
Filter_14025
I
[ "number_to_words", "check_writer" ]
2
[ [ "check_writer", "number_to_words" ] ]
1
[]
false
[]
false
pytest
true
[]
true
73c345d7e83d4d6d86fd8a193a86a9f2875bfea4
792312ba788999f711350a07850a2751bd011c38
v1.0
instruct
Filter
Filter_14041_I
Can you provide a code example of Python training a simple neural network using only built-in Python libraries and the bias for a logistic regression model?
import random import math def sigmoid(x): return 1 / (1 + math.exp(-x)) def sigmoid_derivative(x): return x * (1 - x) def train_nn(inputs, outputs, epochs, learning_rate): n_features = len(inputs[0]) # Initialize weights and bias weights = [random.random() for _ in range(n_features)] bia...
from solution import train_nn, predict_nn def test_train_nn_single_epoch(): inputs = [[0.0, 0.0], [0.0, 1.0], [1.0, 0.0], [1.0, 1.0]] outputs = [0.0, 0.0, 0.0, 1.0] epochs = 1 learning_rate = 0.5 weights, bias = train_nn(inputs, outputs, epochs, learning_rate) assert len(weights) == 2 ...
[ { "docstring": null, "function_declaration": "def sigmoid(x):", "function_name": "sigmoid", "parameter_list": "(x)" }, { "docstring": null, "function_declaration": "def sigmoid_derivative(x):", "function_name": "sigmoid_derivative", "parameter_list": "(x)" }, { "docstring...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport math\n\ndef sigmoid(x):\n return 1 / (1 + math.exp(-x))\n\ndef sigmoid_derivative(x):\n return x * (1 - x)\n\ndef train_nn(inputs, outputs, epochs, learning_rate):\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00014041", "row_id": 14041, "seed_ids": "['Llama-3.3-70B-Instruct_36261']" }
0.378956
Filter_14041
I
[ "sigmoid", "sigmoid_derivative", "train_nn", "predict_nn" ]
4
[ [ "predict_nn", "sigmoid" ], [ "train_nn", "sigmoid" ], [ "train_nn", "sigmoid_derivative" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e9a79d12091d6a8737331624053f378889bddd58
2343544ce3ea6c1bf436b9f46112302c05b8e4de
v1.0
instruct
Filter
Filter_14042_I
I have multiple datasets that are all formatted the same. Each dataset has a collection of records that I want to process. I want to keep all the dataset processing logic in one place and be able to easily switch between datasets. Here is a simplified example of a dataset: ```python # example dataset dataset = [ ...
def process_dataset(dataset): """ Process the dataset by printing each record. """ for record in dataset: print(record) # Dictionary to store multiple datasets datasets = { "dataset1": [ {"name": "John", "age": 25, "city": "New York"}, {"name": "Alice", "age": 30, "city": "C...
import io import sys from solution import process_dataset, switch_and_process def capture_output(func, *args, **kwargs): """ Helper function to capture the output of a function call """ captured_output = io.StringIO() # Create StringIO object sys.stdout = captured_output # Redi...
[ { "docstring": "Process the dataset by printing each record.", "function_declaration": "def process_dataset(dataset):", "function_name": "process_dataset", "parameter_list": "(dataset)" }, { "docstring": "Switch to a specified dataset by its key and process it.", "function_declaration": ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def process_dataset(dataset):\n \"\"\"\n Process the dataset by printing each record.\n \"\"\"\n for record in dataset:\n print(record)\n\n# List of different datasets\ndata...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014042", "row_id": 14042, "seed_ids": "['Llama-3.3-70B-Instruct_36262']" }
0.378686
Filter_14042
I
[ "process_dataset", "switch_and_process" ]
2
[ [ "switch_and_process", "process_dataset" ] ]
1
[ "process_dataset" ]
false
[]
false
pytest
true
[]
true
a5fbb8b49f5bcde7191fedf93aa630f4756f097e
791b1fe1f53ce5602523c33b4f4e75d2b06ffb11
v1.0
instruct
Filter
Filter_14069_I
As part of my work in computer vision, I want to generate two sets of labelled data; each set consists of digits from 0 to 9 and each digit will be represented as a binary vector of length 784 (28x28 pixels). The first set is referred to as the 'reference' dataset and the second set is referred to as the 'query' data...
import numpy as np def generate_single_digit_vector(digit: int) -> np.ndarray: """ Generates a binary vector of length 784 representing a perfect, noise-free image of a digit. Since generating perfect digits programmatically can be complex and depends on the specific patterns one would like to create,...
import numpy as np from solution import generate_reference_dataset, generate_query_dataset def test_generate_reference_dataset_length(): digits, labels = generate_reference_dataset() assert len(digits) == 1000 assert len(labels) == 1000 def test_generate_reference_dataset_content(): digits, labels = g...
[ { "docstring": "Generates a binary vector of length 784 representing a perfect, noise-free image of a digit.\nSince generating perfect digits programmatically can be complex and depends on the \nspecific patterns one would like to create, this function is a placeholder.\nFor simplicity, we will use random binar...
[ 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\n\ndef generate_digit_image(digit: int) -> np.ndarray:\n \"\"\"\n Generates a perfect binary image of the given digit.\n Note: This is a simplistic implementation a...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014069", "row_id": 14069, "seed_ids": "['Llama-3.3-70B-Instruct_36330']" }
0.505573
Filter_14069
I
[ "generate_single_digit_vector", "generate_reference_dataset", "generate_query_dataset" ]
3
[ [ "generate_query_dataset", "generate_reference_dataset" ], [ "generate_reference_dataset", "generate_single_digit_vector" ] ]
2
[]
false
[]
false
pytest
true
[ "numpy" ]
false
589bc089b75efaeed5d5b96ac904900cb6d1a2f9
3fe53f3b2722ec8873aa8fe1ea101cfdf06de9c8
v1.0
instruct
Filter
Filter_14083_I
I've been given a dataset of points in n-dimensional space, and I've been asked to write a program to cluster these points using the K-Means algorithm. Here's a sample input dataset: ```python points = [ [1, 2, 3], [1, 4, 5], [4, 5, 6], [4, 5, 7], [10, 10, 10], [10, 10, 11], [10, 10, 12], ]...
import random import numpy as np def initialize_centroids(points, k): """ Randomly initialize the centroids from the dataset points. """ random_indices = random.sample(range(len(points)), k) centroids = [points[i] for i in random_indices] return centroids def assign_points_to_centroids(points,...
from solution import kmeans def test_kmeans_basic(): points = [ [1, 2, 3], [1, 4, 5], [4, 5, 6], [4, 5, 7], [10, 10, 10], [10, 10, 11], [10, 10, 12], ] k = 3 clusters, centroids = kmeans(points, k) # Check if the number of clusters formed...
[ { "docstring": "Randomly initialize the centroids from the dataset points.", "function_declaration": "def initialize_centroids(points, k):", "function_name": "initialize_centroids", "parameter_list": "(points, k)" }, { "docstring": "Assign each point to the centroid closest to it.", "fun...
[ 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 numpy as np\n\ndef kmeans(points, k, max_iters=100):\n # Convert points to numpy array for easier calculations\n points = np.array(points)\n \n # Step 1: Init...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014083", "row_id": 14083, "seed_ids": "['Llama-3.3-70B-Instruct_36366']" }
0.570396
Filter_14083
I
[ "initialize_centroids", "assign_points_to_centroids", "update_centroids", "kmeans" ]
4
[ [ "kmeans", "assign_points_to_centroids" ], [ "kmeans", "initialize_centroids" ], [ "kmeans", "update_centroids" ] ]
3
[]
false
[]
false
pytest
true
[ "numpy" ]
false
f2a8fa872b7e91c434aa58dfdfe14b889a38b3d7
43790a9f544c94d4e8ccd3b2a9eade1a304187b3
v1.0
instruct
Filter
Filter_14111_I
endarax is a calendar that can be used to keep track of the days of the month. Suppose that you have a function `days_in_month` that takes a month and the year as input, and returns the number of days in that month. You need to add the ability to check if a given date is valid.
def days_in_month(month, year): # Checks for leap year if month == 2: if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0): return 29 else: return 28 elif month in {4, 6, 9, 11}: return 30 elif month in {1, 3, 5, 7, 8, 10, 12}: return 31 ...
from solution import days_in_month, is_valid_date def test_days_in_month(): assert days_in_month(1, 2023) == 31 assert days_in_month(2, 2023) == 28 assert days_in_month(2, 2024) == 29 # Leap year assert days_in_month(4, 2023) == 30 assert days_in_month(11, 2023) == 30 assert days_in_month(12, ...
[ { "docstring": null, "function_declaration": "def days_in_month(month, year):", "function_name": "days_in_month", "parameter_list": "(month, year)" }, { "docstring": "Returns True if the given date is valid, False otherwise.", "function_declaration": "def is_valid_date(day, month, year):...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def days_in_month(month, year):\n \"\"\"\n Returns the number of days in the given month of the given year.\n \"\"\"\n if month == 2:\n # Check for leap year\n if (ye...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014111", "row_id": 14111, "seed_ids": "['Llama-3.3-70B-Instruct_36446']" }
0.618358
Filter_14111
I
[ "days_in_month", "is_valid_date" ]
2
[ [ "is_valid_date", "days_in_month" ] ]
1
[]
false
[]
false
pytest
true
[]
true
aa595cb15d65eb0a8d3ed6426fc9b431288f9162
047ee9b5e8702fc103e6c55867d8df650142cfb2
v1.0
instruct
Filter
Filter_14114_I
I wrote a Python program which generates a lot of Cartesian coordinate pairs and stores them in a list. The coordinates represent cuts in a workpiece. I want to sort these coordinate pairs based on the nearest neighbor algorithm for the traveling salesman problem, so I calculate the shortest path that visits each cut ...
import math from typing import List, Tuple def calculate_distance(point1: Tuple[float, float], point2: Tuple[float, float]) -> float: return math.sqrt((point2[0] - point1[0])**2 + (point2[1] - point1[1])**2) def nearest_neighbor(points: List[Tuple[float, float]], start_point: Tuple[float, float]) -> List[Tuple[fl...
from solution import nearest_neighbor, calculate_distance def test_calculate_distance(): assert math.isclose(calculate_distance((0, 0), (3, 4)), 5.0) assert math.isclose(calculate_distance((1, 2), (4, 6)), 5.0) assert math.isclose(calculate_distance((2, 2), (2, 2)), 0.0) def test_nearest_neighbor_simple()...
[ { "docstring": null, "function_declaration": "def calculate_distance(point1, point2):", "function_name": "calculate_distance", "parameter_list": "(point1, point2)" }, { "docstring": null, "function_declaration": "def nearest_neighbor(points, start_point):", "function_name": "nearest_...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom typing import List, Tuple\n\ndef calculate_distance(point1: Tuple[float, float], point2: Tuple[float, float]) -> float:\n return math.sqrt((point2[0] - point1[0])**2 + (po...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00014114", "row_id": 14114, "seed_ids": "['Llama-3.3-70B-Instruct_36460']" }
0.622779
Filter_14114
I
[ "calculate_distance", "nearest_neighbor" ]
2
[ [ "nearest_neighbor", "calculate_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c7057d623b709d5abb7249147ed53b5ae4e2b4dc
2be8daf23b977dfd5f78f71fb5eba65ab624e6c2
v1.0
instruct
Filter
Filter_14130_I
### Lane Detection Lane detection is a critical component in autonomous vehicles. It can be achieved through various techniques, including machine learning and traditional computer vision methods. #### Background Lane detection involves identifying the boundaries of lanes on a road, which can be challenging due to var...
import cv2 import numpy as np def process_frame(frame): """ Process a single frame to detect lanes using the Hough Transform technique. Args: frame (ndarray): The input video frame. Returns: ndarray: The frame with lane markings detected and highlighted. """ # Convert the fram...
import pytest import cv2 from solution import process_frame def test_process_frame(): # Create a black test frame black_frame = np.zeros((720, 1280, 3), dtype=np.uint8) # Add white lane markings cv2.line(black_frame, (600, 700), (700, 500), (255, 255, 255), 10) cv2.line(black_frame, (900, 700)...
[ { "docstring": "Process a single frame to detect lanes using the Hough Transform technique.\n\nArgs:\nframe (ndarray): The input video frame.\n\nReturns:\nndarray: The frame with lane markings detected and highlighted.", "function_declaration": "def process_frame(frame):", "function_name": "process_fram...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import cv2\nimport numpy as np\n\ndef detect_lanes(video_file):\n # Load the video capture device\n cap = cv2.VideoCapture(video_file)\n\n while cap.isOpened():\n # Read a fram...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014130", "row_id": 14130, "seed_ids": "['Llama-3.3-70B-Instruct_36511']" }
0.379918
Filter_14130
I
[ "process_frame", "lane_detection" ]
2
[ [ "lane_detection", "process_frame" ] ]
1
[]
false
[]
false
pytest
true
[ "cv2", "numpy" ]
false
ccf939626926d9a2a8f1936c72cf7bcac398a02f
2a67d5141c7c1d0cad25344c73edb9b8bbaf6286
v1.0
instruct
Filter
Filter_14145_I
I have been tasked with writing a program to generate random cave maps for a game, and I have been trying to use a technique called "cave generation" to create realistic caverns. However, I'm struggling to create natural-looking caves using this method. The Delaunay triangulation algorithm is often used in cave genera...
import random import matplotlib.pyplot as plt from scipy.spatial import Delaunay def generate_random_points(num_points, x_range, y_range): points = [(random.uniform(*x_range), random.uniform(*y_range)) for _ in range(num_points)] return points def delaunay_triangulation(points): tri = Delaunay(points) ...
from solution import generate_random_points, delaunay_triangulation, generate_cave_map def test_generate_random_points(): points = generate_random_points(10, (0, 50), (0, 50)) assert len(points) == 10 for x, y in points: assert 0 <= x <= 50 assert 0 <= y <= 50 def test_delaunay_triangulati...
[ { "docstring": null, "function_declaration": "def generate_random_points(num_points, x_range, y_range):", "function_name": "generate_random_points", "parameter_list": "(num_points, x_range, y_range)" }, { "docstring": null, "function_declaration": "def delaunay_triangulation(points):", ...
[ 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\nimport matplotlib.pyplot as plt\nfrom scipy.spatial import Delaunay\n\ndef generate_random_points(num_points, width, height):\n \"\"\"\n Generate a set of random poin...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014145", "row_id": 14145, "seed_ids": "['Llama-3.3-70B-Instruct_36533']" }
0.355752
Filter_14145
I
[ "generate_random_points", "delaunay_triangulation", "plot_triangles", "generate_cave_map" ]
4
[ [ "generate_cave_map", "delaunay_triangulation" ], [ "generate_cave_map", "generate_random_points" ], [ "generate_cave_map", "plot_triangles" ] ]
3
[]
false
[]
false
pytest
true
[ "matplotlib", "scipy" ]
false
ae866d373aea22bf2d020b089d71056c75a487df
9229df4fabf0910c75276d71427c2e0b433621a3
v1.0
instruct
Filter
Filter_14178_I
I have a vast collection of my favorite TV shows and movies. I have a list of the titles in a text file named "list.txt". The titles are written in the following format: "Title (Year) - Genre". I want to create a program that can read the text file and parse the titles into an organized data structure. I'd like the pro...
import re def parse_title(title): """ Parses a single line of title in the format "Title (Year) - Genre". Returns the title, year, and genres in a dictionary. """ pattern = r"^(.*) \((\d{4})\) - (.*)$" match = re.match(pattern, title.strip()) if not match: raise ValueError(f"Invalid...
import pytest from solution import parse_title, read_titles_from_file, write_titles_to_file, add_title def test_parse_title_valid(): assert parse_title("The Shawshank Redemption (1994) - Drama") == { "title": "The Shawshank Redemption", "year": 1994, "genres": ["Drama"] } assert par...
[ { "docstring": "Parses a single line of title in the format \"Title (Year) - Genre\".\nReturns the title, year, and genres in a dictionary.", "function_declaration": "def parse_title(title):", "function_name": "parse_title", "parameter_list": "(title)" }, { "docstring": "Reads titles from a ...
[ 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 parse_title(title):\n \"\"\"\n Parses a single title string in the format \"Title (Year) - Genre\"\n and returns the title, year, and genres.\n \"\"\"\n pattern...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014178", "row_id": 14178, "seed_ids": "['Llama-3.3-70B-Instruct_36614']" }
0.670776
Filter_14178
I
[ "parse_title", "read_titles_from_file", "write_titles_to_file", "add_title" ]
4
[ [ "read_titles_from_file", "parse_title" ] ]
1
[]
false
[]
false
pytest
true
[]
true
13bba46b213a8ceb6f5064a557181ee289fc9ed7
d5f154c74a24a16a2c67df566f1aac4fcd3ddc3c
v1.0
instruct
Filter
Filter_14221_I
I have a program that reads lines from a file and does some processing on them. I have a while loop that reads the lines and performs the following actions: - reads a line - strips the line of leading and trailing whitespace - checks if the line starts with a comment character (
def process_line(line): """ Placeholder function for processing a line (implementation detail would vary). """ # For demonstration purposes, let's simply return the line in uppercase. return line.upper() def read_and_process_lines(file_path): processed_lines = [] with open(file_pat...
import tempfile import os from solution import read_and_process_lines, process_line def create_temp_file(content): temp_file = tempfile.NamedTemporaryFile(delete=False, mode='w') temp_file.write(content) temp_file.close() return temp_file.name def test_process_line(): assert process_line("hello") ...
[ { "docstring": "Placeholder function for processing a line (implementation detail would vary).", "function_declaration": "def process_line(line):", "function_name": "process_line", "parameter_list": "(line)" }, { "docstring": null, "function_declaration": "def read_and_process_lines(file...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def process_line(line):\n \"\"\"\n Placeholder function for processing a line (implementation detail would vary).\n \"\"\"\n # For demonstration purposes, let's simply return the l...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00014221", "row_id": 14221, "seed_ids": "['Llama-3.3-70B-Instruct_36717']" }
0.34534
Filter_14221
I
[ "process_line", "read_and_process_lines" ]
2
[ [ "read_and_process_lines", "process_line" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4cbb6aaf10168e993013c1e348da853e840c0db3
7495019cf2479fe08390247f47a5e96ef5a30be3
v1.0
instruct
Filter
Filter_14222_I
Please write a code that can display 4 different games that a user can play in a text-based interface. Each game should have a unique description and a unique name. This code should be able to handle user inputs and should be able to start each game when the user chooses.
def game_selection_interface(): """ Displays 4 different games and allows the user to select one to start. """ games = { "1": {"name": "Tic-Tac-Toe", "description": "A simple tic-tac-toe game."}, "2": {"name": "Guess the Number", "description": "Try to guess the randomly selected number....
from solution import game_selection_interface, start_game def test_game_selection_interface(monkeypatch): choices = iter(['1']) # Simulate user choosing the first game monkeypatch.setattr('builtins.input', lambda _: next(choices)) # Capture output for assertion import io import sys capture...
[ { "docstring": "Displays 4 different games and allows the user to select one to start.", "function_declaration": "def game_selection_interface():", "function_name": "game_selection_interface", "parameter_list": "()" }, { "docstring": "Starts the specified game.", "function_declaration": ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def game_selection_interface():\n \"\"\"\n Displays 4 different games and allows the user to select one to start.\n \"\"\"\n games = {\n \"1\": {\"name\": \"Tic-Tac-Toe\", \...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00014222", "row_id": 14222, "seed_ids": "['Llama-3.3-70B-Instruct_36718']" }
0.441293
Filter_14222
I
[ "game_selection_interface", "start_game", "start_tic_tac_toe", "start_guess_the_number", "start_hangman", "start_rock_paper_scissors" ]
6
[ [ "game_selection_interface", "start_game" ], [ "start_game", "start_guess_the_number" ], [ "start_game", "start_hangman" ], [ "start_game", "start_rock_paper_scissors" ], [ "start_game", "start_tic_tac_toe" ] ]
5
[]
false
[]
false
pytest
true
[]
true
3fa112da9c389c6fc006fc30aff20a213a90e2a5
968a3eafc7f8f2cfbc63fd21aeb9b8a185ba7b2a
v1.0
instruct
Filter
Filter_14236_I
I would like to create a simple calculator that includes the following operations: Addition, Subtraction, Multiplication, and Division. Below is my current code: ```python def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): if y == 0: ...
def add(numbers): total = 0 for num in numbers: total += num return total def subtract(numbers): total = numbers[0] for num in numbers[1:]: total -= num return total def multiply(numbers): total = 1 for num in numbers: total *= num return total def divide(n...
def test_add(): assert add([2, 5, 7, 1]) == 15 assert add([1, 2, 3]) == 6 assert add([0, 0, 0]) == 0 def test_subtract(): assert subtract([10, 4, 1]) == 5 assert subtract([10]) == 10 assert subtract([0, 0, 0]) == 0 def test_multiply(): assert multiply([2, 3, 4]) == 24 assert multiply([...
[ { "docstring": null, "function_declaration": "def add(numbers):", "function_name": "add", "parameter_list": "(numbers)" }, { "docstring": null, "function_declaration": "def subtract(numbers):", "function_name": "subtract", "parameter_list": "(numbers)" }, { "docstring": n...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def add(numbers):\n total = 0\n for num in numbers:\n total += num\n return total\n\ndef subtract(numbers):\n total = numbers[0]\n for num in numbers[1:]:\n total ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014236", "row_id": 14236, "seed_ids": "['Llama-3.3-70B-Instruct_36747']" }
0.600425
Filter_14236
I
[ "add", "subtract", "multiply", "divide", "calculator" ]
5
[ [ "calculator", "add" ], [ "calculator", "divide" ], [ "calculator", "multiply" ], [ "calculator", "subtract" ] ]
4
[]
false
[]
false
pytest
false
[]
true
ea10f62cc12ece3dd742a621a911968f44eb5949
a513ed74eba46b2658275bfeb9a8d0abb30e15b2
v1.0
instruct
Filter
Filter_14266_I
I am using a Docker container to generate images of math equations using a custom implementation of LaTeX that supports rendering to a raster image. The problem I'm experiencing is that when generating images with largely different dimensions, the container is using a significant amount of memory. I am looking for a wa...
import numpy as np from PIL import Image from io import BytesIO def render(latex_equation: str, width: int, height: int) -> bytes: """ Mock function for rendering LaTeX equation to raster image. This should call the actual LaTeX renderer implementation. """ # Mock rendering: create a blank white im...
import numpy as np from PIL import Image from solution import generate_large_image def test_generate_large_image(): latex_equation = "E = mc^2" width, height = 800, 600 tile_width, tile_height = 200, 150 # Generate the large image large_image = generate_large_image(latex_equation, width, height, ...
[ { "docstring": "Mock function for rendering LaTeX equation to raster image.\nThis should call the actual LaTeX renderer implementation.", "function_declaration": "def render(latex_equation, width, height):", "function_name": "render", "parameter_list": "(latex_equation, width, height)" }, { ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nfrom PIL import Image\nfrom io import BytesIO\n\ndef render(latex_equation: str, width: int, height: int) -> bytes:\n \"\"\"\n Mock function for rendering LaTeX equat...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00014266", "row_id": 14266, "seed_ids": "['Llama-3.3-70B-Instruct_36826']" }
0.301145
Filter_14266
I
[ "render", "generate_image_tile", "generate_large_image" ]
3
[ [ "generate_image_tile", "render" ], [ "generate_large_image", "generate_image_tile" ] ]
2
[]
false
[]
false
pytest
true
[ "PIL", "numpy" ]
false
faad7834ac26586b3e71546bda9b698d06847264
c4a6a77aa5c102d4197b6fea7be5cb005b55001b
v1.0
instruct
Filter
Filter_14272_I
I have a 2D array of shape (100, 100) and each cell in the array can have one of three possible values: -1, 0, or 1. I need to find all the unique sequences of length 5 that can be constructed by moving right, down, or staying at the current cell. The movement is restricted such that if the current cell has a value o...
def is_valid_move(x, y, direction, matrix): rows, cols = len(matrix), len(matrix[0]) if direction == 'right': return y + 1 < cols elif direction == 'down': return x + 1 < rows elif direction == 'stay': return True return False def find_sequences(matrix): rows, cols = len...
import pytest from solution import find_sequences def test_all_ones_matrix(): matrix = [[1 for _ in range(5)] for _ in range(5)] sequences = find_sequences(matrix) assert len(sequences) > 0 # should have some sequences found since all moves are allowed def test_all_minus_ones_matrix(): matrix = [[-1 ...
[ { "docstring": null, "function_declaration": "def is_valid_move(x, y, direction, matrix):", "function_name": "is_valid_move", "parameter_list": "(x, y, direction, matrix)" }, { "docstring": null, "function_declaration": "def find_sequences(matrix):", "function_name": "find_sequences"...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_unique_sequences(grid):\n \"\"\"\n Finds all unique sequences of length 5 in the given 100x100 grid\n by moving right, down, or staying according to the rules.\n \n :pa...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014272", "row_id": 14272, "seed_ids": "['Llama-3.3-70B-Instruct_36837']" }
0.690046
Filter_14272
I
[ "is_valid_move", "find_sequences" ]
2
[ [ "find_sequences", "is_valid_move" ] ]
1
[]
false
[]
false
pytest
true
[]
true
41249da74362c11d48f82b865aa55dd11c5c002a
52de2b1fc677071ea45184e542007c7c79bc7773
v1.0
instruct
Filter
Filter_14310_I
Here's a problem: I'm building an app for a fantasy football league, and I'm trying to decide on the best way to sort the players. I want to sort them by last name, but also want to be able to filter by position (e.g., quarterback, running back, etc.) and then sort the remaining players. I think the best way to do thi...
class Player: def __init__(self, first_name, last_name, position): self.first_name = first_name self.last_name = last_name self.position = position def sort_players_by_last_name(players): return sorted(players, key=lambda x: x.last_name) def filter_by_position(players, position): r...
import pytest from solution import Player, sort_players_by_last_name, filter_by_position, filter_and_sort_players def test_sort_players_by_last_name(): players = [ Player("Tom", "Brady", "Quarterback"), Player("Aaron", "Rodgers", "Quarterback"), Player("Christian", "McCaffrey", "Running Bac...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class Player:\n def __init__(self, first_name, last_name, position):\n self.first_name = first_name\n self.last_name = last_name\n self.position = position\n\n def _...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014310", "row_id": 14310, "seed_ids": "['Llama-3.3-70B-Instruct_36921']" }
0.539828
Filter_14310
I
[ "sort_players_by_last_name", "filter_by_position", "filter_and_sort_players" ]
3
[ [ "filter_and_sort_players", "filter_by_position" ], [ "filter_and_sort_players", "sort_players_by_last_name" ] ]
2
[]
false
[ "Player" ]
true
pytest
true
[]
true
671c1fefaab5775075544d454eccf90582248ed8
959ebf2f3a6f0ca80a721889775f56e3cdfd4852
v1.0
instruct
Filter
Filter_14334_I
I've been presented with a list of US states and I am to create a function that converts them to their respective 2-letter abbreviations. The provided list may contain some invalid state names. For instance if the input is ["Alabama", "Alaska", "Arizona", "InvalidState", "California"], the output should be ["AL", "AK...
def get_state_abbreviation(state_name): """ Returns the 2-letter abbreviation of the given US state name. If the state name is invalid, returns None. """ states = { 'Alabama': 'AL', 'Alaska': 'AK', 'Arizona': 'AZ', 'Arkansas': 'AR', 'California': 'CA', 'Colorado': 'CO', 'Connecticut'...
from solution import convert_states_to_abbreviations def test_convert_valid_states(): states = ["Alabama", "Alaska", "Arizona", "California"] expected = ["AL", "AK", "AZ", "CA"] assert convert_states_to_abbreviations(states) == expected def test_convert_invalid_state(): states = ["InvalidState"] e...
[ { "docstring": "Returns the 2-letter abbreviation of the given US state name.\nIf the state name is invalid, returns None.", "function_declaration": "def get_state_abbreviation(state_name):", "function_name": "get_state_abbreviation", "parameter_list": "(state_name)" }, { "docstring": "Conve...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def state_abbreviations(states):\n \"\"\"\n Converts a list of state names to their respective 2-letter abbreviations.\n \n Args:\n states (list of str): List of state names.\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014334", "row_id": 14334, "seed_ids": "['Llama-3.3-70B-Instruct_36968']" }
0.583896
Filter_14334
I
[ "get_state_abbreviation", "convert_states_to_abbreviations" ]
2
[ [ "convert_states_to_abbreviations", "get_state_abbreviation" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0b700cb6571a8d13cd9145ebec965a684fa7a678
12e0d423c1b35583ee0d6aa42fa1f97a8e38a0c1
v1.0
instruct
Filter
Filter_14359_I
Here are 5 codes that I need to create for a message that encrypts and decrypts the messages. Please help me in creating for the following encryption and decryption algorithms: 1. Caesar Cipher (Shift of 1) 2. Monoalphabetic Cipher (using the letter’s position) 3. Vigenère Cipher (using the keyword “secret”) 4. Atbash...
def caesar_cipher_encrypt(message, shift=1): """ Encrypts a message using Caesar Cipher with a shift of 1. """ encrypted_message = [] for char in message: if char.isalpha(): shift_amount = 65 if char.isupper() else 97 encrypted_message.append(chr((ord(char) + shift - ...
from solution import caesar_cipher_encrypt, caesar_cipher_decrypt def test_caesar_cipher_encrypt(): assert caesar_cipher_encrypt("HELLO") == "IFMMP" assert caesar_cipher_encrypt("hello") == "ifmmp" assert caesar_cipher_encrypt("Hello, World!") == "Ifmmp, Xpsme!" assert caesar_cipher_encrypt("HELLO", 3)...
[ { "docstring": "Encrypts a message using Caesar Cipher with a shift of 1.", "function_declaration": "def caesar_cipher_encrypt(message, shift=1):", "function_name": "caesar_cipher_encrypt", "parameter_list": "(message, shift=1)" }, { "docstring": "Decrypts a message using Caesar Cipher with ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def caesar_cipher_encrypt(message, shift=1):\n \"\"\"\n Encrypt the message using Caesar Cipher with a shift of 1.\n \"\"\"\n encrypted_message = []\n \n for char in message:...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014359", "row_id": 14359, "seed_ids": "['Llama-3.3-70B-Instruct_37011']" }
0.54618
Filter_14359
I
[ "caesar_cipher_encrypt", "caesar_cipher_decrypt" ]
2
[ [ "caesar_cipher_decrypt", "caesar_cipher_encrypt" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ed839fe758d652ba18213b18b999e5a5910296db
21a9dd657e5b7c3f83b0c4ccdb520e0a2b503701
v1.0
instruct
Filter
Filter_14379_I
Here is a Python function that calculates the sum of all prime numbers in a list: ```python def sum_of_primes(numbers): def is_prime(n): """Check if a number is prime.""" if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return...
def sieve_of_eratosthenes(limit): sieve = [True] * (limit + 1) sieve[0] = sieve[1] = False # 0 and 1 are not primes for start in range(2, int(limit**0.5) + 1): if sieve[start]: for multiple in range(start*start, limit + 1, start): sieve[multiple] = False return [num ...
from solution import sum_of_primes def test_sum_of_primes_empty_list(): assert sum_of_primes([]) == 0 def test_sum_of_primes_no_primes(): assert sum_of_primes([1, 4, 6, 8, 10]) == 0 def test_sum_of_primes_all_primes(): assert sum_of_primes([2, 3, 5, 7, 11, 13]) == 41 def test_sum_of_primes_mixed_list():...
[ { "docstring": null, "function_declaration": "def sieve_of_eratosthenes(limit):", "function_name": "sieve_of_eratosthenes", "parameter_list": "(limit)" }, { "docstring": null, "function_declaration": "def sum_of_primes(numbers):", "function_name": "sum_of_primes", "parameter_list...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_of_eratosthenes(limit):\n \"\"\"Generate a list of primes up to the given limit using the Sieve of Eratosthenes.\"\"\"\n sieve = [True] * (limit + 1)\n sieve[0] = sieve[1] =...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014379", "row_id": 14379, "seed_ids": "['Llama-3.3-70B-Instruct_37056']" }
0.576178
Filter_14379
I
[ "sieve_of_eratosthenes", "sum_of_primes" ]
2
[ [ "sum_of_primes", "sieve_of_eratosthenes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
13b99135fdfec99276391235aa1eb23afc91f428
82869bef38248953d1d2fd83b52756708183bf5d
v1.0
instruct
Filter
Filter_14396_I
I have a matrix of 64x64 pixel where each pixel is classified as one of the 64 categories. I need to find all the adjacent pixels that are of the same category as the pixel in the current position. I will traverse the matrix from left to right and top to bottom. For each pixel, I need to mark the connected pixels of ...
import numpy as np from collections import deque # Define the matrix matrix = np.random.randint(0, 64, size=(64, 64)) # Initialize a visited matrix visited = np.zeros((64, 64), dtype='bool') def find_connected_pixels(matrix, x, y): """ Find all adjacent pixels of the same category using BFS. Args: -...
from solution import find_all_connected_components def test_find_connected_pixels(): # Create a simple matrix to test matrix = np.array([ [1, 1, 2, 3], [1, 1, 2, 3], [4, 4, 2, 3], [4, 4, 2, 2] ]) # Expected output: There should be connected components for each group...
[ { "docstring": "Find all adjacent pixels of the same category using BFS.\n\nArgs:\n- matrix: The input matrix.\n- x (int): The current x-coordinate.\n- y (int): The current y-coordinate.\n\nReturns:\n- A list of connected pixels.", "function_declaration": "def find_connected_pixels(matrix, x, y):", "fun...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nfrom collections import deque\n\n# Define the matrix\nmatrix = np.random.randint(0, 64, size=(64, 64))\n\n# Initialize a visited matrix\nvisited = np.zeros((64, 64), dtype=...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014396", "row_id": 14396, "seed_ids": "['Llama-3.3-70B-Instruct_37108']" }
0.481432
Filter_14396
I
[ "find_connected_pixels", "find_all_connected_components" ]
2
[ [ "find_all_connected_components", "find_connected_pixels" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
08929d8d216a04e7ab4592cc08096bb2cf2b945f
74fbb3bec749d15a74dcf68515cb7ccf4a513f19
v1.0
instruct
Filter
Filter_14398_I
Implement the merge sort algorithm to sort a list of integers. The merge sort algorithm works by splitting the input list into two halves, sorting them individually, and then merging the sorted halves.
def merge_sort(arr): """ Sorts an array of integers using the merge sort algorithm. """ if len(arr) <= 1: return arr mid = len(arr) // 2 left_half = merge_sort(arr[:mid]) right_half = merge_sort(arr[mid:]) return merge(left_half, right_half) def merge(left, right): """ ...
from solution import merge_sort def test_merge_sort_empty(): assert merge_sort([]) == [] def test_merge_sort_single_element(): assert merge_sort([1]) == [1] def test_merge_sort_sorted(): assert merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_merge_sort_unsorted(): assert merge_sort([4, 2, 5,...
[ { "docstring": "Sorts an array of integers using the merge sort algorithm.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": "Merges two sorted lists into one sorted list.", "function_declaration": "def merge(left...
[ 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 Perform merge sort on the given list `arr`.\n \n Args:\n arr (list of int): The list of integers to be sorted.\n \n Returns:\n list of i...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014398", "row_id": 14398, "seed_ids": "['Llama-3.3-70B-Instruct_37110']" }
0.656924
Filter_14398
I
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0c5d564ccc648be0c5131a2ef79d7d5d58ff3e94
b7112fec683a3a7689499a2da3e2e4002677a712
v1.0
instruct
Filter
Filter_14399_I
I've got a "word of the day" list that I'd like to use to generate flashcards. Does anyone know how to create a flashcard app using Python? Here is the list of words: scarce, abundant, diminutive, inaugural, garrulous, capricious, enigmatic, indefatigable, perfunctory, vociferous, diligent, ephemeral, odious, obsequi...
import requests import random def get_word_definition(word): """ Fetches the definition of a word from Dictionary API. Args: word (str): The word for which definition is needed. Returns: str: Definition of the word. """ url = f"https://api.dictionaryapi.dev/api/v2/entr...
import pytest from unittest.mock import patch, Mock import requests from solution import get_word_definition, create_word_definition_pairs @patch('requests.get') def test_get_word_definition(mock_get): sample_api_response = [{ "word": "scarce", "meanings": [ { "partOfSpe...
[ { "docstring": "Fetches the definition of a word from Dictionary API.\n\nArgs:\n word (str): The word for which definition is needed.\n\nReturns:\n str: Definition of the word.", "function_declaration": "def get_word_definition(word):", "function_name": "get_word_definition", "parameter_list":...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import requests\nimport random\n\n# Retrieve the definition of a word from the API.\ndef get_word_definition(word):\n url = f\"https://api.dictionaryapi.dev/api/v2/entries/en/{word}\"\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014399", "row_id": 14399, "seed_ids": "['Llama-3.3-70B-Instruct_37113']" }
0.487826
Filter_14399
I
[ "get_word_definition", "create_word_definition_pairs", "flashcard_app" ]
3
[ [ "create_word_definition_pairs", "get_word_definition" ] ]
1
[]
false
[]
false
pytest
true
[ "requests" ]
false
4b12dfcc22dce8ed65c7564fb1a6b1ed7adda715
b64cc2de52e2818fa2e621061f4c4e8ba2bf4c68
v1.0
instruct
Filter
Filter_14401_I
In this task, you will design a Python solution to sort an array of integers using the Merge Sort algorithm. Merge Sort is a divide-and-conquer algorithm that divides the input array into two halves, recursively sorts each half, and then merges them.
def merge_sort(arr): """ Sorts an array of integers using the Merge Sort algorithm. """ if len(arr) <= 1: return arr mid = len(arr) // 2 left_half = arr[:mid] right_half = arr[mid:] left_sorted = merge_sort(left_half) right_sorted = merge_sort(right_half) return merge(...
from solution import merge_sort def test_merge_sort_empty(): assert merge_sort([]) == [] def test_merge_sort_single_element(): assert merge_sort([1]) == [1] def test_merge_sort_sorted_array(): assert merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_merge_sort_reverse_sorted_array(): assert me...
[ { "docstring": "Sorts an array of integers using the Merge Sort algorithm.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { "docstring": "Merge two sorted arrays into one sorted array.", "function_declaration": "def merge(lef...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_sort(arr):\n \"\"\"\n Sorts an array of integers using the Merge Sort algorithm.\n \"\"\"\n if len(arr) <= 1:\n return arr\n\n mid = len(arr) // 2\n left_hal...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014401", "row_id": 14401, "seed_ids": "['Llama-3.3-70B-Instruct_37117']" }
0.676961
Filter_14401
I
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
37a01103cdba7679f271f05a2055c268017d7c94
472be07b0ad991f16e3036cf788c7b748d98c1c7
v1.0
instruct
Filter
Filter_14410_I
Could you provide me with the steps to create a basic 2-player text-based Tic Tac Toe game in Python?
def create_board(): return [" " for _ in range(9)] def print_board(board): for row in [board[i*3:(i+1)*3] for i in range(3)]: print("|" + "|".join(row) + "|") def check_winner(board, player): win_conditions = [(0, 1, 2), (3, 4, 5), (6, 7, 8), (0, 3, 6), (1, 4, 7), (2, 5, 8), ...
from solution import create_board, print_board, check_winner, is_board_full, make_move, switch_player def test_create_board(): assert create_board() == [" "] * 9 def test_check_winner(): board = ["X", "X", "X", " ", " ", " ", " ", " ", " "] assert check_winner(board, "X") == True board = ["X", "O", "X...
[ { "docstring": null, "function_declaration": "def create_board():", "function_name": "create_board", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def print_board(board):", "function_name": "print_board", "parameter_list": "(board)" }, { "docstri...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def create_board():\n return [\" \"] * 9\n\ndef display_board(board):\n for i in range(0, 9, 3):\n print(f\"{board[i]}|{board[i+1]}|{board[i+2]}\")\n if i < 6:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014410", "row_id": 14410, "seed_ids": "['Llama-3.3-70B-Instruct_37136']" }
0.37453
Filter_14410
I
[ "create_board", "print_board", "check_winner", "is_board_full", "make_move", "switch_player", "tic_tac_toe" ]
7
[ [ "tic_tac_toe", "check_winner" ], [ "tic_tac_toe", "create_board" ], [ "tic_tac_toe", "is_board_full" ], [ "tic_tac_toe", "make_move" ], [ "tic_tac_toe", "print_board" ], [ "tic_tac_toe", "switch_player" ] ]
6
[]
false
[]
false
pytest
true
[]
true
6a8a06a2e97bd6f9383f3e0f923bdbc73de46834
c17cc24409cb45e3ebfb9ac962dcdc0c4ce8c01a
v1.0
instruct
Filter
Filter_14418_I
I've been trying to solve this problem for a while, and I could use some help. I'm writing a program that helps with mental math practice. One of the exercises is to multiply a random number by 9. Here's my code: ``` def multiply_by_nine(num): # calculate result result = num * 9 # print result r...
def multiply_by_nine(num): """ Multiplies the given number by 9 and returns the result. """ return num * 9 def get_hint(num): """ Returns the first digit of the result of multiplying the given number by 9. """ result = multiply_by_nine(num) return str(result)[0] def main(): whi...
from solution import multiply_by_nine, get_hint def test_multiply_by_nine(): assert multiply_by_nine(2) == 18 assert multiply_by_nine(5) == 45 assert multiply_by_nine(10) == 90 assert multiply_by_nine(-3) == -27 def test_get_hint(): assert get_hint(2) == '1' assert get_hint(5) == '4' asser...
[ { "docstring": "Multiplies the given number by 9 and returns the result.", "function_declaration": "def multiply_by_nine(num):", "function_name": "multiply_by_nine", "parameter_list": "(num)" }, { "docstring": "Returns the first digit of the result of multiplying the given number by 9.", ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def multiply_by_nine(num):\n \"\"\"\n Multiplies the given number by 9 and returns the result.\n \"\"\"\n return num * 9\n\ndef get_hint(num):\n \"\"\"\n Returns the first di...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014418", "row_id": 14418, "seed_ids": "['Llama-3.3-70B-Instruct_37155']" }
0.6068
Filter_14418
I
[ "multiply_by_nine", "get_hint", "main" ]
3
[ [ "get_hint", "multiply_by_nine" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dfa83b9d95d7621e5c49616c986a33e8c50e6e6c
c4771a8f085a68faf8aa432ebc62560c6c1ea636
v1.0
instruct
Filter
Filter_14440_I
I want to create a simple neural network from scratch using only the NumPy library in Python. Here's what I'd like to help with: 1. Initialize the weights and biases. 2. Implement the Xavier initialization method for the weights. 3. Create a simple feed-forward network with one input layer, one hidden layer, and one o...
import numpy as np def xavier_initialization(shape): """ Xavier initialization for the weights. """ return np.random.randn(*shape) * np.sqrt(2 / sum(shape)) def sigmoid(x): """ Sigmoid activation function. """ return 1 / (1 + np.exp(-x)) def sigmoid_derivative(x): """ Derivati...
from solution import xavier_initialization, sigmoid, sigmoid_derivative, mse_loss, SimpleNeuralNetwork def test_xavier_initialization(): shape = (3, 2) weights = xavier_initialization(shape) assert weights.shape == shape def test_sigmoid(): assert np.isclose(sigmoid(0), 0.5) assert np.isclose(sigm...
[]
[ 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\n\n# Sigmoid and its derivative\ndef sigmoid(x):\n return 1 / (1 + np.exp(-x))\n\ndef sigmoid_derivative(x):\n return x * (1 - x)\n\n# Mean Squared Error Loss\ndef mse...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014440", "row_id": 14440, "seed_ids": "['Llama-3.3-70B-Instruct_37205']" }
0.381252
Filter_14440
I
[ "xavier_initialization", "sigmoid", "sigmoid_derivative", "mse_loss" ]
4
[ [ "sigmoid_derivative", "sigmoid" ] ]
1
[]
false
[ "SimpleNeuralNetwork" ]
true
pytest
true
[ "numpy" ]
false
7295170ebab044c89b7b121759e4e1741e2f5e2c
9e5e554f0425bacf8a37fe477b867ff407b6d9d3
v1.0
instruct
Filter
Filter_14451_I
The given code passes the current date and time as an argument to a function. Here's how you can modify it to pass an arbitrary date and time instead: ```python from datetime import datetime def my_function(date_time): # function body return # example usage date_time = datetime.now() my_function(date_time) `...
from datetime import datetime def my_function(date_time): """ Function that prints the supplied datetime. """ print(f"The entered datetime is: {date_time}") return def get_user_input_and_call_function(): year = int(input("Enter year: ")) month = int(input("Enter month: ")) day = int(in...
import pytest from solution import my_function from datetime import datetime def test_my_function(): date_time = datetime(2024, 1, 1) assert my_function(date_time) == None # The function currently only prints, doesn't return def test_get_user_input_and_call_function(monkeypatch): user_input = "2024\n1\n1...
[ { "docstring": "Function that prints the supplied datetime.", "function_declaration": "def my_function(date_time):", "function_name": "my_function", "parameter_list": "(date_time)" }, { "docstring": null, "function_declaration": "def get_user_input_and_call_function():", "function_na...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from datetime import datetime\n\ndef my_function(date_time):\n \"\"\"\n This function prints the provided datetime.\n \"\"\"\n print(f\"The entered datetime is: {date_time}\")\n\nd...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014451", "row_id": 14451, "seed_ids": "['Llama-3.3-70B-Instruct_37239']" }
0.628929
Filter_14451
I
[ "my_function", "get_user_input_and_call_function" ]
2
[ [ "get_user_input_and_call_function", "my_function" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a94b6f2141b245f4642e8fe3c3360463af98a5c7
fd8b1c2cdd26860487d8cb7033af14de426d3f63
v1.0
instruct
Filter
Filter_14487_I
I need a simple slot machine program. It can have 3 reels and 5 symbols. Can you also have it take bets and pay out wins.
import random def spin_reels(): """ Simulates the spinning of 3 slot machine reels with 5 symbols. Returns: A tuple of 3 elements representing the resulting symbols. """ symbols = ["Cherry", "Lemon", "Orange", "Plum", "Bell"] return random.choice(symbols), random.choice(symbols), r...
import pytest import random from solution import spin_reels, check_win, calculate_payout def test_spin_reels(): reels = spin_reels() assert len(reels) == 3 symbols = {"Cherry", "Lemon", "Orange", "Plum", "Bell"} assert all(reel in symbols for reel in reels) def test_check_win(): assert check_win((...
[ { "docstring": "Simulates the spinning of 3 slot machine reels with 5 symbols.\n\nReturns:\n A tuple of 3 elements representing the resulting symbols.", "function_declaration": "def spin_reels():", "function_name": "spin_reels", "parameter_list": "()" }, { "docstring": "Checks if the spun...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\nclass SlotMachine:\n def __init__(self):\n self.reels = 3\n self.symbols = ['Cherry', 'Lemon', 'Apple', 'Banana', 'Grapes']\n self.payouts = {\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014487", "row_id": 14487, "seed_ids": "['Llama-3.3-70B-Instruct_37324']" }
0.430211
Filter_14487
I
[ "spin_reels", "check_win", "calculate_payout" ]
3
[ [ "calculate_payout", "check_win" ] ]
1
[]
false
[]
false
pytest
true
[]
true
112a170fd5703635cf07b85f2a9939f461b6c9db
45590dd754a3f24213f8e7c09a01603709fa86d2
v1.0
instruct
Filter
Filter_14493_I
Here are the three requirement of the project: 1. develop an interactive shell for a user to input their name 2. develop a simple game where user have to guess a number between 1 to 10 3. develop a greeting module which welcomes the user based on a greeting time of the day Here is a simple code which meets the above r...
import random def get_user_name(name=None): """ Interactive method that asks for the user's name. Optionally takes a name as parameter for testing purposes. """ if name: return name user_name = input("Please enter your name: ") return user_name def guess_number_game(random_number=N...
from solution import get_user_name, guess_number_game, greeting def test_get_user_name(): assert get_user_name("Alice") == "Alice" def test_guess_number_game(monkeypatch): inputs = iter(["3", "7", "6"]) monkeypatch.setattr('builtins.input', lambda _: next(inputs)) output = [] monkeypatch.setattr('...
[ { "docstring": "Interactive method that asks for the user's name.\nOptionally takes a name as parameter for testing purposes.", "function_declaration": "def get_user_name(name=None):", "function_name": "get_user_name", "parameter_list": "(name=None)" }, { "docstring": "Interactive game where...
[ 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_user_name():\n user_name = input(\"Please enter your name: \")\n return user_name\n\ndef guess_number_game():\n random_number = random.randint(1, 10)\n whi...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014493", "row_id": 14493, "seed_ids": "['Llama-3.3-70B-Instruct_37340']" }
0.480266
Filter_14493
I
[ "get_user_name", "guess_number_game", "greeting", "main" ]
4
[ [ "greeting", "get_user_name" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2c08e1155a6405aa4c421f5e06c35c708574f7b1
91bdf3db3fc7c4796ff555283259600187d9e8c9
v1.0
instruct
Filter
Filter_14512_I
I am working on a project where I need to represent conditional statements. I want to understand the differences between the "if-else" statement and the "switch" statement. I'd like to know the syntax, usage, and examples for "if-else" and "switch" in Python. Please provide a detailed explanation and code examples ...
# Explanation and examples for if-else statements and switch statements in Python. # if-else statement in Python: # The if-else statement allows for conditional execution of code blocks based on boolean expressions. def check_number_if_else(number): if number > 0: return "Positive" elif number == 0: ...
from solution import check_number_if_else, check_number_switch, compare_if_else_switch def test_check_number_if_else(): assert check_number_if_else(10) == "Positive" assert check_number_if_else(0) == "Zero" assert check_number_if_else(-5) == "Negative" assert check_number_if_else(100) == "Positive" ...
[ { "docstring": null, "function_declaration": "def check_number_if_else(number):", "function_name": "check_number_if_else", "parameter_list": "(number)" }, { "docstring": null, "function_declaration": "def check_number_switch(number):", "function_name": "check_number_switch", "par...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "# Demonstrating if-else statement in Python\ndef if_else_demo(grade):\n if grade >= 90:\n return \"A\"\n elif grade >= 80:\n return \"B\"\n elif grade >= 70:\n re...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014512", "row_id": 14512, "seed_ids": "['Llama-3.3-70B-Instruct_37390']" }
0.457072
Filter_14512
I
[ "check_number_if_else", "check_number_switch", "compare_if_else_switch" ]
3
[ [ "compare_if_else_switch", "check_number_if_else" ], [ "compare_if_else_switch", "check_number_switch" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5802ca4c4ce01a18fb4bf45ce4708242cd89b758
ee5600cd9f5a5fc8bd20871ceda02dc2ef251f68
v1.0
instruct
Filter
Filter_14540_I
### Exercise: Guess My Number # # For this exercise, we will create a number guessing game. The computer will think of a random number between 1 and 100, # and the user will try to guess the number. After each guess, the computer will tell the user if their guess is higher or lower # than the number it's thinking of...
import random def get_user_guess(): """Gets and validates the user's guess.""" while True: try: guess = int(input("Take a guess: ")) if 1 <= guess <= 100: return guess else: print("Please enter a number between 1 and 100.") exc...
import pytest from unittest.mock import patch from solution import get_user_guess, play_game # Mock input for get_user_guess function def test_get_user_guess_valid_input(): with patch('builtins.input', return_value='50'): assert get_user_guess() == 50 def test_get_user_guess_invalid_input_then_valid_input...
[ { "docstring": "Gets and validates the user's guess.", "function_declaration": "def get_user_guess():", "function_name": "get_user_guess", "parameter_list": "()" }, { "docstring": "Plays a round of the number guessing game.", "function_declaration": "def play_game():", "function_name...
[ 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_user_guess():\n \"\"\"Gets and validates the user's guess.\"\"\"\n while True:\n try:\n guess = int(input(\"Take a guess: \"))\n if ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00014540", "row_id": 14540, "seed_ids": "['Llama-3.3-70B-Instruct_37459']" }
0.597325
Filter_14540
I
[ "get_user_guess", "play_game", "main" ]
3
[ [ "play_game", "get_user_guess" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7990069d8815aea6caef422d9a33756bac6b3009
44df12d3a1f3646db18c93ee0acf3e8df8fcfc51
v1.0
instruct
Filter
Filter_14557_I
Create a service that reads data from a text file as a stream, processes the data in real-time, and writes the processed data to a separate file. Provide a detailed explanation of the solution including code snippets and step-by-step breakdown. Use Python as the programming language. Assume the input text file is...
def process_line(line): """ Process a single line of text. For example, let's convert the text to uppercase. You can implement your own logic here. """ return line.upper() def read_and_process_file(input_file, output_file): """ Reads data from input_file as a stream, processes the data ...
from solution import process_line, read_and_process_file import os def test_process_line(): assert process_line("hello\n") == "HELLO\n" assert process_line("world") == "WORLD" def test_read_and_process_file(): input_text = "hello\nworld\n" expected_output_text = "HELLO\nWORLD\n" # Create a te...
[ { "docstring": "Process a single line of text.\nFor example, let's convert the text to uppercase.\nYou can implement your own logic here.", "function_declaration": "def process_line(line):", "function_name": "process_line", "parameter_list": "(line)" }, { "docstring": "Reads data from input_...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def process_line(line):\n \"\"\"\n Process a single line of text.\n For example, let's convert the text to uppercase.\n You can implement your own logic here.\n \"\"\"\n retu...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00014557", "row_id": 14557, "seed_ids": "['Llama-3.3-70B-Instruct_37499']" }
0.424291
Filter_14557
I
[ "process_line", "read_and_process_file" ]
2
[ [ "read_and_process_file", "process_line" ] ]
1
[]
false
[]
false
pytest
true
[]
true
aad4d2c10231f1fa73497b3eedda691a028e1e03
0ff57e7906de6d092fddf25b8b9d2e5c831828dd
v1.0
instruct
Filter
Filter_14576_I
### Programming Challenge: Rock, Paper, Scissors #### Objective Create a Rock, Paper, Scissors game for one player against the computer. The game should: 1. Ask the player for their name. 2. Ask the player for their choice (rock, paper, or scissors). 3. Generate the computer's random choice (rock, paper, or scissors). ...
import random def get_computer_choice(): choices = ["rock", "paper", "scissors"] return random.choice(choices) def determine_winner(player_choice, computer_choice): if player_choice == computer_choice: return "It's a tie!" if (player_choice == "rock" and computer_choice == "scissors") or \ ...
from solution import determine_winner, get_computer_choice def test_determine_winner_tie(): assert determine_winner("rock", "rock") == "It's a tie!" assert determine_winner("paper", "paper") == "It's a tie!" assert determine_winner("scissors", "scissors") == "It's a tie!" def test_determine_winner_player_...
[ { "docstring": null, "function_declaration": "def get_computer_choice():", "function_name": "get_computer_choice", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def determine_winner(player_choice, computer_choice):", "function_name": "determine_winner", ...
[ 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 choices = [\"rock\", \"paper\", \"scissors\"]\n return random.choice(choices)\n\ndef determine_winner(player_choice, computer_choice):\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00014576", "row_id": 14576, "seed_ids": "['Llama-3.3-70B-Instruct_37554']" }
0.60358
Filter_14576
I
[ "get_computer_choice", "determine_winner", "play_game" ]
3
[ [ "play_game", "determine_winner" ], [ "play_game", "get_computer_choice" ] ]
2
[]
false
[]
false
pytest
true
[]
true
eec51080646665fd97cf490875ad01bb3664b1b5
1a842c6fd9526479f33de3740e2806d64638e46a
v1.0
instruct
Filter
Filter_14595_I
I am looking to make a plugin that allows users to create custom playlists using music files from their local hard drive. The plugin should allow users to select a directory, choose which files to include in the playlist, and then save the playlist as a file. I have experience with Python, but I need help with the fo...
import os import tkinter as tk from tkinter import filedialog, messagebox from typing import List def get_music_files(directory: str, file_extensions: List[str] = ['.mp3', '.wav', '.flac']) -> List[str]: """ Retrieves music files from the given directory with specified extensions. """ music_files = [] ...
import os from solution import get_music_files, save_playlist def test_get_music_files(tmpdir): music_dir = tmpdir.mkdir("music") music_file = music_dir.join("song.mp3") music_file.write("dummy data") non_music_file = music_dir.join("document.txt") non_music_file.write("dummy data") retri...
[ { "docstring": "Retrieves music files from the given directory with specified extensions.", "function_declaration": "def get_music_files(directory, file_extensions=['.mp3', '.wav', '.flac']):", "function_name": "get_music_files", "parameter_list": "(directory, file_extensions=['.mp3', '.wav', '.flac...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\nfrom tkinter import Tk, filedialog, Listbox, Button, END, simpledialog\nimport json\n\ndef select_directory():\n root = Tk()\n root.withdraw()\n folder_selected = filedialo...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014595", "row_id": 14595, "seed_ids": "['Llama-3.3-70B-Instruct_37588']" }
0.344734
Filter_14595
I
[ "get_music_files", "save_playlist", "choose_directory", "create_playlist_gui" ]
4
[ [ "create_playlist_gui", "choose_directory" ], [ "create_playlist_gui", "get_music_files" ], [ "create_playlist_gui", "save_playlist" ] ]
3
[]
false
[]
false
pytest
true
[]
true
ee4c959865f9d7c2cee59d36dbb75679d9022702
8160d1d51e5a70927647f48e5f52d09412bf6947
v1.0
instruct
Filter
Filter_14613_I
### Assignment: Counting Primes #### Objective: To practice writing recursive and iterative algorithms for solving the same problem. #### Problem Description: Write a program that counts the number of prime numbers in a given range of integers from `a` to `b` (inclusive). Your program should have two functions: - `c...
def isPrime(n): if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def countPrimesRecursive(a, b): if a > b: return 0 else: return (1 if isPrime(a) else 0) + countPrimesRecursive(a + 1, b) def countPrimesIt...
from solution import isPrime, countPrimesRecursive, countPrimesIterative def test_isPrime(): assert isPrime(2) == True assert isPrime(3) == True assert isPrime(4) == False assert isPrime(17) == True assert isPrime(18) == False assert isPrime(19) == True assert isPrime(1) == False assert...
[ { "docstring": null, "function_declaration": "def isPrime(n):", "function_name": "isPrime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def countPrimesRecursive(a, b):", "function_name": "countPrimesRecursive", "parameter_list": "(a, b)" }, { ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def isPrime(n):\n if n < 2:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True\n\ndef countPrimesRecursive(a, ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014613", "row_id": 14613, "seed_ids": "['Llama-3.3-70B-Instruct_37632']" }
0.757633
Filter_14613
I
[ "isPrime", "countPrimesRecursive", "countPrimesIterative" ]
3
[ [ "countPrimesIterative", "isPrime" ], [ "countPrimesRecursive", "isPrime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
8ef06a29df28bc6a2a6f3c73641fb12e307326ba
0b0c28224fbd86f6584cbba137b37cb2e671b08b
v1.0
instruct
Filter
Filter_14642_I
To determine if a number is prime, we can use the following algorithm: Test if the number is divisible by all prime numbers less than or equal to the square root of the number. Using this algorithm, I have an input list of numbers from 1 to n, where n can be any positive integer, where n >= 1. My task is to output a ...
import math def is_prime(number): """ Determines if a number is a prime. Parameters: number (int): The number to check. Returns: bool: True if number is a prime, otherwise False. """ if number <= 1: return False if number <= 3: return True if number % 2...
from solution import is_prime, list_primes def test_is_prime(): # Test non-primes assert not is_prime(1) assert not is_prime(4) assert not is_prime(9) assert not is_prime(21) # Test primes assert is_prime(2) assert is_prime(3) assert is_prime(5) assert is_prime(13) assert i...
[ { "docstring": "Determines if a number is a prime.\n\nParameters:\nnumber (int): The number to check.\n\nReturns:\nbool: True if number is a prime, otherwise False.", "function_declaration": "def is_prime(number):", "function_name": "is_prime", "parameter_list": "(number)" }, { "docstring": ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(n):\n \"\"\"\n Determines if a number is prime.\n \n Args:\n n (int): The number to check for primality.\n \n Returns:\n bool: True if n is ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014642", "row_id": 14642, "seed_ids": "['Llama-3.3-70B-Instruct_37695']" }
0.700189
Filter_14642
I
[ "is_prime", "list_primes" ]
2
[ [ "list_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
42d8f361f80af15764dcec52263e38a450bedc9f
f09cf5fae6da6ad671a3f0bd4c790fefd5489e32
v1.0
instruct
Filter
Filter_14670_I
Here is the code: ```python import os import fnmatch from typing import List, Dict def get_collection_files(directory: str, file_extension: str) -> List[str]: """ Get the list of files in the specified directory with the specified file extension. :param directory: The directory to search for files. ...
import os import fnmatch from typing import List, Dict, Tuple def get_collection_files(directory: str, file_extension: str) -> List[str]: """ Get the list of files in the specified directory with the specified file extension. :param directory: The directory to search for files. :param file_extensi...
import os from unittest.mock import patch, mock_open import pytest from solution import get_collection_stats, get_collection_files, get_collection_metadata def test_get_collection_files(): with patch('os.listdir', return_value=['file1.txt', 'file2.txt', 'file3.md']): result = get_collection_files('/fake/di...
[ { "docstring": "Get the list of files in the specified directory\nwith the specified file extension.\n\n:param directory: The directory to search for files.\n:param file_extension: The file extension to filter by.\n:return: List of file names with the specified extension.", "function_declaration": "def get_...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\nimport fnmatch\nfrom typing import List, Dict, Tuple\n\ndef get_collection_files(directory: str, file_extension: str) -> List[str]:\n \"\"\"\n Get the list of files in the spe...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014670", "row_id": 14670, "seed_ids": "['Llama-3.3-70B-Instruct_37758']" }
0.611425
Filter_14670
I
[ "get_collection_files", "get_collection_metadata", "get_collection_stats", "main" ]
4
[ [ "get_collection_metadata", "get_collection_files" ], [ "get_collection_stats", "get_collection_files" ] ]
2
[]
false
[]
false
pytest
true
[]
true
14dc0c443e32a209fe23d9dc633380ff7474d961
09ef0047b768de213d75a017ffd7928a1822b34f
v1.0
instruct
Filter
Filter_14685_I
### Combining Code and Explanation Let's consider an example of using decorators to measure the execution time of a function. **Code** ```python import time from functools import wraps def timer_decorator(func): @wraps(func) def wrapper(*args, **kwargs): start_time = time.time() result = func...
import time from functools import wraps def timer_decorator(label=None): def decorator(func): @wraps(func) def wrapper(*args, **kwargs): start_time = time.time() result = func(*args, **kwargs) end_time = time.time() execution_time = end_time - start_t...
import time from io import StringIO import sys import pytest from solution import timer_decorator def test_example_function_execution_time(): @timer_decorator() def example_function(): time.sleep(1) return "Done" start_time = time.time() result = example_function() end_time = time....
[ { "docstring": null, "function_declaration": "def timer_decorator(label=None):", "function_name": "timer_decorator", "parameter_list": "(label=None)" }, { "docstring": null, "function_declaration": "def example_function():", "function_name": "example_function", "parameter_list": ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import time\nfrom functools import wraps\n\ndef timer_decorator(label=None):\n def decorator(func):\n @wraps(func)\n def wrapper(*args, **kwargs):\n start_time = ti...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014685", "row_id": 14685, "seed_ids": "['Llama-3.3-70B-Instruct_37787']" }
0.530084
Filter_14685
I
[ "timer_decorator", "example_function", "another_function" ]
3
[ [ "another_function", "timer_decorator" ], [ "example_function", "timer_decorator" ] ]
2
[]
false
[]
false
pytest
true
[]
true
dd54c83d0606aabd195d08922bb8dfd08a31572c
a341b0149c91ddb4f152afac053c3adbb35e7c50
v1.0
instruct
Filter
Filter_14686_I
How to make a Linear Regression model from scratch in Python without any library like NumPy, Pandas, Scikit-learn or Matplotlib?
def mean(values): return sum(values) / len(values) def variance(values, mean_value): return sum((x - mean_value) ** 2 for x in values) def covariance(x, mean_x, y, mean_y): covar = 0.0 for i in range(len(x)): covar += (x[i] - mean_x) * (y[i] - mean_y) return covar def linear_regression(x,...
from solution import mean, variance, covariance, linear_regression, predict def test_mean(): assert mean([1, 2, 3, 4, 5]) == 3.0 def test_variance(): values = [1, 2, 3, 4, 5] mean_value = mean(values) assert variance(values, mean_value) == 10.0 def test_covariance(): x = [1, 2, 3, 4, 5] y = [...
[ { "docstring": null, "function_declaration": "def mean(values):", "function_name": "mean", "parameter_list": "(values)" }, { "docstring": null, "function_declaration": "def variance(values, mean_value):", "function_name": "variance", "parameter_list": "(values, mean_value)" }, ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def mean(values):\n \"\"\"\n Calculate the mean of a list of values.\n \"\"\"\n return sum(values) / len(values)\n\ndef variance(values, mean):\n \"\"\"\n Calculate the varia...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014686", "row_id": 14686, "seed_ids": "['Llama-3.3-70B-Instruct_37788']" }
0.62795
Filter_14686
I
[ "mean", "variance", "covariance", "linear_regression", "predict" ]
5
[ [ "linear_regression", "covariance" ], [ "linear_regression", "mean" ], [ "linear_regression", "variance" ] ]
3
[]
false
[]
false
pytest
true
[]
true
52c301a87f237d0e96a750bfe322aa7db1d2a3ed
514832dd29faf8b1df46d3a53f624f0380354dd0
v1.0
instruct
Filter
Filter_14696_I
I have multiple text files containing large amounts of text, and I need to remove all non-ASCII characters from them. Here's a example of what I have in a text file: ``` ünicode char ``` And I want it to look like this: ``` nicode char ``` I'm using Python for this task. What would be the best approach?
import os def remove_non_ascii_from_text(text): """ Removes non-ASCII characters from the provided text. Parameters: text (str): The text to process. Returns: str: The text with non-ASCII characters removed. """ return ''.join(char for char in text if ord(char) < 128) def p...
import os import pytest from tempfile import TemporaryDirectory from solution import remove_non_ascii_from_text, process_file, process_directory def test_remove_non_ascii_from_text(): assert remove_non_ascii_from_text("ünicode char") == "nicode char" assert remove_non_ascii_from_text("hello world") == "hello w...
[ { "docstring": "Removes non-ASCII characters from the provided text.\n\nParameters: \ntext (str): The text to process.\n\nReturns: \nstr: The text with non-ASCII characters removed.", "function_declaration": "def remove_non_ascii_from_text(text):", "function_name": "remove_non_ascii_from_text", "par...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef remove_non_ascii(text):\n \"\"\"\n Removes all non-ASCII characters from the given text.\n \"\"\"\n return re.sub(r'[^\\x00-\\x7F]', '', text)\n\ndef process_file(...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014696", "row_id": 14696, "seed_ids": "['Llama-3.3-70B-Instruct_37804']" }
0.537442
Filter_14696
I
[ "remove_non_ascii_from_text", "process_file", "process_directory" ]
3
[ [ "process_directory", "process_file" ], [ "process_file", "remove_non_ascii_from_text" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f6a8dcadd7350a8bfb690daaead1f93c4f40505a
b7ebec854e1cca79d18e8770a76d399bd437f7da
v1.0
instruct
Filter
Filter_14712_I
### Scraping Property Details from Website I have a list of URLs, and I would like to scrape property details from each one. I want the code to scrape the following details: * Title * Price * Description * Address * Latitude * Longitude To do this, I want to use Python with `requests` and `BeautifulSoup`...
import requests from bs4 import BeautifulSoup def scrape_property_details(url): try: # Send GET request response = requests.get(url, timeout=10) response.raise_for_status() # Raise an HTTPError if the HTTP request returned an unsuccessful status code # Parse content of request wit...
import pytest from unittest.mock import patch from bs4 import BeautifulSoup import requests from solution import scrape_property_details, scrape_properties def mock_requests_get(*args, **kwargs): class MockResponse: def __init__(self, content, status_code): self.content = content s...
[ { "docstring": null, "function_declaration": "def scrape_property_details(url):", "function_name": "scrape_property_details", "parameter_list": "(url)" }, { "docstring": null, "function_declaration": "def scrape_properties(urls):", "function_name": "scrape_properties", "parameter...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import requests\nfrom bs4 import BeautifulSoup\nimport pandas as pd\n\ndef scrape_property_details(url):\n try:\n # Send GET request\n response = requests.get(url)\n # ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014712", "row_id": 14712, "seed_ids": "['Llama-3.3-70B-Instruct_37839']" }
0.729575
Filter_14712
I
[ "scrape_property_details", "scrape_properties" ]
2
[ [ "scrape_properties", "scrape_property_details" ] ]
1
[]
false
[]
false
pytest
true
[ "bs4", "requests" ]
false
778955eefd7a5a39c971357482dfe9957b87a522
866de204bc15ea9ec313e62061a45e0ec224adad
v1.0
instruct
Filter
Filter_14727_I
Here is a code snippet in Python to solve a problem. I'll paste the Python code, then explain what the code does and what I need help with. ```python import os import sys def get_user_input(): user_input = input("Please enter file path: ") return user_input def file_exists(file_path): try: with o...
import os import sys import pandas as pd def get_user_input(): user_input = input("Please enter file path: ") return user_input def file_exists(file_path): try: with open(file_path, 'r') as file: return True except FileNotFoundError: return False def is_excel_file(file_pat...
import pytest import pandas as pd from unittest.mock import patch, mock_open from solution import file_exists, is_excel_file, is_valid_file, process_excel_file def test_file_exists(): with patch("builtins.open", mock_open(read_data="data")): assert file_exists("dummy_path.txt") == True with patch("bui...
[ { "docstring": null, "function_declaration": "def get_user_input():", "function_name": "get_user_input", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def file_exists(file_path):", "function_name": "file_exists", "parameter_list": "(file_path)" }, { ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\nimport pandas as pd\n\ndef get_user_input():\n user_input = input(\"Please enter file path: \")\n return user_input\n\ndef file_exists(file_path):\n try:\n with open...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014727", "row_id": 14727, "seed_ids": "['Llama-3.3-70B-Instruct_37873']" }
0.65776
Filter_14727
I
[ "get_user_input", "file_exists", "is_excel_file", "is_valid_file", "process_excel_file", "main" ]
6
[ [ "is_valid_file", "file_exists" ], [ "is_valid_file", "is_excel_file" ] ]
2
[]
false
[]
false
pytest
true
[ "pandas" ]
false
707e32fa56229d16b82e6edb5fef2b4d6884e58f
5290cdce0498b250609807a9a6d4e94b8abae53f
v1.0
instruct
Filter
Filter_14729_I
I have a set of locations and I need to know closest location to my current location. Can you help me write a Python code for finding the closest location based on euclidean distance between two GPS coordinates?
from math import sqrt def euclidean_distance(coord1, coord2): """ Calculate the Euclidean distance between two GPS coordinates. """ return sqrt((coord1[0] - coord2[0]) ** 2 + (coord1[1] - coord2[1]) ** 2) def closest_location(current_location, locations): """ Returns the closest location from ...
from solution import euclidean_distance, closest_location def test_euclidean_distance(): assert euclidean_distance((0, 0), (3, 4)) == 5 assert euclidean_distance((1, 1), (1, 1)) == 0 assert euclidean_distance((1, 2), (4, 6)) == 5 def test_closest_location(): current_location = (0, 0) locations = [...
[ { "docstring": "Calculate the Euclidean distance between two GPS coordinates.", "function_declaration": "def euclidean_distance(coord1, coord2):", "function_name": "euclidean_distance", "parameter_list": "(coord1, coord2)" }, { "docstring": "Returns the closest location from a set of locatio...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef euclidean_distance(coord1, coord2):\n \"\"\"\n Calculate the Euclidean distance between two GPS coordinates.\n \n Parameters:\n coord1 (tuple): A tuple contai...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014729", "row_id": 14729, "seed_ids": "['Llama-3.3-70B-Instruct_37878']" }
0.553295
Filter_14729
I
[ "euclidean_distance", "closest_location" ]
2
[ [ "closest_location", "euclidean_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
89be62962ba48a2091bd057797bbedee192d8410
d186dd4cccd08e598c9144d4b34e821ebb2ea382
v1.0
instruct
Filter
Filter_14754_I
Write a code that monitors and kills any processes holding system files open during system shutdown to ensure a clean shutdown.
import os import subprocess def list_open_files_by_process(): """ Lists open files by processes. """ try: result = subprocess.run(['lsof'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) if result.returncode != 0: raise Exception(result.stderr) f...
import subprocess import os from unittest.mock import patch, MagicMock from solution import list_open_files_by_process, kill_process, monitor_and_kill_processes def test_list_open_files_by_process_no_files(): with patch('subprocess.run') as mock_run: mock_run.return_value = MagicMock(returncode=0, stdout=...
[ { "docstring": "Lists open files by processes.", "function_declaration": "def list_open_files_by_process():", "function_name": "list_open_files_by_process", "parameter_list": "()" }, { "docstring": "Kills the process by given PID.", "function_declaration": "def kill_process(pid):", "...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\nimport psutil\nimport signal\nimport subprocess\n\ndef get_system_files():\n \"\"\"\n Retrieve a list of system-critical files.\n Note: This function would be system-depend...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014754", "row_id": 14754, "seed_ids": "['Llama-3.3-70B-Instruct_37927']" }
0.347331
Filter_14754
I
[ "list_open_files_by_process", "kill_process", "monitor_and_kill_processes" ]
3
[ [ "monitor_and_kill_processes", "kill_process" ], [ "monitor_and_kill_processes", "list_open_files_by_process" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0e0028315272fe455d35d126a3563af18c5c65a4
d7c11567f7aeea788033369cb18b1e0b98faa94e
v1.0
instruct
Filter
Filter_14763_I
Here's the problem: An Enterprise has a security system that can only render warnings for security incidents that meet certain criteria. The criteria are as follows: - The incident must be a security incident - The incident must have been opened in the last 30 days - The incident's source must be Email - The incident'...
import datetime def is_security_incident(incident): return incident.get('type') == 'security' def is_recent_incident(incident): return datetime.datetime.strptime(incident.get('opened_at'), '%Y-%m-%d') >= datetime.datetime.now() - datetime.timedelta(days=30) def is_from_email(incident): return incident.ge...
from solution import is_security_incident, is_recent_incident, is_from_email, is_status_new, should_render_warning import datetime def test_is_security_incident(): incident = {'type': 'security'} assert is_security_incident(incident) == True incident = {'type': 'fraud'} assert is_security_incident...
[ { "docstring": null, "function_declaration": "def is_security_incident(incident):", "function_name": "is_security_incident", "parameter_list": "(incident)" }, { "docstring": null, "function_declaration": "def is_recent_incident(incident):", "function_name": "is_recent_incident", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import datetime\n\ndef is_security_incident(incident):\n return incident.get('type') == 'security'\n\ndef is_recent_incident(incident):\n return datetime.datetime.strptime(incident.get('...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014763", "row_id": 14763, "seed_ids": "['Llama-3.3-70B-Instruct_37953']" }
0.483655
Filter_14763
I
[ "is_security_incident", "is_recent_incident", "is_from_email", "is_status_new", "should_render_warning" ]
5
[ [ "should_render_warning", "is_from_email" ], [ "should_render_warning", "is_recent_incident" ], [ "should_render_warning", "is_security_incident" ], [ "should_render_warning", "is_status_new" ] ]
4
[]
false
[]
false
pytest
true
[]
true
c58dc2d18c831a9005835f231cd826cc9f53ee1f
c0344bfa0892e5aae65a7f45b02940b2231d86ef
v1.0
instruct
Filter
Filter_14785_I
I have a text with different words, some of which are in uppercase and some in lowercase. I want to write a program that counts the number of uppercase and lowercase letters in each word in the text, and then print out the results. Here is an example of what the text might look like: ``` The Quick Brown Fox Jumps Over...
import re def count_case(word): """ Returns the count of uppercase and lowercase letters in the given word. """ uppercase_count = sum(1 for char in word if char.isupper()) lowercase_count = sum(1 for char in word if char.islower()) return uppercase_count, lowercase_count def analyze_text(text)...
from solution import count_case, analyze_text import io import sys def test_count_case(): assert count_case("The") == (1, 2) assert count_case("Quick") == (1, 4) assert count_case("Brown") == (1, 4) assert count_case("Fox") == (1, 2) assert count_case("Jumps") == (1, 4) assert count_case("Over"...
[ { "docstring": "Returns the count of uppercase and lowercase letters in the given word.", "function_declaration": "def count_case(word):", "function_name": "count_case", "parameter_list": "(word)" }, { "docstring": "Analyzes the text and prints the number of uppercase and lowercase letters\n...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_case(text):\n \"\"\"\n Count the number of uppercase and lowercase letters in each word in the text.\n \"\"\"\n import re\n result = []\n\n # Define the regular exp...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00014785", "row_id": 14785, "seed_ids": "['Llama-3.3-70B-Instruct_38002']" }
0.747192
Filter_14785
I
[ "count_case", "analyze_text" ]
2
[ [ "analyze_text", "count_case" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ed9de6a0fd6cde362cbec92685ea2356fa2ea397
80db6b6d0f937365f211ae4d0038924e314993ac
v1.0
instruct
Filter
Filter_14792_I
Here is a Python implementation of the recursive approach to find the closest pair of points in a set of points: ```python import math def distance(p1, p2): return math.sqrt((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2) def brute_force_closest_pair(points): n = len(points) min_distance = float('inf') close...
import math def distance(p1, p2): return math.sqrt((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2) def brute_force_closest_pair(points): n = len(points) min_distance = float('inf') closest_points = [] for i in range(n): for j in range(i + 1, n): dist = distance(points[i], points[j]) ...
from solution import closest_pair_of_points def test_closest_pair_simple(): points = [(0, 0), (1, 1), (2, 2), (3, 3)] expected_pair = [(0, 0), (1, 1)] closest_points, distance = closest_pair_of_points(points) assert set(closest_points) == set(expected_pair) assert distance == math.sqrt(2) def test...
[ { "docstring": null, "function_declaration": "def distance(p1, p2):", "function_name": "distance", "parameter_list": "(p1, p2)" }, { "docstring": null, "function_declaration": "def brute_force_closest_pair(points):", "function_name": "brute_force_closest_pair", "parameter_list": ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef distance(p1, p2):\n return math.sqrt((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)\n\ndef brute_force_closest_pair(points):\n n = len(points)\n min_distance = float('inf...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00014792", "row_id": 14792, "seed_ids": "['Llama-3.3-70B-Instruct_38011']" }
0.691639
Filter_14792
I
[ "distance", "brute_force_closest_pair", "strip_closest", "recursive_closest_pair", "closest_pair_of_points" ]
5
[ [ "brute_force_closest_pair", "distance" ], [ "closest_pair_of_points", "recursive_closest_pair" ], [ "recursive_closest_pair", "brute_force_closest_pair" ], [ "recursive_closest_pair", "strip_closest" ], [ "strip_closest", "distance" ] ]
5
[]
false
[]
false
pytest
true
[]
true
44b33db68d6566403ea5ffcd3ed291e8ad0a1cf8
0a99431944be4399adfee97eabea7afab3d36b9e