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_83116_I
Objective: Create a Python program that simulates a simple dice rolling game. Requirements: The program should ask the user how many dice they want to roll. The program should then simulate rolling that many dice and display the result of each roll. The program should calculate and display the total of all the di...
import random def roll_dice(number_of_dice): """ Simulates rolling a specified number of dice. Args: number_of_dice (int): The number of dice to roll. Returns: tuple: A tuple containing a list of the results of each dice roll and the total sum of the rolls. """ results = [] for _ ...
from solution import roll_dice def test_roll_dice_single_roll(): results, total = roll_dice(1) assert len(results) == 1 assert 1 <= results[0] <= 6 assert total == results[0] def test_roll_dice_multiple_rolls(): results, total = roll_dice(5) assert len(results) == 5 assert all(1 <= roll <=...
[ { "docstring": "Simulates rolling a specified number of dice.\n\nArgs:\nnumber_of_dice (int): The number of dice to roll.\n\nReturns:\ntuple: A tuple containing a list of the results of each dice roll and the total sum of the rolls.", "function_declaration": "def roll_dice(number_of_dice):", "function_n...
[ 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 roll_dice(num_dice):\n \"\"\"\n Simulates rolling num_dice six-sided dice.\n Returns:\n tuple: A tuple containing a list of individual roll results and the...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00083116", "row_id": 83116, "seed_ids": "['gemma-2-27b-it_168784']" }
0.629786
Filter_83116
I
[ "roll_dice", "simulate_dice_game" ]
2
[ [ "simulate_dice_game", "roll_dice" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ac704b252366f98e0a18188e198d0db26ffd8be9
73fbf10121081973f6efa55bac72d05ca9f796b1
v1.0
instruct
Filter
Filter_83123_I
Here's my code for a program that counts the number of prime numbers within a given range: ```python def is_prime(n): """Checks if a number is prime.""" if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def count_primes(start, end): """Counts t...
def is_prime(n): """Checks if a number is prime.""" if n <= 1: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True def count_primes(start, end): """Counts the number of prime numbers within a given range.""" count = 0 for nu...
from solution import is_prime, count_primes # Testing the is_prime function def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(11) == True assert is_prime(0) == False assert is_prime(1) == False assert is_prime(-7) == False...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Counts the number of prime numbers within a given range.", "function_declaration": "def count_primes(start, end):", "func...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Checks 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 r...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00083123", "row_id": 83123, "seed_ids": "['gemma-2-27b-it_168796']" }
0.714981
Filter_83123
I
[ "is_prime", "count_primes" ]
2
[ [ "count_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f331507a806b4d62840a395eac69c5784411a074
796e9f3b12d4bf7d59558cb1ee08d8ab129208b9
v1.0
instruct
Filter
Filter_83133_I
Objective: To create a functional, interactive quiz game that tests users' knowledge about Python programming. Features: Multiple choice questions. Keep track of the user's score. Provide feedback on the user's answers (correct/incorrect). Display the final score at the end. Allow the user to...
import random def ask_question(question, options, answer): print(question) for i, option in enumerate(options): print(f"{i+1}. {option}") user_answer = input("Enter your answer (1-4): ") if int(user_answer) == answer: print("Correct!") return 1 else: print(f"Incorrec...
from solution import ask_question, play_quiz def test_ask_question_correct_answer(capsys): # Return a correct answer to simulate user input def mock_input(prompt): return "1" # Set the input function to mock_input during this test import builtins builtins.input = mock_input co...
[ { "docstring": null, "function_declaration": "def ask_question(question, options, answer):", "function_name": "ask_question", "parameter_list": "(question, options, answer)" }, { "docstring": null, "function_declaration": "def play_quiz(questions):", "function_name": "play_quiz", ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef ask_question(question, options, answer):\n \"\"\"\n Asks the user a question and checks if the answer is correct.\n \"\"\"\n print(question)\n for i, option...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00083133", "row_id": 83133, "seed_ids": "['gemma-2-27b-it_168814']" }
0.565116
Filter_83133
I
[ "ask_question", "play_quiz" ]
2
[ [ "play_quiz", "ask_question" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9f266bf42953848389e2f5ba0e7362b1fdfd915e
319bde5d5425ff701b21e6f456d89f8a9aa93f8a
v1.0
instruct
Filter
Filter_83151_I
These are the rules for the game: **Objective:** Be the first player to reach 100 points. **Gameplay:** * Players take turns rolling a six-sided die. * On their turn, a player can choose to: * **Roll the die:** The number rolled is added to their current score. * **Hold:** Their current score is added to ...
import random def simulate_turn(player_total_score): """ Simulates a single turn for a player in the game of Pig. Arguments: player_total_score -- Current total score of the player. Returns: player_total_score -- Updated total score after the turn. """ turn_score = 0 while Tru...
import pytest from solution import simulate_turn, pig_game def test_simulate_turn(): # Test that simulate_turn produces a valid total score increase score = 50 new_score = simulate_turn(score) assert new_score >= score def test_pig_game_winner(): # Test that the game ends with a valid winner ...
[ { "docstring": "Simulates a single turn for a player in the game of Pig.\n\nArguments:\nplayer_total_score -- Current total score of the player.\n\nReturns:\nplayer_total_score -- Updated total score after the turn.", "function_declaration": "def simulate_turn(player_total_score):", "function_name": "si...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef play_game():\n \"\"\"\n Simulates a game of Pig.\n \"\"\"\n player1_score = 0\n player2_score = 0\n\n current_player = 1 \n\n while player1_score < 10...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00083151", "row_id": 83151, "seed_ids": "['gemma-2-27b-it_168864']" }
0.545885
Filter_83151
I
[ "simulate_turn", "pig_game" ]
2
[ [ "pig_game", "simulate_turn" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c9d3dd0b41245465b9a5eaa7f2cfd493b4cc127a
1308825d985e3b7f3cc5f402f6cc259e266bb6ca
v1.0
instruct
Filter
Filter_83153_I
Here is my code: ```python def is_prime(n): """Checks if a number is prime.""" if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True primes = [] for num in range(2, 100): if is_prime(num): primes.append(num) print(pr...
def is_prime(n): """Checks if a number is prime.""" if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def find_primes_in_range(start, end): """ Returns a list of all prime numbers in the specified range [start, end). ...
from solution import is_prime, find_primes_in_range def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(19) == True assert is_prime(1) == False assert is_prime(0) ...
[ { "docstring": "Checks if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of all prime numbers in the specified range [start, end).", "function_declaration": "def find_primes_in_range(...
[ 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 \"\"\"Checks if a number is prime.\"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00083153", "row_id": 83153, "seed_ids": "['gemma-2-27b-it_168866']" }
0.60036
Filter_83153
I
[ "is_prime", "find_primes_in_range" ]
2
[ [ "find_primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3b097a05826a44767f546a7dd027054d6efcf978
956c51f79f83ffcfffd0b86375b5f7505217b3a2
v1.0
instruct
Filter
Filter_83164_I
I want to create a function that takes a list of strings as input and returns a new list containing only the strings that are palindromes.
def is_palindrome(s): """ Check if the given string s is a palindrome. """ return s == s[::-1] def filter_palindromes(strings): """ Returns a list of only the palindromes found in the input list of strings. Args: strings (list): A list of strings. Returns: list: A list...
from solution import filter_palindromes, is_palindrome def test_is_palindrome(): assert is_palindrome("radar") assert is_palindrome("level") assert not is_palindrome("hello") assert is_palindrome("") def test_filter_palindromes_all_palindromes(): assert filter_palindromes(["madam", "racecar", "lev...
[ { "docstring": "Check if the given string s is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns a list of only the palindromes found in the input list of strings.\n\nArgs:\nstrings (list): A ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Checks if the given string 's' is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef filter_palindromes(strings):\n \"\"\"\n Returns a list ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00083164", "row_id": 83164, "seed_ids": "['gemma-2-27b-it_168897']" }
0.679712
Filter_83164
I
[ "is_palindrome", "filter_palindromes" ]
2
[ [ "filter_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e31562e5fe60960a35c48d6736eaf77a7b05a2a3
3b21feeb1bce8c8c26de4f4a5e362dd4535a6183
v1.0
instruct
Filter
Filter_83202_I
This is a continuation from a previous question: I’ve created a simple text-based game where the player must guess a randomly generated number between 1 and 100. I want to add a feature that keeps track of the number of guesses the player makes. Here's the current code: ```python import random number = random.randi...
import random def initialize_game(difficulty): # Set the number range based on difficulty if difficulty == "easy": return random.randint(1, 50), 50 elif difficulty == "medium": return random.randint(1, 100), 100 elif difficulty == "hard": return random.randint(1, 200), 200 e...
from solution import initialize_game def test_initialize_game_easy(): number, max_range = initialize_game("easy") assert 1 <= number <= 50 assert max_range == 50 def test_initialize_game_medium(): number, max_range = initialize_game("medium") assert 1 <= number <= 100 assert max_range == 100 ...
[ { "docstring": null, "function_declaration": "def initialize_game(difficulty):", "function_name": "initialize_game", "parameter_list": "(difficulty)" }, { "docstring": null, "function_declaration": "def number_guessing_game():", "function_name": "number_guessing_game", "parameter...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef get_number_range(difficulty):\n \"\"\"\n Returns the range of numbers (low, high) based on the difficulty level.\n \n :param difficulty: A string representing ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00083202", "row_id": 83202, "seed_ids": "['gemma-2-27b-it_169026']" }
0.473793
Filter_83202
I
[ "initialize_game", "number_guessing_game" ]
2
[ [ "number_guessing_game", "initialize_game" ] ]
1
[]
false
[]
false
pytest
true
[]
true
93f95f718a31519abfa942f51c445bdf4099bb8d
bb3f82ef7691f4fad9aebf10588aca48fc956206
v1.0
instruct
Filter
Filter_83212_I
This is the last part of the exercise. I've already finished the rest and feel ready to tackle this one. I'm working on a program to simulate a dice rolling game. Here's the situation: * There are two players. * Each player rolls a six-sided die. * The player with the higher roll wins. If they roll the sam...
import random def roll_die(): """Simulates rolling a six-sided die.""" return random.randint(1, 6) def simulate_game(): """Simulates a dice rolling game between two players.""" player1_roll = roll_die() player2_roll = roll_die() if player1_roll > player2_roll: result = "Player 1 wins ...
from solution import roll_die, simulate_game import pytest # Patch the random.randint function to control the output of roll_die in tests from unittest.mock import patch def test_roll_die(): with patch('random.randint', return_value=4): assert roll_die() == 4 def test_simulate_game_player1_wins(): wi...
[ { "docstring": "Simulates rolling a six-sided die.", "function_declaration": "def roll_die():", "function_name": "roll_die", "parameter_list": "()" }, { "docstring": "Simulates a dice rolling game between two players.", "function_declaration": "def simulate_game():", "function_name":...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef roll_die():\n \"\"\"Simulates rolling a six-sided die.\"\"\"\n return random.randint(1, 6)\n\ndef simulate_game():\n \"\"\"Simulates a dice rolling game between t...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00083212", "row_id": 83212, "seed_ids": "['gemma-2-27b-it_169062']" }
0.543451
Filter_83212
I
[ "roll_die", "simulate_game" ]
2
[ [ "simulate_game", "roll_die" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f57fdc7d1f99e888e46aad261ae39a17711c5db1
615fba906725d4a3fbb775d893b4ddf0dab2ee24
v1.0
instruct
Filter
Filter_83215_I
The problem statement says: Given a set of n distinct numbers, find the kth smallest element in the set. **Input:** ``` n: the number of elements in the set (1 <= n <= 10^5) nums: an array of n distinct integers (1 <= nums[i] <= 10^9) k: the desired kth smallest element (1 <= k <= n) ``` **Example:** ``` n = 5 num...
def partition(nums, low, high): pivot = nums[high] i = low - 1 for j in range(low, high): if nums[j] <= pivot: i += 1 nums[i], nums[j] = nums[j], nums[i] nums[i + 1], nums[high] = nums[high], nums[i + 1] return i + 1 def quick_select(nums, low, high, k): if low <...
from solution import findKthSmallest def test_findKthSmallest_simple_case(): nums = [3, 2, 1, 5, 6] k = 2 assert findKthSmallest(nums, k) == 2 def test_findKthSmallest_one_element(): nums = [10] k = 1 assert findKthSmallest(nums, k) == 10 def test_findKthSmallest_unsorted_input(): nums = ...
[ { "docstring": null, "function_declaration": "def partition(nums, low, high):", "function_name": "partition", "parameter_list": "(nums, low, high)" }, { "docstring": null, "function_declaration": "def quick_select(nums, low, high, k):", "function_name": "quick_select", "parameter...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def partition(nums, low, high):\n pivot = nums[high]\n i = low - 1\n for j in range(low, high):\n if nums[j] <= pivot:\n i += 1\n nums[i], nums[j] = nums[...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00083215", "row_id": 83215, "seed_ids": "['gemma-2-27b-it_169071']" }
0.661122
Filter_83215
I
[ "partition", "quick_select", "findKthSmallest" ]
3
[ [ "findKthSmallest", "quick_select" ], [ "quick_select", "partition" ] ]
2
[]
false
[]
false
pytest
true
[]
true
21e755183174ca24e66cddc2492631157ba15e54
825a5c3b467c7336bb781a7421164fce2a158f3b
v1.0
instruct
Filter
Filter_83220_I
Exercise: Find a Python function called `sum_of_primes` that takes a single integer `n` as input and returns the sum of all prime numbers less than or equal to `n`.
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num ** 0.5) + 1, 2): if num % i == 0: return False return True def...
from solution import sum_of_primes def test_sum_of_primes_with_small_numbers(): assert sum_of_primes(10) == 17 # primes are 2, 3, 5, 7 def test_sum_of_primes_with_no_primes(): assert sum_of_primes(1) == 0 # no primes less than or equal to 1 def test_sum_of_primes_with_large_prime(): assert sum_of_prime...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers less than or equal to n.", "function_declaration": "def sum_of_pri...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Returns True if num is a prime number, False otherwise.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n if n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00083220", "row_id": 83220, "seed_ids": "['gemma-2-27b-it_169085']" }
0.68999
Filter_83220
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
12118242419fcd77d6718f180a6b1803bc037415
f1fe231ae0f0a5f1790f56e157a68130c9bb9b00
v1.0
instruct
Filter
Filter_83274_I
Here's a problem: You are playing a game where you roll two six-sided dice. * If the sum of the dice is 7 or 11, you win. * If the sum is 2, 3, or 12, you lose. * If the sum is any other number, that number becomes your "point." You continue rolling the dice until you either roll your "point" again (you win) or you r...
import random def roll_dice(): """Simulates rolling two six-sided dice.""" die1 = random.randint(1, 6) die2 = random.randint(1, 6) return die1 + die2 def play_round(): """Simulates a single round of the dice game.""" total = roll_dice() if total in [7, 11]: return "Win" elif to...
import pytest from solution import roll_dice, play_round, simulate_games def test_roll_dice(): for _ in range(1000): result = roll_dice() assert 2 <= result <= 12 def test_play_round_win_immediate(): random.seed(0) # to reproduce the random results result = [] while len(result) < 100:...
[ { "docstring": "Simulates rolling two six-sided dice.", "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": "Simulates a single round of the dice game.", "function_declaration": "def play_round():", "function_name": "play...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef roll_dice():\n \"\"\"Simulates rolling two six-sided dice.\"\"\"\n die1 = random.randint(1, 6)\n die2 = random.randint(1, 6)\n return die1 + die2\n\ndef play_r...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00083274", "row_id": 83274, "seed_ids": "['gemma-2-27b-it_169257']" }
0.574184
Filter_83274
I
[ "roll_dice", "play_round", "simulate_games" ]
3
[ [ "play_round", "roll_dice" ], [ "simulate_games", "play_round" ] ]
2
[]
false
[]
false
pytest
true
[]
true
cb111ced6e212815ace917688ffdf239705cc6f3
a172b635dc9675cd597612c73117ac38513165e6
v1.0
instruct
Filter
Filter_83280_I
Here's the problem statement: You are given a string representing a sequence of parentheses, and your task is to find the longest valid (well-formed) parentheses substring. Example: Input: "(()" Output: "()" Input: ")()())" Output: "()()" Here's a Python solution using the stack data structure: ```python def lon...
def longest_valid_parentheses(s): """ Returns the longest valid (well-formed) parentheses substring. :param s: Input string containing sequence of parentheses :return: Longest valid parentheses substring """ max_length = 0 stack = [-1] for i in range(len(s)): if s[i] == '(':...
from solution import longest_valid_parentheses def test_longest_valid_parentheses_example1(): assert longest_valid_parentheses("(()") == "()" def test_longest_valid_parentheses_example2(): assert longest_valid_parentheses(")()())") == "()()" def test_longest_valid_parentheses_empty(): assert longest_vali...
[ { "docstring": "Returns the longest valid (well-formed) parentheses substring.\n\n:param s: Input string containing sequence of parentheses\n:return: Longest valid parentheses substring", "function_declaration": "def longest_valid_parentheses(s):", "function_name": "longest_valid_parentheses", "para...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def longest_valid_parentheses(s):\n \"\"\"\n Given a string containing just the characters '(' and ')', this function finds the length of the longest valid (well-formed) parentheses subs...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00083280", "row_id": 83280, "seed_ids": "['gemma-2-27b-it_169271']" }
0.667375
Filter_83280
I
[ "longest_valid_parentheses", "is_valid" ]
2
[ [ "longest_valid_parentheses", "is_valid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4beb3263d5df0f8737b0c56b9f8a2112acc48884
5986f2faf83708ddf17f61dfb3daa62b73032db7
v1.0
instruct
Filter
Filter_83312_I
What are the steps involved in creating a simple calculator using Python?
def add(a, b): """ Returns the sum of a and b. """ return a + b def subtract(a, b): """ Returns the difference between a and b. """ return a - b def multiply(a, b): """ Returns the product of a and b. """ return a * b def divide(a, b): """ Returns the result of...
from solution import add, subtract, multiply, divide, calculator def test_add(): assert add(2, 3) == 5 assert add(-1, 1) == 0 assert add(0, 0) == 0 def test_subtract(): assert subtract(5, 3) == 2 assert subtract(0, 5) == -5 assert subtract(-1, -1) == 0 def test_multiply(): assert multiply...
[ { "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 between a and b.", "function_declaration": "def subtract(a, b):", "function_name": "subtract", "par...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def add(a, b):\n return a + b\n\ndef subtract(a, b):\n return a - b\n\ndef multiply(a, b):\n return a * b\n\ndef divide(a, b):\n if b == 0:\n raise ValueError(\"Cannot divid...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00083312", "row_id": 83312, "seed_ids": "['gemma-2-27b-it_169364']" }
0.515662
Filter_83312
I
[ "add", "subtract", "multiply", "divide", "calculator" ]
5
[ [ "calculator", "add" ], [ "calculator", "divide" ], [ "calculator", "multiply" ], [ "calculator", "subtract" ] ]
4
[]
false
[]
false
pytest
true
[]
true
591c781212995573e18cafca9358a23819e0248a
999f1a05f131d3a508e5630948e8092a8fddceb3
v1.0
instruct
Filter
Filter_83374_I
Here's the problem: Write a program that does the following: 1. Asks the user for a positive integer input. 2. Determines if the entered integer is prime. 3. Prints a message indicating whether the input is prime or not. ```python
def is_prime(n): """ Determines if a number n is prime. :param n: integer, the number to check for primality :return: boolean, True if n is prime, False otherwise """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = ...
from solution import is_prime, check_prime_from_input 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) == False assert is_prime(-...
[ { "docstring": "Determines if a number n is prime.\n:param n: integer, the number to check for primality\n:return: boolean, True if n is prime, False otherwise", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Asks the user ...
[ 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 Determine if the given number n is a prime number.\n \n Args:\n n (int): The number to check.\n \n Returns:\n bool: True if n is prime, Fals...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00083374", "row_id": 83374, "seed_ids": "['gemma-2-27b-it_169538']" }
0.754658
Filter_83374
I
[ "is_prime", "check_prime_from_input" ]
2
[ [ "check_prime_from_input", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
45875227cde8d15c77ba1304392f05482807e029
88b7617cb37acc617c94e2743b800bb86230a5a1
v1.0
instruct
Filter
Filter_83375_I
This is for a personal project. I am trying to make a program that simulates a deck of cards and blackjack. I'm fairly new to programming, and I'm struggling with creating a function that deals cards from the "deck". Here's what I have so far: ```python import random suits = ["Hearts", "Diamonds", "Clubs", "Spades...
import random def create_deck(): suits = ["Hearts", "Diamonds", "Clubs", "Spades"] ranks = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"] deck = [f"{rank} of {suit}" for suit in suits for rank in ranks] random.shuffle(deck) return deck def deal_card(deck): """...
from solution import create_deck, deal_card def test_create_deck_length(): deck = create_deck() assert len(deck) == 52 def test_create_deck_unique_cards(): deck = create_deck() assert len(deck) == len(set(deck)) # All cards should be unique def test_deal_card_reduces_deck_size(): deck = create_d...
[ { "docstring": null, "function_declaration": "def create_deck():", "function_name": "create_deck", "parameter_list": "()" }, { "docstring": "Deals a card from the deck. If the deck is empty, reshuffles and returns a new deck with the dealt card.", "function_declaration": "def deal_card(d...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\nsuits = [\"Hearts\", \"Diamonds\", \"Clubs\", \"Spades\"]\nranks = [\"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"Jack\", \"Queen\", \"King\", \"Ace\"]\n\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00083375", "row_id": 83375, "seed_ids": "['gemma-2-27b-it_169540']" }
0.659892
Filter_83375
I
[ "create_deck", "deal_card" ]
2
[ [ "deal_card", "create_deck" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b2ba52e1431734076cd9027586d040ddef88e216
1f7eb75d7671b87202cb6b4b0fb22f56a930ab6d
v1.0
instruct
Filter
Filter_83379_I
This is the code I have so far: ```python import numpy as np def generate_points(n_points): """Generates n_points random points in 2D within a unit square.""" return np.random.rand(n_points, 2) def distance(point1, point2): """Calculates the Euclidean distance between two points.""" return np.sqrt((...
import numpy as np def generate_points(n_points): """Generates n_points random points in 2D within a unit square.""" return np.random.rand(n_points, 2) def distance(point1, point2): """Calculates the Euclidean distance between two points.""" return np.sqrt(((point1 - point2)**2).sum()) def closest_pa...
from solution import generate_points, distance, closest_pair import numpy as np def test_generate_points(): points = generate_points(5) assert points.shape == (5, 2) assert np.all(points >= 0) and np.all(points <= 1) def test_distance(): point1 = np.array([0, 0]) point2 = np.array([3, 4]) asse...
[ { "docstring": "Generates n_points random points in 2D within a unit square.", "function_declaration": "def generate_points(n_points):", "function_name": "generate_points", "parameter_list": "(n_points)" }, { "docstring": "Calculates the Euclidean distance between two points.", "function...
[ 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_points(n_points):\n \"\"\"Generates n_points random points in 2D within a unit square.\"\"\"\n return np.random.rand(n_points, 2)\n\ndef distance(point...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00083379", "row_id": 83379, "seed_ids": "['gemma-2-27b-it_169549']" }
0.777156
Filter_83379
I
[ "generate_points", "distance", "closest_pair" ]
3
[ [ "closest_pair", "distance" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
64eb491df698798f94241fcc9c73029dfd183a15
463557d238ebd04055b134f9d3aec0194cea4d19
v1.0
instruct
Filter
Filter_83405_I
Create a Python program that reads a list of numbers from a file named "numbers.txt" and calculates the average of all the numbers in the file.
def read_numbers(file_path): """ Reads a list of numbers from a file. Each number is expected to be on a new line. Parameters: file_path (str): The path to the file containing numbers. Returns: list of float: The list of numbers read from the file. """ numbers = [] with open(fi...
from solution import read_numbers, calculate_average, average_from_file import os def test_read_numbers(tmpdir): file_path = tmpdir.join("numbers.txt") file_path.write("1\n2\n3.5\n4") expected = [1.0, 2.0, 3.5, 4.0] result = read_numbers(str(file_path)) assert result == expected def test_read_num...
[ { "docstring": "Reads a list of numbers from a file. Each number is expected to be on a new line.\n\nParameters:\nfile_path (str): The path to the file containing numbers.\n\nReturns:\nlist of float: The list of numbers read from the file.", "function_declaration": "def read_numbers(file_path):", "funct...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "Magpie-Filter-89K_sanitized_prepared1_results_combined.jsonl", "solution_code": "def calculate_average_from_file(filename):\n \"\"\"\n Reads a list of numbers from a file and calculates the average.\n \n Parameters:\n filename (str):...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00083405", "row_id": 83405, "seed_ids": "['gemma-2-27b-it_169631']" }
0.648603
Filter_83405
I
[ "read_numbers", "calculate_average", "average_from_file" ]
3
[ [ "average_from_file", "calculate_average" ], [ "average_from_file", "read_numbers" ] ]
2
[]
false
[]
false
pytest
true
[]
true
bdc84fc43139127ada959f464cfb4c97e824626e
52a9dfc9c77917b5998a53eb562f4880ab83f8bc
v1.0
instruct
Filter
Filter_83423_I
The game involves rolling a single six-sided die. Players bet on whether the outcome will be odd or even. Here's a breakdown of the game: * **Payout:** If a player bets correctly, they win an amount equal to their bet. * **Loss:** If a player bets incorrectly, they lose their bet. **Here's how you could represent t...
import random def roll_die(): """Simulate rolling a six-sided die and return the result.""" return random.randint(1, 6) def evaluate_bet(bet, roll): """Evaluate the bet against the roll outcome.""" if (roll % 2 == 0 and bet == "even") or (roll % 2 != 0 and bet == "odd"): return "win" else:...
from solution import roll_die, evaluate_bet, play_dice_game def test_roll_die(): for _ in range(100): roll = roll_die() assert 1 <= roll <= 6, f"Roll out of bounds: {roll}" def test_evaluate_bet_win(): assert evaluate_bet("odd", 1) == "win" assert evaluate_bet("odd", 3) == "win" assert...
[ { "docstring": "Simulate rolling a six-sided die and return the result.", "function_declaration": "def roll_die():", "function_name": "roll_die", "parameter_list": "()" }, { "docstring": "Evaluate the bet against the roll outcome.", "function_declaration": "def evaluate_bet(bet, roll):",...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef roll_die():\n \"\"\"Simulate rolling a six-sided die and return the result.\"\"\"\n return random.randint(1, 6)\n\ndef evaluate_bet(bet, roll):\n \"\"\"Evaluate t...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00083423", "row_id": 83423, "seed_ids": "['gemma-2-27b-it_169702']" }
0.501808
Filter_83423
I
[ "roll_die", "evaluate_bet", "play_dice_game" ]
3
[ [ "play_dice_game", "evaluate_bet" ], [ "play_dice_game", "roll_die" ] ]
2
[]
false
[]
false
pytest
true
[]
true
71d6b5551cd2b7528458482af30922eef2baf6df
64f8b45288baae96499dfb9f63bc387d5470d364
v1.0
instruct
Filter
Filter_83467_I
I have a list of numbers in a Python list. I have a function that takes a single number and returns True if the number is prime, False otherwise. How can I efficiently use this function to determine which numbers in the list are prime?
def is_prime(n): """ Returns True if the number is prime, False otherwise. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False ...
from solution import is_prime, filter_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(16) == False assert is_prime(17) == True assert is_prime(-1) == False assert is_prime(0) == Fals...
[ { "docstring": "Returns True if the number is prime, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the input list of numbers.", "function_declaration": "def filte...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if the number is prime, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00083467", "row_id": 83467, "seed_ids": "['gemma-2-27b-it_169841']" }
0.761632
Filter_83467
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c16e9e0375eb48d8dd0b3e2d7d37f04f786dd40c
b07bd74e805ce7200ba62690cea7c09b90cc9a27
v1.0
instruct
Filter
Filter_83517_I
This program will prompt the user to enter five words. The program will then determine if any of the words are palindromes and print out the results.
def is_palindrome(word): """ Check if a word is a palindrome. Parameters: word (str): The word to check. Returns: bool: True if the word is a palindrome, False otherwise. """ return word == word[::-1] def check_palindromes(words): """ Check which words in a list are palindrome...
from solution import is_palindrome, check_palindromes def test_is_palindrome(): assert is_palindrome("radar") == True assert is_palindrome("level") == True assert is_palindrome("world") == False assert is_palindrome("madam") == True assert is_palindrome("hello") == False assert is_palindrome(""...
[ { "docstring": "Check if a word is a palindrome.\n\nParameters:\nword (str): The word to check.\n\nReturns:\nbool: True if the word is a palindrome, False otherwise.", "function_declaration": "def is_palindrome(word):", "function_name": "is_palindrome", "parameter_list": "(word)" }, { "docst...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(word):\n \"\"\"\n Check if a given word is a palindrome.\n \"\"\"\n return word == word[::-1]\n\ndef check_palindromes(words):\n \"\"\"\n Given a list of wo...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00083517", "row_id": 83517, "seed_ids": "['gemma-2-27b-it_169983']" }
0.689078
Filter_83517
I
[ "is_palindrome", "check_palindromes" ]
2
[ [ "check_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f9b5184846d7474dfb9a50466ab8e3b379529fcd
a1b094e2e34f8e5ea9691a6abb5e7a2512c50b8c
v1.0
instruct
Filter
Filter_83518_I
Objective: Create a Python program that simulates a simple dice rolling game against the computer. Game Rules: 1. The user and the computer each roll a six-sided die. 2. The player with the higher roll wins. 3. If there is a tie, the game ends in a draw. Program Features: The program should use the `random` modul...
import random def roll_die(): """Simulates rolling a six-sided die.""" return random.randint(1, 6) def play_dice_game(): user_roll = roll_die() computer_roll = roll_die() result = { "user_roll": user_roll, "computer_roll": computer_roll, "outcome": "" } if...
from solution import roll_die, play_dice_game def test_roll_die(): result = roll_die() assert 1 <= result <= 6 def test_play_dice_game_user_wins(monkeypatch): monkeypatch.setattr('solution.roll_die', lambda: 5) result = play_dice_game() assert result["user_roll"] == 5 assert result["computer_r...
[ { "docstring": "Simulates rolling a six-sided die.", "function_declaration": "def roll_die():", "function_name": "roll_die", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def play_dice_game():", "function_name": "play_dice_game", "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 roll_die():\n \"\"\"Simulates rolling a six-sided die.\"\"\"\n return random.randint(1, 6)\n\ndef play_dice_game():\n user_roll = roll_die()\n computer_roll = ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00083518", "row_id": 83518, "seed_ids": "['gemma-2-27b-it_169984']" }
0.525253
Filter_83518
I
[ "roll_die", "play_dice_game" ]
2
[ [ "play_dice_game", "roll_die" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4be4ac6a26e141d25da5b2bb3121fa71822cc1d5
dcfcb0467d58e0cbd5b4fc5806428ef76debfb24
v1.0
instruct
Filter
Filter_83523_I
Part A: Write a Python function called `count_occurrences` that takes a list of strings as input and returns a dictionary where the keys are the unique strings in the list and the values are the number of times each string appears in the list. Part B: Write a Python function called `most_frequent` that takes a list ...
import re from collections import Counter def count_occurrences(strings): """ Returns a dictionary of string occurrences. Parameters: strings (list): List of strings Returns: dict: A dictionary with strings as keys and their counts as values """ return dict(Counter(strings)) ...
from solution import count_occurrences, most_frequent, extract_words, main def test_count_occurrences(): assert count_occurrences(['a', 'b', 'a', 'c', 'b', 'a']) == {'a': 3, 'b': 2, 'c': 1} assert count_occurrences(['apple', 'banana', 'apple']) == {'apple': 2, 'banana': 1} assert count_occurrences([]) == {...
[ { "docstring": "Returns a dictionary of string occurrences.\n\nParameters:\nstrings (list): List of strings\n\nReturns:\ndict: A dictionary with strings as keys and their counts as values", "function_declaration": "def count_occurrences(strings):", "function_name": "count_occurrences", "parameter_li...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\nimport re\n\ndef count_occurrences(words):\n \"\"\"\n Returns a dictionary where the keys are the unique strings in the list\n and the values are the ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00083523", "row_id": 83523, "seed_ids": "['gemma-2-27b-it_170013']" }
0.751281
Filter_83523
I
[ "count_occurrences", "most_frequent", "extract_words", "main" ]
4
[ [ "most_frequent", "count_occurrences" ] ]
1
[]
false
[]
false
pytest
true
[]
true
5f9d2c3ac7bc2a0346788ca92ee0ed815494827f
d3e0cb4110bdf2cf85c23239acf99d197782f1fc
v1.0
instruct
Filter
Filter_83531_I
Let's say I want to make a game where the player has to guess a secret code. Here's a basic outline: - The computer generates a secret code consisting of 4 digits between 0 and 9. - The player enters a 4-digit guess. - The computer provides feedback **Feedback** - For each correct digit in the correct position (exa...
import random def generate_secret_code(length=4): """Generate a secret code consisting of 4 random digits between 0 and 9.""" return [random.randint(0, 9) for _ in range(length)] def get_feedback(secret_code, guess): """Provide feedback in terms of 'bullseyes' and 'cows' for the guess.""" bullseyes = ...
import pytest from solution import generate_secret_code, get_feedback def test_generate_secret_code_length(): code = generate_secret_code() assert len(code) == 4 def test_generate_secret_code_range(): code = generate_secret_code() assert all(0 <= digit <= 9 for digit in code) def test_get_feedback_al...
[ { "docstring": "Generate a secret code consisting of 4 random digits between 0 and 9.", "function_declaration": "def generate_secret_code(length=4):", "function_name": "generate_secret_code", "parameter_list": "(length=4)" }, { "docstring": "Provide feedback in terms of 'bullseyes' and 'cows...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef generate_secret_code():\n \"\"\"\n Generates a random 4-digit secret code with digits between 0 and 9.\n \"\"\"\n return ''.join([str(random.randint(0, 9)) for...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00083531", "row_id": 83531, "seed_ids": "['gemma-2-27b-it_170038']" }
0.563848
Filter_83531
I
[ "generate_secret_code", "get_feedback", "play_game" ]
3
[ [ "play_game", "generate_secret_code" ], [ "play_game", "get_feedback" ] ]
2
[]
false
[]
false
pytest
true
[]
true
117e1210916492d317a9930a39d579236a86695d
9ef1ddd650aa3f2cac85db313c3934d094eb15e2
v1.0
instruct
Filter
Filter_83533_I
This is the code I have: ```python import random def coin_flip( ): return random.choice(['Heads', 'Tails']) def simulate_flips(num_flips): heads_count = 0 for i in range(num_flips): result = coin_flip() if result == 'Heads': heads_count += 1 return heads_count / num_flips
import random def coin_flip(): """ Simulates a coin flip and returns either 'Heads' or 'Tails'. """ return random.choice(['Heads', 'Tails']) def simulate_flips(num_flips): """ Simulates flipping a coin `num_flips` times and returns the proportion of flips that result in 'Heads'. P...
from solution import coin_flip, simulate_flips def test_coin_flip(): result = coin_flip() assert result in ['Heads', 'Tails'], "The result should be 'Heads' or 'Tails'." def test_simulate_flips_invalid(): try: simulate_flips(0) except ZeroDivisionError: assert True, "The function shoul...
[ { "docstring": "Simulates a coin flip and returns either 'Heads' or 'Tails'.", "function_declaration": "def coin_flip():", "function_name": "coin_flip", "parameter_list": "()" }, { "docstring": "Simulates flipping a coin `num_flips` times and returns the proportion of flips that\nresult in '...
[ 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 coin_flip():\n return random.choice(['Heads', 'Tails'])\n\ndef simulate_flips(num_flips):\n heads_count = 0\n for _ in range(num_flips):\n result = coin_fl...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00083533", "row_id": 83533, "seed_ids": "['gemma-2-27b-it_170041']" }
0.587179
Filter_83533
I
[ "coin_flip", "simulate_flips" ]
2
[ [ "simulate_flips", "coin_flip" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dfc3e981ce836bc148e4fe3d48f22070a9660565
e52cccca476f2168c873afc3ceeb5a4d095a33c5
v1.0
instruct
Filter
Filter_83538_I
This is my attempt at a code for solving the Travelling Salesperson Problem using Simulated Annealing: ```python import random import math def distance(city1, city2): """Calculates the Euclidean distance between two cities.""" return math.sqrt((city1[0] - city2[0])**2 + (city1[1] - city2[1])**2) def generate_ran...
import random import math def distance(city1, city2): """ Calculates the Euclidean distance between two cities. """ return math.sqrt((city1[0] - city2[0])**2 + (city1[1] - city2[1])**2) def generate_random_route(cities): """ Generates a random route through all cities. """ return rando...
from solution import distance, generate_random_route, calculate_total_distance def test_distance(): assert distance((0, 0), (3, 4)) == 5 assert distance((1, 1), (1, 1)) == 0 assert distance((-1, -1), (1, 1)) == math.sqrt(8) def test_generate_random_route(): cities = [(1, 2), (3, 4), (5, 6), (7, 8)] ...
[ { "docstring": "Calculates the Euclidean distance between two cities.", "function_declaration": "def distance(city1, city2):", "function_name": "distance", "parameter_list": "(city1, city2)" }, { "docstring": "Generates a random route through all cities.", "function_declaration": "def ge...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport math\n\ndef distance(city1, city2):\n \"\"\"Calculates the Euclidean distance between two cities.\"\"\"\n return math.sqrt((city1[0] - city2[0])**2 + (city1[1] - ci...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00083538", "row_id": 83538, "seed_ids": "['gemma-2-27b-it_170052']" }
0.532167
Filter_83538
I
[ "distance", "generate_random_route", "calculate_total_distance" ]
3
[ [ "calculate_total_distance", "distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
236de97adc1c464822980baee8dee6cf6c35cd9a
4102da52333981984d4c19866ebaa57286404ca5
v1.0
instruct
Filter
Filter_83545_I
Please provide a sample code for implementing a basic CRUD (Create, Read, Update, Delete) operation on a CSV file using Python.
import csv import os # Filename for the CSV file FILENAME = 'data.csv' def create_row(data): """ Appends a new row to the CSV file. :param data: A dictionary containing the data to be added as a new row. """ file_exists = os.path.isfile(FILENAME) with open(FILENAME, mode='a', newline='') ...
from solution import create_row, read_rows, update_row, delete_row, clear_csv def setup_function(function): clear_csv() def test_create_row(): create_row({'id': '1', 'name': 'Alice'}) rows = read_rows() assert len(rows) == 1 assert rows[0]['name'] == 'Alice' def test_read_rows_empty(): rows =...
[ { "docstring": "Appends a new row to the CSV file.\n\n:param data: A dictionary containing the data to be added as a new row.", "function_declaration": "def create_row(data):", "function_name": "create_row", "parameter_list": "(data)" }, { "docstring": "Reads and returns all the rows from th...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import csv\nimport os\n\ndef create_record(filename, record):\n with open(filename, mode='a', newline='') as file:\n writer = csv.writer(file)\n writer.writerow(record)\n\ndef...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00083545", "row_id": 83545, "seed_ids": "['gemma-2-27b-it_170069']" }
0.521415
Filter_83545
I
[ "create_row", "read_rows", "update_row", "delete_row", "clear_csv" ]
5
[ [ "delete_row", "read_rows" ], [ "update_row", "read_rows" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a24cafd71263cd5713941e86f9027f7a86b16e76
6179fe192e4a64276d0afa3311afa1e507e8afee
v1.0
instruct
Filter
Filter_83560_I
**Please generate a Python script** that will: 1. **Take a user-provided number as input.** 2. **Check if the number is prime.** 3. **Print a message indicating whether the number is prime or not.** ```python
def is_prime(n): """ Check if a number is prime. Parameters: n (int): The number to check. Returns: bool: True if the number is prime, False otherwise. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False ...
from solution import is_prime def test_is_prime_negative_number(): assert not is_prime(-5) def test_is_prime_zero(): assert not is_prime(0) def test_is_prime_one(): assert not is_prime(1) def test_is_prime_two(): assert is_prime(2) def test_is_prime_three(): assert is_prime(3) def test_is_prim...
[ { "docstring": "Check if a number is prime.\n\nParameters:\nn (int): The number to check.\n\nReturns:\nbool: True if the number is prime, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Take a user-provide...
[ 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 Parameters:\n n (int): The number to check.\n \n Returns:\n bool: True if the number is prime, False otherw...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00083560", "row_id": 83560, "seed_ids": "['gemma-2-27b-it_170117']" }
0.766885
Filter_83560
I
[ "is_prime", "check_prime" ]
2
[ [ "check_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d1e1fa4b7ac261bcc3635959a5a7bb850d525d75
0db369606b3c5f5af74849fb19da68fdc21c5779
v1.0
instruct
Filter
Filter_83568_I
This is the question: Assuming we have access to a function `isValid(str)` which checks if a string is valid, write a function called `partitionString(str)` that partitions a string into the smallest possible number of valid substrings. Explain the solution and time complexity. **Example:** ``` partitionString("aba...
def partitionString(s): """ Partitions the string into the smallest number of valid substrings. Args: s (str): The input string. Returns: list: A list of valid substrings. """ result = [] i = 0 while i < len(s): for j in range(i + 1, len(s) + 1): if ...
from solution import partitionString, isValid def mock_isValid(s): """ Returns True if the string s is not empty. """ return s != "" def test_empty_string(): assert partitionString('') == [] def test_single_characters(): assert partitionString('a') == ['a'] assert partitionString('abc') =...
[ { "docstring": "Partitions the string into the smallest number of valid substrings.\n\nArgs:\ns (str): The input string.\n\nReturns:\nlist: A list of valid substrings.", "function_declaration": "def partitionString(s):", "function_name": "partitionString", "parameter_list": "(s)" }, { "docst...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "Magpie-Filter-89K_sanitized_prepared1_results_combined.jsonl", "solution_code": "def partitionString(s):\n \"\"\"\n Partitions the string into the smallest number of valid substrings.\n \n Args:\n s (str): The input string.\n \n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00083568", "row_id": 83568, "seed_ids": "['gemma-2-27b-it_170144']" }
0.74058
Filter_83568
I
[ "partitionString", "isValid" ]
2
[ [ "partitionString", "isValid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9b76a06609c376cc051aab3f49adc146efb9df1b
c545ab25cde35b7474e00235ef58127f45dbc9da
v1.0
instruct
Filter
Filter_83571_I
You are given two sorted arrays, A and B, and you are asked to find the median of the merged array. For example: A = [1, 3, 5] B = [2, 4, 6] Median = 3.5 A = [1, 2, 3] B = [4, 5, 6] Median = 3.5 **Here's a breakdown of how to find the median of two sorted arrays:** 1. **Merge the Arrays:** The first step is to...
def find_median_sorted_arrays(A, B): """ Finds the median of the two sorted arrays A and B. """ merged_array = merge_sorted_arrays(A, B) n = len(merged_array) if n % 2 == 1: # odd number of elements return merged_array[n // 2] else: # even number of elements return (me...
from solution import find_median_sorted_arrays, merge_sorted_arrays def test_merge_sorted_arrays(): assert merge_sorted_arrays([1, 3, 5], [2, 4, 6]) == [1, 2, 3, 4, 5, 6] assert merge_sorted_arrays([1, 2, 3], [4, 5, 6]) == [1, 2, 3, 4, 5, 6] assert merge_sorted_arrays([], [1, 2, 3]) == [1, 2, 3] assert...
[ { "docstring": "Finds the median of the two sorted arrays A and B.", "function_declaration": "def find_median_sorted_arrays(A, B):", "function_name": "find_median_sorted_arrays", "parameter_list": "(A, B)" }, { "docstring": "Merges two sorted arrays A and B to create a single sorted array.",...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_median_sorted_arrays(A, B):\n \"\"\"\n Finds the median of the two sorted arrays A and B.\n \"\"\"\n merged_array = merge_sorted_arrays(A, B)\n n = len(merged_array)\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00083571", "row_id": 83571, "seed_ids": "['gemma-2-27b-it_170167']" }
0.659249
Filter_83571
I
[ "find_median_sorted_arrays", "merge_sorted_arrays" ]
2
[ [ "find_median_sorted_arrays", "merge_sorted_arrays" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d1dcb76f5c1354cf1485205957047ba27811a45a
71be03db754776342b284b966f114f91b4e13db2
v1.0
instruct
Filter
Filter_83608_I
There are three people playing a game. Each player receives a card with a unique number from 1 to 3. The aim of the game is to guess the cards held by the other two players. Here are the rules: * Each player writes down a guess for each of the other two players' cards. * The guesses are revealed simultaneously. * A...
import random def simulate_round(): cards = [1, 2, 3] random.shuffle(cards) player_cards = { 'A': cards[0], 'B': cards[1], 'C': cards[2] } guesses = { 'A': { 'B': random.choice(cards), 'C': random.choice(cards) }, 'B': { ...
from solution import simulate_round, simulate_game def test_simulate_round(): result = simulate_round() assert 'A' in result assert 'B' in result assert 'C' in result assert sum(result.values()) >= 0 def test_simulate_game_single_round(): result = simulate_game(1) assert 'A' in result ...
[ { "docstring": null, "function_declaration": "def simulate_round():", "function_name": "simulate_round", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def simulate_game(rounds):", "function_name": "simulate_game", "parameter_list": "(rounds)" } ]
[ 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 simulate_round():\n cards = [1, 2, 3]\n random.shuffle(cards)\n \n player_cards = {\n 'A': cards[0],\n 'B': cards[1],\n 'C': cards[2]\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00083608", "row_id": 83608, "seed_ids": "['gemma-2-27b-it_170284']" }
0.610505
Filter_83608
I
[ "simulate_round", "simulate_game" ]
2
[ [ "simulate_game", "simulate_round" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3762e7162d4d367283bfc092bced493e305fd567
a5570572f07a90a7aacb483b6e4d9fd5008cceca
v1.0
instruct
Filter
Filter_83610_I
Create a Python script that compares the performance of different sorting algorithms on randomly generated datasets of varying sizes.
import time import random def bubble_sort(arr): n = len(arr) for i in range(n-1): for j in range(n-i-1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] return arr def insertion_sort(arr): for i in range(1, len(arr)): key = arr[i] j = i-1 ...
import time from solution import bubble_sort, insertion_sort, selection_sort, quick_sort, generate_random_list def test_bubble_sort(): arr = generate_random_list(100) assert bubble_sort(arr) == sorted(arr) def test_insertion_sort(): arr = generate_random_list(100) assert insertion_sort(arr) == sorted(...
[ { "docstring": null, "function_declaration": "def bubble_sort(arr):", "function_name": "bubble_sort", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def insertion_sort(arr):", "function_name": "insertion_sort", "parameter_list": "(arr)" }, { "d...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import time\nimport random\n\ndef bubble_sort(arr):\n n = len(arr)\n for i in range(n-1):\n for j in range(n-i-1):\n if arr[j] > arr[j+1]:\n arr[j], arr[...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00083610", "row_id": 83610, "seed_ids": "['gemma-2-27b-it_170289']" }
0.557724
Filter_83610
I
[ "bubble_sort", "insertion_sort", "selection_sort", "quick_sort", "generate_random_list", "compare_sorting_algorithms" ]
6
[ [ "compare_sorting_algorithms", "generate_random_list" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f90a3c976b2f0279642db9d45bc01d8d08004b73
07da4ab132c3de65c0adf8635166827a0f70efd2
v1.0
instruct
Filter
Filter_83633_I
This is the code for a text adventure game. ```python def show_intro(): print("Welcome to the Lost Temple!") print("You are an adventurer on a quest for a lost artifact.") print("Legend has it that the artifact is hidden inside a dangerous temple.") print("You must explore the temple, solve puzzles, an...
locations = { "entrance": { "description": "You are standing at the entrance of the lost temple.", "exits": {"north": "main_hall"} }, "main_hall": { "description": "You are in a large hall with pillars and torches.", "exits": {"south": "entrance", "east": "treasure_room"} ...
import pytest from solution import move, locations def test_move_north_from_entrance(): assert move("entrance", "north") == "main_hall" def test_move_south_from_main_hall(): assert move("main_hall", "south") == "entrance" def test_move_east_from_main_hall(): assert move("main_hall", "east") == "treasure_...
[ { "docstring": null, "function_declaration": "def show_intro():", "function_name": "show_intro", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def move(current_location, direction):", "function_name": "move", "parameter_list": "(current_location, directi...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "locations = {\n \"entrance\": {\n \"description\": \"You are standing at the entrance of the lost temple.\",\n \"exits\": {\"north\": \"main_hall\"}\n },\n \"main_hall\"...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00083633", "row_id": 83633, "seed_ids": "['gemma-2-27b-it_170363']" }
0.453516
Filter_83633
I
[ "show_intro", "move", "play_game" ]
3
[ [ "play_game", "move" ], [ "play_game", "show_intro" ] ]
2
[]
false
[]
false
pytest
true
[]
true
f653103e8522b43cadf662ef32ed527c7a62876a
ef4d9dc75cd2d65e9439a7938a11886e3ddcc918
v1.0
instruct
Filter
Filter_83635_I
The following problem relates to cryptography. Imagine a scenario where you are trying to send a secret message to a friend across an insecure channel. Caesar cipher is a simple encryption technique that shifts each letter in the plaintext message by a fixed number of positions down the alphabet. For example, with a ...
def encrypt_caesar_cipher(plain_text, shift): """ Encrypts the plain_text using Caesar cipher with the given shift. """ encrypted_message = [] for char in plain_text: # Check for uppercase characters if char.isupper(): encrypted_message.append(chr((ord(char) + shift - 65)...
from solution import encrypt_caesar_cipher, decrypt_caesar_cipher, brute_force_decrypt_caesar_cipher def test_encrypt_caesar_cipher(): assert encrypt_caesar_cipher("HELLO", 3) == "KHOOR" assert encrypt_caesar_cipher("WORLD", 5) == "BTWQI" assert encrypt_caesar_cipher("abc", 2) == "cde" assert encrypt_c...
[ { "docstring": "Encrypts the plain_text using Caesar cipher with the given shift.", "function_declaration": "def encrypt_caesar_cipher(plain_text, shift):", "function_name": "encrypt_caesar_cipher", "parameter_list": "(plain_text, shift)" }, { "docstring": "Decrypts the encrypted_message usi...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "# Solution for Problem 1\ndef caesar_encrypt(plaintext, shift):\n \"\"\"\n Encrypt the given plaintext using Caesar cipher with the given shift value.\n \"\"\"\n encrypted = []\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00083635", "row_id": 83635, "seed_ids": "['gemma-2-27b-it_170370']" }
0.582409
Filter_83635
I
[ "encrypt_caesar_cipher", "decrypt_caesar_cipher", "brute_force_decrypt_caesar_cipher" ]
3
[ [ "brute_force_decrypt_caesar_cipher", "decrypt_caesar_cipher" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c027634bdd81a0ec9f43d3af13fe9252af31c213
1d581fa1916a7003faf634222e567088676e2a77
v1.0
instruct
Filter
Filter_83720_I
You have a string representing a series of chess moves. Your task is to determine if the given sequence is a valid sequence of moves according to the rules of chess. Here are some basic rules of chess: * The board is an 8x8 grid. * Each piece has a specific movement pattern. * Pieces cannot move through other piece...
def is_valid_chess_move_sequence(moves): """ Determines if the given sequence of moves is a valid sequence of moves according to the basic rules of chess. Args: moves (str): A string representing a series of chess moves in standard algebraic notation. Returns: bool: True if the se...
from solution import is_valid_chess_move_sequence, is_valid_move def test_is_valid_chess_move_sequence_valid(): assert is_valid_chess_move_sequence("e2e4 e7e5 g1f3 b8c6 f3e5 d7d6") assert is_valid_chess_move_sequence("e2e4 e7e5") def test_is_valid_chess_move_sequence_invalid_format(): assert not is_va...
[ { "docstring": "Determines if the given sequence of moves is a valid sequence of moves \naccording to the basic rules of chess.\n\nArgs:\nmoves (str): A string representing a series of chess moves in standard algebraic notation.\n\nReturns:\nbool: True if the sequence is valid, False otherwise.", "function_...
[ 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_chess_move_sequence(moves):\n \"\"\"\n Determines if the given sequence of moves is a valid sequence of moves \n according to the basic rules of chess.\n \n Args:\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00083720", "row_id": 83720, "seed_ids": "['gemma-2-27b-it_170610']" }
0.611562
Filter_83720
I
[ "is_valid_chess_move_sequence", "is_valid_move" ]
2
[ [ "is_valid_chess_move_sequence", "is_valid_move" ] ]
1
[]
false
[]
false
pytest
true
[]
true
570411720dd7233b666960eef0d0059c6d54c881
a4e171c3ed287184448bb618c2fb3837d365d8a6
v1.0
instruct
Filter
Filter_83724_I
This is the code I have: ```python import time import random def guess_the_number(): """Lets the user guess a random number between 1 and 100.""" number = random.randint(1, 100) guesses_left = 7 print("I'm thinking of a number between 1 and 100.") while guesses_left > 0: print(f"You have {guesses_le...
import time import random def get_guesses_for_difficulty(difficulty): """Returns the number of guesses allowed based on the difficulty level.""" if difficulty == "easy": return 10 elif difficulty == "medium": return 7 elif difficulty == "hard": return 5 else: raise V...
from solution import get_guesses_for_difficulty def test_get_guesses_for_easy_difficulty(): assert get_guesses_for_difficulty("easy") == 10 def test_get_guesses_for_medium_difficulty(): assert get_guesses_for_difficulty("medium") == 7 def test_get_guesses_for_hard_difficulty(): assert get_guesses_for_dif...
[ { "docstring": "Returns the number of guesses allowed based on the difficulty level.", "function_declaration": "def get_guesses_for_difficulty(difficulty):", "function_name": "get_guesses_for_difficulty", "parameter_list": "(difficulty)" }, { "docstring": "Lets the user guess a random number...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import time\nimport random\n\ndef guess_the_number():\n \"\"\"Lets the user guess a random number between 1 and 100 based on chosen difficulty level.\"\"\"\n\n def get_guesses_left(diffi...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00083724", "row_id": 83724, "seed_ids": "['gemma-2-27b-it_170622']" }
0.499099
Filter_83724
I
[ "get_guesses_for_difficulty", "guess_the_number" ]
2
[ [ "guess_the_number", "get_guesses_for_difficulty" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6fd98100d14dbb24c57710f052b9874ae048c395
cda46f9cbf30f3e6c9b2955c5573dd80681701bf
v1.0
instruct
Filter
Filter_83727_I
You are provided with a text file containing a list of words, one word per line. You need to write a Python script that reads this file and prints out only the words that are palindromes.
def is_palindrome(word): """ Returns True if the word is a palindrome, False otherwise. """ return word == word[::-1] def find_palindromes(file_path): """ Reads a file from the given file path and prints out only the words that are palindromes. Args: file_path (str): Path to the fi...
import pytest from solution import is_palindrome, find_palindromes def test_is_palindrome(): assert is_palindrome("madam") == True assert is_palindrome("racecar") == True assert is_palindrome("python") == False assert is_palindrome("level") == True assert is_palindrome("palindrome") == False def t...
[ { "docstring": "Returns True if the word is a palindrome, False otherwise.", "function_declaration": "def is_palindrome(word):", "function_name": "is_palindrome", "parameter_list": "(word)" }, { "docstring": "Reads a file from the given file path and prints out only the words that are palind...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def read_file(file_path):\n \"\"\"\n Reads a file and returns a list of words.\n \"\"\"\n with open(file_path, 'r') as file:\n words = file.read().splitlines()\n return w...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00083727", "row_id": 83727, "seed_ids": "['gemma-2-27b-it_170631']" }
0.638462
Filter_83727
I
[ "is_palindrome", "find_palindromes" ]
2
[ [ "find_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f0559d59f3b81e8a367b324251b196323a82431a
b153c9ca19d85dd46e0aa3c2f149752c47090f46
v1.0
instruct
Filter
Filter_83734_I
It's time to have some fun with Python! Let's create something playful and interactive: Imagine a mystical garden filled with enchanted flowers. This garden needs a Python script that: 1. **Presents a menu:** * Option 1: "Discover a flower" – Reveals a randomly chosen flower name from a list. * Option 2: "Sme...
import random flowers = [ "Rose", "Tulip", "Daisy", "Sunflower", "Lily", "Orchid", "Lavender", "Peony", "Marigold", "Jasmine" ] descriptions = { "Rose": "a rich and romantic scent that fills your heart with warmth.", "Tulip": "a fresh and delicate aroma hinting at the e...
from solution import discover_flower, smell_flower, leave_garden def test_discover_flower(monkeypatch): responses = [] def mock_print(output): responses.append(output) monkeypatch.setattr("builtins.print", mock_print) try: discover_flower() assert any(flower in re...
[ { "docstring": null, "function_declaration": "def present_menu():", "function_name": "present_menu", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def discover_flower():", "function_name": "discover_flower", "parameter_list": "()" }, { "docstring...
[ 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 display_menu():\n \"\"\"\n Displays the menu to the user.\n \"\"\"\n print(\"\\nWelcome to the mystical garden! What would you like to do?\")\n print(\"1. D...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00083734", "row_id": 83734, "seed_ids": "['gemma-2-27b-it_170654']" }
0.48222
Filter_83734
I
[ "present_menu", "discover_flower", "smell_flower", "leave_garden", "mystical_garden" ]
5
[ [ "mystical_garden", "discover_flower" ], [ "mystical_garden", "leave_garden" ], [ "mystical_garden", "present_menu" ], [ "mystical_garden", "smell_flower" ] ]
4
[]
false
[]
false
pytest
true
[]
true
4c46aade9a528c0a9052522a674eb8f51a6719d3
db9a48759a4b137584e9bbaa711fdaf66e3e749d
v1.0
instruct
Filter
Filter_83753_I
This code generates a random walking pattern, but how to make it more interesting by adding constraints and variations ```python import random def random_walk(steps): x, y = 0, 0 path = [(x, y)] for _ in range(steps): dx, dy = random.choice([(0, 1), (0, -1), (1, 0), (-1, 0)]) x += dx y += dy pat...
import random def in_boundary(x, y, boundary): """ Check if the (x, y) is within the given boundary. Boundary is a tuple (min_x, max_x, min_y, max_y). """ min_x, max_x, min_y, max_y = boundary return min_x <= x <= max_x and min_y <= y <= max_y def random_walk(steps, boundary=None, obstacles=None, ...
from solution import random_walk, in_boundary def test_in_boundary(): assert in_boundary(0, 0, (-5, 5, -5, 5)) assert not in_boundary(6, 0, (-5, 5, -5, 5)) assert not in_boundary(0, 6, (-5, 5, -5, 5)) assert in_boundary(-5, -5, (-5, 5, -5, 5)) def test_random_walk_no_constraints(): path = random_w...
[ { "docstring": "Check if the (x, y) is within the given boundary. Boundary is a tuple (min_x, max_x, min_y, max_y).", "function_declaration": "def in_boundary(x, y, boundary):", "function_name": "in_boundary", "parameter_list": "(x, y, boundary)" }, { "docstring": null, "function_declara...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef in_boundary(x, y, boundary):\n \"\"\"\n Check if the (x, y) is within the given boundary. Boundary is a tuple (min_x, max_x, min_y, max_y).\n \"\"\"\n min_x, m...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00083753", "row_id": 83753, "seed_ids": "['gemma-2-27b-it_170708']" }
0.650382
Filter_83753
I
[ "in_boundary", "random_walk" ]
2
[ [ "random_walk", "in_boundary" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f2694e6d6692af398d9cca39c93dbeb3cafe330c
58a05038a83bc8869f69d2ba8dbfc93878698176
v1.0
instruct
Filter
Filter_83764_I
This is a code snippet for a program that simulates a simple card game: ```python import random suits = ["Hearts", "Diamonds", "Clubs", "Spades"] ranks = ["Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"] def create_deck(): deck = [] for suit in suits: for rank in ranks: dec...
import random suits = ["Hearts", "Diamonds", "Clubs", "Spades"] ranks = ["Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"] rank_values = {"2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9, "10": 10, "Jack": 11, "Queen": 12, "King": 13, "Ace": 14} def create_deck(): deck = ...
from solution import create_deck, shuffle_deck, deal_hand, get_highest_card, determine_winner, coin_flip, rank_values def test_create_deck(): deck = create_deck() assert len(deck) == 52 assert "Ace of Hearts" in deck assert "King of Spades" in deck def test_shuffle_deck(): deck = create_deck() ...
[ { "docstring": null, "function_declaration": "def create_deck():", "function_name": "create_deck", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def shuffle_deck(deck):", "function_name": "shuffle_deck", "parameter_list": "(deck)" }, { "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\n\nsuits = [\"Hearts\", \"Diamonds\", \"Clubs\", \"Spades\"]\nranks = [\"Ace\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"Jack\", \"Queen\", \"King\"]\nra...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00083764", "row_id": 83764, "seed_ids": "['gemma-2-27b-it_170759']" }
0.637385
Filter_83764
I
[ "create_deck", "shuffle_deck", "deal_hand", "get_highest_card", "determine_winner", "coin_flip" ]
6
[ [ "determine_winner", "get_highest_card" ] ]
1
[]
false
[]
false
pytest
true
[]
true
abf02256becaaa6a1da2cf460713b8ee0cb42ba9
3f978747c0da4af430acbf679a70b40b8546e86a
v1.0
instruct
Filter
Filter_83772_I
You are tasked with creating a Python script to evaluate student performance on a multiple-choice quiz. **Script Requirements:** 1. **Input:** The script should take a text file containing quiz questions and answers as input. The file format should be as follows: * Each line represents a question-answer pair. ...
def load_quiz(file_name): """ Loads quiz questions and answers from a file. """ questions = [] answers = [] correct_answers = [] with open(file_name, 'r') as file: for line in file: question, answer = line.strip().split(':') questions.append(question) ...
from solution import load_quiz, evaluate_quiz, performance_summary import io import pytest from unittest.mock import patch def test_load_quiz(tmpdir): quiz_file = tmpdir.join("quiz.txt") quiz_file.write("What is the capital of France?:#Paris\nWhat is 2+2?:#4\n") questions, correct_answers = load_quiz(...
[ { "docstring": "Loads quiz questions and answers from a file.", "function_declaration": "def load_quiz(file_name):", "function_name": "load_quiz", "parameter_list": "(file_name)" }, { "docstring": "Evaluates a multiple choice quiz from a file and interactively prompts user for answers.", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def load_quiz(file_name):\n \"\"\"\n Loads quiz questions and answers from a file.\n \"\"\"\n questions = []\n answers = []\n correct_answers = []\n \n with open(file_n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00083772", "row_id": 83772, "seed_ids": "['gemma-2-27b-it_170774']" }
0.505623
Filter_83772
I
[ "load_quiz", "evaluate_quiz", "performance_summary" ]
3
[ [ "evaluate_quiz", "load_quiz" ], [ "evaluate_quiz", "performance_summary" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fde47a34991d23ee0c34c88a19bdcbec00ba4b9f
41689625f2cdd57d4cc63ac16bac5f17bf55b4f2
v1.0
instruct
Filter
Filter_83777_I
You've been given a text file named "emails.txt" that contains a list of email addresses. Your task is to write a Python script that reads the email addresses from the file, validates them using a regular expression, and prints only the valid email addresses.
import re def validate_email(email): """ Returns True if the email is valid, False otherwise. """ email_regex = re.compile( r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)" ) return re.match(email_regex, email) is not None def get_valid_emails(file_path): """ Reads the ema...
from solution import validate_email, get_valid_emails import tempfile def test_validate_email(): assert validate_email("test@example.com") assert validate_email("user.name+tag+sorting@example.com") assert not validate_email("plainaddress") assert not validate_email("@missingusername.com") assert no...
[ { "docstring": "Returns True if the email is valid, False otherwise.", "function_declaration": "def validate_email(email):", "function_name": "validate_email", "parameter_list": "(email)" }, { "docstring": "Reads the email addresses from the file, validates them, and returns a list of valid ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef read_and_validate_emails(file_path):\n \"\"\"\n Reads email addresses from the given file, validates them, and prints the valid ones.\n \"\"\"\n valid_email_patter...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00083777", "row_id": 83777, "seed_ids": "['gemma-2-27b-it_170801']" }
0.533652
Filter_83777
I
[ "validate_email", "get_valid_emails", "print_valid_emails" ]
3
[ [ "get_valid_emails", "validate_email" ], [ "print_valid_emails", "get_valid_emails" ] ]
2
[]
false
[]
false
pytest
true
[]
true
038eda73da64e2106c2a7b5e6a8e8a049c1da580
0292b527e8f65451dcc8a3b47e0f99dd7e87e9e0
v1.0
instruct
Filter
Filter_83797_I
You are tasked with writing a Python program that simulates a simple game of Rock, Paper, Scissors. Requirements: The program should ask the user for their choice (Rock, Paper, or Scissors). The computer should randomly choose its own choice. The program should determine the winner based on the classic rules of ...
import random def get_computer_choice(): choices = ["Rock", "Paper", "Scissors"] return random.choice(choices) def determine_winner(user_choice, computer_choice): if user_choice == computer_choice: return "Tie" elif (user_choice == "Rock" and computer_choice == "Scissors") or \ (user_...
from solution import get_computer_choice, determine_winner, play_round def test_get_computer_choice(): assert get_computer_choice() in ["Rock", "Paper", "Scissors"] def test_determine_winner(): assert determine_winner("Rock", "Scissors") == "User" assert determine_winner("Rock", "Paper") == "Computer" ...
[ { "docstring": null, "function_declaration": "def get_computer_choice():", "function_name": "get_computer_choice", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def determine_winner(user_choice, computer_choice):", "function_name": "determine_winner", "p...
[ 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 get_winner(user_choice, computer_choice):\n if user_...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00083797", "row_id": 83797, "seed_ids": "['gemma-2-27b-it_170872']" }
0.497635
Filter_83797
I
[ "get_computer_choice", "determine_winner", "play_round" ]
3
[ [ "play_round", "determine_winner" ] ]
1
[]
false
[]
false
pytest
true
[]
true
074df039c3af91c277b44cbf771ec412b50f22bd
59dc564f24ba80612e53763dae7007ee93ea488f
v1.0
instruct
Filter
Filter_83811_I
Problem Statement: You have been tasked with creating a program to generate unique random passwords. This program should: Take user input for the desired password length. Generate a password with the specified length, consisting of uppercase letters, lowercase letters, numbers, and symbols. Ensure each generated p...
import random import string def generate_password(length): """ Generates a random password with the given length. The password will consist of uppercase letters, lowercase letters, numbers, and symbols. Args: length (int): Length of the password to be generated. Returns: str:...
from solution import generate_password, generate_unique_passwords import pytest def test_generate_password_length(): password = generate_password(10) assert len(password) == 10 def test_generate_password_content(): password = generate_password(20) assert any(c.islower() for c in password) assert a...
[ { "docstring": "Generates a random password with the given length.\n\nThe password will consist of uppercase letters, lowercase letters, numbers, and symbols.\n\nArgs:\nlength (int): Length of the password to be generated.\n\nReturns:\nstr: The generated password.", "function_declaration": "def generate_pas...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport string\nfrom typing import List, Set\n\ndef generate_password(length: int) -> str:\n characters = string.ascii_letters + string.digits + \"!@#$%^&()_+[]{}|;':\\\",./<>...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00083811", "row_id": 83811, "seed_ids": "['gemma-2-27b-it_170914']" }
0.690693
Filter_83811
I
[ "generate_password", "generate_unique_passwords" ]
2
[ [ "generate_unique_passwords", "generate_password" ] ]
1
[]
false
[]
false
pytest
true
[]
true
37cb4baea22e239b1c06a729c9e8e7e442bc6ae3
96de0dbf0c82b00fe455c904424dcb7345625ac9
v1.0
instruct
Filter
Filter_83823_I
The Goal: Develop a Python script that analyzes a CSV file containing financial transaction data and identifies potentially fraudulent transactions based on certain criteria. Data Description: The CSV file (`transactions.csv`) contains the following columns: TransactionID: Unique identifier for each transaction ...
import pandas as pd from datetime import datetime, timedelta def load_csv(file_path): return pd.read_csv(file_path) def identify_unusual_transaction_amount(transactions, threshold=500): return transactions['Amount'] > threshold def detect_frequent_transactions(transactions, timeframe_in_minutes=60): tran...
import pandas as pd from solution import analyze_transactions, identify_unusual_transaction_amount, detect_frequent_transactions, flag_suspicious_merchants, determine_unusual_location def test_identify_unusual_transaction_amount(): transactions = pd.DataFrame({ 'Amount': [100, 200, 600, 700] }) ass...
[ { "docstring": null, "function_declaration": "def load_csv(file_path):", "function_name": "load_csv", "parameter_list": "(file_path)" }, { "docstring": null, "function_declaration": "def identify_unusual_transaction_amount(transactions, threshold=500):", "function_name": "identify_un...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import pandas as pd\nfrom datetime import datetime, timedelta\n\n# Constants for fraud detection criteria\nUNUSUAL_AMOUNT_THRESHOLD = 500.00\nFREQUENT_TRANSACTION_THRESHOLD = timedelta(hours=1...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00083823", "row_id": 83823, "seed_ids": "['gemma-2-27b-it_170952']" }
0.563212
Filter_83823
I
[ "load_csv", "identify_unusual_transaction_amount", "detect_frequent_transactions", "flag_suspicious_merchants", "determine_unusual_location", "analyze_transactions" ]
6
[ [ "analyze_transactions", "detect_frequent_transactions" ], [ "analyze_transactions", "determine_unusual_location" ], [ "analyze_transactions", "flag_suspicious_merchants" ], [ "analyze_transactions", "identify_unusual_transaction_amount" ], [ "analyze_transaction...
5
[]
false
[]
false
pytest
true
[ "pandas" ]
false
f69c844a12aa82e5c53e1ed37f74a39f5fb85c55
4a22ae48ca5fc8fe7799be6dd51806a2f7ff1845
v1.0
instruct
Filter
Filter_83846_I
This is my problem: I'm trying to write a program that can analyze text input and determine whether it expresses a positive, negative, or neutral sentiment. I've started with a simple approach: 1. **Create a dictionary of words**: I've built a dictionary where keys are words and values are their associated sentim...
sentiment_dict = { "awesome": "positive", "terrible": "negative", "house": "neutral", "great": "positive", "bad": "negative", "good": "positive", "horrible": "negative", "excellent": "positive", "awful": "negative", "nice": "positive", "poor": "negative", "neutral": "neut...
from solution import tokenize, analyze_sentiment def test_tokenize(): assert tokenize("This is awesome!") == ["this", "is", "awesome!"] assert tokenize("Terrible day!") == ["terrible", "day!"] assert tokenize("House is neutral.") == ["house", "is", "neutral."] def test_analyze_sentiment_positive(): as...
[ { "docstring": "Splits the input text into individual words.", "function_declaration": "def tokenize(text):", "function_name": "tokenize", "parameter_list": "(text)" }, { "docstring": "Analyzes the sentiment of the input text.\nReturns 'positive', 'negative', or 'neutral' based on the sentim...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "sentiment_dict = {\n \"awesome\": \"positive\",\n \"terrible\": \"negative\",\n \"house\": \"neutral\",\n \"great\": \"positive\",\n \"bad\": \"negative\",\n \"good\": \"posi...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00083846", "row_id": 83846, "seed_ids": "['gemma-2-27b-it_171026']" }
0.763413
Filter_83846
I
[ "tokenize", "analyze_sentiment" ]
2
[ [ "analyze_sentiment", "tokenize" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a48377c5c221ce53858f8eb252c2b8e3a2590b23
b3cad5eaa53f37ff75117a655741c436d9a550ab
v1.0
instruct
Filter
Filter_83878_I
This is a Python program that reads a list of words from a file called "words.txt" and then outputs a list of the words that are palindromes.
def read_words_from_file(file_name): """ Reads a list of words from a file and returns them as a list. """ with open(file_name, 'r') as file: words = file.read().splitlines() return words def is_palindrome(word): """ Checks if a given word is a palindrome. """ return word ==...
from solution import read_words_from_file, is_palindrome, find_palindromes def test_is_palindrome(): assert is_palindrome("madam") == True assert is_palindrome("hello") == False assert is_palindrome("racecar") == True assert is_palindrome("palindrome") == False assert is_palindrome("level") == True...
[ { "docstring": "Reads a list of words from a file and returns them as a list.", "function_declaration": "def read_words_from_file(file_name):", "function_name": "read_words_from_file", "parameter_list": "(file_name)" }, { "docstring": "Checks if a given word is a palindrome.", "function_...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(word):\n \"\"\"\n Checks if a given word is a palindrome.\n \n Parameters:\n word (str): The word to check.\n \n Returns:\n bool: True if the word is ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00083878", "row_id": 83878, "seed_ids": "['gemma-2-27b-it_171109']" }
0.657385
Filter_83878
I
[ "read_words_from_file", "is_palindrome", "find_palindromes" ]
3
[ [ "find_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8dfca3f15cb074d56198faff4ef2a0b6f4901b2d
2128183cdb228f62fa542687789f54fdc651f1ea
v1.0
instruct
Filter
Filter_83915_I
A restaurant wants to offer a "Lunch Special" during specific hours. Create a Python program that: 1. **Takes user input:** - Ask the user for the start and end times of the lunch special. 2. **Validates input:** - Ensure the entered times are in the format HH:MM (e.g., 12:00). - Ensure the start time is earl...
from datetime import datetime def parse_time(t): """ Parse the time string in HH:MM format. """ try: return datetime.strptime(t, "%H:%M") except ValueError: raise ValueError("Time must be in HH:MM format") def calculate_duration(start, end): """ Calculate the duration betwe...
import pytest from solution import parse_time, calculate_duration def test_parse_time_valid_format(): assert parse_time("12:30") == datetime.strptime("12:30", "%H:%M") def test_parse_time_invalid_format(): with pytest.raises(ValueError, match="Time must be in HH:MM format"): parse_time("1230") def te...
[ { "docstring": "Parse the time string in HH:MM format.", "function_declaration": "def parse_time(t):", "function_name": "parse_time", "parameter_list": "(t)" }, { "docstring": "Calculate the duration between start and end time.", "function_declaration": "def calculate_duration(start, end...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from datetime import datetime\n\ndef parse_time(t):\n \"\"\"\n Parse the time string in HH:MM format.\n \"\"\"\n try:\n return datetime.strptime(t, \"%H:%M\")\n except Va...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00083915", "row_id": 83915, "seed_ids": "['gemma-2-27b-it_171201']" }
0.493246
Filter_83915
I
[ "parse_time", "calculate_duration", "lunch_special" ]
3
[ [ "calculate_duration", "parse_time" ], [ "lunch_special", "calculate_duration" ], [ "lunch_special", "parse_time" ] ]
3
[]
false
[]
false
pytest
true
[]
true
023f0753538a934c1504e14eec6becca32553b4c
a74ea5954f9411ebfdadea716ca0bb29d6232ab5
v1.0
instruct
Filter
Filter_83950_I
This is a Python program that reads a list of numbers from a file named "numbers.txt" and calculates the average of the numbers.
def read_numbers_from_file(file_path): """ Reads a list of numbers from the specified file and returns the list of numbers. Assumes the file contains one number per line. """ numbers = [] with open(file_path, 'r') as file: for line in file: try: number = float...
import os import pytest from solution import read_numbers_from_file, calculate_average, average_from_file TEST_FILE = 'test_numbers.txt' def setup_module(module): with open(TEST_FILE, 'w') as f: f.write('10\n20\n30\n40\n50\n') def teardown_module(module): os.remove(TEST_FILE) def test_read_numbers_f...
[ { "docstring": "Reads a list of numbers from the specified file and returns the list of numbers.\nAssumes the file contains one number per line.", "function_declaration": "def read_numbers_from_file(file_path):", "function_name": "read_numbers_from_file", "parameter_list": "(file_path)" }, { ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_average_from_file(file_path):\n \"\"\"\n Reads a list of numbers from a file and calculates the average.\n \n :param file_path: Path to the file containing numbers.\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00083950", "row_id": 83950, "seed_ids": "['gemma-2-27b-it_171301']" }
0.619336
Filter_83950
I
[ "read_numbers_from_file", "calculate_average", "average_from_file" ]
3
[ [ "average_from_file", "calculate_average" ], [ "average_from_file", "read_numbers_from_file" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2dc248f218663e6cf3e3664556f9c8362ff84cc3
f506c34fe419fd434794be2187931ad1b9a509d4
v1.0
instruct
Filter
Filter_83961_I
This is my code for a text adventure game. ```python inventory = [] def show_inventory(inventory): if inventory: print("You are carrying:") for item in inventory: print(f"- {item}") else: print("You are not carrying anything.") def get_input(): return input("> ") def ...
inventory = [] def show_inventory(inventory): if inventory: print("You are carrying:") for item in inventory: print(f"- {item}") else: print("You are not carrying anything.") def get_input(): return input("> ") def take_item(inventory, item): inventory.append(item)...
from solution import show_inventory, take_item def test_show_inventory_empty(capfd): inventory = [] show_inventory(inventory) out, err = capfd.readouterr() assert out == "You are not carrying anything.\n" def test_show_inventory_with_items(capfd): inventory = ["sword", "shield"] show_inventory...
[ { "docstring": null, "function_declaration": "def show_inventory(inventory):", "function_name": "show_inventory", "parameter_list": "(inventory)" }, { "docstring": null, "function_declaration": "def get_input():", "function_name": "get_input", "parameter_list": "()" }, { ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "inventory = []\n\ndef show_inventory(inventory):\n if inventory:\n print(\"You are carrying:\")\n for item in inventory:\n print(f\"- {item}\")\n else:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00083961", "row_id": 83961, "seed_ids": "['gemma-2-27b-it_171337']" }
0.504008
Filter_83961
I
[ "show_inventory", "get_input", "take_item", "start_game" ]
4
[ [ "start_game", "get_input" ], [ "start_game", "show_inventory" ], [ "start_game", "take_item" ] ]
3
[]
false
[]
false
pytest
true
[]
true
82751653b8df2534bac0c9b23d46298be3d56ed9
a7f435f90a6fe584b34111d2d8365ac9b12a7ab8
v1.0
instruct
Filter
Filter_84065_I
The following functions are given: ```python def f(x): return x**2 def g(x): return 2*x + 1 ``` Write a Python program that 1. Takes an input number from the user. 2. Applies the functions `f` and `g` to the input number in that order. 3. Prints the result of applying `g` to the result of applying `f` to ...
def f(x): return x**2 def g(x): return 2*x + 1 def apply_functions(x): """ Applies f to x, then applies g to the result of f(x), and returns the final result. """ return g(f(x))
def test_apply_functions(): assert apply_functions(3) == 19 # f(3) = 9, g(9) = 19 assert apply_functions(0) == 1 # f(0) = 0, g(0) = 1 assert apply_functions(-3) == 19 # f(-3) = 9, g(9) = 19 assert apply_functions(2) == 9 # f(2) = 4, g(4) = 9 def test_f(): assert f(3) == 9 assert f(0) == 0 ...
[ { "docstring": null, "function_declaration": "def f(x):", "function_name": "f", "parameter_list": "(x)" }, { "docstring": null, "function_declaration": "def g(x):", "function_name": "g", "parameter_list": "(x)" }, { "docstring": "Applies f to x, then applies g to the resu...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def f(x):\n \"\"\"\n Applies the function x^2.\n \"\"\"\n return x**2\n\ndef g(x):\n \"\"\"\n Applies the function 2*x + 1.\n \"\"\"\n return 2*x + 1\n\ndef apply_funct...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084065", "row_id": 84065, "seed_ids": "['gemma-2-27b-it_171603']" }
0.593278
Filter_84065
I
[ "f", "g", "apply_functions" ]
3
[ [ "apply_functions", "f" ], [ "apply_functions", "g" ] ]
2
[]
false
[]
false
pytest
false
[]
true
b16c13a396013c9bab36f7c709db7670367d9e0a
10ab74031a26299d5e70bba0df2309fd231695e5
v1.0
instruct
Filter
Filter_84067_I
Please write a Python program that simulates a simple Blackjack game. The program should deal two cards to the player and two cards to the dealer. The player can choose to "hit" (take another card) or "stand" (keep their current hand). The dealer must hit until their hand total is 17 or more. The program should det...
import random # Define card values card_values = {'A': 11, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, 'J': 10, 'Q': 10, 'K': 10} # Create a deck of cards suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] ranks = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '...
from solution import shuffle_deck, calculate_hand, deal_card, initial_deal, player_turn, dealer_turn, determine_winner, blackjack_game def test_calculate_hand(): assert calculate_hand([('A', 'Hearts'), ('K', 'Diamonds')]) == 21 assert calculate_hand([('A', 'Hearts'), ('9', 'Diamonds')]) == 20 assert calcul...
[ { "docstring": null, "function_declaration": "def shuffle_deck():", "function_name": "shuffle_deck", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def calculate_hand(hand):", "function_name": "calculate_hand", "parameter_list": "(hand)" }, { "doc...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\n# Define card values\ncard_values = {'A': 11, '2': 2, '3': 3, '4': 4, '5': 5,\n '6': 6, '7': 7, '8': 8, '9': 9, '10': 10,\n 'J': 10, 'Q': 10, 'K': 10...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00084067", "row_id": 84067, "seed_ids": "['gemma-2-27b-it_171609']" }
0.554301
Filter_84067
I
[ "shuffle_deck", "calculate_hand", "deal_card", "initial_deal", "player_turn", "dealer_turn", "determine_winner", "blackjack_game" ]
8
[ [ "blackjack_game", "calculate_hand" ], [ "blackjack_game", "dealer_turn" ], [ "blackjack_game", "determine_winner" ], [ "blackjack_game", "initial_deal" ], [ "blackjack_game", "player_turn" ], [ "blackjack_game", "shuffle_deck" ], [ "deale...
11
[]
false
[]
false
pytest
true
[]
true
35e3f7fc980717c80ded1eca36421272bc8b696b
b50267f8edc5e85448bbe349bbe3df2a9f1219f4
v1.0
instruct
Filter
Filter_84082_I
Here are some Python code snippets for generating prime numbers: **Snippet 1:** ```python def is_prime(n): """ This function checks if a number is prime. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def generate_primes(limit): """...
def is_prime(n): """ This function checks if a number is prime. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def generate_primes(limit): """ Generates a list of prime numbers up to a given limit. ...
from solution import is_prime, generate_primes def test_is_prime_with_non_primes(): assert is_prime(0) == False assert is_prime(1) == False assert is_prime(4) == False assert is_prime(9) == False def test_is_prime_with_primes(): assert is_prime(2) == True assert is_prime(3) == True assert ...
[ { "docstring": "This function checks if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generates a list of prime numbers up to a given limit.", "function_declaration": "def generate_primes(limit):",...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n This function checks 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...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084082", "row_id": 84082, "seed_ids": "['gemma-2-27b-it_171656']" }
0.617477
Filter_84082
I
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e2d62f62ac03846f095fdd203a5f03b24e83b793
154c757b2a2b87929892258f251d3f0d65f7a640
v1.0
instruct
Filter
Filter_84156_I
This is what I'm trying to accomplish: I want to create a simple calculator that can perform basic arithmetic operations (addition, subtraction, multiplication, and division) on two numbers. Here's what I've got so far: ```python def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): ...
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: return "Division by zero error!" else: return x / y def calculator(): try: x = float(input("Enter the first number: ")) y = float(input("...
from solution import add, subtract, multiply, divide, calculator def test_add(): assert add(3, 4) == 7 assert add(-1, 1) == 0 assert add(0, 0) == 0 def test_subtract(): assert subtract(3, 4) == -1 assert subtract(10, 5) == 5 assert subtract(0, 0) == 0 def test_multiply(): assert multiply(...
[ { "docstring": null, "function_declaration": "def add(x, y):", "function_name": "add", "parameter_list": "(x, y)" }, { "docstring": null, "function_declaration": "def subtract(x, y):", "function_name": "subtract", "parameter_list": "(x, y)" }, { "docstring": null, "fu...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def add(x, y):\n return x + y\n\ndef subtract(x, y):\n return x - y\n\ndef multiply(x, y):\n return x * y\n\ndef divide(x, y):\n if y == 0:\n return \"Division by zero error...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00084156", "row_id": 84156, "seed_ids": "['gemma-2-27b-it_171849']" }
0.638162
Filter_84156
I
[ "add", "subtract", "multiply", "divide", "calculator" ]
5
[ [ "calculator", "add" ], [ "calculator", "divide" ], [ "calculator", "multiply" ], [ "calculator", "subtract" ] ]
4
[]
false
[]
false
pytest
true
[]
true
76ef3264e93e3f58d430d445409aedb7e68d3bf8
c3aaeb96e78c4392e20ddb9c2bd14101a3a3829d
v1.0
instruct
Filter
Filter_84158_I
I have recently started learning Python, and I want to practice my skills by creating a simple program that can convert temperatures between Celsius and Fahrenheit. Here's what I have so far: ```python def celsius_to_fahrenheit(celsius): return (celsius * 9/5) + 32 def fahrenheit_to_celsius(fahrenheit): return (...
def celsius_to_fahrenheit(celsius): return (celsius * 9/5) + 32 def fahrenheit_to_celsius(fahrenheit): return (fahrenheit - 32) * 5/9 def convert_temperature(temp, unit): if unit.lower() == 'c': converted_temp = celsius_to_fahrenheit(temp) converted_unit = 'F' elif unit.lower() == 'f':...
from solution import celsius_to_fahrenheit, fahrenheit_to_celsius, convert_temperature def test_celsius_to_fahrenheit(): assert celsius_to_fahrenheit(0) == 32 assert celsius_to_fahrenheit(100) == 212 assert celsius_to_fahrenheit(-40) == -40 def test_fahrenheit_to_celsius(): assert fahrenheit_to_celsiu...
[ { "docstring": null, "function_declaration": "def celsius_to_fahrenheit(celsius):", "function_name": "celsius_to_fahrenheit", "parameter_list": "(celsius)" }, { "docstring": null, "function_declaration": "def fahrenheit_to_celsius(fahrenheit):", "function_name": "fahrenheit_to_celsiu...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def celsius_to_fahrenheit(celsius):\n \"\"\"\n Converts Celsius to Fahrenheit.\n Formula: (C * 9/5) + 32\n \"\"\"\n return (celsius * 9/5) + 32\n\ndef fahrenheit_to_celsius(fahr...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00084158", "row_id": 84158, "seed_ids": "['gemma-2-27b-it_171852']" }
0.501437
Filter_84158
I
[ "celsius_to_fahrenheit", "fahrenheit_to_celsius", "convert_temperature" ]
3
[ [ "convert_temperature", "celsius_to_fahrenheit" ], [ "convert_temperature", "fahrenheit_to_celsius" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a87609e1b93771c7b652a14cee2a4840a1c9d09a
e29f1d4b18b5b03235cbb7a7cd45fa146ceff617
v1.0
instruct
Filter
Filter_84159_I
I need help with a Python script that takes a series of numerical values as input from the user and calculates their sum, average, minimum and maximum values.
def get_sum(nums): """ Returns the sum of a list of numbers. """ return sum(nums) def get_average(nums): """ Returns the average of a list of numbers. """ return sum(nums) / len(nums) if nums else 0 def get_min(nums): """ Returns the minimum value in a list of numbers. """ ...
from solution import get_sum, get_average, get_min, get_max, calculate_stats def test_get_sum(): assert get_sum([1, 2, 3, 4, 5]) == 15 assert get_sum([-1, -2, -3, -4, -5]) == -15 assert get_sum([0, 0, 0, 0, 0]) == 0 assert get_sum([]) == 0 def test_get_average(): assert get_average([1, 2, 3, 4, 5]...
[ { "docstring": "Returns the sum of a list of numbers.", "function_declaration": "def get_sum(nums):", "function_name": "get_sum", "parameter_list": "(nums)" }, { "docstring": "Returns the average of a list of numbers.", "function_declaration": "def get_average(nums):", "function_name...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_statistics(numbers):\n \"\"\"\n Takes a list of numbers and returns a dictionary with their sum, average, minimum, and maximum values.\n \n :param numbers: List of nu...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084159", "row_id": 84159, "seed_ids": "['gemma-2-27b-it_171853']" }
0.574603
Filter_84159
I
[ "get_sum", "get_average", "get_min", "get_max", "calculate_stats" ]
5
[ [ "calculate_stats", "get_average" ], [ "calculate_stats", "get_max" ], [ "calculate_stats", "get_min" ], [ "calculate_stats", "get_sum" ] ]
4
[]
false
[]
false
pytest
true
[]
true
1abddd521d9d536568ddfddd968879e3c129d37a
3b872f7ab9b3293947b869418e58cfd0ed65db64
v1.0
instruct
Filter
Filter_84166_I
Project Goal: Develop a Python code that simulates a simple dice rolling game. The player will: Roll two six-sided dice. The sum of the dice will determine the player's score. The game will continue until the player chooses to stop. Features: User interaction: The code should prompt the player to roll the d...
import random def roll_dice(): """ Simulates rolling two six-sided dice and returns their sum. """ return random.randint(1, 6) + random.randint(1, 6) def play_dice_game(): """ Simulates the dice rolling game. The player is prompted to roll the dice, and their score is updated accordingly. ...
import pytest from unittest.mock import patch import solution def test_roll_dice(): roll = solution.roll_dice() assert 2 <= roll <= 12 @patch('builtins.input', side_effect=['y', 'y', 'n']) @patch('solution.roll_dice', side_effect=[7, 5]) def test_play_dice_game(mock_roll_dice, mock_input, capsys): solutio...
[ { "docstring": "Simulates rolling two six-sided dice and returns their sum.", "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": "Simulates the dice rolling game.\nThe player is prompted to roll the dice, and their score is upda...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef roll_dice():\n \"\"\"\n Simulates rolling two six-sided dice and returns their sum.\n \"\"\"\n return random.randint(1, 6) + random.randint(1, 6)\n\ndef play_d...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00084166", "row_id": 84166, "seed_ids": "['gemma-2-27b-it_171891']" }
0.56933
Filter_84166
I
[ "roll_dice", "play_dice_game" ]
2
[ [ "play_dice_game", "roll_dice" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8ac2c974e0226999b190dbeea2131a6767034e3a
3b45460d2a13dff4f492cf35f05b93e20ac0fe52
v1.0
instruct
Filter
Filter_84249_I
This week's challenge is to create a program that plays simple games against a human player. This week, let's keep it simple: **Rock, Paper, Scissors**. **Here are the requirements:** 1. **User Input:** - Ask the user to choose either "Rock", "Paper", or "Scissors". - Convert the input to lowercase. 2. **Comp...
import random def get_computer_choice(): choices = ['rock', 'paper', 'scissors'] return random.choice(choices) def determine_winner(user_choice, computer_choice): if user_choice == computer_choice: return "It's a tie!" if (user_choice == 'rock' and computer_choice == 'scissors' or ...
from solution import get_computer_choice, determine_winner def test_get_computer_choice(): choices = ['rock', 'paper', 'scissors'] assert get_computer_choice() in choices def test_determine_winner_tie(): assert determine_winner('rock', 'rock') == "It's a tie!" assert determine_winner('paper', 'paper')...
[ { "docstring": null, "function_declaration": "def get_computer_choice():", "function_name": "get_computer_choice", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def determine_winner(user_choice, computer_choice):", "function_name": "determine_winner", "p...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef get_computer_choice():\n \"\"\"Returns the computer's choice: 'rock', 'paper', or 'scissors'.\"\"\"\n choices = ['rock', 'paper', 'scissors']\n return random.choi...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084249", "row_id": 84249, "seed_ids": "['gemma-2-27b-it_172179']" }
0.581353
Filter_84249
I
[ "get_computer_choice", "determine_winner", "play_game" ]
3
[ [ "play_game", "determine_winner" ], [ "play_game", "get_computer_choice" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c0148266a7bfc3764a255c599786905de6c32498
763c0fb393e3d7ae52baf505f36b4b0ced934057
v1.0
instruct
Filter
Filter_84250_I
Objective: Create a Python program that utilizes multithreading to expedite the process of finding prime numbers within a specified range.
import threading def is_prime(n): """ Checks if a number is a prime number. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def fi...
from solution import is_prime, find_primes, find_primes_multithreaded def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(19) == True def test_find_primes(): result =...
[ { "docstring": "Checks if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Finds prime numbers in the given range and stores them in result list.", "function_declaration": "def find_primes(st...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import threading\n\ndef is_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084250", "row_id": 84250, "seed_ids": "['gemma-2-27b-it_172181']" }
0.540971
Filter_84250
I
[ "is_prime", "find_primes", "find_primes_multithreaded" ]
3
[ [ "find_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0c60e22f9e0304677b71a150147eda1c3e647077
e9174376b1c776fcfd792c8dd71e6bae2ea5fa4f
v1.0
instruct
Filter
Filter_84280_I
The game is described as follows: * **Players:** Two players (Player 1 and Player 2). * **Gameplay:** Players take turns placing their mark (X or O) on an empty square of a 3x3 grid. * **Goal:** Be the first player to get three of their marks in a row, horizontally, vertically, or diagonally. **Rules:** * Player 1 g...
def print_board(board): """Prints the current state of the Tic-Tac-Toe board.""" for row in board: print(" | ".join(row)) print("-" * 5) def check_win(board): """Checks if there is a winning condition on the board.""" # check rows for row in board: if row[0] == row[1] =...
from solution import check_win, check_draw def test_check_win_row(): board = [["X", "X", "X"], ["O", " ", "O"], [" ", "O", " "]] assert check_win(board) == True def test_check_win_column(): board = [["X", "O", " "], ["X", "O", " "], ["X", " ", " "]] assert check_win(board) == True def test_check_win_...
[ { "docstring": "Prints the current state of the Tic-Tac-Toe board.", "function_declaration": "def print_board(board):", "function_name": "print_board", "parameter_list": "(board)" }, { "docstring": "Checks if there is a winning condition on the board.", "function_declaration": "def check...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def print_board(board):\n \"\"\"Prints the current state of the Tic-Tac-Toe board.\"\"\"\n for row in board:\n print(\" \".join(row))\n print()\n\ndef check_win(board):\n \...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00084280", "row_id": 84280, "seed_ids": "['gemma-2-27b-it_172255']" }
0.500058
Filter_84280
I
[ "print_board", "check_win", "check_draw", "tic_tac_toe" ]
4
[ [ "tic_tac_toe", "check_draw" ], [ "tic_tac_toe", "check_win" ], [ "tic_tac_toe", "print_board" ] ]
3
[]
false
[]
false
pytest
true
[]
true
84cdc6e37b8ac8347c7de1a3f5851196e8434f07
d38f751bf837cb07403f30aff5b725fb9a996e4b
v1.0
instruct
Filter
Filter_84284_I
Create a Python code snippet to generate a list of all prime numbers between 1 and 100.
def generate_primes(n): """ Generate a list of all prime numbers from 2 up to n (inclusive). Args: n (int): The upper limit to generate prime numbers for. Returns: list: A list containing all the prime numbers up to n. """ if n < 2: return [] primes = [] for num in...
from solution import generate_primes, primes_up_to_100 def test_generate_primes_within_100(): expected_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] assert primes_up_to_100() == expected_primes def test_generate_primes_empty(): assert generate_pr...
[ { "docstring": "Generate a list of all prime numbers from 2 up to n (inclusive).\n\nArgs:\nn (int): The upper limit to generate prime numbers for.\n\nReturns:\nlist: A list containing all the prime numbers up to n.", "function_declaration": "def generate_primes(n):", "function_name": "generate_primes", ...
[ 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 Determine if a number is a prime.\n Returns True if the number is a prime, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n if n <= ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00084284", "row_id": 84284, "seed_ids": "['gemma-2-27b-it_172260']" }
0.604678
Filter_84284
I
[ "generate_primes", "primes_up_to_100" ]
2
[ [ "primes_up_to_100", "generate_primes" ] ]
1
[]
false
[]
false
pytest
true
[]
true
db6285eed991a8e358a250645eff17fab0d42525
69f8393d279acb3081f8293f35daeb83701c4ddc
v1.0
instruct
Filter
Filter_84324_I
Create a program (in Python) that plays rock, paper, scissors against the user. Requirements: 1. The program should ask the user for their choice (rock, paper, or scissors). 2. The program should randomly choose rock, paper, or scissors. 3. The program should determine the winner based on the rules of the game. 4. T...
import random def determine_winner(user_choice, computer_choice): """ Determine the winner of a rock-paper-scissors game. Args: user_choice (str): the user's choice ("rock", "paper", or "scissors") computer_choice (str): the computer's choice ("rock", "paper", or "scissors") Returns: ...
from solution import determine_winner, play_round def test_determine_winner_tie(): assert determine_winner("rock", "rock") == "tie" assert determine_winner("paper", "paper") == "tie" assert determine_winner("scissors", "scissors") == "tie" def test_determine_winner_user_wins(): assert determine_winner...
[ { "docstring": "Determine the winner of a rock-paper-scissors game.\n\nArgs:\nuser_choice (str): the user's choice (\"rock\", \"paper\", or \"scissors\")\ncomputer_choice (str): the computer's choice (\"rock\", \"paper\", or \"scissors\")\n\nReturns:\nstr: \"user\" if the user wins, \"computer\" if the computer...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef get_computer_choice():\n \"\"\"\n Randomly choose one of 'rock', 'paper', or 'scissors' for the computer.\n \"\"\"\n return random.choice([\"rock\", \"paper\",...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00084324", "row_id": 84324, "seed_ids": "['gemma-2-27b-it_172389']" }
0.521139
Filter_84324
I
[ "determine_winner", "play_round" ]
2
[ [ "play_round", "determine_winner" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cf3c4748dfd446053f0ab38ba4ca44859698b14e
dd8a9796e28bc2222ac9bf615f0f53be960a4ff4
v1.0
instruct
Filter
Filter_84341_I
This website shows a list of popular movies: [website URL here] I want to create a Python program that will: 1. Scrape the website for movie titles. 2. Allow the user to choose a movie from the list. 3. Print a summary of the chosen movie. Note: You will need to use a library like "requests" to fetch the website con...
import requests from bs4 import BeautifulSoup def scrape_movie_titles(url): """ Scrapes the given website for movie titles. Parameters: ----------- url : str The URL of the website to scrape movie titles from. Returns: -------- list A list of movie titles found...
from solution import scrape_movie_titles, get_movie_summary def test_scrape_movie_titles(monkeypatch): # Mock the requests.get and BeautifulSoup for testing class MockResponse: @property def content(self): return ''' <html> <body> <div class="...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import requests\nfrom bs4 import BeautifulSoup\n\ndef fetch_movie_titles(url):\n \"\"\"\n Fetch movie titles from the provided URL.\n\n :param url: URL of the website to scrape for mo...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084341", "row_id": 84341, "seed_ids": "['gemma-2-27b-it_172448']" }
0.658009
Filter_84341
I
[ "scrape_movie_titles", "get_movie_summary", "choose_and_print_movie_summary" ]
3
[ [ "choose_and_print_movie_summary", "get_movie_summary" ], [ "choose_and_print_movie_summary", "scrape_movie_titles" ] ]
2
[]
false
[]
false
pytest
true
[ "bs4", "requests" ]
false
a7cf6e6bc43d8466bdc955f1e3207f5ff7ce0340
01f8a47c30889bf490503bc13b4e8ee5af6dd68f
v1.0
instruct
Filter
Filter_84379_I
We’ll use a simple algorithm to find the closest pair of points in a set of points. This algorithm is by no means the most efficient, but it's easy to understand and implement. Here’s the outline: 1. **Sort the points by x-coordinate.** 2. **Divide the set of points into two halves.** 3. **Recursively find the close...
from math import sqrt import sys def euclidean_distance(p1, p2): return sqrt((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) def brute_force(points): min_dist = sys.maxsize n = len(points) for i in range(n): for j in range(i + 1, n): if euclidean_distance(points[i], points[j]) < min_d...
from solution import closest_pair def test_closest_pair_basic(): points = [(0, 0), (1, 1), (2, 2), (3, 3)] assert abs(closest_pair(points) - 1.414) < 0.001 def test_closest_pair_two_points(): points = [(1, 1), (4, 4)] assert abs(closest_pair(points) - 4.242) < 0.001 def test_closest_pair_collinear_po...
[ { "docstring": null, "function_declaration": "def euclidean_distance(p1, p2):", "function_name": "euclidean_distance", "parameter_list": "(p1, p2)" }, { "docstring": null, "function_declaration": "def brute_force(points):", "function_name": "brute_force", "parameter_list": "(poin...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nfrom typing import List, Tuple\n\ndef distance(point1: Tuple[int, int], point2: Tuple[int, int]) -> float:\n return math.sqrt((point1[0] - point2[0]) ** 2 + (point1[1] - point2...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00084379", "row_id": 84379, "seed_ids": "['gemma-2-27b-it_172579']" }
0.640959
Filter_84379
I
[ "euclidean_distance", "brute_force", "closest_pair_recursive", "closest_pair" ]
4
[ [ "brute_force", "euclidean_distance" ], [ "closest_pair", "closest_pair_recursive" ], [ "closest_pair_recursive", "brute_force" ], [ "closest_pair_recursive", "euclidean_distance" ] ]
4
[]
false
[]
false
pytest
true
[]
true
18602251a1413c51ee2f3d027a027da7a93d92f6
a1fa70c2178367b94b64ae16652ff87d68d74d15
v1.0
instruct
Filter
Filter_84421_I
. Write a Python function `largest_palindrome_product(n)` that takes an integer `n` as input and returns the largest palindrome that can be formed by the product of two n-digit numbers.
def is_palindrome(number): """ Check if a given number is a palindrome. """ return str(number) == str(number)[::-1] def largest_palindrome_product(n): """ Find the largest palindrome made from the product of two n-digit numbers. """ max_num = int('9' * n) min_num = int('1' + '0' * (...
from solution import largest_palindrome_product def test_largest_palindrome_product_2_digits(): assert largest_palindrome_product(2) == 9009 # 91 * 99 def test_largest_palindrome_product_3_digits(): assert largest_palindrome_product(3) == 906609 # 913 * 993 def test_largest_palindrome_product_1_digit(): ...
[ { "docstring": "Check if a given number is a palindrome.", "function_declaration": "def is_palindrome(number):", "function_name": "is_palindrome", "parameter_list": "(number)" }, { "docstring": "Find the largest palindrome made from the product of two n-digit numbers.", "function_declara...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(number):\n \"\"\"\n Returns True if the number is a palindrome, False otherwise.\n \"\"\"\n return str(number) == str(number)[::-1]\n\ndef largest_palindrome_prod...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00084421", "row_id": 84421, "seed_ids": "['gemma-2-27b-it_172724']" }
0.704126
Filter_84421
I
[ "is_palindrome", "largest_palindrome_product" ]
2
[ [ "largest_palindrome_product", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
312f75fe1fdd6081890642cc4bd1248b0d543968
4d199b4439c7fe464a5e254fc0700f074dd2283c
v1.0
instruct
Filter
Filter_84426_I
Goal: Create a Python function `sum_of_primes` that takes an integer `n` as input and returns the sum of all prime numbers less than or equal to `n`.
def is_prime(num): """ Returns True if the given number is prime, False otherwise. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: ...
from solution import sum_of_primes def test_sum_of_primes_zero(): assert sum_of_primes(0) == 0 def test_sum_of_primes_one(): assert sum_of_primes(1) == 0 def test_sum_of_primes_prime_below_ten(): assert sum_of_primes(10) == 17 # Primes are 2, 3, 5, 7 def test_sum_of_primes_prime_below_twenty(): ass...
[ { "docstring": "Returns True if the given number is prime, False otherwise.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers less than or equal to n.", "function_declaration": "d...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Returns True if the given number is prime, False otherwise.\n \"\"\"\n if num <= 1:\n return False\n if num <= 3:\n return True\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00084426", "row_id": 84426, "seed_ids": "['gemma-2-27b-it_172741']" }
0.742524
Filter_84426
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ee2e9719daab2fc4979c02cdf053a5a1c9678164
2ac9cb1ad80867650873bc92aa18e9b79055644e
v1.0
instruct
Filter
Filter_84429_I
I need help writing a Python code to simulate a game of Tic-Tac-Toe. Here's what I have so far: ```python def print_board(board): """Prints the Tic-Tac-Toe board.""" print("-------------") for row in board: print("|", end="") for cell in row: print(" " + cell + " |", end="") print("\n---------...
def print_board(board): """Prints the Tic-Tac-Toe board.""" print("-------------") for row in board: print("|", end="") for cell in row: print(" " + cell + " |", end="") print("\n-------------") def get_player_move(player): """Gets the player's move.""" while Tru...
def test_check_for_win(): # Test horizontal win board = [ ["X", "X", "X"], [" ", " ", " "], [" ", " ", " "] ] assert check_for_win(board, "X") == True # Test vertical win board = [ ["X", " ", " "], ["X", " ", " "], ["X", " ", " "] ] assert...
[ { "docstring": "Prints the Tic-Tac-Toe board.", "function_declaration": "def print_board(board):", "function_name": "print_board", "parameter_list": "(board)" }, { "docstring": "Gets the player's move.", "function_declaration": "def get_player_move(player):", "function_name": "get_pl...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def print_board(board):\n \"\"\"Prints the Tic-Tac-Toe board.\"\"\"\n print(\"-------------\")\n for row in board:\n print(\"|\", end=\"\")\n for cell in row:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084429", "row_id": 84429, "seed_ids": "['gemma-2-27b-it_172760']" }
0.535134
Filter_84429
I
[ "print_board", "get_player_move", "check_for_win", "check_for_draw", "is_valid_move", "play_game" ]
6
[ [ "play_game", "check_for_draw" ], [ "play_game", "check_for_win" ], [ "play_game", "get_player_move" ], [ "play_game", "is_valid_move" ], [ "play_game", "print_board" ] ]
5
[]
false
[]
false
pytest
false
[]
true
d96b9847efd550bb750af66f2841a73c4cd2f8f9
9a7a82a3afeab05ff9afd1e874c681fd00ad6181
v1.0
instruct
Filter
Filter_84432_I
This program calculates the factorial of a number taken as input from the user. ```python def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) # Get input from the user num = int(input("Enter a non-negative integer: ")) # Calculate factorial if num < 0: print("Factorial is not defined ...
def factorial(n): """ Returns the factorial of a non-negative integer n. """ if n == 0: return 1 else: return n * factorial(n-1) def get_factorial(num): """ Computes the factorial of a given number after validating it. """ if num < 0: return "Factorial is not...
from solution import factorial, get_factorial def test_factorial_base_case(): assert factorial(0) == 1 def test_factorial_small_numbers(): assert factorial(1) == 1 assert factorial(2) == 2 assert factorial(3) == 6 assert factorial(4) == 24 assert factorial(5) == 120 def test_get_factorial_neg...
[ { "docstring": "Returns the factorial of a non-negative integer n.", "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": "Computes the factorial of a given number after validating it.", "function_declaration": "def get_fact...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def factorial(n):\n if n == 0:\n return 1\n else:\n return n * factorial(n - 1)", "test_code": "from solution import factorial\n\ndef test_factorial_zero():\n assert...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084432", "row_id": 84432, "seed_ids": "['gemma-2-27b-it_172768']" }
0.656228
Filter_84432
I
[ "factorial", "get_factorial" ]
2
[ [ "get_factorial", "factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0b5857c44aeb681893b87588351b21a2b41a3a69
b67f715e9b085ddef6eb524cb58d9d436564c6f1
v1.0
instruct
Filter
Filter_84436_I
These are the rules of a game: * Two players take turns. * Each player can choose either 1, 2, or 3 items from a pile of items. * The player who takes the last item(s) wins. This game is called Nim. How would you program a Nim AI **Simple Version (for learning):** Here's a basic Python implementation of a Nim AI u...
import random def computer_move(items_left): """ Makes an optimal move for the computer based on the current items_left. """ # Smart move: if the items left can be divided by 4 without a remainder, then the computer will leave a non-multiple of 4 to the player. if items_left % 4 != 0: retur...
def test_computer_winning_strategy(): # Fixed seed for reproducibility random.seed(0) # Play multiple games to test AI's consistency in winning computer_wins = 0 player_wins = 0 for _ in range(1000): winner = play_game() if winner == 'Computer': computer_win...
[ { "docstring": "Makes an optimal move for the computer based on the current items_left.", "function_declaration": "def computer_move(items_left):", "function_name": "computer_move", "parameter_list": "(items_left)" }, { "docstring": "Dummy function for simulating player move.\nReceives a lis...
[ 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 computer_move(items_left):\n \"\"\"\n Makes an optimal move for the computer based on the current items_left.\n \"\"\"\n # Smart move: if the items left can be...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00084436", "row_id": 84436, "seed_ids": "['gemma-2-27b-it_172791']" }
0.523029
Filter_84436
I
[ "computer_move", "get_player_move", "play_game" ]
3
[ [ "play_game", "computer_move" ], [ "play_game", "get_player_move" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0780f96b54f77a4e601968d3bc197ab4d87229a8
a803fb7770dafcf126b74ef5f521da74968e6df1
v1.0
instruct
Filter
Filter_84445_I
Define a function called `is_prime` that takes an integer as input and returns True if the integer is a prime number, and False otherwise. Write a program that uses the `is_prime` function to find and print all prime numbers between 1 and 100. Here's some information on prime numbers and how to determine if a number...
import math def is_prime(n): """ Returns True if n is a prime number, and False otherwise. """ if n <= 1: return False for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: return False return True def find_primes_in_range(start, end): """ Returns a list ...
from solution import is_prime, find_primes_in_range def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-7) == False assert is_prime(29) ...
[ { "docstring": "Returns True if n is a prime number, and False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of all prime numbers between start and end (inclusive).", "function_declaration":...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if the integer n is a prime number, and False otherwise.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084445", "row_id": 84445, "seed_ids": "['gemma-2-27b-it_172807']" }
0.661925
Filter_84445
I
[ "is_prime", "find_primes_in_range" ]
2
[ [ "find_primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c1c767b71d6f4366fccb61eda2964dada0d6f409
2cdf66cca16ebb5444a0520738046d876ac33fff
v1.0
instruct
Filter
Filter_84475_I
Objective: To build a simple chatbot using Python. Description: The chatbot should be able to understand basic greetings, farewells, and a few simple questions. It should be able to respond appropriately to user input. The chatbot should have a simple, text-based interface. Technology: Python 3 Libraries: ...
import random greetings = ["Hello!", "Hi there!", "Hey!", "Greetings!"] farewells = ["Goodbye!", "See you later!", "Bye!"] name = "ChatBot" def greet(): return f"{random.choice(greetings)}\nMy name is {name}. How can I help you?" def farewell(): return random.choice(farewells) def respond(input_text): i...
from solution import chat_bot def test_greeting_responses(): greetings_responses = [ "Hello!\nMy name is ChatBot. How can I help you?", "Hi there!\nMy name is ChatBot. How can I help you?", "Hey!\nMy name is ChatBot. How can I help you?", "Greetings!\nMy name is ChatBot. How can I h...
[ { "docstring": null, "function_declaration": "def greet():", "function_name": "greet", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def farewell():", "function_name": "farewell", "parameter_list": "()" }, { "docstring": null, "function_decla...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ngreetings = [\"Hello!\", \"Hi there!\", \"Hey!\", \"Greetings!\"]\nfarewells = [\"Goodbye!\", \"See you later!\", \"Bye!\"]\nresponses = {\n \"how are you\": \"I'm just a b...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084475", "row_id": 84475, "seed_ids": "['gemma-2-27b-it_172912']" }
0.464654
Filter_84475
I
[ "greet", "farewell", "respond", "chat_bot" ]
4
[ [ "chat_bot", "respond" ], [ "respond", "farewell" ], [ "respond", "greet" ] ]
3
[]
false
[]
false
pytest
true
[]
true
08d8eef2ce5eccefc04268d32416f06da5d9ffa9
416baddcdf420d0795f54e7e2348019af79f22d2
v1.0
instruct
Filter
Filter_84493_I
Given an integer array, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Output: 6 Explanation: The contiguous subarray [4,-1,2,1] has the largest sum = 6. Follow up: If you have figured out the O(n) solutio...
def max_crossing_sum(arr, left, mid, right): # Include elements on left of mid sm = 0 left_sum = float('-inf') for i in range(mid, left-1, -1): sm = sm + arr[i] if (sm > left_sum): left_sum = sm # Include elements on right of mid sm = 0 right_sum = float('-inf') ...
def test_max_sub_array(): assert max_sub_array([-2,1,-3,4,-1,2,1,-5,4]) == 6 assert max_sub_array([1]) == 1 assert max_sub_array([5,4,-1,7,8]) == 23 assert max_sub_array([-1, -2, -3, -4]) == -1 assert max_sub_array([1, 2, 3, 4]) == 10 assert max_sub_array([3, -2, 5, -1]) == 6 assert max_sub_...
[ { "docstring": null, "function_declaration": "def max_crossing_sum(arr, left, mid, right):", "function_name": "max_crossing_sum", "parameter_list": "(arr, left, mid, right)" }, { "docstring": null, "function_declaration": "def max_sub_array_sum(arr, left, right):", "function_name": "...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def max_crossing_sum(nums, left, mid, right):\n # Include elements on the left of mid.\n sum_left = float('-inf')\n sum_temp = 0\n for i in range(mid, left - 1, -1):\n sum_t...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00084493", "row_id": 84493, "seed_ids": "['gemma-2-27b-it_172955']" }
0.719952
Filter_84493
I
[ "max_crossing_sum", "max_sub_array_sum", "max_sub_array" ]
3
[ [ "max_sub_array", "max_sub_array_sum" ], [ "max_sub_array_sum", "max_crossing_sum" ] ]
2
[]
false
[]
false
pytest
false
[]
true
2ed2ede1085ae6b1ac2b0e4a3a9bef2151582334
8be177d237625e8c415fe9d69a3946599ff5d78e
v1.0
instruct
Filter
Filter_84504_I
This code analyzes a single string to check if it's a palindrome. Is it possible to modify it to analyze multiple strings at once?
def is_palindrome(s): """ Checks if a string s is a palindrome. """ return s == s[::-1] def check_palindromes(strings): """ Analyzes multiple strings to check if they are palindromes. Parameters: - strings: List of strings to be checked Returns: - List of boolean value...
from solution import is_palindrome, check_palindromes def test_is_palindrome(): assert is_palindrome("racecar") == True assert is_palindrome("hello") == False assert is_palindrome("madam") == True assert is_palindrome("python") == False assert is_palindrome("a") == True assert is_palindrome("")...
[ { "docstring": "Checks if a string s is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Analyzes multiple strings to check if they are palindromes.\n\nParameters:\n- strings: List of strings to be c...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(string):\n \"\"\"\n Returns True if the string is a palindrome, False otherwise.\n \"\"\"\n return string == string[::-1]\n\ndef check_palindromes(strings):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084504", "row_id": 84504, "seed_ids": "['gemma-2-27b-it_172988']" }
0.607451
Filter_84504
I
[ "is_palindrome", "check_palindromes" ]
2
[ [ "check_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f76db7add7b2bddc8ca50084f14a67216006e125
cfd6a15c69428dd7487e583c3d026a4dcd53586c
v1.0
instruct
Filter
Filter_84568_I
I need a step-by-step guide to creating a simple text-based adventure game in Python. **Fundamentals:** * The game should allow the player to choose between different paths or actions. * The player's choices should affect the outcome of the game. * The game should have a clear beginning, middle, and end. **Bon...
def start_game(): """ Starts the text-based adventure game. """ print("Welcome to the Text Adventure!") print("You find yourself in a dark forest. Your quest is to find the hidden treasure.") print("You see a path leading north and another leading east.") choice = input("What do you do? Choo...
import pytest from unittest import mock from solution import start_game, north_path, east_path def test_north_path_fight(): with mock.patch('builtins.input', return_value='fight'): with mock.patch('builtins.print') as mocked_print: north_path() mocked_print.assert_any_call("You brav...
[ { "docstring": "Starts the text-based adventure game.", "function_declaration": "def start_game():", "function_name": "start_game", "parameter_list": "()" }, { "docstring": "Handles the scenario when the player chooses the north path.", "function_declaration": "def north_path():", "f...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TextAdventureGame:\n def __init__(self):\n self.introduction()\n self.play_game()\n \n def introduction(self):\n print(\"Welcome to the Text Adventure!\")\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00084568", "row_id": 84568, "seed_ids": "['gemma-2-27b-it_173189']" }
0.387269
Filter_84568
I
[ "start_game", "north_path", "east_path" ]
3
[ [ "start_game", "east_path" ], [ "start_game", "north_path" ] ]
2
[]
false
[]
false
pytest
true
[]
true
05b281d32023cf70f1e666baaa5a5c612af0b0ca
b851136b33c01c328ec3bbc805efa0b051309ca8
v1.0
instruct
Filter
Filter_84576_I
Exercise 1 Part A: Write a function called `count_vowels` that takes a string as an argument and returns the number of vowels in the string. Part B: Write a function called `reverse_string` that takes a string as an argument and returns the reverse of the string. Part C: Write a function called `is_palindrome` th...
import random # Exercise 1 - Part A def count_vowels(string): """Counts the number of vowels in a string.""" vowels = 'aeiouAEIOU' count = 0 for char in string: if char in vowels: count += 1 return count # Exercise 1 - Part B def reverse_string(string): """Reverses a string...
from solution import count_vowels, reverse_string, is_palindrome, user_greeting, sum_of_numbers def test_count_vowels(): assert count_vowels("hello") == 2 assert count_vowels("world") == 1 assert count_vowels("") == 0 assert count_vowels("AEIOUaeiou") == 10 def test_reverse_string(): assert revers...
[ { "docstring": "Counts the number of vowels in a string.", "function_declaration": "def count_vowels(string):", "function_name": "count_vowels", "parameter_list": "(string)" }, { "docstring": "Reverses a string.", "function_declaration": "def reverse_string(string):", "function_name"...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_vowels(string):\n \"\"\"Counts the number of vowels in a string.\"\"\"\n vowels = 'aeiouAEIOU'\n count = 0\n for char in string:\n if char in vowels:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00084576", "row_id": 84576, "seed_ids": "['gemma-2-27b-it_173211']" }
0.661699
Filter_84576
I
[ "count_vowels", "reverse_string", "is_palindrome", "user_greeting", "sum_of_numbers", "guess_number", "read_file" ]
7
[ [ "is_palindrome", "reverse_string" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a75e3a19827ad4f2334ab0ce83565a849c36c4f4
3e828ca2dabe0e3332c1756152310e12e95b4b3e
v1.0
instruct
Filter
Filter_84609_I
This code is written in Python, and aims to determine the largest prime number less than a given integer N.
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 is_prime, largest_prime_less_than def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(29) == True assert is_prime(1) == False assert is_prime(-4) == False assert is_prime(0) == False def test_largest_pr...
[ { "docstring": "Determines if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the largest prime number less than n.", "function_declaration": "def largest_prime_less_than(n):", "functio...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00084609", "row_id": 84609, "seed_ids": "['gemma-2-27b-it_173319']" }
0.715609
Filter_84609
I
[ "is_prime", "largest_prime_less_than" ]
2
[ [ "largest_prime_less_than", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ec9aeb0ab2e08473c142e627bb5c6f257eb8a5f3
007114074b875c7215e066ce1b0c1f2410ae78bd
v1.0
instruct
Filter
Filter_84611_I
This is the code I have written so far: ```python import random def play_game(): """Plays a number guessing game with the user.""" number = random.randint(1, 100) guesses_left = 7 print("Welcome to the Number Guessing Game!") print("I'm thinking of a number between 1 and 100.") while guesses_left > 0: ...
import random def get_max_number_for_difficulty(difficulty): """ Returns the max number for the specified difficulty level. """ if difficulty == "easy": return 50 elif difficulty == "medium": return 100 elif difficulty == "hard": return 200 else: return 100 ...
from solution import get_max_number_for_difficulty def test_get_max_number_for_easy(): assert get_max_number_for_difficulty("easy") == 50 def test_get_max_number_for_medium(): assert get_max_number_for_difficulty("medium") == 100 def test_get_max_number_for_hard(): assert get_max_number_for_difficulty("h...
[ { "docstring": "Returns the max number for the specified difficulty level.", "function_declaration": "def get_max_number_for_difficulty(difficulty):", "function_name": "get_max_number_for_difficulty", "parameter_list": "(difficulty)" }, { "docstring": "Plays a number guessing game with the u...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef play_game():\n \"\"\"Plays a number guessing game with the user.\"\"\"\n \n difficulty = input(\"Choose a difficulty level (easy, medium, hard): \").lower()\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00084611", "row_id": 84611, "seed_ids": "['gemma-2-27b-it_173325']" }
0.477959
Filter_84611
I
[ "get_max_number_for_difficulty", "play_game" ]
2
[ [ "play_game", "get_max_number_for_difficulty" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0ac8bc6109f790e37b191d397dd93b171765b79d
eb77b723dd55c7167ebe5add6f36bd26de12fcca
v1.0
instruct
Filter
Filter_84621_I
Let's say I have a text file containing a bunch of email addresses, one per line. I want to use Python to:** 1. **Read the file and extract each email address.** 2. **Validate the email addresses** using a regular expression. **Here's a sample text file (emails.txt):** ``` test@example.com invalid_email another.tes...
import re def read_emails_from_file(filename): """ Reads email addresses from a given file. """ with open(filename, 'r') as file: emails = file.read().splitlines() return emails def validate_email(email): """ Validates an email address using regular expression. """ email_re...
import pytest from solution import read_emails_from_file, validate_email, extract_and_validate_emails def test_read_emails_from_file(tmp_path): d = tmp_path / "sub" d.mkdir() f = d / "emails.txt" content = "test@example.com\ninvalid_email\nanother.test@domain.net\nmore.test@sub.domain.co.uk" f.writ...
[ { "docstring": "Reads email addresses from a given file.", "function_declaration": "def read_emails_from_file(filename):", "function_name": "read_emails_from_file", "parameter_list": "(filename)" }, { "docstring": "Validates an email address using regular expression.", "function_declarat...
[ 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 extract_and_validate_emails(file_path):\n \"\"\"\n Reads the file, extracts and validates email addresses using regex.\n Returns a list of valid email addresses.\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084621", "row_id": 84621, "seed_ids": "['gemma-2-27b-it_173352']" }
0.551767
Filter_84621
I
[ "read_emails_from_file", "validate_email", "extract_and_validate_emails" ]
3
[ [ "extract_and_validate_emails", "read_emails_from_file" ], [ "extract_and_validate_emails", "validate_email" ] ]
2
[]
false
[]
false
pytest
true
[]
true
cae766c372ce198fa6a5af898e43162efa106307
e5bd3c3963bf22783d0b1c9627fc54b3504a0718
v1.0
instruct
Filter
Filter_84629_I
The goal of the game is to win 3 rounds. 1. **Round 1:** * Player 1 chooses Rock, Paper, Rock, or Scissors. * Player 2 chooses Rock, Paper, or Scissors. * The winner is determined based on the classic rules of Rock, Paper, Scissors. 2. **Rounds 2 and 3:** * The winner of the previous round chooses first. * *...
import random def determine_winner(choice1, choice2): """Determines the winner based on classic Rock, Paper, Scissors rules""" rules = { 'Rock': 'Scissors', 'Scissors': 'Paper', 'Paper': 'Rock' } if choice1 == choice2: return 0 # Tie elif rules[choice1] == choi...
from solution import determine_winner, simulate_game def test_determine_tie(): assert determine_winner('Rock', 'Rock') == 0 assert determine_winner('Paper', 'Paper') == 0 assert determine_winner('Scissors', 'Scissors') == 0 def test_determine_winner(): assert determine_winner('Rock', 'Scissors') == 1 ...
[ { "docstring": "Determines the winner based on classic Rock, Paper, Scissors rules", "function_declaration": "def determine_winner(choice1, choice2):", "function_name": "determine_winner", "parameter_list": "(choice1, choice2)" }, { "docstring": null, "function_declaration": "def simulat...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def rock_paper_scissors_winner(p1_choice, p2_choice):\n \"\"\"\n Determines the winner of a single round of Rock, Paper, Scissors.\n \n Parameters:\n p1_choice (str): The choice...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084629", "row_id": 84629, "seed_ids": "['gemma-2-27b-it_173384']" }
0.564886
Filter_84629
I
[ "determine_winner", "simulate_game" ]
2
[ [ "simulate_game", "determine_winner" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3fda01f1bdcc6caab34cd782b8cfff90948ca4d2
3b5c9f8e0a33705704634d226d900c556ad15b24
v1.0
instruct
Filter
Filter_84640_I
A group of friends are playing a board game where they roll dice to move around the board. Each player starts with 100 points. Landing on certain spaces can award or deduct points. The player with the highest amount of points at the end wins. Goal: Develop a Python program that simulates this board game. Feature...
import random def roll_dice(): return random.randint(1, 6) def simulate_game(player_names): points = {name: 100 for name in player_names} game_on = True turns = 10 # Define number of turns for the game for turn in range(turns): print(f"\nTurn {turn + 1}") for player in player_nam...
from solution import simulate_game, roll_dice def test_roll_dice(): for _ in range(100): roll = roll_dice() assert 1 <= roll <= 6 def test_simulate_game(): player_names = ["Alice", "Bob", "Charlie"] winner, points = simulate_game(player_names) # Check the points are within expected ra...
[ { "docstring": null, "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def simulate_game(player_names):", "function_name": "simulate_game", "parameter_list": "(player_names)" }, { ...
[ 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 simulate dice roll\ndef roll_dice():\n return random.randint(1, 6)\n\ndef initialize_players(num_players):\n players = []\n for i in range(num_players):...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00084640", "row_id": 84640, "seed_ids": "['gemma-2-27b-it_173419']" }
0.504414
Filter_84640
I
[ "roll_dice", "simulate_game", "main" ]
3
[ [ "simulate_game", "roll_dice" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1cd6d23fdee4e7bed2bf4940700679d46f50e8e6
7ba287ac4f97fc2b3e6a3a5d4650966e0c516ac3
v1.0
instruct
Filter
Filter_84644_I
I'm having trouble understanding how to write a program to solve the Travelling Salesperson Problem (TSP) using simulated annealing. **What I understand:** * **TSP:** Find the shortest route that visits all cities exactly once and returns to the starting city. * **Simulated Annealing:** A probabilistic technique to a...
import random import math def distance_matrix(cities): """ Calculate the distance matrix for the given list of cities. Each city is represented as a tuple (x, y). Returns a 2D list where element [i][j] is the distance between city i and city j. """ n = len(cities) dist = [[0] * n for _ in r...
from solution import distance_matrix, route_length, simulated_annealing def test_distance_matrix(): cities = [(0, 0), (3, 4), (6, 8)] dist_matrix = distance_matrix(cities) assert dist_matrix[0][1] == 5.0 assert dist_matrix[1][2] == 5.0 assert dist_matrix[0][2] == 10.0 def test_route_length...
[ { "docstring": "Calculate the distance matrix for the given list of cities.\nEach city is represented as a tuple (x, y).\nReturns a 2D list where element [i][j] is the distance between city i and city j.", "function_declaration": "def distance_matrix(cities):", "function_name": "distance_matrix", "p...
[ 0, 1, 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 distance(cities, tour):\n \"\"\"\n Calculate the total distance of the given tour.\n \"\"\"\n d = 0\n for i in range(len(tour)):\n d += ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00084644", "row_id": 84644, "seed_ids": "['gemma-2-27b-it_173428']" }
0.40022
Filter_84644
I
[ "distance_matrix", "route_length", "simulated_annealing" ]
3
[ [ "simulated_annealing", "distance_matrix" ], [ "simulated_annealing", "route_length" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c150ec345ff7be0ba3ee964e4048a4893e6d9eb8
fd8fde9c481cb34f879be8d92e6435a364620046
v1.0
instruct
Filter
Filter_84650_I
This code is part of a larger program that calculates permutations, calculates the sum of all permutations for a given number, and displays the result. **Part of my program** ```python def permutations(n): # Implement the logic to calculate permutations of n pass def sum_permutations(n): # Implement the log...
import math def permutations(n): """ Returns the number of permutations of `n` items. """ return math.factorial(n) def sum_permutations(n): """ Returns the sum of all permutations from 1 to n. """ total_sum = 0 for i in range(1, n + 1): total_sum += permutations(i) retu...
from solution import permutations, sum_permutations def test_permutations(): assert permutations(1) == 1 assert permutations(2) == 2 assert permutations(3) == 6 assert permutations(4) == 24 assert permutations(5) == 120 def test_sum_permutations(): assert sum_permutations(1) == 1 assert su...
[ { "docstring": "Returns the number of permutations of `n` items.", "function_declaration": "def permutations(n):", "function_name": "permutations", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all permutations from 1 to n.", "function_declaration": "def sum_permutations(...
[ 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 permutations(n):\n \"\"\"\n Returns the number of permutations of n digits.\n We assume n! (factorial of n) as the count of permutations.\n \"\"\"\n return ma...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084650", "row_id": 84650, "seed_ids": "['gemma-2-27b-it_173435']" }
0.681512
Filter_84650
I
[ "permutations", "sum_permutations" ]
2
[ [ "sum_permutations", "permutations" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b378fad676157598a36f9aa326e5bc37c7129fd0
e69e74cc5164f8fd05c39d8f89d4200622dcba54
v1.0
instruct
Filter
Filter_84656_I
I need help with creating a basic Python calculator. Here's what I want it to do: 1. **Present a menu to the user:** This menu should list the available operations: * Addition * Subtraction * Multiplication * Division 2. **Prompt the user to select an operation.** 3. **Prompt the user to enter two num...
def menu(): """ Displays the menu of operations. """ print("Select operation:") print("1. Addition") print("2. Subtraction") print("3. Multiplication") print("4. Division") def add(a, b): """ Returns the sum of a and b. """ return a + b def subtract(a, b): """ R...
import pytest from solution import add, subtract, multiply, divide def test_add(): assert add(2, 3) == 5 assert add(-1, -1) == -2 assert add(0, 0) == 0 assert add(2.5, 3.5) == 6.0 def test_subtract(): assert subtract(3, 2) == 1 assert subtract(-1, -1) == 0 assert subtract(0, 0) == 0 as...
[ { "docstring": "Displays the menu of operations.", "function_declaration": "def menu():", "function_name": "menu", "parameter_list": "()" }, { "docstring": "Returns the sum of a and b.", "function_declaration": "def add(a, b):", "function_name": "add", "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 menu():\n \"\"\"\n Displays the menu of operations.\n \"\"\"\n print(\"Select operation:\")\n print(\"1. Addition\")\n print(\"2. Subtraction\")\n print(\"3. Multiplic...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00084656", "row_id": 84656, "seed_ids": "['gemma-2-27b-it_173455']" }
0.577761
Filter_84656
I
[ "menu", "add", "subtract", "multiply", "divide", "calculator" ]
6
[ [ "calculator", "add" ], [ "calculator", "divide" ], [ "calculator", "menu" ], [ "calculator", "multiply" ], [ "calculator", "subtract" ] ]
5
[]
false
[]
false
pytest
true
[]
true
be98fdd6036f363c275a3cdd26c2111ae7254a5e
4542ec02a0324e12dead0df7520fc0ad51802613
v1.0
instruct
Filter
Filter_84657_I
In Python, how can I create a function that takes a list of integers as input and returns a new list containing only the prime numbers from the original list?
def is_prime(n): """ Check if a number is a prime number. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 re...
from solution import filter_primes def test_filter_primes(): assert filter_primes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 3, 5, 7] assert filter_primes([11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [11, 13, 17, 19] assert filter_primes([0, 1, -5, -7, 23]) == [23] assert filter_primes([29, 30, 31, 32, 33...
[ { "docstring": "Check if a number is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the given list of integers.", "function_declaration": "def filter_primes(numbers...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if the given number n is a prime number, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084657", "row_id": 84657, "seed_ids": "['gemma-2-27b-it_173456']" }
0.616734
Filter_84657
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
88a4ed909578fd91be0a84273b37f12e3a9a0603
50c316945889e7221f10a74cc01bf376c3257bed
v1.0
instruct
Filter
Filter_84668_I
We want to create a simple, but effective, chatbot using Python. **Goal:** The chatbot should be able to greet the user, ask for their name, remember it, and use it in subsequent responses. **Libraries:** * We'll use the `random` library for randomly selecting greetings and responses. I can't help with actual code...
import random def greet(name): """ Returns a greeting message that includes the user's name. """ greetings = ["Hello", "Hi", "Hey there", "Hey"] return random.choice(greetings) + ", " + name + "!" def get_user_name(): """ Prompts the user for their name and returns it. """ name = i...
from unittest.mock import patch from solution import greet, get_user_name, chatbot def test_greet(): name = "Alice" greeting = greet(name) assert any(g in greeting for g in ["Hello", "Hi", "Hey there", "Hey"]) assert name in greeting def test_get_user_name(): with patch('builtins.input', return_va...
[ { "docstring": "Returns a greeting message that includes the user's name.", "function_declaration": "def greet(name):", "function_name": "greet", "parameter_list": "(name)" }, { "docstring": "Prompts the user for their name and returns it.", "function_declaration": "def get_user_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\ndef greet(name):\n \"\"\"\n Greets the user with a random greeting followed by their name.\n \"\"\"\n greetings = [\"Hello\", \"Hi\", \"Hey there\", \"Hey\"]\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00084668", "row_id": 84668, "seed_ids": "['gemma-2-27b-it_173475']" }
0.460069
Filter_84668
I
[ "greet", "get_user_name", "chatbot" ]
3
[ [ "chatbot", "get_user_name" ], [ "chatbot", "greet" ] ]
2
[]
false
[]
false
pytest
true
[]
true
382703ad364a65d16d064f029c556b82db4255cd
5ba4c3f97c08be0a71aac8365a6866dc3ed12282
v1.0
instruct
Filter
Filter_84680_I
How can I create a simple, interactive quiz using Python?
def ask_question(question, options, correct_answer): """ Asks a question and checks if the provided answer is correct. :param question: The question to ask :param options: A list of answer options :param correct_answer: The correct answer :return: True if the answer is correct, False otherw...
from solution import ask_question, start_quiz def test_ask_question_correct(monkeypatch): monkeypatch.setattr('builtins.input', lambda _: '3') assert ask_question("What is the capital of France?", ["London", "Berlin", "Paris", "Madrid"], "Paris") def test_ask_question_incorrect(monkeypatch): monkeypatch.s...
[ { "docstring": "Asks a question and checks if the provided answer is correct.\n\n:param question: The question to ask\n:param options: A list of answer options\n:param correct_answer: The correct answer\n:return: True if the answer is correct, False otherwise", "function_declaration": "def ask_question(ques...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def ask_question(question, options, correct_answer):\n \"\"\"\n Asks a question and checks if the provided answer is correct.\n \n :param question: The question to ask\n :param ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00084680", "row_id": 84680, "seed_ids": "['gemma-2-27b-it_173508']" }
0.404146
Filter_84680
I
[ "ask_question", "start_quiz" ]
2
[ [ "start_quiz", "ask_question" ] ]
1
[]
false
[]
false
pytest
true
[]
true
87e225c2c74aa2464a9eb1d83a09fc09ef42e86a
fd539e9872e7e22c435771d4e7a22b858189629c
v1.0
instruct
Filter
Filter_84719_I
This is a tricky one! I want to create a program that will solve a Sudoku puzzle. **Input:** A 9x9 grid representing the Sudoku puzzle. Empty cells will be represented by a **Output:** The solved Sudoku puzzle, or an indication that the puzzle has no solution. I think using a backtracking algorithm would be a goo...
def is_valid(board, row, col, num): """ Check if it's valid to place num in the board at (row, col) """ # Check row if num in board[row]: return False # Check column if num in [board[i][col] for i in range(9)]: return False # Check 3x3 sub-grid start_row, start_...
from solution import solve_sudoku, print_sudoku def test_sudoku_solver(): 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], [...
[ { "docstring": "Check if it's valid to place num in the board at (row, col)", "function_declaration": "def is_valid(board, row, col, num):", "function_name": "is_valid", "parameter_list": "(board, row, col, num)" }, { "docstring": "Find the first unassigned location on the board.\nReturns a ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_valid(board, row, col, num):\n \"\"\"\n Check if placing num in the position board[row][col] is valid.\n \"\"\"\n for x in range(9):\n if board[row][x] == num:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00084719", "row_id": 84719, "seed_ids": "['gemma-2-27b-it_173621']" }
0.435312
Filter_84719
I
[ "is_valid", "find_unassigned_location", "solve_sudoku", "print_sudoku" ]
4
[ [ "solve_sudoku", "find_unassigned_location" ], [ "solve_sudoku", "is_valid" ] ]
2
[]
false
[]
false
pytest
true
[]
true
44a719c53c0d4f52a5ea239d2e336dcf2e150114
f3bf0069f96c72f8f4fa0eed26a16d67558c4750
v1.0
instruct
Filter
Filter_84729_I
There is a problem statement: "Write a Python script that reads a file containing a list of words, one word per line, and prints the words in reverse alphabetical order." You are given a Python script: ```python def read_words(filename): """Reads a file and returns a list of words.""" with open(filename, 'r') as ...
def read_words(filename): """Reads a file and returns a list of words.""" with open(filename, 'r') as file: words = file.readlines() return [word.strip() for word in words] def reverse_alphabetical_order(words): """Sorts a list of words in reverse alphabetical order.""" return sorted(words,...
from solution import read_words, reverse_alphabetical_order, print_words_in_reverse_alphabetical_order import pytest from io import StringIO import sys def test_read_words(tmp_path): words = ["apple", "banana", "cherry"] file = tmp_path / "words.txt" file.write_text("\n".join(words)) assert read_words(...
[ { "docstring": "Reads a file and returns a list of words.", "function_declaration": "def read_words(filename):", "function_name": "read_words", "parameter_list": "(filename)" }, { "docstring": "Sorts a list of words in reverse alphabetical order.", "function_declaration": "def reverse_al...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def read_words(filename):\n \"\"\"\n Reads a file and returns a list of words.\n \"\"\"\n with open(filename, 'r') as file:\n words = file.readlines()\n return [word.stri...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084729", "row_id": 84729, "seed_ids": "['gemma-2-27b-it_173641']" }
0.570387
Filter_84729
I
[ "read_words", "reverse_alphabetical_order", "print_words_in_reverse_alphabetical_order" ]
3
[ [ "print_words_in_reverse_alphabetical_order", "read_words" ], [ "print_words_in_reverse_alphabetical_order", "reverse_alphabetical_order" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5baf43c5f5be01f8c1a0859057e18a456965ec95
190a4d14edf25b0101f8fa4a3087732f231aa66f
v1.0
instruct
Filter
Filter_84737_I
This code solves the N-Queens problem using backtracking. ```python def is_safe(board, row, col, N): # Check row on left side for i in range(col): if board[row][i] == 1: return False # Check upper diagonal on left side for i, j in zip(range(row, -1, -1), range(col, -1, -1)): ...
def is_safe(board, row, col, N): # Check row on left side for i in range(col): if board[row][i] == 1: return False # Check upper diagonal on left side for i, j in zip(range(row, -1, -1), range(col, -1, -1)): if board[i][j] == 1: return False # Check lower di...
from solution import solve_nqueens def test_solve_nqueens_4(): solutions = solve_nqueens(4) expected_solutions = [ [".Q..","...Q","Q...","..Q."], ["..Q.","Q...","...Q",".Q.."] ] assert len(solutions) == len(expected_solutions) assert all(solution in expected_solutions for solution i...
[ { "docstring": null, "function_declaration": "def is_safe(board, row, col, N):", "function_name": "is_safe", "parameter_list": "(board, row, col, N)" }, { "docstring": null, "function_declaration": "def solve_nqueens_util(board, col, N, solutions):", "function_name": "solve_nqueens_u...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_safe(board, row, col, N):\n # Check row on left side\n for i in range(col):\n if board[row][i] == 1:\n return False\n\n # Check upper diagonal on left side\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084737", "row_id": 84737, "seed_ids": "['gemma-2-27b-it_173661']" }
0.562676
Filter_84737
I
[ "is_safe", "solve_nqueens_util", "solve_nqueens" ]
3
[ [ "solve_nqueens", "solve_nqueens_util" ], [ "solve_nqueens_util", "is_safe" ] ]
2
[]
false
[]
false
pytest
true
[]
true
18cf3a0f64df76d72227ba32362c905df3161642
2c681654c02c4a55306fd9f2e2ed03148ffaa5b9
v1.0
instruct
Filter
Filter_84753_I
I have a list of lists, where each inner list represents a sequence of operations. I want to find the longest common subsequence (LCS) of all these sequences. For example: ``` sequences = [ [1, 2, 3, 4, 5], [2, 4, 5, 6, 7], [1, 3, 4, 5, 8] ] # Expected Output: [4, 5] ``` Can you implement a Python funct...
from functools import lru_cache def lcs(X, Y): """ Returns the longest common subsequence of sequences X and Y. """ @lru_cache(maxsize=None) def lcs_helper(m, n): if m == 0 or n == 0: return [] elif X[m-1] == Y[n-1]: return lcs_helper(m-1, n-1) + [X[m-1]] ...
from solution import find_lcs_of_sequences def test_find_lcs_of_sequences(): sequences = [ [1, 2, 3, 4, 5], [2, 4, 5, 6, 7], [1, 3, 4, 5, 8] ] assert find_lcs_of_sequences(sequences) == [4, 5] def test_find_lcs_with_no_common_subsequence(): sequences = [ [1, 2, 3], ...
[ { "docstring": "Returns the longest common subsequence of sequences X and Y.", "function_declaration": "def lcs(X, Y):", "function_name": "lcs", "parameter_list": "(X, Y)" }, { "docstring": "Returns the longest common subsequence among all the input sequences.", "function_declaration": "...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from functools import lru_cache\n\ndef lcs(seq1, seq2):\n \"\"\"\n Helper function to calculate the longest common subsequence between two sequences.\n \"\"\"\n m, n = len(seq1), l...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084753", "row_id": 84753, "seed_ids": "['gemma-2-27b-it_173705']" }
0.583439
Filter_84753
I
[ "lcs", "find_lcs_of_sequences" ]
2
[ [ "find_lcs_of_sequences", "lcs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a1ca8614e3acc815fc6e5be384faf993e87aa5a3
889976cadcac3db1e88fee2518f7bc544bae06eb
v1.0
instruct
Filter
Filter_84767_I
The following code in Python defines a function that takes a list of strings as input and returns a new list containing only the strings that are palindromes.
def is_palindrome(s): """ Checks if a given string s is a palindrome. """ return s == s[::-1] def filter_palindromes(lst): """ Filters and returns only the palindrome strings from the input list lst. """ return [s for s in lst if is_palindrome(s)]
from solution import is_palindrome, filter_palindromes def test_is_palindrome(): assert is_palindrome("madam") == True assert is_palindrome("racecar") == True assert is_palindrome("hello") == False assert is_palindrome("a") == True assert is_palindrome("abcba") == True assert is_palindrome("") ...
[ { "docstring": "Checks if a given string s is a palindrome.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Filters and returns only the palindrome strings from the input list lst.", "function_declaration": "...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Returns True if the string s is a palindrome, False otherwise.\n \"\"\"\n return s == s[::-1]\n\ndef filter_palindromes(strings):\n \"\"\"\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084767", "row_id": 84767, "seed_ids": "['gemma-2-27b-it_173733']" }
0.742859
Filter_84767
I
[ "is_palindrome", "filter_palindromes" ]
2
[ [ "filter_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6700c33f56623667d54b5697423ac65e5e9916ee
05a0c258ad404fec35c2a22a6189aac7b1f63ce0
v1.0
instruct
Filter
Filter_84775_I
You are creating a game where the player needs to choose a secret 4-digit code. Goal: Write a program that: 1. Generates a random 4-digit code. 2. Asks the player to guess the code. 3. Provides feedback on the guess: Correct digits in the correct position: Displayed as "●" (black circle) Correct digits but in...
import random def generate_code(): """Generates a random 4-digit code with unique digits.""" digits = list(range(10)) random.shuffle(digits) return "".join(map(str, digits[:4])) def check_guess(code, guess): """Compares the code and guess, returning feedback.""" feedback = ["-"] * 4 # Initial...
from solution import generate_code, check_guess def test_generate_code_length(): code = generate_code() assert len(code) == 4 def test_generate_code_unique_digits(): code = generate_code() assert len(set(code)) == 4 def test_generate_code_is_digit(): code = generate_code() assert code.isdigit...
[ { "docstring": "Generates a random 4-digit code with unique digits.", "function_declaration": "def generate_code():", "function_name": "generate_code", "parameter_list": "()" }, { "docstring": "Compares the code and guess, returning feedback.", "function_declaration": "def check_guess(co...
[ 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 generate_code():\n \"\"\"Generates a random 4-digit code with unique digits.\"\"\"\n digits = list(range(10))\n random.shuffle(digits)\n return \"\".join(map(s...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084775", "row_id": 84775, "seed_ids": "['gemma-2-27b-it_173757']" }
0.538286
Filter_84775
I
[ "generate_code", "check_guess", "play_game" ]
3
[ [ "play_game", "check_guess" ], [ "play_game", "generate_code" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6691c3425ddac9d452e5085acd57f702e244c1ca
621cb6a513eb8456f5aa47593f6b72d20d836bce
v1.0
instruct
Filter
Filter_84779_I
This is the code for a simple game in Python: ```python import random def guess_the_number(): number = random.randint(1, 100) guesses_left = 7 print("Welcome to Guess the Number!") print("I'm thinking of a number between 1 and 100.") while guesses_left > 0: print(f"You have {guesses_left}...
import random def get_number_range_for_difficulty(difficulty): if difficulty == "easy": return 1, 10 elif difficulty == "medium": return 1, 100 else: # hard return 1, 1000 def guess_the_number(): print("Welcome to Guess the Number!") while True: difficulty = input(...
from solution import get_number_range_for_difficulty, play_again def test_get_number_range_for_difficulty(): assert get_number_range_for_difficulty("easy") == (1, 10) assert get_number_range_for_difficulty("medium") == (1, 100) assert get_number_range_for_difficulty("hard") == (1, 1000) def test_play_agai...
[ { "docstring": null, "function_declaration": "def get_number_range_for_difficulty(difficulty):", "function_name": "get_number_range_for_difficulty", "parameter_list": "(difficulty)" }, { "docstring": null, "function_declaration": "def guess_the_number():", "function_name": "guess_the...
[ 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 guess_the_number():\n print(\"Welcome to Guess the Number!\")\n difficulty = input(\"Choose difficulty level (easy/medium/hard): \").strip().lower()\n\n if diffic...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084779", "row_id": 84779, "seed_ids": "['gemma-2-27b-it_173767']" }
0.603671
Filter_84779
I
[ "get_number_range_for_difficulty", "guess_the_number", "play_again" ]
3
[ [ "guess_the_number", "get_number_range_for_difficulty" ], [ "guess_the_number", "play_again" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2130d98dc0d2e6154c8f838d40f4cca57652581c
572a2723ff315bf834410a174485e827feb1498a
v1.0
instruct
Filter
Filter_84785_I
Here's the plan: 1. **Create a Python script that generates a list of prime numbers** 2. **Specify a range (lower and upper bounds) for the prime number generation.** 3. **Take user input for both the lower and upper bounds.** ```python
def is_prime(n): """ Check if a number is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True...
from solution import is_prime, generate_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(11) == True assert is_prime(1) == False assert is_prime(0) == Fal...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Generate a list of prime numbers in a given range.", "function_declaration": "def generate_primes(lower, upper):", "functi...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00084785", "row_id": 84785, "seed_ids": "['gemma-2-27b-it_173789']" }
0.596812
Filter_84785
I
[ "is_prime", "generate_primes" ]
2
[ [ "generate_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0ddd9edc704d3a1adece8a6cc8c017449252fbf0
5cfa5ddc3cd4a397b998566fdb4c8f8631c113cc
v1.0
instruct
Filter
Filter_84794_I
Problem statement: Develop a Python program that simulates a simple rock-paper-scissors game. Program Requirements: 1. The program should allow the user to input their choice (rock, paper, or scissors). 2. The program should randomly generate the computer's choice. 3. The program should determine the winner based...
import random def get_computer_choice(): """ Randomly generate the computer's choice. """ return random.choice(["rock", "paper", "scissors"]) def determine_winner(user_choice, computer_choice): """ Determine the winner of the game. :param user_choice: Choice made by the user ('rock', 'pape...
from solution import get_computer_choice, determine_winner, play_rock_paper_scissors def test_get_computer_choice(): choices = ["rock", "paper", "scissors"] assert get_computer_choice() in choices def test_determine_winner(): assert determine_winner("rock", "scissors") == "You win!" assert determine_w...
[ { "docstring": "Randomly generate the computer's choice.", "function_declaration": "def get_computer_choice():", "function_name": "get_computer_choice", "parameter_list": "()" }, { "docstring": "Determine the winner of the game.\n:param user_choice: Choice made by the user ('rock', 'paper', ...
[ 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 \"\"\"\n Randomly generates the computer's choice of rock, paper, or scissors.\n \"\"\"\n return random.choice([\"rock\", \"paper\", \...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084794", "row_id": 84794, "seed_ids": "['gemma-2-27b-it_173808']" }
0.553329
Filter_84794
I
[ "get_computer_choice", "determine_winner", "play_rock_paper_scissors" ]
3
[ [ "play_rock_paper_scissors", "determine_winner" ], [ "play_rock_paper_scissors", "get_computer_choice" ] ]
2
[]
false
[]
false
pytest
true
[]
true
526941bb00098bf4cc314e89d7a32a1479b1c33e
3eec0af4161c08b2f1db3d911c5a874557d69695
v1.0
instruct
Filter
Filter_84809_I
There is a new game called "Catch The Dragon". Here are the rules: 1. The game is played on a grid of squares. 2. A dragon starts at a random square. *The dragon can only move diagonally, up, down, left, or right one square at a time*. 3. The player can choose a square to "throw a net" at. 4. If the net lands on th...
import random # Define grid size grid_size = 5 def create_grid(size): return [[' ' for _ in range(size)] for _ in range(size)] def place_dragon(grid): size = len(grid) dragon_x, dragon_y = random.randint(0, size - 1), random.randint(0, size - 1) grid[dragon_y][dragon_x] = 'D' return dragon_x, dra...
import pytest from solution import create_grid, place_dragon, throw_net, move_dragon def test_create_grid(): grid = create_grid(5) assert len(grid) == 5 assert len(grid[0]) == 5 assert all(cell == ' ' for row in grid for cell in row) def test_place_dragon(): grid = create_grid(5) dragon_x, dra...
[ { "docstring": null, "function_declaration": "def create_grid(size):", "function_name": "create_grid", "parameter_list": "(size)" }, { "docstring": null, "function_declaration": "def place_dragon(grid):", "function_name": "place_dragon", "parameter_list": "(grid)" }, { "d...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\n# Define grid size\ngrid_size = 5\n\n# Create the grid\ndef create_grid():\n return [[' ' for _ in range(grid_size)] for _ in range(grid_size)]\n\n# Function to randomly pl...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084809", "row_id": 84809, "seed_ids": "['gemma-2-27b-it_173841']" }
0.528255
Filter_84809
I
[ "create_grid", "place_dragon", "display_grid", "move_dragon", "throw_net", "play_game" ]
6
[ [ "play_game", "create_grid" ], [ "play_game", "display_grid" ], [ "play_game", "move_dragon" ], [ "play_game", "place_dragon" ], [ "play_game", "throw_net" ] ]
5
[]
false
[]
false
pytest
true
[]
true
d9404605e766591f5eeffcb99cc5bd88f3c1b040
347096d15e4116a067d3a08d73e9ea5f6f9836ba
v1.0
instruct
Filter
Filter_84929_I
I want to write a program that solves a Sudoku puzzle. Can you give me a detailed breakdown of the steps and algorithms involved?
def is_safe(board, row, col, num): """ Check if placing the num at board[row][col] is a valid move. """ # Check row for x in range(9): if board[row][x] == num: return False # Check column for x in range(9): if board[x][col] == num: return False #...
from solution import solve_sudoku def test_solve_sudoku(): 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, 0, 0, ...
[ { "docstring": "Check if placing the num at board[row][col] is a valid move.", "function_declaration": "def is_safe(board, row, col, num):", "function_name": "is_safe", "parameter_list": "(board, row, col, num)" }, { "docstring": "Find an empty spot on the Sudoku grid.", "function_declar...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_safe(board, row, col, num):\n \"\"\"\n Check if placing the num at board[row][col] is a valid move.\n \"\"\"\n # Check row\n for x in range(9):\n if board[row][x] ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00084929", "row_id": 84929, "seed_ids": "['gemma-2-27b-it_174197']" }
0.375718
Filter_84929
I
[ "is_safe", "find_empty_location", "solve_sudoku" ]
3
[ [ "solve_sudoku", "find_empty_location" ], [ "solve_sudoku", "is_safe" ] ]
2
[]
false
[]
false
pytest
true
[]
true
29fae2dd9c78f29b55078b8719a4d0cf63854ab2
a009ec9c91597ac99271b417cee1cb4b24fa567a
v1.0
instruct
Filter
Filter_84936_I
This ``` def sum_of_primes(n: int) -> int: """ Given an integer n, return the sum of all prime numbers less than or equal to n. Example: sum_of_primes(10) == 17 """ ``` This function expects an integer as input and should return the sum of all prime numbers less than or equal to that integer. Ca...
def is_prime(num: int) -> bool: """ Helper function to check if a number is prime. """ if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: ...
from solution import sum_of_primes def test_sum_of_primes_up_to_10(): assert sum_of_primes(10) == 17 # primes are 2, 3, 5, 7 def test_sum_of_primes_up_to_1(): assert sum_of_primes(1) == 0 # no primes <= 1 def test_sum_of_primes_up_to_2(): assert sum_of_primes(2) == 2 # only prime is 2 def test_sum_of...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Given an integer n, return the sum of all prime numbers less than or equal to n.", "function_declaratio...
[ 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: int) -> bool:\n \"\"\"\n Helper function to determine if a given number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00084936", "row_id": 84936, "seed_ids": "['gemma-2-27b-it_174219']" }
0.712498
Filter_84936
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
376c6a9d403f98d5887fa1b3e4819b4655c52f45
459a6aeb927b41a97f474ea1e9fb5fd49e813ebd
v1.0
instruct
Filter
Filter_84970_I
This project involves creating a basic chatbot using Python. **Here are the key concepts and technologies involved:** * **Natural Language Processing (NLP):** Analyzing and understanding human language. * **Pattern Matching:** Identifying patterns in text to determine user intent. * **Rule-Based System:** Using prede...
import re import random # Dictionary of intents and responses intents = { "greeting": ["Hello!", "Hi there! How can I help you?", "Hey!"], "goodbye": ["Goodbye!", "Have a nice day!", "See you later!"], "weather": ["The weather is sunny!", "Looks like it might rain today.", "It's quite cloudy at the moment....
from solution import get_intent, chatbot_response def test_get_intent_greeting(): assert get_intent("Hello!") == "greeting" assert get_intent("Hi there") == "greeting" assert get_intent("Hey!") == "greeting" def test_get_intent_goodbye(): assert get_intent("Goodbye!") == "goodbye" assert get_inten...
[ { "docstring": "Determine the intent of the user input using pattern matching.", "function_declaration": "def get_intent(user_input):", "function_name": "get_intent", "parameter_list": "(user_input)" }, { "docstring": "Generate a response based on user input.", "function_declaration": "d...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\nimport random\n\n# Dictionary of intents and responses\nintents = {\n \"greeting\": [\"Hello!\", \"Hi there! How can I help you?\", \"Hey!\"],\n \"goodbye\": [\"Goodbye!\", \"...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00084970", "row_id": 84970, "seed_ids": "['gemma-2-27b-it_174326']" }
0.50971
Filter_84970
I
[ "get_intent", "chatbot_response" ]
2
[ [ "chatbot_response", "get_intent" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a803c9656ec8e385e19c74460c6a74f04188f2b8
4049b23989da220fe365da09ac8221b6e05c2189
v1.0
instruct
Filter
Filter_85002_I
This is the problem: We have a collection of integers that will be sorted. We are looking for an efficient way to find duplicate and unique numbers. We want to output both lists, "duplicate numbers" and "unique numbers", in ascending order. You have to achieve this by using only the functions provided below: - `ap...
def append(lst, element): lst += [element] return lst def sort(lst): lst.sort() return lst def find_duplicates_and_uniques(numbers): duplicate_numbers = [] unique_numbers = [] if len(numbers) == 0: return sort(duplicate_numbers), sort(unique_numbers) previous = number...
def test_find_duplicates_and_uniques_no_numbers(): assert find_duplicates_and_uniques([]) == ([], []) def test_find_duplicates_and_uniques_single_element(): assert find_duplicates_and_uniques([1]) == ([], [1]) def test_find_duplicates_and_uniques_all_unique(): assert find_duplicates_and_uniques([1, 2, 3, ...
[ { "docstring": null, "function_declaration": "def append(lst, element):", "function_name": "append", "parameter_list": "(lst, element)" }, { "docstring": null, "function_declaration": "def sort(lst):", "function_name": "sort", "parameter_list": "(lst)" }, { "docstring": n...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_duplicates_and_uniques(numbers):\n \"\"\"\n Finds duplicate and unique numbers in a sorted list of integers.\n\n Args:\n numbers: A sorted list of integers.\n\n Ret...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00085002", "row_id": 85002, "seed_ids": "['gemma-2-27b-it_174408']" }
0.720372
Filter_85002
I
[ "append", "sort", "find_duplicates_and_uniques" ]
3
[ [ "find_duplicates_and_uniques", "append" ], [ "find_duplicates_and_uniques", "sort" ] ]
2
[]
false
[]
false
pytest
false
[]
true
c8b94d9300f2b0b49c1d6aa8081b57ca0749f5a3
5320ecbec33ccebb85ae138c708ed49deaaf69ea
v1.0
instruct
Filter
Filter_85034_I
Here are some more rules for my game: * **Number of Players:** 2 * **Objective:** Be the first player to reach a predetermined number of points. * **Gameplay:** Players take turns drawing two cards from a standard 52-card deck. Players can choose to keep either, both, or neither of the drawn cards and discard them f...
import random # Constants SUITS = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] RANKS = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'] POINTS = {str(i): i for i in range(2, 11)} POINTS.update({'J': 10, 'Q': 10, 'K': 10, 'A': (1, 11)}) # Initialize deck of cards def initialize_deck(): return [(rank...
from solution import initialize_deck, shuffle_deck, draw_two_cards, evaluate_card, take_turn, play_game def test_initialize_deck(): deck = initialize_deck() assert len(deck) == 52 assert ('A', 'Hearts') in deck assert ('10', 'Spades') in deck def test_shuffle_deck(): deck = initialize_deck() d...
[ { "docstring": null, "function_declaration": "def initialize_deck():", "function_name": "initialize_deck", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def shuffle_deck(deck):", "function_name": "shuffle_deck", "parameter_list": "(deck)" }, { "d...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "Magpie-Filter-89K_sanitized_prepared1_results_combined.jsonl", "solution_code": "import random\n\ndef create_deck():\n \"\"\"\n Creates a standard deck of 52 cards.\n \"\"\"\n values = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J',...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00085034", "row_id": 85034, "seed_ids": "['gemma-2-27b-it_174490']" }
0.573421
Filter_85034
I
[ "initialize_deck", "shuffle_deck", "draw_two_cards", "evaluate_card", "take_turn", "play_game" ]
6
[ [ "play_game", "initialize_deck" ], [ "play_game", "shuffle_deck" ], [ "play_game", "take_turn" ], [ "take_turn", "draw_two_cards" ], [ "take_turn", "evaluate_card" ] ]
5
[]
false
[]
false
pytest
true
[]
true
2808ae231a97c18b2fd0f6ee4d8f0e781bfe47c7
88fd8fd56f2eda1c7441b973ce4caad29b6048ad