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_87458_I | I am creating a system to track customer orders.
Input: I will receive orders in the form of a list of dictionaries, where each dictionary represents an item in the order.
Example Input:
```python
order = [
{'item': 'Apple', 'quantity': 2, 'price': 1.00},
{'item': 'Banana', 'quantity': 3, 'price': 0.50},
... | def calculate_order_cost(order):
"""
Calculate the total cost of an order.
Parameters:
order (list): A list of dictionaries where each dictionary has 'item', 'quantity', and 'price'.
Returns:
float: Total cost of the order.
"""
total_cost = sum(item['quantity'] * item['price'] ... | from solution import calculate_order_cost, calculate_total_cost
def test_calculate_order_cost():
order = [
{'item': 'Apple', 'quantity': 2, 'price': 1.00},
{'item': 'Banana', 'quantity': 3, 'price': 0.50},
{'item': 'Milk', 'quantity': 1, 'price': 2.50}
]
assert calculate_order_cost(... | [
{
"docstring": "Calculate the total cost of an order.\n\nParameters:\norder (list): A list of dictionaries where each dictionary has 'item', 'quantity', and 'price'.\n\nReturns:\nfloat: Total cost of the order.",
"function_declaration": "def calculate_order_cost(order):",
"function_name": "calculate_ord... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def calculate_total_cost(orders):\n \"\"\"\n Calculates the total cost of each order and the total cost of all orders.\n \n Args:\n orders (list): A list where each element is a... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087458",
"row_id": 87458,
"seed_ids": "['gemma-2-27b-it_181507']"
} | 0.522075 | Filter_87458 | I | [
"calculate_order_cost",
"calculate_total_cost"
] | 2 | [
[
"calculate_total_cost",
"calculate_order_cost"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | dc9e5b01b89008d825115aea38eb9e626573c341 | b620a53802f2d9c3f258600280beb1192dfa5091 | |||
v1.0 | instruct | Filter | Filter_87460_I | Problem Statement:
Design a program that performs a brute-force attack on a simple Caesar cipher.
Caesar Cipher: A Caesar cipher is a type of substitution cipher in which each letter in the plaintext is shifted a certain number of places down the alphabet. For example, with a shift of 3, A would be replaced by D, B w... | def decrypt_caesar(ciphertext, shift):
"""Decrypts a Caesar cipher with the given shift."""
plaintext = ''
for char in ciphertext:
if char.isalpha():
start = ord('a') if char.islower() else ord('A')
shifted_char = chr((ord(char) - start - shift) % 26 + start)
else:
... | from solution import decrypt_caesar, brute_force_caesar
def test_decrypt_caesar_lower_case():
assert decrypt_caesar("d", 3) == "a"
assert decrypt_caesar("e", 4) == "a"
assert decrypt_caesar("z", 1) == "y"
def test_decrypt_caesar_upper_case():
assert decrypt_caesar("D", 3) == "A"
assert decrypt_cae... | [
{
"docstring": "Decrypts a Caesar cipher with the given shift.",
"function_declaration": "def decrypt_caesar(ciphertext, shift):",
"function_name": "decrypt_caesar",
"parameter_list": "(ciphertext, shift)"
},
{
"docstring": "Performs a brute-force attack on the given Caesar cipher ciphertext... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def decrypt_caesar(ciphertext, shift):\n \"\"\"\n Decrypts a Caesar cipher with the given shift.\n \"\"\"\n plaintext = ''\n for char in ciphertext:\n if char.isalpha():\... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087460",
"row_id": 87460,
"seed_ids": "['gemma-2-27b-it_181518']"
} | 0.562901 | Filter_87460 | I | [
"decrypt_caesar",
"brute_force_caesar"
] | 2 | [
[
"brute_force_caesar",
"decrypt_caesar"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 0c4e1477a1970b97c58a9da041fdb2e863a56ed7 | d78835347bb8ff29952cd84d40cf589da583574b | |||
v1.0 | instruct | Filter | Filter_87472_I | The game is Rock, Paper, Scissors.
Player 1 and Player 2 always play the following repeating cycles:
Player 1: Rock, Paper, Scissors
Player 2: Scissors, Paper, Rock
You can simulate this to predict who would win each round by generating a random number for each player. A random number between 1 and 3, inclusive, ca... | import random
def get_move(player, round_number):
"""
Returns the move of the player in the given round.
Player 1 follows a cycle of 'Rock', 'Paper', 'Scissors'.
Player 2 follows a cycle of 'Scissors', 'Paper', 'Rock'.
"""
moves_player1 = ['Rock', 'Paper', 'Scissors']
moves_player2 = ['Scis... | import pytest
from solution import get_move, determine_winner, simulate_round
def test_get_move():
assert get_move(1, 0) == 'Rock'
assert get_move(1, 1) == 'Paper'
assert get_move(1, 2) == 'Scissors'
assert get_move(1, 3) == 'Rock'
assert get_move(2, 0) == 'Scissors'
assert get_move(2, 1) == 'P... | [
{
"docstring": "Returns the move of the player in the given round.\nPlayer 1 follows a cycle of 'Rock', 'Paper', 'Scissors'.\nPlayer 2 follows a cycle of 'Scissors', 'Paper', 'Rock'.",
"function_declaration": "def get_move(player, round_number):",
"function_name": "get_move",
"parameter_list": "(pla... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\n\ndef get_move(player):\n \"\"\"\n Given a player number (1 or 2), it returns their move in the cyclic pattern. \n 1: Rock, 2: Paper, 3: Scissors.\n \"\"\"\n if p... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087472",
"row_id": 87472,
"seed_ids": "['gemma-2-27b-it_181546']"
} | 0.568368 | Filter_87472 | I | [
"get_move",
"determine_winner",
"simulate_round"
] | 3 | [
[
"simulate_round",
"determine_winner"
],
[
"simulate_round",
"get_move"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | f813829c1f2310256fab4abadcccb31d87582d44 | 515dec31cf153de5285a7756a7e8bbc0edc8de56 | |||
v1.0 | instruct | Filter | Filter_87481_I | This is a follow-up question to a previous question. My goal is to write a Python code that calculates the determinant of a matrix.
The previous response gave me a recursive solution for finding the determinant of a square matrix of any size. I am now working on implementing it in Python but facing difficulty understa... | def determinant(matrix):
"""
Calculate the determinant of a square matrix.
"""
n = len(matrix)
if n == 1:
return matrix[0][0]
elif n == 2:
return matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0]
else:
det = 0
for i in range(n):
sub_matrix ... | from solution import determinant, create_submatrix
def test_determinant_1x1_matrix():
assert determinant([[5]]) == 5
def test_determinant_2x2_matrix():
assert determinant([[1, 2], [3, 4]]) == -2
def test_determinant_3x3_matrix():
matrix = [
[1, 2, 3],
[0, 1, 4],
[5, 6, 0]
]
... | [
{
"docstring": "Calculate the determinant of a square matrix.",
"function_declaration": "def determinant(matrix):",
"function_name": "determinant",
"parameter_list": "(matrix)"
},
{
"docstring": "Create a submatrix by removing the first row and the specified column.",
"function_declarati... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def determinant(matrix):\n \"\"\"\n Calculate the determinant of a square matrix.\n \"\"\"\n n = len(matrix)\n if n == 1:\n return matrix[0][0]\n elif n == 2:\n ... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00087481",
"row_id": 87481,
"seed_ids": "['gemma-2-27b-it_181602']"
} | 0.413948 | Filter_87481 | I | [
"determinant",
"create_submatrix"
] | 2 | [
[
"determinant",
"create_submatrix"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 2bcd7a3e834be95ed00fa84edfb59a4e79d9f89f | 3831337266f362348f6d3f90ca40cb93a350895d | |||
v1.0 | instruct | Filter | Filter_87538_I | There is a game played with a regular 52-card deck.
**The Goal:** To have the highest scoring hand at the end of the round.
**Gameplay:**
* Each player is dealt 5 cards.
* Players wager on their hands, and then simultaneously reveal and score their hands based on the following:
**Hand Scores:**
* **Royal Flush:** 1... | import random
from collections import Counter
# Ranks and suits for a standard deck of cards
ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
suits = ['hearts', 'diamonds', 'clubs', 'spades']
# Mapping of card values for straight calculations
rank_values = {rank: i for i, rank in enumerate(r... | from solution import create_deck, shuffle_deck, deal_hand, score_hand
def test_create_deck():
deck = create_deck()
assert len(deck) == 52
assert ('A', 'spades') in deck
assert ('2', 'clubs') in deck
def test_shuffle_deck():
deck = create_deck()
shuffled_deck = deck[:]
shuffle_deck(shuffled... | [
{
"docstring": "Creates and returns a standard 52 card deck",
"function_declaration": "def create_deck():",
"function_name": "create_deck",
"parameter_list": "()"
},
{
"docstring": "Shuffles the deck in place",
"function_declaration": "def shuffle_deck(deck):",
"function_name": "shuf... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\nfrom collections import Counter\n\n# Representing the values and suits of the cards\nVALUES = \"23456789TJQKA\"\nSUITS = \"CDHS\" # Clubs, Diamonds, Hearts, Spades\n\n# Mapping... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087538",
"row_id": 87538,
"seed_ids": "['gemma-2-27b-it_181779']"
} | 0.565708 | Filter_87538 | I | [
"create_deck",
"shuffle_deck",
"deal_hand",
"score_hand",
"play_game"
] | 5 | [
[
"play_game",
"create_deck"
],
[
"play_game",
"deal_hand"
],
[
"play_game",
"score_hand"
],
[
"play_game",
"shuffle_deck"
]
] | 4 | [] | false | [] | false | pytest | true | [] | true | 75cef2920aa0aa724d37a775b9cc23fff442603a | 96b44ae45f0ade8bacb394ea106901572f7572c3 | |||
v1.0 | instruct | Filter | Filter_87542_I | [The following text is a portion of code:]
```python
def quicksort(array):
if len(array) < 2:
return array
else:
# Choose the rightmost element as pivot
pivot = array[-1]
# Partition the array around the pivot
less = [i for i in array[:-1] if i <= pivot]
... | def hoare_partition(array, low, high):
pivot = array[(low + high) // 2]
i = low - 1
j = high + 1
while True:
i += 1
while array[i] < pivot:
i += 1
j -= 1
while array[j] > pivot:
j -= 1
if i >= j:
return j
array[i], array... | from solution import quicksort
def test_quicksort_empty_array():
assert quicksort([]) == []
def test_quicksort_single_element():
assert quicksort([1]) == [1]
def test_quicksort_sorted_array():
assert quicksort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]
def test_quicksort_reverse_sorted_array():
assert quic... | [
{
"docstring": null,
"function_declaration": "def hoare_partition(array, low, high):",
"function_name": "hoare_partition",
"parameter_list": "(array, low, high)"
},
{
"docstring": null,
"function_declaration": "def quicksort(array, low=0, high=None):",
"function_name": "quicksort",
... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def quicksort(array):\n def hoare_partition(arr, low, high):\n pivot = arr[low]\n left = low - 1\n right = high + 1\n\n while True:\n left += 1\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087542",
"row_id": 87542,
"seed_ids": "['gemma-2-27b-it_181791']"
} | 0.591135 | Filter_87542 | I | [
"hoare_partition",
"quicksort"
] | 2 | [
[
"quicksort",
"hoare_partition"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 7f8a904381d4ab59f33a5aaee557f64dd53c3cd7 | 989f70d43cf52e8068daf615980289c39252bff4 | |||
v1.0 | instruct | Filter | Filter_87543_I | This is the problem:
You're at a casino, and you're betting repeatedly on black at roulette. The odds of winning on each spin are always 47.37%.
You want to write a Python program to simulate this scenario.
Here's what I have so far:
```python
import random
def spin_roulette():
"""Simulates a single spin of the... | import random
def spin_roulette():
"""
Simulates a single spin of the roulette wheel, returning "Black" or "Red".
"""
if random.random() < 0.4737:
return "Black"
else:
return "Red"
def simulate_betting(spins):
"""
Simulates betting on black for a given number of spins and r... | from solution import spin_roulette, simulate_betting
def test_spin_roulette():
results = [spin_roulette() for _ in range(1000)]
black_count = results.count("Black")
red_count = results.count("Red")
# Check that black and red results are within a reasonable range
assert 400 < black_count < 550 # ap... | [
{
"docstring": "Simulates a single spin of the roulette wheel, returning \"Black\" or \"Red\".",
"function_declaration": "def spin_roulette():",
"function_name": "spin_roulette",
"parameter_list": "()"
},
{
"docstring": "Simulates betting on black for a given number of spins and returns\nthe... | [
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 spin_roulette():\n \"\"\"\n Simulates a single spin of the roulette wheel, returning \"Black\" or \"Red\".\n \"\"\"\n if random.random() < 0.4737:\n ret... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087543",
"row_id": 87543,
"seed_ids": "['gemma-2-27b-it_181795']"
} | 0.540112 | Filter_87543 | I | [
"spin_roulette",
"simulate_betting"
] | 2 | [
[
"simulate_betting",
"spin_roulette"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | fa3852fe6ee36bb78354138bd7a49b0f3b908456 | 34298cb4c9f009c9e9de894553d515d35474cfee | |||
v1.0 | instruct | Filter | Filter_87551_I | Create a Python program that asks the user for an integer and then prints all the prime numbers up to that integer. | def is_prime(n):
"""
Check if a number is a prime number.
"""
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
re... | from solution import is_prime, primes_up_to
def test_is_prime():
# Test for prime numbers
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(5) == True
assert is_prime(7) == True
# Test for non-prime numbers
assert is_prime(1) == False
assert is_prime(4) == False... | [
{
"docstring": "Check if a number is a prime number.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Generate a list of prime numbers up to n (inclusive).",
"function_declaration": "def primes_up_to(n):",
"function... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(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": "00087551",
"row_id": 87551,
"seed_ids": "['gemma-2-27b-it_181818']"
} | 0.648903 | Filter_87551 | I | [
"is_prime",
"primes_up_to",
"main"
] | 3 | [
[
"primes_up_to",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 445356d188854726ab661725ff47f9166b62d409 | 8df1c50544a0d3371bcd554b713fb30b6819f1b1 | |||
v1.0 | instruct | Filter | Filter_87629_I | Objective:
The objective of this code is to take a series of integers as input from the user and find the greatest common divisor (GCD) of these integers.
Methodology:
1. Input: The code will first prompt the user to enter the number of integers.
2. Number Input: The code will then prompt the user to enter each inte... | def gcd(a, b):
while b:
a, b = b, a % b
return a
def calculate_gcd_of_list(integers):
result = integers[0]
for i in range(1, len(integers)):
result = gcd(result, integers[i])
return result
def main():
num_integers = int(input("Enter the number of integers: "))
if num_intege... | from solution import gcd, calculate_gcd_of_list
def test_gcd():
assert gcd(48, 18) == 6
assert gcd(54, 24) == 6
def test_calculate_gcd_of_list():
assert calculate_gcd_of_list([48, 18]) == 6
assert calculate_gcd_of_list([48, 18, 30]) == 6
assert calculate_gcd_of_list([1]) == 1
assert calculate_... | [
{
"docstring": null,
"function_declaration": "def gcd(a, b):",
"function_name": "gcd",
"parameter_list": "(a, b)"
},
{
"docstring": null,
"function_declaration": "def calculate_gcd_of_list(integers):",
"function_name": "calculate_gcd_of_list",
"parameter_list": "(integers)"
},
... | [
0,
1
] | 1 | medium | 0.5 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import math\nfrom functools import reduce\n\ndef gcd(a, b):\n \"\"\"\n Returns the GCD of two integers a and b using the Euclidean algorithm.\n \"\"\"\n while b:\n a, b = b,... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087629",
"row_id": 87629,
"seed_ids": "['gemma-2-27b-it_182080']"
} | 0.76892 | Filter_87629 | I | [
"gcd",
"calculate_gcd_of_list",
"main"
] | 3 | [
[
"calculate_gcd_of_list",
"gcd"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | db586b753207f1d892b4cfedeb3110cec0412bab | 2d79d05ef1fb2f97d126bdf3e7966bb1b9407f07 | |||
v1.0 | instruct | Filter | Filter_87630_I | . **The Problem:** You're given a list of words, and you need to find the longest word that is a subsequence of another word in the list.
**Input:**
A list of words, where each word is a string.
**
Output:**
The longest word that is a subsequence of another word in the list. If there are multiple words with the sa... | def is_subsequence(small, large):
"""
Function to check if 'small' is a subsequence of 'large'.
"""
it = iter(large)
return all(char in it for char in small)
def longest_subsequence(words):
"""
Function to find the longest word in the list that is a subsequence of another word in the list.... | from solution import is_subsequence, longest_subsequence
# Test for is_subsequence function
def test_is_subsequence_true():
assert is_subsequence('ape', 'apple') == True
def test_is_subsequence_false():
assert is_subsequence('april', 'ape') == False
def test_is_subsequence_partially_true():
assert is_sub... | [
{
"docstring": "Function to check if 'small' is a subsequence of 'large'.",
"function_declaration": "def is_subsequence(small, large):",
"function_name": "is_subsequence",
"parameter_list": "(small, large)"
},
{
"docstring": "Function to find the longest word in the list that is a subsequenc... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_subsequence(word1, word2):\n \"\"\"\n Helper function to check if word1 is a subsequence of word2.\n \"\"\"\n it = iter(word2)\n return all(char in it for char in word1)\... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087630",
"row_id": 87630,
"seed_ids": "['gemma-2-27b-it_182082']"
} | 0.683871 | Filter_87630 | I | [
"is_subsequence",
"longest_subsequence"
] | 2 | [
[
"longest_subsequence",
"is_subsequence"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 9e38755db87317e1a964786239f406e1309a8e0a | 064807dea6e9911064c295c06657f86946ce7a69 | |||
v1.0 | instruct | Filter | Filter_87638_I | The game starts with a grid, like this:
```
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
```
And the player can place an 'X' in any available space.
The goal is to get 3 'X's in a row, either horizontally, vertically, or diagonally.
**Here's how the game works:**
1. The computer starts the game by placing the ... | import random
def print_board(board):
"""Prints the Tic-Tac-Toe board in a user-friendly format."""
for row in board:
print(" ".join(row))
print()
def create_board():
"""Creates the initial 5x5 Tic-Tac-Toe board."""
return [['.' for _ in range(5)] for _ in range(5)]
def check_winner(board... | from solution import create_board, print_board, check_winner, computer_move
def test_create_board():
board = create_board()
assert len(board) == 5
assert all(len(row) == 5 for row in board)
assert all(cell == '.' for row in board for cell in row)
def test_print_board(capsys):
board = create_board... | [
{
"docstring": "Prints the Tic-Tac-Toe board in a user-friendly format.",
"function_declaration": "def print_board(board):",
"function_name": "print_board",
"parameter_list": "(board)"
},
{
"docstring": "Creates the initial 5x5 Tic-Tac-Toe board.",
"function_declaration": "def create_boa... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def print_board(board):\n \"\"\"Prints the Tic-Tac-Toe board in a user-friendly format.\"\"\"\n for row in board:\n print(\" \".join(row))\n\ndef create_board():\n \"\"\"Create... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00087638",
"row_id": 87638,
"seed_ids": "['gemma-2-27b-it_182127']"
} | 0.567172 | Filter_87638 | I | [
"print_board",
"create_board",
"check_winner",
"computer_move"
] | 4 | [
[
"computer_move",
"print_board"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | bcc6c5ff50d469c3b541050e8b958637b11e027f | 65eed95be0a3c65980d7ad5a8bfb45d56c1d3d1a | |||
v1.0 | instruct | Filter | Filter_87655_I | This is the problem:
Assume a game is played where you roll two dice. After rolling, 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 anything else, you “continue.”
**Implement this game in Python, allowing the user to play multiple games until they choose to stop.**
H... | import random
def roll_dice():
"""Simulates rolling two dice."""
return random.randint(1, 6), random.randint(1, 6)
def play_game():
"""Plays a single round of the dice game."""
dice1, dice2 = roll_dice()
total = dice1 + dice2
print(f"You rolled a {dice1} and a {dice2} for a total of {total}.")... | from solution import play_game, roll_dice
def test_roll_dice():
for _ in range(100): # Run this multiple times to increase coverage
dice1, dice2 = roll_dice()
assert 1 <= dice1 <= 6
assert 1 <= dice2 <= 6
def test_play_game_win():
random.seed(0) # To control the randomness
result... | [
{
"docstring": "Simulates rolling two dice.",
"function_declaration": "def roll_dice():",
"function_name": "roll_dice",
"parameter_list": "()"
},
{
"docstring": "Plays a single round of the dice game.",
"function_declaration": "def play_game():",
"function_name": "play_game",
"pa... | [
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():\n \"\"\"Simulates rolling two dice.\"\"\"\n return random.randint(1, 6), random.randint(1, 6)\n\ndef play_game():\n \"\"\"Plays a single round of the... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087655",
"row_id": 87655,
"seed_ids": "['gemma-2-27b-it_182174']"
} | 0.551532 | Filter_87655 | I | [
"roll_dice",
"play_game"
] | 2 | [
[
"play_game",
"roll_dice"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 83619782660e148051e568685cf3d1e12b8ad22c | 8ae692cda4b9f8ec6e5455c32b508c64d6365eb0 | |||
v1.0 | instruct | Filter | Filter_87657_I | This is the code for a game:
```python
import random
def get_secret_number():
"""This function generates a random number between 1 and 100."""
return random.randint(1, 100)
def get_user_guess():
"""This function gets the user's guess as input."""
while True:
try:
guess = int(input("Gue... | import random
def choose_difficulty():
"""
This function gets the difficulty level as input from the user.
Easy: Guess a number between 1 and 50
Medium: Guess a number between 1 and 100
Hard: Guess a number between 1 and 200
"""
while True:
print("Choose a difficulty level:")
print("1. Easy (1 to... | import pytest
from unittest import mock
from solution import choose_difficulty, get_secret_number, get_user_guess, check_guess
def test_choose_difficulty(monkeypatch):
# Mock user input to select difficulty level 2 (Medium)
monkeypatch.setattr('builtins.input', lambda _: '2')
assert choose_difficulty() ==... | [
{
"docstring": "This function gets the difficulty level as input from the user.\nEasy: Guess a number between 1 and 50\nMedium: Guess a number between 1 and 100\nHard: Guess a number between 1 and 200",
"function_declaration": "def choose_difficulty():",
"function_name": "choose_difficulty",
"parame... | [
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_secret_number(range_start, range_end):\n \"\"\"This function generates a random number within a specified range.\"\"\"\n return random.randint(range_start, range_end... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00087657",
"row_id": 87657,
"seed_ids": "['gemma-2-27b-it_182181']"
} | 0.622024 | Filter_87657 | I | [
"choose_difficulty",
"get_secret_number",
"get_user_guess",
"check_guess",
"play_game"
] | 5 | [
[
"play_game",
"check_guess"
],
[
"play_game",
"choose_difficulty"
],
[
"play_game",
"get_secret_number"
],
[
"play_game",
"get_user_guess"
]
] | 4 | [] | false | [] | false | pytest | true | [] | true | eaaea368563feb17ce2ad4adf694e45f9fa0f209 | c3461b276412442ed6fabea30decd40cc5367250 | |||
v1.0 | instruct | Filter | Filter_87666_I | I'm working on a project that involves building a simple text-based adventure game.
Here's what I have so far:
```python
def start_game():
print("Welcome to the Adventure!")
name = input("What is your name, adventurer? | def start_game():
"""
Starts the game by greeting the player and getting their name.
"""
name = input("What is your name, adventurer? ")
return name
def encounter():
"""
Simulates a random encounter and returns the outcome.
"""
import random
outcomes = ["You encountered a dragon... | import pytest
from solution import start_game, encounter, play_turn
def test_start_game(monkeypatch):
monkeypatch.setattr('builtins.input', lambda _: 'Arthur')
assert start_game() == 'Arthur'
def test_encounter():
outcomes = [
"You encountered a dragon! You were burned!",
"You found a tr... | [
{
"docstring": "Starts the game by greeting the player and getting their name.",
"function_declaration": "def start_game():",
"function_name": "start_game",
"parameter_list": "()"
},
{
"docstring": "Simulates a random encounter and returns the outcome.",
"function_declaration": "def enco... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def start_game():\n \"\"\"\n This function starts the text-based adventure game by welcoming the player\n and asking for their name.\n \"\"\"\n print(\"Welcome to the Adventure!... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00087666",
"row_id": 87666,
"seed_ids": "['gemma-2-27b-it_182208']"
} | 0.450412 | Filter_87666 | I | [
"start_game",
"encounter",
"play_turn",
"main"
] | 4 | [
[
"play_turn",
"encounter"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 79561962096054b682f7d22729c704f3e9695183 | e28f366bc23fdc15af5f13e7675cafa1e288db43 | |||
v1.0 | instruct | Filter | Filter_87669_I | Here is the task:
Create a Python program that takes a list of numbers as input from the user and determines if the list is sorted in ascending order.
The program should:
1. Take a list of numbers as input from the user, separated by spaces.
2. Convert the input string into a list of numbers.
3. Check if the list... | def is_ascending(numbers):
"""
Checks if a list of numbers is sorted in ascending order.
Args:
numbers (list): A list of numbers.
Returns:
bool: True if the list is sorted in ascending order, False otherwise.
"""
for i in range(len(numbers) - 1):
if numbers[i] > numbers... | from solution import is_ascending
def test_ascending_list():
assert is_ascending([1, 2, 3, 4, 5]) == True
def test_not_ascending_list():
assert is_ascending([1, 3, 2, 4, 5]) == False
def test_empty_list():
assert is_ascending([]) == True
def test_single_element_list():
assert is_ascending([1]) == Tr... | [
{
"docstring": "Checks if a list of numbers is sorted in ascending order.\n\nArgs:\n numbers (list): A list of numbers.\n\nReturns:\n bool: True if the list is sorted in ascending order, False otherwise.",
"function_declaration": "def is_ascending(numbers):",
"function_name": "is_ascending",
"... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_ascending(numbers):\n \"\"\"\n Checks if a list of numbers is sorted in ascending order.\n\n Args:\n numbers (list): A list of numbers.\n\n Returns:\n bool: Tr... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00087669",
"row_id": 87669,
"seed_ids": "['gemma-2-27b-it_182213']"
} | 0.736176 | Filter_87669 | I | [
"is_ascending",
"check_list_sorted"
] | 2 | [
[
"check_list_sorted",
"is_ascending"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 21c7700bd060c18a208f44c87a74afed78f9d41c | 57a1ab1290fbece7794758c67ccbbef7f3f7851d | |||
v1.0 | instruct | Filter | Filter_87681_I | I want to build a simple chatbot using Python.
Here are some of the requirements:
* **Text-based interaction**
* **Rule-based approach**
* **Ability to handle simple greetings**: ("Hello", "Hi", "Hey") and provide corresponding responses
* **Ask for the user's name**:
* **Remember the user's name**
* **Provide a... | def greet(name):
"""
Return a greeting message using the given name.
"""
return f"Hello, {name}!\nHi {name}, nice to meet you!\nHey {name}! How can I help you today?"
def get_user_name():
"""
Ask the user for their name and return it.
"""
name = input("What is your name? ")
return n... | def test_greet():
assert greet("Alice") == "Hello, Alice!\nHi Alice, nice to meet you!\nHey Alice! How can I help you today?"
def test_get_user_name(monkeypatch):
monkeypatch.setattr('builtins.input', lambda _: "Bob")
assert get_user_name() == "Bob"
def test_chatbot_conversation(monkeypatch):
"""
... | [
{
"docstring": "Return a greeting message using the given name.",
"function_declaration": "def greet(name):",
"function_name": "greet",
"parameter_list": "(name)"
},
{
"docstring": "Ask the user for their name and return it.",
"function_declaration": "def get_user_name():",
"function... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def greet(name):\n \"\"\"\n Return a greeting message using the given name.\n \"\"\"\n return f\"Hello, {name}!\\nHi {name}, nice to meet you!\\nHey {name}! How can I help you toda... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00087681",
"row_id": 87681,
"seed_ids": "['gemma-2-27b-it_182234']"
} | 0.400005 | Filter_87681 | I | [
"greet",
"get_user_name",
"chatbot_conversation"
] | 3 | [
[
"chatbot_conversation",
"get_user_name"
],
[
"chatbot_conversation",
"greet"
]
] | 2 | [] | false | [] | false | pytest | false | [] | true | cce36ed5e68ba59d8e490cbd8e46d2dc96b2383a | 21fc2ccf250ad7c0cabc76faa9bf5fd83937403f | |||
v1.0 | instruct | Filter | Filter_87698_I | Given an array of strings, find all the possible substrings of each string.
I already have a function to generate the substrings of a single string. Can you please help me to combine the function to work for an array of strings? | def generate_substrings(s):
"""
Generate all possible substrings of a single string.
Args:
s (str): Input string.
Returns:
list: List of all possible substrings of the input string.
"""
substrings = []
for i in range(len(s)):
for j in range(i + 1, len(s) + 1):
... | from solution import generate_substrings_for_array
def test_generate_substrings_single_string():
assert generate_substrings_for_array(["abc"]) == [["a", "ab", "abc", "b", "bc", "c"]]
def test_generate_substrings_multiple_strings():
input_array = ["abc", "xy"]
expected_output = [
["a", "ab", "abc",... | [
{
"docstring": "Generate all possible substrings of a single string.\n\nArgs:\ns (str): Input string.\n\nReturns:\nlist: List of all possible substrings of the input string.",
"function_declaration": "def generate_substrings(s):",
"function_name": "generate_substrings",
"parameter_list": "(s)"
},
... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def generate_substrings(s):\n \"\"\"\n Generate all possible substrings for a given string.\n\n :param s: A string to generate substrings of.\n :return: A list of substrings.\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087698",
"row_id": 87698,
"seed_ids": "['gemma-2-27b-it_182278']"
} | 0.633116 | Filter_87698 | I | [
"generate_substrings",
"generate_substrings_for_array"
] | 2 | [
[
"generate_substrings_for_array",
"generate_substrings"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 4eccd5528e65cf6ccb2899a305b8403890c1925d | c5e1a22f50680c82d42acc9482d2bb40a0944f78 | |||
v1.0 | instruct | Filter | Filter_87718_I | This is the problem statement:
Write a program that generates a list of prime numbers within a given range.
**Please provide a Python code solution:**
```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:
ret... | 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 generate_primes(low, high):
"""
Generates a list of prime numbers within a given range.
"""
p... | from solution import is_prime, generate_primes
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(17) == True
assert is_prime(18) == False
def test_generate_primes():
assert generate_primes(1, 10) == [2, 3, 5, 7]
assert ge... | [
{
"docstring": "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 within a given range.",
"function_declaration": "def generate_primes(low, high):",
"fun... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n r... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087718",
"row_id": 87718,
"seed_ids": "['gemma-2-27b-it_182332']"
} | 0.638962 | Filter_87718 | I | [
"is_prime",
"generate_primes"
] | 2 | [
[
"generate_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 44c7d7eb43f10f86fe56f62b54bedfb9d259d91a | be5c17a1508030b732a250dd7fb5a003f615c837 | |||
v1.0 | instruct | Filter | Filter_87734_I | Here’s a problem I encountered in my computer science class:
You are given a sorted array of integers with possible duplicates.
Example input:
```
[1, 1, 2, 2, 2, 3, 4, 4, 5]
```
Task:
Write a function that takes this sorted array and a target integer as input and returns the starting and ending index of the targe... | def find_leftmost(arr, target):
left, right = 0, len(arr) - 1
leftmost_index = -1
while left <= right:
mid = left + (right - left) // 2
if arr[mid] == target:
leftmost_index = mid
right = mid - 1
elif arr[mid] < target:
left = mid + 1
else:... | def test_find_range():
assert find_range([1, 1, 2, 2, 2, 3, 4, 4, 5], 2) == [2, 4]
assert find_range([1, 1, 2, 2, 2, 3, 4, 4, 5], 1) == [0, 1]
assert find_range([1, 1, 2, 2, 2, 3, 4, 4, 5], 3) == [5, 5]
assert find_range([1, 1, 2, 2, 2, 3, 4, 4, 5], 4) == [6, 7]
assert find_range([1, 1, 2, 2, 2, 3, ... | [
{
"docstring": null,
"function_declaration": "def find_leftmost(arr, target):",
"function_name": "find_leftmost",
"parameter_list": "(arr, target)"
},
{
"docstring": null,
"function_declaration": "def find_rightmost(arr, target):",
"function_name": "find_rightmost",
"parameter_li... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find_range(arr, target):\n \"\"\"\n Finds the starting and ending index of the target integer in a sorted array with possible duplicates.\n \n Parameters:\n arr (list): Sort... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087734",
"row_id": 87734,
"seed_ids": "['gemma-2-27b-it_182371']"
} | 0.581907 | Filter_87734 | I | [
"find_leftmost",
"find_rightmost",
"find_range"
] | 3 | [
[
"find_range",
"find_leftmost"
],
[
"find_range",
"find_rightmost"
]
] | 2 | [] | false | [] | false | pytest | false | [] | true | c845da6205d31dcb3a83bb6883ef70329e48cfaf | 6dc687b0ac909b9818b9f7aede10ef48d59bad1d | |||
v1.0 | instruct | Filter | Filter_87744_I | The following is a problem for a computer science class:
**Problem:**
Let's say you have a website which allows users to upload photos.
**Requirements:**
1. Allow users to upload multiple photos at once.
2. Verify that the uploaded files are actually image files (e.g., JPG, PNG, GIF).
*Please provide a detailed sol... | from werkzeug.utils import secure_filename
from flask import Flask, request, jsonify
import os
from PIL import Image
app = Flask(__name__)
# Configure app to save uploads to a particular folder
UPLOAD_FOLDER = 'uploads'
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
i... | import pytest
from flask import Flask
from io import BytesIO
import tempfile
from PIL import Image as PILImage
from solution import app, allowed_file, is_image
@pytest.fixture
def client():
with app.test_client() as client:
yield client
def create_image_file(filename, extension='png'):
file = tempfil... | [
{
"docstring": "Check if the uploaded file has a valid image extension.",
"function_declaration": "def allowed_file(filename):",
"function_name": "allowed_file",
"parameter_list": "(filename)"
},
{
"docstring": "Verify that a file is an actual image by attempting to open it with PIL.",
"... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from werkzeug.utils import secure_filename\nfrom flask import Flask, request, jsonify\nimport os\n\napp = Flask(__name__)\n\n# Define the allowed extensions for image files\nALLOWED_EXTENSIONS... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087744",
"row_id": 87744,
"seed_ids": "['gemma-2-27b-it_182405']"
} | 0.473979 | Filter_87744 | I | [
"allowed_file",
"is_image",
"upload_file"
] | 3 | [
[
"upload_file",
"allowed_file"
],
[
"upload_file",
"is_image"
]
] | 2 | [] | false | [] | false | pytest | true | [
"PIL",
"flask",
"werkzeug"
] | false | 1b4eb637eef2b51771b101e4a5da5bd105c8b2a1 | 8b622f584b7f204e2fd1e320c4997d56c8ef2aac | |||
v1.0 | instruct | Filter | Filter_87754_I | Write a Python program that takes a list of strings as input and returns a list containing only the palindrome strings from the input list. | def is_palindrome(s):
"""
Helper function to check if a string is a palindrome.
"""
return s == s[::-1]
def filter_palindromes(strings):
"""
Returns a list containing only the palindrome strings from the input list.
"""
return [s for s in strings if is_palindrome(s)] | from solution import filter_palindromes
def test_empty_list():
assert filter_palindromes([]) == []
def test_no_palindromes():
assert filter_palindromes(['hello', 'world', 'python']) == []
def test_all_palindromes():
assert filter_palindromes(['madonna', 'adam', 'madam', 'racecar']) == ['madam', 'racecar'... | [
{
"docstring": "Helper function to check if a string is a palindrome.",
"function_declaration": "def is_palindrome(s):",
"function_name": "is_palindrome",
"parameter_list": "(s)"
},
{
"docstring": "Returns a list containing only the palindrome strings from the input list.",
"function_dec... | [
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 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 co... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087754",
"row_id": 87754,
"seed_ids": "['gemma-2-27b-it_182430']"
} | 0.753572 | Filter_87754 | I | [
"is_palindrome",
"filter_palindromes"
] | 2 | [
[
"filter_palindromes",
"is_palindrome"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 736a0468ffb355fdbf65bf9c9794e45cb552316f | 762e68275ea8392e3a920b1ac5c4e1421aa9a164 | |||
v1.0 | instruct | Filter | Filter_87764_I | This question was asked me in a software interview:
You are provided with an API that
returns true if a given string is a palindrome and false otherwise. `isPalindrome(string)`
Write a function that takes a list of strings and
returns a list containing only the palindromes from the original list.
Example:
Input: ["... | def get_palindromes(string_list):
"""
Returns a list of palindromes from the given list of strings.
Args:
string_list: A list of strings.
Returns:
A list of palindromes from the input list.
"""
return [string for string in string_list if isPalindrome(string)]
def isPal... | import pytest
from solution import get_palindromes, isPalindrome
def test_isPalindrome():
assert isPalindrome("racecar") == True
assert isPalindrome("apple") == False
assert isPalindrome("madam") == True
assert isPalindrome("banana") == False
assert isPalindrome("") == True # Empty string is consi... | [
{
"docstring": "Returns a list of palindromes from the given list of strings.\n\nArgs:\n string_list: A list of strings.\n\nReturns:\n A list of palindromes from the input list.",
"function_declaration": "def get_palindromes(string_list):",
"function_name": "get_palindromes",
"parameter_list":... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def isPalindrome(string):\n \"\"\"\n Placeholder API function that returns true if a given string is a palindrome and false otherwise.\n \"\"\"\n return string == string[::-1]\n\nd... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00087764",
"row_id": 87764,
"seed_ids": "['gemma-2-27b-it_182451']"
} | 0.707389 | Filter_87764 | I | [
"get_palindromes",
"isPalindrome"
] | 2 | [
[
"get_palindromes",
"isPalindrome"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | acedbcebb99109939a625212e88d38837905165e | 8bef901654ad7114dea634fb2747f23a6ee0605a | |||
v1.0 | instruct | Filter | Filter_87767_I | This question pertains to Python and working with images.
Let's say I have a function that takes an image as input and outputs a list of bounding boxes.
```python
def find_objects(image):
# Some image processing magic to detect objects
# ...
return bounding_boxes
```
Now, I have another function that takes a ... | from PIL import Image, ImageDraw
def find_objects(image):
"""
Mock implementation of object detection.
In a real scenario, this would involve complex algorithms or ML models.
"""
# Placeholder bounding boxes, each defined by a tuple (x_min, y_min, x_max, y_max)
bounding_boxes = [
(50, 5... | import pytest
from PIL import Image
from solution import find_objects, draw_bounding_boxes, process_image
@pytest.fixture
def sample_image():
"""Fixture to create a sample image for testing."""
return Image.new('RGB', (400, 400), 'white')
@pytest.fixture
def sample_bounding_boxes():
"""Fixture for sample ... | [
{
"docstring": "Mock implementation of object detection.\nIn a real scenario, this would involve complex algorithms or ML models.",
"function_declaration": "def find_objects(image):",
"function_name": "find_objects",
"parameter_list": "(image)"
},
{
"docstring": "Draws bounding boxes on the ... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import cv2\n\ndef find_objects(image):\n \"\"\"\n Detect objects in the image and return a list of bounding boxes.\n Each bounding box is defined as [x, y, width, height].\n \"\"\"... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087767",
"row_id": 87767,
"seed_ids": "['gemma-2-27b-it_182460']"
} | 0.410226 | Filter_87767 | I | [
"find_objects",
"draw_bounding_boxes",
"process_image"
] | 3 | [
[
"process_image",
"draw_bounding_boxes"
],
[
"process_image",
"find_objects"
]
] | 2 | [] | false | [] | false | pytest | true | [
"PIL"
] | false | 8f44b84be73588d9ccfe32d0b44e34fda4e86083 | 1091883a1bf2aec427f94e901a7980205cfdbfbf | |||
v1.0 | instruct | Filter | Filter_87809_I | This is my Python code:
```python
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return (a * b) // gcd(a, b)
print(f"LCM of 12 and 18 is {lcm(12, 18)}")
```
The code works as expected for finding the least common multiple (LCM) of two numbers using Euclidean algorithm for GCD.
I ... | def gcd(a, b):
"""
Computes the greatest common divisor (GCD) of a and b using the Euclidean algorithm.
"""
while b:
a, b = b, a % b
return a
def lcm(a, b):
"""
Computes the least common multiple (LCM) of a and b using the relationship between GCD and LCM.
"""
return (a * b)... | def test_gcd():
assert gcd(48, 18) == 6
assert gcd(12, 18) == 6
assert gcd(101, 103) == 1 # Prime numbers
assert gcd(9, 28) == 1 # Relatively prime numbers
def test_lcm():
assert lcm(12, 18) == 36
assert lcm(48, 18) == 144
assert lcm(101, 103) == 10403 # Prime numbers
assert lcm(9... | [
{
"docstring": "Computes the greatest common divisor (GCD) of a and b using the Euclidean algorithm.",
"function_declaration": "def gcd(a, b):",
"function_name": "gcd",
"parameter_list": "(a, b)"
},
{
"docstring": "Computes the least common multiple (LCM) of a and b using the relationship be... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def gcd(a, b):\n \"\"\"\n Computes the greatest common divisor (GCD) of a and b using the Euclidean algorithm.\n \"\"\"\n while b:\n a, b = b, a % b\n return a\n\ndef lcm... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00087809",
"row_id": 87809,
"seed_ids": "['gemma-2-27b-it_182577']"
} | 0.620264 | Filter_87809 | I | [
"gcd",
"lcm"
] | 2 | [
[
"lcm",
"gcd"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 9f6c9e49960cb5a80d531ac510b5af1bda41b916 | 0667a4840737a8bb25b03993576a7dda36933c29 | |||
v1.0 | instruct | Filter | Filter_87811_I | There's a pattern in this sequence of numbers:
1, 11, 21, 1211, 111221, 312211, 13112221
Write Python code to print the first five numbers in this sequence.
def look_and_say(n):
"""
Generates the nth term of the "Look and Say" sequence.
"""
if n == 1:
return '1'
prev_term = '1'
for i in range(2, n + 1):
ne... | def look_and_say(n):
"""
Generates the nth term of the "Look and Say" sequence.
"""
if n == 1:
return '1'
prev_term = '1'
for i in range(2, n + 1):
next_term = ''
count = 1
for j in range(1, len(prev_term)):
if prev_term[j] == prev_term[j - 1]:
... | from solution import look_and_say, first_five_look_and_say
def test_look_and_say():
assert look_and_say(1) == '1'
assert look_and_say(2) == '11'
assert look_and_say(3) == '21'
assert look_and_say(4) == '1211'
assert look_and_say(5) == '111221'
def test_first_five_look_and_say():
expected_outpu... | [
{
"docstring": "Generates the nth term of the \"Look and Say\" sequence.",
"function_declaration": "def look_and_say(n):",
"function_name": "look_and_say",
"parameter_list": "(n)"
},
{
"docstring": "Prints the first five numbers in the Look and Say sequence.",
"function_declaration": "de... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def look_and_say(n):\n \"\"\"\n Generates the nth term of the \"Look and Say\" sequence.\n \"\"\"\n if n == 1:\n return '1'\n \n prev_term = '1'\n for i in range(2,... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087811",
"row_id": 87811,
"seed_ids": "['gemma-2-27b-it_182581']"
} | 0.609498 | Filter_87811 | I | [
"look_and_say",
"first_five_look_and_say"
] | 2 | [
[
"first_five_look_and_say",
"look_and_say"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | ee27ceccad9eccd22e96892340739a3831a70c73 | 9467c8f242e510d4c1a8c55a0f30faca512fef9b | |||
v1.0 | instruct | Filter | Filter_87862_I | The following functions:
```python
def sum_to_n(n):
"""Calculate the sum of numbers from 1 to n
Args:
n: An integer.
Returns:
The sum of numbers from 1 to n.
"""
total = 0
for i in range(1, n + 1):
total += i
return total
def sum_multiples_of_3_to_n(n):
"""Calculate the sum of... | def calculate_total(n):
"""
Calculate the sum of all numbers from 1 to n plus the sum of all multiples of 3 up to n
Args:
n: An integer.
Returns:
The combined sum of numbers from 1 to n and multiples of 3 up to n.
"""
sum_to_n_total = sum_to_n(n)
sum_multiples_3_total = sum_mul... | from solution import calculate_total, sum_to_n, sum_multiples_of_3_to_n
def test_sum_to_n():
assert sum_to_n(10) == 55
assert sum_to_n(0) == 0
assert sum_to_n(1) == 1
assert sum_to_n(5) == 15
def test_sum_multiples_of_3_to_n():
assert sum_multiples_of_3_to_n(10) == 18
assert sum_multiples_of_3... | [
{
"docstring": "Calculate the sum of all numbers from 1 to n plus the sum of all multiples of 3 up to n\n\nArgs:\n n: An integer.\n\nReturns:\n The combined sum of numbers from 1 to n and multiples of 3 up to n.",
"function_declaration": "def calculate_total(n):",
"function_name": "calculate_total",
... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def calculate_total(n):\n \"\"\"\n Calculate the sum of all numbers from 1 to n plus the sum of all multiples of 3 up to n\n\n Args:\n n: An integer.\n\n Returns:\n The c... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087862",
"row_id": 87862,
"seed_ids": "['gemma-2-27b-it_182730']"
} | 0.629154 | Filter_87862 | I | [
"calculate_total",
"sum_to_n",
"sum_multiples_of_3_to_n"
] | 3 | [
[
"calculate_total",
"sum_multiples_of_3_to_n"
],
[
"calculate_total",
"sum_to_n"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 6ce4bde94c3d0e6bf7d41046d31013cc8f5ab547 | f90004ba9ee8da286f981ffac0c04d382e9d422c | |||
v1.0 | instruct | Filter | Filter_87865_I | The game is Tic-Tac-Toe, I want to make sure the program runs until a player has won or the board is full.
The program currently:
* Has a board representation.
* Has print_board() function.
* Has functions for player moves (get_player_move()).
I need to add logic for:
* Game loop which continues until win or draw.
* ... | def initialize_board():
"""
Initializes and returns a 3x3 board for Tic-Tac-Toe.
"""
return [[' ' for _ in range(3)] for _ in range(3)]
def print_board(board):
"""
Prints the Tic-Tac-Toe board.
"""
for row in board:
print('|'.join(row))
print('-' * 5)
def get_player_mov... | from solution import initialize_board, print_board, get_player_move, check_win, check_draw, play_game
def test_initialize_board():
board = initialize_board()
assert len(board) == 3
assert all(len(row) == 3 for row in board)
assert all(cell == ' ' for row in board for cell in row)
def test_check_win():... | [
{
"docstring": "Initializes and returns a 3x3 board for Tic-Tac-Toe.",
"function_declaration": "def initialize_board():",
"function_name": "initialize_board",
"parameter_list": "()"
},
{
"docstring": "Prints the Tic-Tac-Toe board.",
"function_declaration": "def print_board(board):",
... | [
1,
0,
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 \"\"\"\n Prints the current state of the board.\n \"\"\"\n for row in board:\n print(\" | \".join(row))\n print(\"-\" * 5)\n \ndef ge... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087865",
"row_id": 87865,
"seed_ids": "['gemma-2-27b-it_182737']"
} | 0.466418 | Filter_87865 | I | [
"initialize_board",
"print_board",
"get_player_move",
"check_win",
"check_draw",
"play_game"
] | 6 | [
[
"play_game",
"check_draw"
],
[
"play_game",
"check_win"
],
[
"play_game",
"get_player_move"
],
[
"play_game",
"initialize_board"
],
[
"play_game",
"print_board"
]
] | 5 | [] | false | [] | false | pytest | true | [] | true | 0d83c145546e90b466c609fe4351d2dbae5f1763 | 670b131dc874669cd6704fff47f184f90ff51eb6 | |||
v1.0 | instruct | Filter | Filter_87877_I | This is the description:
```
This program allows the user to input a list of strings. The program then processes the list, identifying any strings that are palindromes. A palindromic string reads the same backward as forward, ignoring case and non-alphanumeric characters.
Example:
Input:
madam, apple, racecar, a man... | import re
def is_palindrome(text):
"""Checks if a string is a palindrome, ignoring case and non-alphanumeric characters."""
cleaned_text = re.sub(r"[^A-Za-z0-9]", "", text).lower()
return cleaned_text == cleaned_text[::-1]
def find_palindromes(strings):
"""Finds palindromes in a list of strings."""
... | from solution import is_palindrome, find_palindromes
def test_is_palindrome_simple_palindromes():
assert is_palindrome("madam") == True
assert is_palindrome("racecar") == True
assert is_palindrome("level") == True
def test_is_palindrome_simple_non_palindromes():
assert is_palindrome("apple") == False
... | [
{
"docstring": "Checks if a string is a palindrome, ignoring case and non-alphanumeric characters.",
"function_declaration": "def is_palindrome(text):",
"function_name": "is_palindrome",
"parameter_list": "(text)"
},
{
"docstring": "Finds palindromes in a list of strings.",
"function_dec... | [
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 is_palindrome(text):\n \"\"\"\n Checks if a string is a palindrome, ignoring case and non-alphanumeric characters.\n \"\"\"\n clean_text = re.sub(r\"[^\\w\\s]\", \... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087877",
"row_id": 87877,
"seed_ids": "['gemma-2-27b-it_182769']"
} | 0.807029 | Filter_87877 | I | [
"is_palindrome",
"find_palindromes"
] | 2 | [
[
"find_palindromes",
"is_palindrome"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 4d036bd353d88f27c2daf431adc2d8abd2fc72d4 | a6b0546afc99f44247bf974f940fc99dec40ddac | |||
v1.0 | instruct | Filter | Filter_87884_I | Objective:
The objective of this assignment is to implement a simple text-based
Tic-Tac-Toe game in Python.
Requirements:
1. Game Board Representation: Use a list or a nested list to represent the
Tic-Tac-Toe board.
2. Player Input:
- Allow two players (X and O) to take turns.
- Prompt the player for their... | def create_board():
"""
Creates and returns a 3x3 Tic-Tac-Toe board as a nested list.
"""
return [[' ' for _ in range(3)] for _ in range(3)]
def print_board(board):
"""
Prints the Tic-Tac-Toe board to the console.
"""
for row in board:
print("|".join(row))
print("-" * 5)... | from solution import create_board, is_valid_move, make_move, check_winner, is_board_full
def test_create_board():
board = create_board()
assert board == [[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' ']]
def test_is_valid_move():
board = create_board()
assert is_valid_move(board, 0, 0) is True
... | [
{
"docstring": "Creates and returns a 3x3 Tic-Tac-Toe board as a nested list.",
"function_declaration": "def create_board():",
"function_name": "create_board",
"parameter_list": "()"
},
{
"docstring": "Prints the Tic-Tac-Toe board to the console.",
"function_declaration": "def print_boar... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def create_board():\n \"\"\"\n Creates and returns a 3x3 Tic-Tac-Toe board as a nested list.\n \"\"\"\n return [[' ' for _ in range(3)] for _ in range(3)]\n\ndef print_board(board)... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00087884",
"row_id": 87884,
"seed_ids": "['gemma-2-27b-it_182785']"
} | 0.494082 | Filter_87884 | I | [
"create_board",
"print_board",
"is_valid_move",
"make_move",
"check_winner",
"is_board_full"
] | 6 | [
[
"make_move",
"is_valid_move"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | b754b7483f4543daa776b522a44807e4d3e76794 | 47e6f14d02f63c87dea7c8b2c6d302c7461354af | |||
v1.0 | instruct | Filter | Filter_87904_I | Objective: Create a Python function that allows me to convert numerical grades into letter grades based on a given grading scale. Your solution should allow both a list of grades and a single grade as input. | def convert_grade_to_letter(grade):
"""
Convert a numerical grade to a letter grade based on standard grading scale.
"""
if 90 <= grade <= 100:
return 'A'
elif 80 <= grade < 90:
return 'B'
elif 70 <= grade < 80:
return 'C'
elif 60 <= grade < 70:
return 'D'
... | from solution import convert_grades, convert_grade_to_letter
import pytest
def test_single_grade():
assert convert_grades(95) == 'A'
assert convert_grades(85) == 'B'
assert convert_grades(75) == 'C'
assert convert_grades(65) == 'D'
assert convert_grades(55) == 'F'
def test_list_of_grades():
as... | [
{
"docstring": "Convert a numerical grade to a letter grade based on standard grading scale.",
"function_declaration": "def convert_grade_to_letter(grade):",
"function_name": "convert_grade_to_letter",
"parameter_list": "(grade)"
},
{
"docstring": "Convert a single grade or a list of grades ... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def convert_to_letter_grade(grades):\n \"\"\"\n Converts numerical grades into letter grades based on a given grading scale.\n \n Args:\n grades (int, float, list of int, list o... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087904",
"row_id": 87904,
"seed_ids": "['gemma-2-27b-it_182859']"
} | 0.724839 | Filter_87904 | I | [
"convert_grade_to_letter",
"convert_grades"
] | 2 | [
[
"convert_grades",
"convert_grade_to_letter"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 5364eee4056fa8dc5f7d0d713586c1c3a08d94b3 | f8567a0a2146887ae063bc3b8538614fea7c1655 | |||
v1.0 | instruct | Filter | Filter_87979_I | This question is related to Python functions.
* Can you provide me with an example demonstrating how Python functions can be used to break down a complex task into smaller, manageable parts? | def extract_grades(students):
"""
Extract grades from a list of students.
Each student is represented by a dictionary with 'name' and 'grade' keys.
"""
return [student['grade'] for student in students]
def calculate_sum(grades):
"""
Calculate the sum of a list of grades.
"""
return ... | from solution import extract_grades, calculate_sum, calculate_average, get_average_grade
def test_extract_grades():
students = [{'name': 'Alice', 'grade': 90}, {'name': 'Bob', 'grade': 80}, {'name': 'Charlie', 'grade': 70}]
assert extract_grades(students) == [90, 80, 70]
def test_calculate_sum():
grades =... | [
{
"docstring": "Extract grades from a list of students.\nEach student is represented by a dictionary with 'name' and 'grade' keys.",
"function_declaration": "def extract_grades(students):",
"function_name": "extract_grades",
"parameter_list": "(students)"
},
{
"docstring": "Calculate the sum... | [
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 the content of a file and returns it as a string.\n \"\"\"\n with open(file_path, 'r') as file:\n content = file.read()\n retur... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00087979",
"row_id": 87979,
"seed_ids": "['gemma-2-27b-it_183069']"
} | 0.55756 | Filter_87979 | I | [
"extract_grades",
"calculate_sum",
"calculate_average",
"get_average_grade"
] | 4 | [
[
"get_average_grade",
"calculate_average"
],
[
"get_average_grade",
"calculate_sum"
],
[
"get_average_grade",
"extract_grades"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | 1d251761acaa1bccbcde45a4e7f8e6ad3ab69a1c | 4caeeb2391cc97888898f3fe4817ee3813a82a35 | |||
v1.0 | instruct | Filter | Filter_87995_I | This is part of the documentation for a piece of software**:
**Function:** `count_primes(low, high)`
**Purpose:** Counts the number of prime numbers between `low` and `high` (inclusive).
**Input:**
* `low:` An integer representing the lower bound of the range.
* `high`: An integer representing the upper bound of ... | def is_prime(n):
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(low, high):
"""
Counts the number of prime numbers between low and high (inclusive).
Args:
low: An integer representing the lo... | from solution import count_primes
def test_count_primes_basic():
assert count_primes(1, 10) == 4 # Primes: 2, 3, 5, 7
def test_count_primes_with_zero_and_negative():
assert count_primes(-10, 0) == 0 # No primes in this range
def test_count_primes_within_prime_range():
assert count_primes(11, 19) == 4 ... | [
{
"docstring": null,
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Counts the number of prime numbers between low and high (inclusive).\n\nArgs:\n low: An integer representing the lower bound of the range.\n high: An int... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Helper function to determine 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 o... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00087995",
"row_id": 87995,
"seed_ids": "['gemma-2-27b-it_183119']"
} | 0.745953 | Filter_87995 | I | [
"is_prime",
"count_primes"
] | 2 | [
[
"count_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 48636e5ce8c2c2ea51c69ea68040b33cb0e9ea12 | a4dece22cf5be46e1687f43ee1a4fc5e57f9601b | |||
v1.0 | instruct | Filter | Filter_88074_I | In Python, how can I identify and print elements that appear only once in a list? | def unique_elements(lst):
"""
Returns a list of elements that appear only once in the input list.
Parameters:
lst (list): The input list
Returns:
list: A list of elements that appear only once
"""
from collections import Counter
count = Counter(lst)
return [element for ... | from solution import unique_elements, print_unique_elements
from io import StringIO
import sys
def test_unique_elements():
assert unique_elements([1, 2, 2, 3, 4, 4]) == [1, 3]
assert unique_elements([4, 4, 4, 4]) == []
assert unique_elements([1, 2, 3, 4]) == [1, 2, 3, 4]
assert unique_elements([]) == [... | [
{
"docstring": "Returns a list of elements that appear only once in the input list.\n\nParameters:\nlst (list): The input list\n\nReturns:\nlist: A list of elements that appear only once",
"function_declaration": "def unique_elements(lst):",
"function_name": "unique_elements",
"parameter_list": "(ls... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def unique_elements(lst):\n \"\"\"\n Returns a list of elements that appear only once in the input list.\n \n :type lst: List[int]\n :rtype: List[int]\n \"\"\"\n from coll... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088074",
"row_id": 88074,
"seed_ids": "['gemma-2-27b-it_183337']"
} | 0.736448 | Filter_88074 | I | [
"unique_elements",
"print_unique_elements"
] | 2 | [
[
"print_unique_elements",
"unique_elements"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | db407b32093996b7b39c82823d92c33e47fb4c4b | 290ec0c018885fbdafe65cfb2ff035ebb4e77f97 | |||
v1.0 | instruct | Filter | Filter_88078_I | Here's the problem:
You want to write a program that can translate English words into Pig Latin.
**Pig Latin Rules:**
* **For words that start with a consonant, move the first consonant or consonant cluster to the end and then add "ay".**
* Example: "pig" becomes "igpay"
* **For words that start with a vowel, ... | def is_vowel(letter):
"""
Returns True if letter is a vowel, False otherwise.
"""
return letter in "aeiouAEIOU"
def pig_latin(word):
"""
Translates the given word into Pig Latin.
If the word starts with a vowel, add "way" to the end.
If the word starts with a consonant or a consona... | from solution import is_vowel, pig_latin
def test_is_vowel():
assert is_vowel('a') == True
assert is_vowel('e') == True
assert is_vowel('i') == True
assert is_vowel('o') == True
assert is_vowel('u') == True
assert is_vowel('A') == True
assert is_vowel('E') == True
assert is_vowel('I') =... | [
{
"docstring": "Returns True if letter is a vowel, False otherwise.",
"function_declaration": "def is_vowel(letter):",
"function_name": "is_vowel",
"parameter_list": "(letter)"
},
{
"docstring": "Translates the given word into Pig Latin.\n\nIf the word starts with a vowel, add \"way\" to the... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def pig_latin_translation(word):\n \"\"\"\n Translates an English word into Pig Latin.\n \"\"\"\n vowels = \"AEIOUaeiou\"\n if word[0] in vowels:\n return word + \"way\"\... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00088078",
"row_id": 88078,
"seed_ids": "['gemma-2-27b-it_183355']"
} | 0.566788 | Filter_88078 | I | [
"is_vowel",
"pig_latin"
] | 2 | [
[
"pig_latin",
"is_vowel"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 1e49a0e027d4440dfcfe543d395c6cc2193a40cc | 8561291f869d593050a4db2e0e3c1823d72bde0d | |||
v1.0 | instruct | Filter | Filter_88129_I | I'm a software engineer, currently working on a personal project involving time handling and calculations in Python.
I need to calculate the difference between two datetime objects in Python and convert the resulting duration into a user-friendly string format.
Could you provide a detailed explanation and code exampl... | from datetime import datetime, timedelta
def format_timedelta(delta):
"""
Convert a timedelta object into a human-friendly string format.
"""
days = delta.days
seconds = delta.seconds
hours, remainder = divmod(seconds, 3600)
minutes, seconds = divmod(remainder, 60)
parts = []
if da... | from solution import datetime_difference
from datetime import datetime, timedelta
def test_datetime_difference_same_date():
start = datetime(2023, 10, 1, 12, 0, 0)
end = datetime(2023, 10, 1, 15, 30, 45)
assert datetime_difference(start, end) == "3 hours, 30 minutes, 45 seconds"
def test_datetime_differen... | [
{
"docstring": "Convert a timedelta object into a human-friendly string format.",
"function_declaration": "def format_timedelta(delta):",
"function_name": "format_timedelta",
"parameter_list": "(delta)"
},
{
"docstring": "Calculate the difference between two datetime objects and return\nit i... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from datetime import datetime\n\ndef calculate_time_difference(start: datetime, end: datetime) -> str:\n \"\"\"\n Calculate the difference between two datetime objects and return the\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088129",
"row_id": 88129,
"seed_ids": "['gemma-2-27b-it_183529']"
} | 0.595675 | Filter_88129 | I | [
"format_timedelta",
"datetime_difference"
] | 2 | [
[
"datetime_difference",
"format_timedelta"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | f90b80e7cf8db954adecb72442010301e785ba7f | a41a0d8ef17cc8f5bfdf7e231268284d17c5cf97 | |||
v1.0 | instruct | Filter | Filter_88176_I | Develop a Python function called `sum_all_primes` that takes a positive integer `n` and returns the sum of all prime numbers less than or equal to `n`. | def is_prime(num):
"""
Returns True if num is a prime number, 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_all_primes
def test_sum_all_primes_up_to_10():
assert sum_all_primes(10) == 17 # primes are 2, 3, 5, 7
def test_sum_all_primes_up_to_1():
assert sum_all_primes(1) == 0 # there are no primes less than or equal to 1
def test_sum_all_primes_up_to_2():
assert sum_all_primes(2) == 2... | [
{
"docstring": "Returns True if num is a prime number, 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": "def s... | [
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 Checks if a given number is prime.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0:\... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088176",
"row_id": 88176,
"seed_ids": "['gemma-2-27b-it_183678']"
} | 0.699463 | Filter_88176 | I | [
"is_prime",
"sum_all_primes"
] | 2 | [
[
"sum_all_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 21a484d76e962e7a3ffa587dcf3bca5695b96481 | af3646c4a143302e14549eb3de4224844637ae79 | |||
v1.0 | instruct | Filter | Filter_88184_I | This program was designed to play a game called Nim. The program is based on the traditional rules of Nim, where two players take turns removing objects from piles.
The objective is to be the last player to remove an object.
Please read your instructions carefully.
## Gameplay Rules
1. **Setup:** The game starts ... | def initialize_piles():
"""
Initializes the piles with default number of objects
Pile 1: 3 objects
Pile 2: 5 objects
Pile 3: 7 objects
Returns:
tuple: a tuple (pile1, pile2, pile3) representing the piles
"""
return (3, 5, 7)
def print_piles(piles):
"""
Prints the current... | from solution import initialize_piles, update_piles, is_game_over
def test_initialize_piles():
piles = initialize_piles()
assert piles == (3, 5, 7)
def test_update_piles():
piles = (3, 5, 7)
updated_piles = update_piles(piles, 1, 2)
assert updated_piles == (1, 5, 7)
updated_piles = update... | [
{
"docstring": "Initializes the piles with default number of objects\nPile 1: 3 objects\nPile 2: 5 objects\nPile 3: 7 objects\nReturns:\n tuple: a tuple (pile1, pile2, pile3) representing the piles",
"function_declaration": "def initialize_piles():",
"function_name": "initialize_piles",
"paramete... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def initialize_piles():\n return [3, 5, 7]\n\ndef display_piles(piles):\n for i, pile in enumerate(piles):\n print(f\"Pile {i+1}: {pile} objects\")\n\ndef get_player_move(piles):\... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00088184",
"row_id": 88184,
"seed_ids": "['gemma-2-27b-it_183703']"
} | 0.649602 | Filter_88184 | I | [
"initialize_piles",
"print_piles",
"update_piles",
"is_game_over",
"nim_game"
] | 5 | [
[
"nim_game",
"initialize_piles"
],
[
"nim_game",
"is_game_over"
],
[
"nim_game",
"print_piles"
],
[
"nim_game",
"update_piles"
]
] | 4 | [] | false | [] | false | pytest | true | [] | true | da80d94e2b465b1221482aeeccf35579c787dabc | 7f4c0be206ce9ace3a83243903242a8bf90a162f | |||
v1.0 | instruct | Filter | Filter_88255_I | This is a code for a Sudoku Solver,
```python
def solve(grid):
"""Solves a Sudoku puzzle.
Args:
grid: A 9x9 list of lists representing the Sudoku grid.
Returns:
True if a solution is found, False otherwise.
"""
for row in range(9):
for col in range(9):
if grid[row][col] == 0:
for... | def solve(grid):
"""Solves a Sudoku puzzle and returns the solved grid.
Args:
grid: A 9x9 list of lists representing the Sudoku grid.
Returns:
The solved grid if a solution is found, None otherwise.
"""
if _solve_recursive(grid):
return grid
else:
return None
... | from solution import solve, is_valid
def test_solve_complete_grid():
grid = [
[5, 3, 4, 6, 7, 8, 9, 1, 2],
[6, 7, 2, 1, 9, 5, 3, 4, 8],
[1, 9, 8, 3, 4, 2, 5, 6, 7],
[8, 5, 9, 7, 6, 1, 4, 2, 3],
[4, 2, 6, 8, 5, 3, 7, 9, 1],
[7, 1, 3, 9, 2, 4, 8, 5, 6],
[9, 6, ... | [
{
"docstring": "Solves a Sudoku puzzle and returns the solved grid.\n\nArgs:\n grid: A 9x9 list of lists representing the Sudoku grid.\n\nReturns:\n The solved grid if a solution is found, None otherwise.",
"function_declaration": "def solve(grid):",
"function_name": "solve",
"parameter_list":... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def solve(grid):\n \"\"\"\n Solves a Sudoku puzzle.\n\n Args:\n grid: A 9x9 list of lists representing the Sudoku grid.\n\n Returns:\n The solved grid if a solution i... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00088255",
"row_id": 88255,
"seed_ids": "['gemma-2-27b-it_183965']"
} | 0.577675 | Filter_88255 | I | [
"solve",
"_solve_recursive",
"is_valid"
] | 3 | [
[
"_solve_recursive",
"is_valid"
],
[
"solve",
"_solve_recursive"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 0eff58558300097fc7130daa2f35890c26f60aea | 29dd6de1a5e713d10c9389dc90bba69df30fba10 | |||
v1.0 | instruct | Filter | Filter_88264_I | The problem I am working on requires generating a sequence of numbers. This sequence should be
* **Strictly increasing**: Each number should be larger than the one before it.
* **Contain only prime numbers**: All numbers in the sequence need to be prime.
Here's the challenge: I need to do it **iteratively**
Let me c... | def is_prime(n):
"""
Checks if a number is prime.
"""
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
return Tru... | from solution import is_prime, generate_prime_sequence
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(17) == True
assert is_prime(18) == False
def test_generate_prime_sequence():
assert generate_prime_sequence(2, 5) == [2,... | [
{
"docstring": "Checks if a number is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Generates a sequence of prime numbers starting from the initial number.\n\n:param initial: Initial number of the sequence.\n:para... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088264",
"row_id": 88264,
"seed_ids": "['gemma-2-27b-it_183993']"
} | 0.639706 | Filter_88264 | I | [
"is_prime",
"generate_prime_sequence"
] | 2 | [
[
"generate_prime_sequence",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | c5baee4ae5baea99ca066746e29758819664a7e8 | f6e0477e2bd44d6b4768f3eae17c0073f1581130 | |||
v1.0 | instruct | Filter | Filter_88320_I | How to write a code for generating a random prime number within a given range using Python? | import random
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
retur... | from solution import is_prime, generate_random_prime
import pytest
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(11) == True
assert is_prime(15) == False
def test... | [
{
"docstring": "Check if a number is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Generates a random prime number within the given range [a, b].",
"function_declaration": "def generate_random_prime(a, b):",
... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\n\ndef is_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 % ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088320",
"row_id": 88320,
"seed_ids": "['gemma-2-27b-it_184149']"
} | 0.600151 | Filter_88320 | I | [
"is_prime",
"generate_random_prime"
] | 2 | [
[
"generate_random_prime",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 2cce888b79d08b05d0ddfece61d3d66be2ea49f8 | 91b22dcec27a35e900841a75b4c68243fd3728c0 | |||
v1.0 | instruct | Filter | Filter_88334_I | Here's what I want to do:
1. **Read a tab-delimited file:** The file contains student performance data with columns like 'StudentID', 'Subject', 'Score'.
2. **Convert the scores toletter grades:** Implement a function `convert_to_letter_grade(score)` that takes a numerical `score` and returns its corresponding letter... | import pandas as pd
def convert_to_letter_grade(score):
"""
Convert a numerical score to a letter grade.
:param score: int, numeric score to convert.
:return: str, corresponding letter grade.
"""
if score >= 90:
return 'A'
elif score >= 80:
return 'B'
elif score >= ... | import os
import pandas as pd
from solution import convert_to_letter_grade, process_student_performance
def test_convert_to_letter_grade():
assert convert_to_letter_grade(95) == 'A'
assert convert_to_letter_grade(85) == 'B'
assert convert_to_letter_grade(75) == 'C'
assert convert_to_letter_grade(65) ==... | [
{
"docstring": "Convert a numerical score to a letter grade.\n\n:param score: int, numeric score to convert.\n:return: str, corresponding letter grade.",
"function_declaration": "def convert_to_letter_grade(score):",
"function_name": "convert_to_letter_grade",
"parameter_list": "(score)"
},
{
... | [
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\n\ndef convert_to_letter_grade(score):\n \"\"\"\n Converts a numerical score to a letter grade based on predefined grading system.\n \n Parameters:\n sco... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088334",
"row_id": 88334,
"seed_ids": "['gemma-2-27b-it_184179']"
} | 0.695078 | Filter_88334 | I | [
"convert_to_letter_grade",
"process_student_performance"
] | 2 | [
[
"process_student_performance",
"convert_to_letter_grade"
]
] | 1 | [] | false | [] | false | pytest | true | [
"pandas"
] | false | 55390c427b7b9fa0e6e29e6de929ea7052347fc9 | 98bb4b662163f11949bb0a0048fe14f5f05dfe59 | |||
v1.0 | instruct | Filter | Filter_88341_I | I've started learning Python, and now I want to create a simple text-based game to solidify my understanding. I've gotten some mechanics working, but I need help with creating an enemy AI.
The game takes place in a dungeon, and the player navigates through rooms. Each room may or may not contain an enemy. If there's a... | import random
def is_wall(dungeon, x, y):
"""
Checks if the given coordinates represent a wall ('W').
"""
return dungeon[x][y] == 'W'
def enemy_ai(dungeon, enemy_position):
directions = [(0, 1), (0, -1), (1, 0), (-1, 0)] # Right, Left, Down, Up
enemy_x, enemy_y = enemy_position
while Tru... | from solution import is_wall, enemy_ai
def test_is_wall():
dungeon = [
["W", "W", "W", "W"],
["W", " ", " ", "W"],
["W", " ", "E", "W"],
["W", "W", "W", "W"]
]
assert is_wall(dungeon, 0, 0) is True
assert is_wall(dungeon, 1, 1) is False
assert is_wall(dungeon, 2, 2) ... | [
{
"docstring": "Checks if the given coordinates represent a wall ('W').",
"function_declaration": "def is_wall(dungeon, x, y):",
"function_name": "is_wall",
"parameter_list": "(dungeon, x, y)"
},
{
"docstring": null,
"function_declaration": "def enemy_ai(dungeon, enemy_position):",
"... | [
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\n# Dungeon map represented\ndungeon = [\n [\"W\", \"W\", \"W\", \"W\"],\n [\"W\", \" \", \" \", \"W\"],\n [\"W\", \" \", \"E\", \"W\"],\n [\"W\", \"W\", \"W\", \"W\... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00088341",
"row_id": 88341,
"seed_ids": "['gemma-2-27b-it_184198']"
} | 0.535387 | Filter_88341 | I | [
"is_wall",
"enemy_ai"
] | 2 | [
[
"enemy_ai",
"is_wall"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | d0c132e729cba11f5428bb989eba31becbd908dd | d0e1a42854b1e6fc5073a1936d4fe71ffc68d43f | |||
v1.0 | instruct | Filter | Filter_88357_I | This time I want to compare the performance of different sorting algorithms on arrays with different initial orderings.
## Goals
* **Compare performance:** Analyze the time complexity of different sorting algorithms on arrays with different initial orderings (e.g., already sorted, reverse sorted, randomly shuffled).
... | import time
import random
import matplotlib.pyplot as plt
def bubble_sort(arr):
n = len(arr)
for i in range(n):
for j in range(0, 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)):
... | from solution import bubble_sort, insertion_sort, merge_sort, quick_sort
def test_bubble_sort():
assert bubble_sort([3, 2, 1]) == [1, 2, 3]
assert bubble_sort([1, 3, 2]) == [1, 2, 3]
assert bubble_sort([1, 2, 3]) == [1, 2, 3]
assert bubble_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5]
def test_insertion_so... | [
{
"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,
0,
1
] | 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):\n for j in range(0, n - i - 1):\n if arr[j] > arr[j + 1]:\n arr[j... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088357",
"row_id": 88357,
"seed_ids": "['gemma-2-27b-it_184246']"
} | 0.487276 | Filter_88357 | I | [
"bubble_sort",
"insertion_sort",
"merge_sort",
"partition",
"quick_sort",
"measure_time"
] | 6 | [
[
"quick_sort",
"partition"
]
] | 1 | [] | false | [] | false | pytest | true | [
"matplotlib"
] | false | df5ab0c39574830e19dcbe4db2a048041111f7d1 | f430381d6993766d2e1d702bd4dc2a135be6d354 | |||
v1.0 | instruct | Filter | Filter_88393_I | Here's a problem that I'm working on:
You are tasked with designing a simple program to determine whether a given string is a palindrome.
**Understanding Palindromes**
A palindrome is a word, phrase, number, or other sequence of characters that reads the same backward as forward, ignoring spaces, punctuation, and ca... | import re
def is_palindrome(input_string):
"""
Determines if the provided input_string is a palindrome.
"""
# Remove spaces, punctuation, and convert to lowercase
processed_string = re.sub(r'[^A-Za-z0-9]', '', input_string).lower()
# Check if the processed string is equal to its reverse
ret... | from solution import is_palindrome, check_palindrome
def test_is_palindrome_positive_cases():
assert is_palindrome("Racecar")
assert is_palindrome("A man, a plan, a canal: Panama")
assert is_palindrome("No lemon, no melon")
assert is_palindrome("")
def test_is_palindrome_negative_cases():
assert n... | [
{
"docstring": "Determines if the provided input_string is a palindrome.",
"function_declaration": "def is_palindrome(input_string):",
"function_name": "is_palindrome",
"parameter_list": "(input_string)"
},
{
"docstring": "Checks if the input_string is a palindrome and returns a formatted st... | [
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 is_palindrome(input_string):\n \"\"\"\n Determines if the given string is a palindrome.\n \n Args:\n input_string (str): The string to check.\n \n Returns... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088393",
"row_id": 88393,
"seed_ids": "['gemma-2-27b-it_184385']"
} | 0.790704 | Filter_88393 | I | [
"is_palindrome",
"check_palindrome"
] | 2 | [
[
"check_palindrome",
"is_palindrome"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 2662a372bccdcb9e24d62022c568b47956b9eeaf | 7b9c921a59e8b4674fd79f6328df4d03d410cac6 | |||
v1.0 | instruct | Filter | Filter_88412_I | Here's the problem:
We have a 3x3 grid, with 9 squares.
Each square can be either empty (represented by '.') or contain a number from 1 to 9.
The goal is to fill the grid so that each row, column, and 3x3 subgrid contains all the digits from 1 to 9.
This is a classic Sudoku puzzle.
Can you provide me with a Python... | def solve_sudoku(grid):
"""
Solves a Sudoku puzzle using backtracking.
Args:
grid: A list of lists representing the Sudoku grid.
Returns:
True if a solution is found, False otherwise.
"""
for row in range(9):
for col in range(9):
if grid[row][col] == '.':
... | from solution import solve_sudoku, is_valid
def test_solve_sudoku_easy():
grid = [
['5', '3', '.', '.', '7', '.', '.', '.', '.'],
['6', '.', '.', '1', '9', '5', '.', '.', '.'],
['.', '9', '8', '.', '.', '.', '.', '6', '.'],
['8', '.', '.', '.', '6', '.', '.', '.', '3'],
['4'... | [
{
"docstring": "Solves a Sudoku puzzle using backtracking.\n\nArgs:\n grid: A list of lists representing the Sudoku grid.\n\nReturns:\n True if a solution is found, False otherwise.",
"function_declaration": "def solve_sudoku(grid):",
"function_name": "solve_sudoku",
"parameter_list": "(grid)"... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def solve_sudoku(grid):\n \"\"\"\n Solves a Sudoku puzzle using backtracking.\n\n Args:\n grid: A list of lists representing the Sudoku grid.\n\n Returns:\n True if a... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088412",
"row_id": 88412,
"seed_ids": "['gemma-2-27b-it_184458']"
} | 0.56676 | Filter_88412 | I | [
"solve_sudoku",
"is_valid"
] | 2 | [
[
"solve_sudoku",
"is_valid"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 017a61f987fc8947448c59591b7571947cd47823 | 39c6ace02ed3b07264e55a7fd6dddd05e2689915 | |||
v1.0 | instruct | Filter | Filter_88413_I | This is a simple puzzle game I'm making.
**Rules:**
* You start with a grid of 4x4 squares.
* Each square can be either "empty" or contain a number from 1 to 15.
* **Goal:** Arrange the numbers 1 to 15 in consecutive order, with the empty square at the bottom right corner.
* **Moves:** You can slide a numbered tile... | def find_empty_square(grid):
"""
Finds the coordinates of the empty square (represented by None) in the 4x4 grid.
"""
for row in range(4):
for col in range(4):
if grid[row][col] is None:
return (row, col)
return None # If no empty square is found, though it shoul... | from solution import find_empty_square, is_valid_move
def test_find_empty_square():
grid = [
[1, 2, 3, 4],
[5, 6, 7, 8],
[9, 10, 11, 12],
[13, 14, None, 15],
]
assert find_empty_square(grid) == (3, 2)
grid = [
[1, 2, 3, 4],
[5, 6, None, 8],
[9, 1... | [
{
"docstring": "Finds the coordinates of the empty square (represented by None) in the 4x4 grid.",
"function_declaration": "def find_empty_square(grid):",
"function_name": "find_empty_square",
"parameter_list": "(grid)"
},
{
"docstring": "Checks if moving the tile at (row, col) into the empt... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "grid = [\n [1, 2, 3, 4],\n [5, 6, 7, 8],\n [9, 10, 11, 12],\n [13, 14, None, 15],\n]\n\ndef find_empty_square(grid):\n \"\"\"\n Finds the coordinates of the empty square (Non... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088413",
"row_id": 88413,
"seed_ids": "['gemma-2-27b-it_184459']"
} | 0.670552 | Filter_88413 | I | [
"find_empty_square",
"is_valid_move"
] | 2 | [
[
"is_valid_move",
"find_empty_square"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | c982b823a31f0bdacc50c325110435cb93215d4e | 097bc7dee6cb9a0ff201795d0a000d2bfa951733 | |||
v1.0 | instruct | Filter | Filter_88415_I | This is the final project for my Introduction to Programming course.
This project requires me to create a program that simulates a simple game of "Rock, Paper, Scissors" against the computer.
Here are the specific requirements:
* **User Input:**
* The program should prompt the user to enter their choice: "Rock"... | import random
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 \
(user_choice == "Scissors" and computer_choice == "Paper") or \
(user_choice == "Paper" and comp... | import random
import pytest
from solution import determine_winner
@pytest.mark.parametrize("user_choice, computer_choice, expected", [
("Rock", "Scissors", "You win!"),
("Scissors", "Paper", "You win!"),
("Paper", "Rock", "You win!"),
("Rock", "Rock", "It's a tie!"),
("Paper", "Paper", "It's a tie!... | [
{
"docstring": null,
"function_declaration": "def determine_winner(user_choice, computer_choice):",
"function_name": "determine_winner",
"parameter_list": "(user_choice, computer_choice)"
},
{
"docstring": null,
"function_declaration": "def play_rock_paper_scissors():",
"function_nam... | [
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 determine_winner(user_choice, computer_choice):\n \"\"\"\n Determines the winner between user and computer.\n Returns \"user\" if user wins, \"computer\" if compu... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088415",
"row_id": 88415,
"seed_ids": "['gemma-2-27b-it_184469']"
} | 0.567877 | Filter_88415 | I | [
"determine_winner",
"play_rock_paper_scissors"
] | 2 | [
[
"play_rock_paper_scissors",
"determine_winner"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 3066bf989f265f6e4c26253844114f914be3e0ac | cf9bd8554c59e05624ee94c9dc5d102199b2ce4c | |||
v1.0 | instruct | Filter | Filter_88426_I | The following code generates a list of prime numbers up to a given limit:
```python
def is_prime(num):
"""Checks if a number is prime."""
if num <= 1:
return False
for i in range(2, int(num**0.5) + 1):
if num % i == 0:
return False
return True
def generate_primes(limit):
"""Generates a list of... | def is_prime(num):
"""Checks if a number is prime."""
if num <= 1:
return False
for i in range(2, int(num**0.5) + 1):
if num % i == 0:
return False
return True
def generate_primes(limit):
"""Generates a list of prime numbers up to a given limit."""
primes = []
for num in range(2, limit + 1)... | 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(0) == False
assert is_prime(1) == False
assert is_prime(29) == True
assert is_prime(30) == False
def test_generate_primes():... | [
{
"docstring": "Checks if a number is prime.",
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": "Generates a list of prime numbers up to a given limit.",
"function_declaration": "def generate_primes(limit):",
"func... | [
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 \"\"\"Checks if a number is prime.\"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0:\n retur... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088426",
"row_id": 88426,
"seed_ids": "['gemma-2-27b-it_184503']"
} | 0.677962 | Filter_88426 | I | [
"is_prime",
"generate_primes"
] | 2 | [
[
"generate_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 10d9ac3424ea7f78397f72126c8a86280105457a | 94a2a838d66da939f033d2a54d21528585cff9f2 | |||
v1.0 | instruct | Filter | Filter_88433_I | This is my code for a simple game.
```python
import random
def generate_number():
return random.randint(1, 10)
def get_guess():
while True:
try:
guess = int(input("Guess a number between 1 and 10: "))
if 1 <= guess <= 10:
return guess
else:
print("Invalid input. Please enter... | import random
def choose_difficulty():
while True:
difficulty = input("Choose difficulty (Easy/Medium/Hard): ").lower()
if difficulty == "easy":
return 10
elif difficulty == "medium":
return 50
elif difficulty == "hard":
return 100
else:
... | from solution import generate_number, choose_difficulty
def test_generate_number():
random.seed(0) # fix the seed for reproducibility
assert 1 <= generate_number(10) <= 10
assert 1 <= generate_number(50) <= 50
assert 1 <= generate_number(100) <= 100
def test_choose_difficulty(monkeypatch):
monkey... | [
{
"docstring": null,
"function_declaration": "def choose_difficulty():",
"function_name": "choose_difficulty",
"parameter_list": "()"
},
{
"docstring": null,
"function_declaration": "def generate_number(max_num):",
"function_name": "generate_number",
"parameter_list": "(max_num)"... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\n\ndef choose_difficulty():\n while True:\n difficulty = input(\"Choose difficulty (Easy/Medium/Hard): \").lower()\n if difficulty == \"easy\":\n retu... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00088433",
"row_id": 88433,
"seed_ids": "['gemma-2-27b-it_184523']"
} | 0.461804 | Filter_88433 | I | [
"choose_difficulty",
"generate_number",
"get_guess",
"play_game"
] | 4 | [
[
"play_game",
"choose_difficulty"
],
[
"play_game",
"generate_number"
],
[
"play_game",
"get_guess"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | 0e8cabb8ef0c7249b2cc4191dba131451cb23845 | a501f67ec3e2475d5c61df8a70c26222dd58fab8 | |||
v1.0 | instruct | Filter | Filter_88462_I | Exercise:
Implement the following functions in Python:
1. `reverse_string(s)`: This function takes a string as input and returns the reversed string.
2. `is_palindrome(s)`: This function takes a string as input and returns `True` if the string is a palindrome (reads the same backward as forward), and `False` otherwi... | def reverse_string(s):
"""
Returns the reversed string of the input string s.
"""
return s[::-1]
def is_palindrome(s):
"""
Returns True if the input string s is a palindrome, False otherwise.
"""
reversed_s = reverse_string(s)
return s == reversed_s | from solution import reverse_string, is_palindrome
def test_reverse_string():
assert reverse_string("hello") == "olleh"
assert reverse_string("") == ""
assert reverse_string("a") == "a"
assert reverse_string("racecar") == "racecar"
assert reverse_string("Python") == "nohtyP"
def test_is_palindrome... | [
{
"docstring": "Returns the reversed string of the input string s.",
"function_declaration": "def reverse_string(s):",
"function_name": "reverse_string",
"parameter_list": "(s)"
},
{
"docstring": "Returns True if the input string s is a palindrome, False otherwise.",
"function_declaratio... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def reverse_string(s):\n \"\"\"\n Returns the reversed string of the input string s.\n \"\"\"\n return s[::-1]\n\ndef is_palindrome(s):\n \"\"\"\n Returns True if the input s... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088462",
"row_id": 88462,
"seed_ids": "['gemma-2-27b-it_184599']"
} | 0.78594 | Filter_88462 | I | [
"reverse_string",
"is_palindrome"
] | 2 | [
[
"is_palindrome",
"reverse_string"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | c7de61192fe4029597342d3e882897ff530e71f9 | deab05d554df805c0cc796eccf0ff179e8d77922 | |||
v1.0 | instruct | Filter | Filter_88512_I | This code is to be used for a simple text adventure game:
```python
def start_game():
"""Starts the text adventure game."""
print("Welcome to the Adventure!")
print("You find yourself in a dark forest.")
choice = input("What do you do? (go north/go south/quit): ")
if choice.lower() == "go... | def start_game():
"""Starts the text adventure game."""
print("Welcome to the Adventure!")
print("You find yourself in a dark forest.")
choice = input("What do you do? (go north/go south/quit): ")
if choice.lower() == "go north":
north_path()
elif choice.lower() == "go south":
... | import pytest
from unittest.mock import patch
from solution import start_game, north_path, south_path
@patch('builtins.input', return_value='go north')
@patch('builtins.print')
def test_start_game_go_north(mock_print, mock_input):
start_game()
mock_print.assert_any_call("You head north and encounter a mysterio... | [
{
"docstring": "Starts the text adventure game.",
"function_declaration": "def start_game():",
"function_name": "start_game",
"parameter_list": "()"
},
{
"docstring": "Path the player takes when choosing to go north.",
"function_declaration": "def north_path():",
"function_name": "no... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def start_game():\n \"\"\"Starts the text adventure game.\"\"\"\n print(\"Welcome to the Adventure!\")\n print(\"You find yourself in a dark forest.\")\n \n choice = input(\"Wha... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088512",
"row_id": 88512,
"seed_ids": "['gemma-2-27b-it_184736']"
} | 0.479341 | Filter_88512 | I | [
"start_game",
"north_path",
"south_path"
] | 3 | [
[
"start_game",
"north_path"
],
[
"start_game",
"south_path"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 67d1c52bd3b3e2cec4f6a97096f266c3d637543f | 1c6c04e733996f4d213de7a429a4df78ea4bf10d | |||
v1.0 | instruct | Filter | Filter_88551_I | We will consider only one-dimensional arrays in this problem.
Implement the following functions:
1. `swap(arr, i, j)`: Swaps the elements at indices `i` and `j` in the array `arr`.
2. `reverse(arr)`: Reverses the elements of the array `arr` in-place.
3. `is_sorted(arr)`: Returns `True` if the array `arr` is sorted ... | def swap(arr, i, j):
"""Swaps the elements at indices i and j in the array arr."""
arr[i], arr[j] = arr[j], arr[i]
def reverse(arr):
"""Reverses the elements of the array arr in-place."""
left = 0
right = len(arr) - 1
while left < right:
swap(arr, left, right)
left += 1
... | from solution import swap, reverse, is_sorted
def test_swap():
arr = [1, 2, 3, 4]
swap(arr, 1, 2)
assert arr == [1, 3, 2, 4]
def test_reverse():
arr = [1, 2, 3, 4]
reverse(arr)
assert arr == [4, 3, 2, 1]
def test_reverse_single_element():
arr = [1]
reverse(arr)
assert arr == [1]
... | [
{
"docstring": "Swaps the elements at indices i and j in the array arr.",
"function_declaration": "def swap(arr, i, j):",
"function_name": "swap",
"parameter_list": "(arr, i, j)"
},
{
"docstring": "Reverses the elements of the array arr in-place.",
"function_declaration": "def reverse(ar... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def swap(arr, i, j):\n \"\"\"Swaps the elements at indices i and j in the array arr.\"\"\"\n arr[i], arr[j] = arr[j], arr[i]\n\ndef reverse(arr):\n \"\"\"Reverses the elements of the ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088551",
"row_id": 88551,
"seed_ids": "['gemma-2-27b-it_184849']"
} | 0.72256 | Filter_88551 | I | [
"swap",
"reverse",
"is_sorted"
] | 3 | [
[
"reverse",
"swap"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | dd83e33d55f9b8adc1172ea160c9386f189efe13 | 8d340b29aa326b0a277385499dc9fc9addc5ad36 | |||
v1.0 | instruct | Filter | Filter_88561_I | This is the problem statement:
You are given an array of integers nums. You need to find the maximum sum of a contiguous subarray.
**Example 1:**
```
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, which is 6.
```
**Example 2:**
```
Input: nums = ... | def maxCrossingSum(nums, left, mid, right):
# Including elements on the left of the mid
sum_left = float('-inf')
temp_sum = 0
for i in range(mid, left - 1, -1):
temp_sum += nums[i]
if temp_sum > sum_left:
sum_left = temp_sum
# Including elements on the right of the mid
... | import pytest
from solution import maxSubArray
def test_example1():
assert maxSubArray([-2, 1, -3, 4, -1, 2, 1, -5, 4]) == 6
def test_example2():
assert maxSubArray([1]) == 1
def test_example3():
assert maxSubArray([5, 4, -1, 7, 8]) == 23
def test_all_negative():
assert maxSubArray([-1, -2, -3, -4])... | [
{
"docstring": null,
"function_declaration": "def maxCrossingSum(nums, left, mid, right):",
"function_name": "maxCrossingSum",
"parameter_list": "(nums, left, mid, right)"
},
{
"docstring": null,
"function_declaration": "def maxSubArrayDivideAndConquer(nums, left, right):",
"function... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def maxCrossingSum(nums, left, mid, right):\n # Include elements on the left of mid.\n left_sum = float('-inf')\n total_sum = 0\n for i in range(mid, left - 1, -1):\n total_... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088561",
"row_id": 88561,
"seed_ids": "['gemma-2-27b-it_184887']"
} | 0.718466 | Filter_88561 | I | [
"maxCrossingSum",
"maxSubArrayDivideAndConquer",
"maxSubArray"
] | 3 | [
[
"maxSubArray",
"maxSubArrayDivideAndConquer"
],
[
"maxSubArrayDivideAndConquer",
"maxCrossingSum"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 0d1f69c0ba045aec0f37ad0d9706f7fe568f8693 | 5be65b8922cba1c9ec8698449c92ffce33a5bc16 | |||
v1.0 | instruct | Filter | Filter_88609_I | This week's challenge:
**Design a program that simulates the classic game of Tic-Tac-Toe.**
**Requirements:**
* The program should allow two players to take turns marking an empty square on a 3x3 grid.
* The program should check for a win condition after each turn.
* The program should announce the winner if a pla... | def print_board(board):
"""Prints the current state of the board."""
for row in board:
print(" | ".join(row))
print("---------")
def check_win(board):
"""Checks if there is a winner."""
# Check rows and columns
for i in range(3):
if board[i][0] == board[i][1] == board[i][2] ... | from solution import print_board, check_win, check_draw, make_move
def test_make_move():
board = [
[' ', ' ', ' '],
[' ', ' ', ' '],
[' ', ' ', ' ']
]
assert make_move(board, 'X', 0, 0) == True
assert board[0][0] == 'X'
assert make_move(board, 'X', 0, 0) == False # Move in ... | [
{
"docstring": "Prints the current state of the board.",
"function_declaration": "def print_board(board):",
"function_name": "print_board",
"parameter_list": "(board)"
},
{
"docstring": "Checks if there is a winner.",
"function_declaration": "def check_win(board):",
"function_name": ... | [
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 board.\"\"\"\n for row in board:\n print(\" | \".join(row))\n print(\"---------\")\n\ndef check_win(board):\... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088609",
"row_id": 88609,
"seed_ids": "['gemma-2-27b-it_185016']"
} | 0.465583 | Filter_88609 | I | [
"print_board",
"check_win",
"check_draw",
"make_move",
"tic_tac_toe"
] | 5 | [
[
"tic_tac_toe",
"check_draw"
],
[
"tic_tac_toe",
"check_win"
],
[
"tic_tac_toe",
"make_move"
],
[
"tic_tac_toe",
"print_board"
]
] | 4 | [] | false | [] | false | pytest | true | [] | true | 86ce789aa64271793fd5999188e0ff41773adb84 | ee9c8fb5124f2d208f076b99f693da7d74e7fb19 | |||
v1.0 | instruct | Filter | Filter_88639_I | Write a Python code snippet to generate a list of prime numbers within a given range. | def is_prime(n):
"""
Determines 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 prime_range(start, end):
"""
Generates a list of prime numbers within the given range [start, end... | from solution import is_prime, prime_range
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(13) == True
assert is_prime(15) == False
def test_prime_range():
assert prime_range(1, 10) == [2, 3, 5, 7]
assert prime_range(10... | [
{
"docstring": "Determines 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 within the given range [start, end].",
"function_declaration": "def prime_range(start, ... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n re... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088639",
"row_id": 88639,
"seed_ids": "['gemma-2-27b-it_185110']"
} | 0.694563 | Filter_88639 | I | [
"is_prime",
"prime_range"
] | 2 | [
[
"prime_range",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 71d9892088b702286d462016710dd0189a1db12e | 75e37ea55051f39d1874c627a15c8ac7ad8ee2d7 | |||
v1.0 | instruct | Filter | Filter_88659_I | This is my homework assignment:
Create a Python program that takes a list of numbers as input from the user and then calculates and prints the mean, median, and mode of the numbers.
Here's what I have so far:
```python
def calculate_stats(numbers):
mean = sum(numbers) / len(numbers) | from typing import List, Union
from collections import Counter
def calculate_mean(numbers: List[Union[int, float]]) -> float:
return sum(numbers) / len(numbers)
def calculate_median(numbers: List[Union[int, float]]) -> float:
sorted_numbers = sorted(numbers)
n = len(sorted_numbers)
middle = n // 2
... | from solution import calculate_mean, calculate_median, calculate_mode, calculate_stats
def test_calculate_mean():
assert calculate_mean([1, 2, 3, 4, 5]) == 3.0
assert calculate_mean([1.5, 2.5, 3.5]) == 2.5
assert calculate_mean([1, 1, 1, 1, 1]) == 1.0
def test_calculate_median():
assert calculate_medi... | [
{
"docstring": null,
"function_declaration": "def calculate_mean(numbers):",
"function_name": "calculate_mean",
"parameter_list": "(numbers)"
},
{
"docstring": null,
"function_declaration": "def calculate_median(numbers):",
"function_name": "calculate_median",
"parameter_list": "... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from typing import List, Union\nfrom collections import Counter\n\ndef calculate_mean(numbers: List[Union[int, float]]) -> float:\n return sum(numbers) / len(numbers)\n\ndef calculate_media... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00088659",
"row_id": 88659,
"seed_ids": "['gemma-2-27b-it_185163']"
} | 0.721691 | Filter_88659 | I | [
"calculate_mean",
"calculate_median",
"calculate_mode",
"calculate_stats",
"main"
] | 5 | [
[
"calculate_stats",
"calculate_mean"
],
[
"calculate_stats",
"calculate_median"
],
[
"calculate_stats",
"calculate_mode"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | d5a0bc246126f6d7e7bbb6c55864df91fdfd8d7e | 295551a9e153619cc5b752ed69837e7ce78756ec | |||
v1.0 | instruct | Filter | Filter_88660_I | You are tasked with creating a program that simulates a simplified version of the game "Rock, Paper, Scissors".
Functionality:
The program should randomly choose between "Rock", "Paper", or "Scissors".
The user should input their choice.
The program should compare the choices and determine the winner.
Output:
Th... | 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!"
elif (user_choice == "Rock" and computer_choice == "Scissors") or \
... | from solution import get_computer_choice, determine_winner, play_round
def test_get_computer_choice():
choices = ["Rock", "Paper", "Scissors"]
for _ in range(100):
choice = get_computer_choice()
assert choice in choices
def test_determine_winner_tie():
assert determine_winner("Rock", "Rock... | [
{
"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 decide_winner(user_choice, computer_choice):\n if computer_choice == user_choice:\n return \"It's a tie!\"\n elif (computer_choice == \"Rock\" and user_choice... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088660",
"row_id": 88660,
"seed_ids": "['gemma-2-27b-it_185167']"
} | 0.558706 | Filter_88660 | I | [
"get_computer_choice",
"determine_winner",
"play_round"
] | 3 | [
[
"play_round",
"determine_winner"
],
[
"play_round",
"get_computer_choice"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 78a32505e1880bd9db1af3da74f2643ebc651578 | 94b374a8f6af6194ac5e90d56a7508615b0108be | |||
v1.0 | instruct | Filter | Filter_88668_I | I want to create a Python program to simulate the rolling of two dice.
Here's what I have so far:
```python
import random
def roll_dice():
"""Simulates the rolling of two dice."""
die1 = random.randint(1, 6)
die2 = random.randint(1, 6)
total = die1 + die2
return die1, die2, total
die1, die2, total = roll_... | import random
def roll_dice():
"""Simulates the rolling of two dice."""
die1 = random.randint(1, 6)
die2 = random.randint(1, 6)
total = die1 + die2
return die1, die2, total
def roll_dice_multiple_times(num_rolls):
"""Rolls dice for a specified number of times and returns the results."""
re... | from solution import roll_dice, roll_dice_multiple_times
def test_roll_dice():
die1, die2, total = roll_dice()
assert 1 <= die1 <= 6
assert 1 <= die2 <= 6
assert total == die1 + die2
def test_roll_dice_multiple_times():
num_rolls = 5
results = roll_dice_multiple_times(num_rolls)
assert len... | [
{
"docstring": "Simulates the rolling of two dice.",
"function_declaration": "def roll_dice():",
"function_name": "roll_dice",
"parameter_list": "()"
},
{
"docstring": "Rolls dice for a specified number of times and returns the results.",
"function_declaration": "def roll_dice_multiple_t... | [
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 \"\"\"Simulates the rolling of two dice.\"\"\"\n die1 = random.randint(1, 6)\n die2 = random.randint(1, 6)\n total = die1 + die2\n return die... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00088668",
"row_id": 88668,
"seed_ids": "['gemma-2-27b-it_185179']"
} | 0.658246 | Filter_88668 | I | [
"roll_dice",
"roll_dice_multiple_times",
"display_results_table",
"main"
] | 4 | [
[
"roll_dice_multiple_times",
"roll_dice"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 0168ef57377543e8f7e25a10e0c9050ff13de71e | 66d3db6e5e22e671caf26d912b20f2ce39584eae | |||
v1.0 | instruct | Filter | Filter_88771_I | The Challenge:
You are tasked with designing a simple text-based adventure game in Python. The game should allow the player to make choices that affect the outcome of the story.
Features:
- Start Screen: Display a welcome message and brief introduction to the game.
- Player Input: Accept text input from the player ... | def start_screen():
"""
Displays the welcome message and brief introduction to the game.
"""
print("Welcome to the Text Adventure!")
print("You find yourself in a dark forest.")
def get_player_choice(prompt):
"""
Accepts text input from the player to determine their actions.
"""
ret... | import builtins
from unittest.mock import patch
from solution import get_player_choice, scene_left_path, scene_right_path
def test_get_player_choice():
with patch.object(builtins, 'input', lambda _: 'left'):
assert get_player_choice('Choose path: ') == 'left'
with patch.object(builtins, 'input', lambd... | [
{
"docstring": "Displays the welcome message and brief introduction to the game.",
"function_declaration": "def start_screen():",
"function_name": "start_screen",
"parameter_list": "()"
},
{
"docstring": "Accepts text input from the player to determine their actions.",
"function_declarat... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def start_game():\n \"\"\"\n Start screen with welcome message and brief introduction.\n \"\"\"\n print(\"Welcome to the Text Adventure!\")\n print(\"You find yourself in a dark... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00088771",
"row_id": 88771,
"seed_ids": "['gemma-2-27b-it_185479']"
} | 0.42034 | Filter_88771 | I | [
"start_screen",
"get_player_choice",
"scene_forest",
"scene_left_path",
"scene_right_path",
"play_game"
] | 6 | [
[
"play_game",
"scene_forest"
],
[
"play_game",
"start_screen"
],
[
"scene_forest",
"get_player_choice"
],
[
"scene_forest",
"scene_left_path"
],
[
"scene_forest",
"scene_right_path"
]
] | 5 | [] | false | [] | false | pytest | true | [] | true | 2bcdb107fb277938ce7c6a6de85c3616a5ac178f | 6c9500031f51bdff3db01b77723ac6251c3723d0 | |||
v1.0 | instruct | Filter | Filter_88784_I | We are given a binary tree and we need to find the sum of all nodes in the left subtree of a given node.
Here's what I've come up with so far:
```python
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def sum_left_subtree(root):
if root is Non... | class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def sum_subtree(root):
if root is None:
return 0
# Sum the current node's data and the sums of the left and right subtrees
return root.data + sum_subtree(root.left) + sum_subtree(ro... | def test_sum_left_subtree():
# Creating a sample tree:
# 10
# / \
# 5 15
# / \ \
# 3 7 18
root = Node(10)
root.left = Node(5)
root.right = Node(15)
root.left.left = Node(3)
root.left.right = Node(7)
root.right.right = Node(18)
... | [] | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class Node:\n def __init__(self, data):\n self.data = data\n self.left = None\n self.right = None\n\ndef sum_left_subtree(root):\n if root is None:\n return 0... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088784",
"row_id": 88784,
"seed_ids": "['gemma-2-27b-it_185519']"
} | 0.50755 | Filter_88784 | I | [
"sum_subtree",
"sum_left_subtree"
] | 2 | [
[
"sum_left_subtree",
"sum_subtree"
]
] | 1 | [] | false | [
"Node"
] | true | pytest | false | [] | true | b1deaac0918a9bda9905755431eaeeb755bad081 | e344047ae0d872049365ee1d3113a1d7c200a6a6 | |||
v1.0 | instruct | Filter | Filter_88795_I | You are tasked with creating a program that simulates the game of "Rock, Paper, Scissors" against a computer opponent.
Requirements:
1. User Input: The program should prompt the user to enter their choice ("rock", "paper", or "scissors").
2. Computer Choice: The computer should randomly choose between "rock", "paper"... | import random
def get_computer_choice():
"""
Randomly returns 'rock', 'paper', or 'scissors' for the computer choice.
"""
choices = ["rock", "paper", "scissors"]
return random.choice(choices)
def determine_winner(user_choice, computer_choice):
"""
Determines the winner of the game.
Ret... | from solution import determine_winner, play_rock_paper_scissors
def test_determine_winner():
assert determine_winner("rock", "scissors") == "user"
assert determine_winner("scissors", "paper") == "user"
assert determine_winner("paper", "rock") == "user"
assert determine_winner("scissors", "rock") == "co... | [
{
"docstring": "Randomly returns 'rock', 'paper', or 'scissors' for the computer choice.",
"function_declaration": "def get_computer_choice():",
"function_name": "get_computer_choice",
"parameter_list": "()"
},
{
"docstring": "Determines the winner of the game.\nReturns 'user' if the user wi... | [
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 get_computer_choice():\n \"\"\" Returns the choice of the computer between rock, paper, and scissors. \"\"\"\n choices = [\"rock\", \"paper\", \"scissors\"]\n ret... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088795",
"row_id": 88795,
"seed_ids": "['gemma-2-27b-it_185562']"
} | 0.568332 | Filter_88795 | 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 | d1d86b21fcfbd1f2cc37b36d15ecf21cee1eb509 | 8f0d1b0bc1c5bb2f942c92cf940b927ffc66d98e | |||
v1.0 | instruct | Filter | Filter_88827_I | I need to write a program that simulates a game of Rock, Paper, Scissors.
Here's what I need it to do:
* **Get player input:** Ask the player to choose Rock, Paper, or Scissors.
* **Generate computer choice:** Randomly choose Rock, Paper, or Scissors for the computer.
* **Determine the winner:** Compare the player's ... | import random
def get_computer_choice():
"""
Randomly select between 'rock', 'paper', 'scissors' for the computer.
"""
return random.choice(["rock", "paper", "scissors"])
def determine_winner(player_choice, computer_choice):
"""
Determine the winner of the game.
Parameters:
player... | import pytest
from solution import get_computer_choice, determine_winner, play_rock_paper_scissors
def test_get_computer_choice():
choices = ["rock", "paper", "scissors"]
for _ in range(100): # Run multiple times to ensure randomness
assert get_computer_choice() in choices
def test_determine_winner()... | [
{
"docstring": "Randomly select between 'rock', 'paper', 'scissors' for the computer.",
"function_declaration": "def get_computer_choice():",
"function_name": "get_computer_choice",
"parameter_list": "()"
},
{
"docstring": "Determine the winner of the game.\n\nParameters:\nplayer_choice (str... | [
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_player_choice():\n \"\"\"\n Asks the player to choose Rock, Paper, or Scissors.\n Returns the player's choice.\n \"\"\"\n choices = [\"Rock\", \"Paper\"... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088827",
"row_id": 88827,
"seed_ids": "['gemma-2-27b-it_185647']"
} | 0.439595 | Filter_88827 | 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 | 640d20356cd6dce90275a4b7f6cff4be6a571cb7 | 085cea84f10b5c626aa7dc341d02b7da097eef04 | |||
v1.0 | instruct | Filter | Filter_88890_I | Problem Statement:
You are tasked with developing a Python program that simulates the game of Rock, Paper, Scissors. The program should allow a human player to play against the computer.
Requirements:
The program should randomly choose between "Rock," "Paper," or "Scissors" for the computer's move.
The program... | import random
def get_computer_choice():
"""
Randomly return 'Rock', 'Paper', or 'Scissors'.
"""
return random.choice(['Rock', 'Paper', 'Scissors'])
def determine_winner(player_choice, computer_choice):
"""
Determine the winner based on player's and computer's choices.
"""
if player_ch... | from solution import get_computer_choice, determine_winner, play_round
def test_get_computer_choice():
choices = ['Rock', 'Paper', 'Scissors']
for _ in range(100): # Test it multiple times to ensure randomness
assert get_computer_choice() in choices
def test_determine_winner():
assert determine_w... | [
{
"docstring": "Randomly return 'Rock', 'Paper', or 'Scissors'.",
"function_declaration": "def get_computer_choice():",
"function_name": "get_computer_choice",
"parameter_list": "()"
},
{
"docstring": "Determine the winner based on player's and computer's choices.",
"function_declaration... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\n\ndef get_computer_choice():\n \"\"\"\n Randomly return 'Rock', 'Paper', or 'Scissors'.\n \"\"\"\n return random.choice(['Rock', 'Paper', 'Scissors'])\n\ndef determi... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00088890",
"row_id": 88890,
"seed_ids": "['gemma-2-27b-it_185831']"
} | 0.56144 | Filter_88890 | I | [
"get_computer_choice",
"determine_winner",
"play_round",
"main"
] | 4 | [
[
"play_round",
"determine_winner"
],
[
"play_round",
"get_computer_choice"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 85b826fa7b10ef6fdb7356c6d9be2caf4348ebf2 | 6d1d9351aaaf6bd83951f54e6c0c436c1669ad67 | |||
v1.0 | instruct | Filter | Filter_88930_I | This question has multiple parts.
**Part 1:**
You are given a string `s` and a character `c`. Return the number of times `c` appears in `s`.
**Example:**
```
s = "hello world"
c = "o"
count_occurrences(s, c) == 2
```
**Part 2:**
Extend your function from Part 1 to count the occurrences of all characters in the st... | def count_occurrences(s, c):
"""
Returns the number of times character c appears in string s.
"""
return s.count(c)
def count_all_characters(s):
"""
Returns a dictionary with the count of each character in the string s.
"""
char_count = {}
for char in s:
if char in char_coun... | from solution import count_occurrences, count_all_characters, most_frequent
def test_count_occurrences():
assert count_occurrences("hello world", "o") == 2
assert count_occurrences("hello world", "l") == 3
assert count_occurrences("hello world", "r") == 1
assert count_occurrences("hello world", "z") ==... | [
{
"docstring": "Returns the number of times character c appears in string s.",
"function_declaration": "def count_occurrences(s, c):",
"function_name": "count_occurrences",
"parameter_list": "(s, c)"
},
{
"docstring": "Returns a dictionary with the count of each character in the string s.",
... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def count_occurrences(s, c):\n \"\"\"\n Returns the number of times character c appears in string s.\n \"\"\"\n return s.count(c)\n\ndef count_all_characters(s):\n \"\"\"\n R... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088930",
"row_id": 88930,
"seed_ids": "['gemma-2-27b-it_185954']"
} | 0.761091 | Filter_88930 | I | [
"count_occurrences",
"count_all_characters",
"most_frequent"
] | 3 | [
[
"most_frequent",
"count_all_characters"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | b5af38ce3279589eff779d265331e1711227a08f | 7a5fbe89d837f6e002f5b9b29392b96c7bcca02a | |||
v1.0 | instruct | Filter | Filter_88937_I | This is the code for the Sudoku solver:
```python
def solve_sudoku(board):
"""Solves a Sudoku puzzle using backtracking.
Args:
board: A 9x9 list of lists representing the Sudoku board.
Empty cells are represented by 0.
Returns:
True if a solution is found, False otherwise.
... | def is_valid(board, row, col, num):
"""
Checks whether it will be legal to assign 'num' to the given 'row' and 'col'.
"""
# Check if 'num' is not in the current row
for i in range(9):
if board[row][i] == num:
return False
# Check if 'num' is not in the current column
for... | from solution import solve_sudoku, is_valid
def test_is_valid():
board = [
[5, 3, 0, 0, 7, 0, 0, 0, 0],
[6, 0, 0, 1, 9, 5, 0, 0, 0],
[0, 9, 8, 0, 0, 0, 0, 6, 0],
[8, 0, 0, 0, 6, 0, 0, 0, 3],
[4, 0, 0, 8, 0, 3, 0, 0, 1],
[7, 0, 0, 0, 2, 0, 0, 0, 6],
[0, 6, 0, ... | [
{
"docstring": "Checks whether it will be legal to assign 'num' to the given 'row' and 'col'.",
"function_declaration": "def is_valid(board, row, col, num):",
"function_name": "is_valid",
"parameter_list": "(board, row, col, num)"
},
{
"docstring": "Solves a Sudoku puzzle using backtracking.... | [
1,
1,
0
] | 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 \"\"\"Checks if it's valid to place num at board[row][col].\"\"\"\n # Check the row\n for c in range(9):\n if board[row][c] == num:\n ... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00088937",
"row_id": 88937,
"seed_ids": "['gemma-2-27b-it_185973']"
} | 0.468076 | Filter_88937 | I | [
"is_valid",
"solve_sudoku"
] | 2 | [
[
"solve_sudoku",
"is_valid"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 15c95b1563ae0f878d9de1dafbf056279c995b51 | 8b35624e9c38c61db953ca95ff190e755be91521 | |||
v1.0 | instruct | Filter | Filter_88954_I | You are given a sorted array of integers `nums` and an integer `target`.
Write a function that uses binary search to find the index of the `target` in `nums`. If the `target` is not found in `nums`, return `-1`.
Example:
```python
nums = [-1, 0, 3, 5, 9, 12]
target = 9
result = search(nums, target) # result = 4
``... | def search(nums, target):
"""
Uses binary search to find the index of the target in the sorted array nums.
Iterative implementation.
"""
left, right = 0, len(nums) - 1
while left <= right:
mid = left + (right - left) // 2
if nums[mid] == target:
return mid
... | from solution import search, search_recursive
def test_search_found():
nums = [-1, 0, 3, 5, 9, 12]
target = 9
assert search(nums, target) == 4
assert search_recursive(nums, target) == 4
def test_search_not_found():
nums = [-1, 0, 3, 5, 9, 12]
target = 2
assert search(nums, target) == -1
... | [
{
"docstring": "Uses binary search to find the index of the target in the sorted array nums.\nIterative implementation.",
"function_declaration": "def search(nums, target):",
"function_name": "search",
"parameter_list": "(nums, target)"
},
{
"docstring": "Uses recursive binary search to find... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def search(nums, target):\n \"\"\"\n Performs a binary search to find the index of the target in the nums array.\n Returns the index of the target if found, otherwise returns -1.\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088954",
"row_id": 88954,
"seed_ids": "['gemma-2-27b-it_186026']"
} | 0.751938 | Filter_88954 | I | [
"search",
"search_recursive",
"binary_search_recursive"
] | 3 | [
[
"search_recursive",
"binary_search_recursive"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | fd17401a7d6cb335369f2542efc13d080e3b00fb | 510e194926e297603588f5c02b37154460f7783d | |||
v1.0 | instruct | Filter | Filter_88957_I | We can use the Fibonacci sequence to generate a spiral.
Here's how it works:
1. **Start with the first two numbers of the Fibonacci sequence:** 0 and 1.
2. **Create squares with sides equal to each Fibonacci number:** You'll have a square with side 0 (which is just a point), followed by a square with side 1.
3. **Arr... | import matplotlib.pyplot as plt
import matplotlib.patches as patches
def fibonacci_sequence(n):
"""
Generates the first n Fibonacci numbers.
"""
fib_seq = [0, 1]
for i in range(2, n):
fib_seq.append(fib_seq[-1] + fib_seq[-2])
return fib_seq
def plot_fibonacci_spiral(n):
"""
Plo... | from solution import fibonacci_sequence, plot_fibonacci_spiral
def test_fibonacci_sequence():
assert fibonacci_sequence(1) == [0, 1]
assert fibonacci_sequence(2) == [0, 1]
assert fibonacci_sequence(3) == [0, 1, 1]
assert fibonacci_sequence(6) == [0, 1, 1, 2, 3, 5]
def test_fibonacci_sequence_length():... | [
{
"docstring": "Generates the first n Fibonacci numbers.",
"function_declaration": "def fibonacci_sequence(n):",
"function_name": "fibonacci_sequence",
"parameter_list": "(n)"
},
{
"docstring": "Plots the Fibonacci spiral for the first n Fibonacci numbers.",
"function_declaration": "def ... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import matplotlib.pyplot as plt\nimport matplotlib.patches as patches\n\ndef fibonacci_spiral(n):\n \"\"\"\n Generates and displays a Fibonacci spiral with n squares.\n \n Args:\n ... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00088957",
"row_id": 88957,
"seed_ids": "['gemma-2-27b-it_186036']"
} | 0.571775 | Filter_88957 | I | [
"fibonacci_sequence",
"plot_fibonacci_spiral"
] | 2 | [
[
"plot_fibonacci_spiral",
"fibonacci_sequence"
]
] | 1 | [] | false | [] | false | pytest | true | [
"matplotlib"
] | false | 7f06ad5853305449838dd1d0ece9058195189d21 | d0037cee3bee831c93afc45f0006eb027e2e871f | |||
v1.0 | instruct | Filter | Filter_88960_I | This is a description of a game:
The game is played with 2 to 4 players. Each player starts with a hand of 7 cards. The remaining cards are placed face down to form a draw pile.
**Objective:** To be the first player to get rid of all their cards.
**Gameplay:**
* On their turn, a player draws a card from the draw pil... | import random
suits = ["Hearts", "Diamonds", "Clubs", "Spades"]
ranks = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"]
wild_card = "Wild"
deck = [(rank, suit) for rank in ranks for suit in suits] + [(wild_card, None)] * 4
random.shuffle(deck)
def deal_cards(num_players):
hands = [... | import pytest
from solution import deal_cards, can_play
def test_deal_cards():
num_players = 3
hands = deal_cards(num_players)
assert len(hands) == num_players
for hand in hands:
assert len(hand) == 7
def test_can_play():
top_card = ("5", "Hearts")
assert can_play(("5", "Diamonds"), to... | [
{
"docstring": null,
"function_declaration": "def deal_cards(num_players):",
"function_name": "deal_cards",
"parameter_list": "(num_players)"
},
{
"docstring": null,
"function_declaration": "def draw_card():",
"function_name": "draw_card",
"parameter_list": "()"
},
{
"doc... | [
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\nsuits = [\"Hearts\", \"Diamonds\", \"Clubs\", \"Spades\"]\nranks = [\"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"Jack\", \"Queen\", \"King\", \"Ace\"]\nwi... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00088960",
"row_id": 88960,
"seed_ids": "['gemma-2-27b-it_186048']"
} | 0.657863 | Filter_88960 | I | [
"deal_cards",
"draw_card",
"can_play",
"play_game"
] | 4 | [
[
"play_game",
"can_play"
],
[
"play_game",
"deal_cards"
],
[
"play_game",
"draw_card"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | a7f72c506848d532e600a80b9ae1a3f4f2d62f45 | 4bd00dc9d0dcdb3dfdeb3bd01aa97230f4d64978 | |||
v1.0 | instruct | Filter | Filter_88969_I | This is a simple text adventure game:
```python
def show_introduction():
print("You are standing in a dark forest. There is a path to the north and a path to the east.")
def get_player_choice():
choice = input("What do you want to do? (north/east) ").lower()
return choice
def handle_choice(choice):
i... | def show_introduction():
print("You are standing in a dark forest. There is a path to the north and a path to the east.")
def get_player_choice():
choice = input("What do you want to do? (north/east) ").lower()
return choice
def handle_choice(choice):
if choice == "north":
show_clearing()
... | from solution import main, get_player_choice, handle_choice, show_introduction, show_clearing, show_bear_encounter
import pytest
from unittest.mock import patch
def test_handle_choice_north(capfd):
handle_choice("north")
out, err = capfd.readouterr()
assert "You are in a sunny clearing" in out
def test_ha... | [
{
"docstring": null,
"function_declaration": "def show_introduction():",
"function_name": "show_introduction",
"parameter_list": "()"
},
{
"docstring": null,
"function_declaration": "def get_player_choice():",
"function_name": "get_player_choice",
"parameter_list": "()"
},
{
... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def show_introduction():\n print(\"You are standing in a dark forest. There is a path to the north and a path to the east.\")\n\ndef get_player_choice():\n choice = input(\"What do you w... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00088969",
"row_id": 88969,
"seed_ids": "['gemma-2-27b-it_186068']"
} | 0.456307 | Filter_88969 | I | [
"show_introduction",
"get_player_choice",
"handle_choice",
"show_clearing",
"show_bear_encounter",
"main"
] | 6 | [
[
"handle_choice",
"show_bear_encounter"
],
[
"handle_choice",
"show_clearing"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 43dc52d1b8d6b42ba90ee31cb48189c27a71978d | ea9a8251397fb15b2a791baba35bdfdb08abac3d | |||
v1.0 | instruct | Filter | Filter_88980_I | This is the code for a simple game that simulates rolling a pair of dice.
```python
import random
def roll_dice():
"""Rolls a pair of six-sided dice and returns the total."""
die1 = random.randint(1, 6)
die2 = random.randint(1, 6)
total = die1 + die2
return total
# Main game loop
while True:
input("Press... | import random
def roll_dice():
"""Rolls a pair of six-sided dice and returns the individual die results and the total."""
die1 = random.randint(1, 6)
die2 = random.randint(1, 6)
total = die1 + die2
return die1, die2, total
def calculate_score(die1, die2, total):
"""Calculates the score based o... | from solution import roll_dice, calculate_score
def test_roll_dice_within_bounds():
die1, die2, total = roll_dice()
assert 1 <= die1 <= 6
assert 1 <= die2 <= 6
assert 2 <= total <= 12
def test_calculate_score_for_seven():
assert calculate_score(4, 3, 7) == 5
assert calculate_score(1, 6, 7) == ... | [
{
"docstring": "Rolls a pair of six-sided dice and returns the individual die results and the total.",
"function_declaration": "def roll_dice():",
"function_name": "roll_dice",
"parameter_list": "()"
},
{
"docstring": "Calculates the score based on the roll result.",
"function_declaratio... | [
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_dice():\n \"\"\"Rolls a pair of six-sided dice and returns the individual die results and the total.\"\"\"\n die1 = random.randint(1, 6)\n die2 = random.rand... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00088980",
"row_id": 88980,
"seed_ids": "['gemma-2-27b-it_186109']"
} | 0.509623 | Filter_88980 | I | [
"roll_dice",
"calculate_score",
"play_game"
] | 3 | [
[
"play_game",
"calculate_score"
],
[
"play_game",
"roll_dice"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 5cf8300f39a1b76645b8deef5eabff4ac0303c6e | 4e005ac06afef7257ab16f7593143cb4f4a6cd9f | |||
v1.0 | instruct | Filter | Filter_88982_I | This question involves a bit of Python coding and some logic. Let's say you have a list of strings representing customer reviews. You need to categorize these reviews as either "Positive", "Negative", or "Neutral". | def categorize_review(review):
"""
Categorizes a review as Positive, Negative, or Neutral based on keywords.
"""
positive_keywords = ["good", "great", "excellent", "amazing", "fantastic", "wonderful", "positive", "satisfied"]
negative_keywords = ["bad", "terrible", "poor", "awful", "horrible", "nega... | from solution import categorize_review, categorize_reviews
def test_categorize_positive_review():
assert categorize_review("The product is absolutely fantastic and wonderful.") == "Positive"
def test_categorize_negative_review():
assert categorize_review("The product is terrible and the experience was awful."... | [
{
"docstring": "Categorizes a review as Positive, Negative, or Neutral based on keywords.",
"function_declaration": "def categorize_review(review):",
"function_name": "categorize_review",
"parameter_list": "(review)"
},
{
"docstring": "Categorizes a list of reviews.",
"function_declarati... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def categorize_review(review):\n \"\"\"\n Categorizes a customer review as 'Positive', 'Negative', or 'Neutral'\n based on the presence of specific keywords.\n \n Args:\n rev... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00088982",
"row_id": 88982,
"seed_ids": "['gemma-2-27b-it_186114']"
} | 0.623819 | Filter_88982 | I | [
"categorize_review",
"categorize_reviews"
] | 2 | [
[
"categorize_reviews",
"categorize_review"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | ed318190c1c1b0f0b6950a226dd277df7b6cb01e | 2addbc1786bfe8b1fe12d00b1373c55ed707d6fa | |||
v1.0 | instruct | Filter | Filter_88997_I | The Challenge:
You are tasked with creating a program that identifies all prime numbers within a given range of integers.
Requirements:
1. User Input: The program should prompt the user to enter the lower and upper bounds of the range.
2. Prime Number Identification: Implement an efficient algorithm to determine wh... | def is_prime(num):
"""
Checks 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 find_primes_in_ra... | 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(5) == True
assert is_prime(11) == True
assert is_prime(4) == False
assert is_prime(9) == False
assert is_prime(0) == False
assert is_prime(1) ==... | [
{
"docstring": "Checks if a number is prime.",
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": "Finds all prime numbers within a given range.",
"function_declaration": "def find_primes_in_range(lower_bound, upper_boun... | [
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 Checks if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True\n if num % 2 == 0:\n retur... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00088997",
"row_id": 88997,
"seed_ids": "['gemma-2-27b-it_186147']"
} | 0.66988 | Filter_88997 | I | [
"is_prime",
"find_primes_in_range"
] | 2 | [
[
"find_primes_in_range",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | a949ce81cf191e04bbec89108a36292cd7d0ed0f | 6fc55ec0e22160875ee2a3d16d3a63d7a2e0a808 | |||
v1.0 | instruct | Filter | Filter_88999_I | I'm trying to figure out how to make a simple text adventure game in Python.
Here's what I want it to do:
1. **Introduce the player to the game world.**
2. **Present the player with a choice of actions.**
3. **Process the player's input and update the game state accordingly.**
4. **Display the results of the player's... | def introduction():
print("Welcome to the Adventure Game!")
print("You find yourself in a dark forest. There is a path to your left and right.")
print("Which direction do you want to go?")
def get_action():
action = input("Enter 'left' or 'right': ").strip().lower()
return action
def process_actio... | import pytest
from unittest.mock import patch
from solution import introduction, get_action, process_action, game_loop
def test_introduction(capsys):
introduction()
captured = capsys.readouterr()
assert "Welcome to the Adventure Game!" in captured.out
assert "dark forest" in captured.out
assert "pa... | [
{
"docstring": null,
"function_declaration": "def introduction():",
"function_name": "introduction",
"parameter_list": "()"
},
{
"docstring": null,
"function_declaration": "def get_action():",
"function_name": "get_action",
"parameter_list": "()"
},
{
"docstring": null,
... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def introduction():\n print(\"Welcome to the Adventure Game!\")\n print(\"You find yourself in a dark forest. There is a path to your left and right.\")\n print(\"Which direction do y... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00088999",
"row_id": 88999,
"seed_ids": "['gemma-2-27b-it_186153']"
} | 0.401664 | Filter_88999 | I | [
"introduction",
"get_action",
"process_action",
"game_loop"
] | 4 | [
[
"game_loop",
"get_action"
],
[
"game_loop",
"introduction"
],
[
"game_loop",
"process_action"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | 14e510881339fa47d430887b4d5d047d4f30acf0 | 11f41fa33f0beae305b3b1570a0809fd08e6df19 | |||
v1.0 | instruct | Filter | Filter_89004_I | This is a test:
Write a Python program that does the following:
1. Takes an integer input from the user.
2. Checks if the input is a prime number.
3. Prints "Prime" if the input is prime, and "Not Prime" otherwise.
```python
def is_prime(n):
"""Returns True if n is a prime number, False otherwise."""
if n <= ... | def is_prime(n):
"""
Returns True if n is a prime number, False otherwise.
"""
if n <= 1:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
def check_prime():
"""
Takes an integer input from the user, checks if it is pri... | def test_is_prime_prime_numbers():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(5) == True
assert is_prime(7) == True
assert is_prime(11) == True
def test_is_prime_not_prime_numbers():
assert is_prime(1) == False
assert is_prime(4) == False
assert is_prime(6) ==... | [
{
"docstring": "Returns True if n is a prime number, False otherwise.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Takes an integer input from the user, checks if it is prime,\nand prints \"Prime\" if it is, \"Not Prime... | [
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, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00089004",
"row_id": 89004,
"seed_ids": "['gemma-2-27b-it_186169']"
} | 0.783792 | Filter_89004 | I | [
"is_prime",
"check_prime"
] | 2 | [
[
"check_prime",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 8a28241624e909d1c0bacc403267c1e62006ea77 | 770e8cf6b3c292e1a1af496d90aeb88331fb2248 | |||
v1.0 | instruct | Filter | Filter_51_I | I wrote a prototype of a numerical method to solve a PDE. The prototype is written in Python and I'm using a NumPy library. Here is the code:
```python
import numpy as np
def f(x, t):
return np.sin(np.pi * x) * np.sin(np.pi * t)
def solve_pde(x, t, x_step, t_step):
X, T = np.meshgrid(x, t)
U = f(X, T)
... | import numpy as np
def f(x, t):
return np.sin(np.pi * x) * np.sin(np.pi * t)
def solve_pde(x, t, x_step, t_step):
X, T = np.meshgrid(x, t)
U = f(X, T)
u_approx = np.zeros((len(x), len(t)))
u_approx[0, :] = U[0, :]
u_approx[:, 0] = U[:, 0]
for i in range(1, len(x)):
for j in r... | from solution import solve_pde
import numpy as np
def test_f_behavior():
x = np.array([0.0, 0.5, 1.0])
t = np.array([0.0, 0.5, 1.0])
result = f(x, t)
expected = np.sin(np.pi * x) * np.sin(np.pi * t)
np.testing.assert_array_almost_equal(result, expected)
def test_solve_pde_initial_conditions():
... | [
{
"docstring": null,
"function_declaration": "def f(x, t):",
"function_name": "f",
"parameter_list": "(x, t)"
},
{
"docstring": null,
"function_declaration": "def solve_pde(x, t, x_step, t_step):",
"function_name": "solve_pde",
"parameter_list": "(x, t, x_step, t_step)"
}
] | [
0,
0,
0,
0,
1,
0,
0,
1,
0,
0
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import numpy as np\n\ndef f(x, t):\n return np.sin(np.pi * x) * np.sin(np.pi * t)\n\ndef solve_pde(x, t, x_step, t_step):\n X, T = np.meshgrid(x, t)\n U = f(X, T)\n\n u_approx = np... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00000051",
"row_id": 51,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_145']"
} | 0.389521 | Filter_51 | I | [
"f",
"solve_pde"
] | 2 | [
[
"solve_pde",
"f"
]
] | 1 | [] | false | [] | false | pytest | true | [
"numpy"
] | false | 3c5fda89d744505d7a7eef399328fe68bfe88d98 | 724ac75b178928220eebd2cad2de9ac1adf67e71 | |||
v1.0 | instruct | Filter | Filter_55_I | Here is the python code to simulate the game of life.
```python
import random
import copy
# Define constants
ALIVE = 1
DEAD = 0
def create_board(rows, cols):
"""
Creates a 2D list filled with random ALIVE or DEAD cells.
Args:
rows (int): The number of rows in the board.
cols (int): The n... | import random
import copy
import matplotlib.pyplot as plt
import matplotlib.animation as animation
# Define constants
ALIVE = 1
DEAD = 0
def create_board(rows, cols):
"""
Creates a 2D list filled with random ALIVE or DEAD cells.
Args:
rows (int): The number of rows in the board.
cols (int... | from solution import create_board, count_neighbors, next_generation
def test_create_board_size():
board = create_board(10, 10)
assert len(board) == 10
assert all(len(row) == 10 for row in board)
def test_create_board_values():
board = create_board(10, 10)
for row in board:
for cell in row:... | [
{
"docstring": "Creates a 2D list filled with random ALIVE or DEAD cells.\n\nArgs:\n rows (int): The number of rows in the board.\n cols (int): The number of columns in the board.\n\nReturns:\n list: A 2D list representing the game board.",
"function_declaration": "def create_board(rows, cols):",
... | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\nimport copy\nimport matplotlib.pyplot as plt\nimport matplotlib.animation as animation\n\n# Define constants\nALIVE = 1\nDEAD = 0\n\ndef create_board(rows, cols):\n \"\"\"\n ... | trial_gpt4o_6 | {
"original_instruction": "",
"prompt_id": "00000055",
"row_id": 55,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_157']"
} | 0.491916 | Filter_55 | I | [
"create_board",
"count_neighbors",
"next_generation",
"update",
"main"
] | 5 | [
[
"next_generation",
"count_neighbors"
],
[
"update",
"next_generation"
]
] | 2 | [] | false | [] | false | pytest | true | [
"matplotlib"
] | false | 73539e007fcff2c28a141c4afa6ff2ce748db88d | 624d9b50f561e1ded22c154aaa09860fd8e691dd | |||
v1.0 | instruct | Filter | Filter_126_I | Here is my code for a program that simulates the game of rock, paper, scissors. It asks the user to input their choice, generates a random choice for the computer, and then it prints out the winner of the game.
```python
import random
def get_computer_choice():
choices = ["rock", "paper", "scissors"]
return ra... | import random
def get_computer_choice():
choices = ["rock", "paper", "scissors"]
return random.choice(choices)
def get_user_choice():
while True:
user_input = input("Enter rock, paper, or scissors: ").lower()
if user_input in ["rock", "paper", "scissors"]:
return user_input
... | from solution import determine_winner
def mock_get_user_choice_rock():
return "rock"
def mock_get_user_choice_paper():
return "paper"
def mock_get_user_choice_scissors():
return "scissors"
def mock_get_computer_choice_rock():
return "rock"
def mock_get_computer_choice_paper():
return "paper"
d... | [
{
"docstring": null,
"function_declaration": "def get_computer_choice():",
"function_name": "get_computer_choice",
"parameter_list": "()"
},
{
"docstring": null,
"function_declaration": "def get_user_choice():",
"function_name": "get_user_choice",
"parameter_list": "()"
},
{
... | [
0,
0,
0,
1,
0,
0,
0,
0,
0
] | 1 | hard | 0.111 | {
"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_user_choice():\n while True:\n user_input... | trial_gpt4o_3 | {
"original_instruction": "",
"prompt_id": "00000126",
"row_id": 126,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_318']"
} | 0.573939 | Filter_126 | I | [
"get_computer_choice",
"get_user_choice",
"determine_winner",
"play_game"
] | 4 | [
[
"determine_winner",
"get_computer_choice"
],
[
"determine_winner",
"get_user_choice"
],
[
"play_game",
"determine_winner"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | 6f3ff13918e664b7e1d3b3ba6d938c3f3e0ab812 | 42a40990c5cee27fe0d899adcde154e3beaec97b | |||
v1.0 | instruct | Filter | Filter_329_I | This is a modified version of the card game Blackjack. In this version, all the 10s have been removed. Therefore, the 9 is the highest playable card. The objective of the game remains the same, i.e. get a hand value closest to 21 points without going over.
The cards 2 through 9 are worth their face value. The cards J... | import random
# Define card values
card_values = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}
# Generate a card
def generate_card():
cards = list(card_values.keys())
return random.choice(cards)
# Calculate the hand value
def calculate_hand_value(hand):
return sum([card_values[card] fo... | from solution import calculate_hand_value, power_play_win, play_game
def test_calculate_hand_value():
assert calculate_hand_value(['2', '3']) == 5
assert calculate_hand_value(['5', '6', '7']) == 18
assert calculate_hand_value(['9', '9']) == 18
def test_power_play_win():
assert power_play_win('6') == T... | [
{
"docstring": null,
"function_declaration": "def generate_card():",
"function_name": "generate_card",
"parameter_list": "()"
},
{
"docstring": null,
"function_declaration": "def calculate_hand_value(hand):",
"function_name": "calculate_hand_value",
"parameter_list": "(hand)"
}... | [
0,
0,
0,
1,
0,
0,
0,
1,
0,
0
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\n\n# Define card values\ncard_values = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}\n\n# Define a function to generate a card\ndef generate_card():\n cards... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00000329",
"row_id": 329,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_785']"
} | 0.536828 | Filter_329 | I | [
"generate_card",
"calculate_hand_value",
"power_play_win",
"play_game"
] | 4 | [
[
"play_game",
"calculate_hand_value"
],
[
"play_game",
"generate_card"
],
[
"play_game",
"power_play_win"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | b007f17964bb2a3dd84e95a6048e3d09319f3d53 | d91f7adbedf4c34580f3b8e364cfea354ae0d36d | |||
v1.0 | instruct | Filter | Filter_393_I | I have 2 XML files and I need to compare them programmatically and determine the differences. If there are differences, I want to store those differences in a new XML file.
What would be the best way to do this in Python? | import xml.etree.ElementTree as ET
from xml.dom import minidom
def compare_elements(e1, e2):
differences = []
if e1.tag != e2.tag:
differences.append(f"Tag names differ: {e1.tag} vs. {e2.tag}")
if e1.text != e2.text:
differences.append(f"Text differs in tags {e1.tag}: {e1.text} vs. {e2.tex... | import pytest
import os
from solution import compare_xml
def test_no_differences():
with open('test1.xml', 'w') as f:
f.write('<root><child>value</child></root>')
with open('test2.xml', 'w') as f:
f.write('<root><child>value</child></root>')
output = compare_xml('test1.xml', 'test2.xml', ... | [
{
"docstring": null,
"function_declaration": "def compare_elements(e1, e2):",
"function_name": "compare_elements",
"parameter_list": "(e1, e2)"
},
{
"docstring": null,
"function_declaration": "def compare_xml(file1, file2, output_file):",
"function_name": "compare_xml",
"paramete... | [
0,
0,
1,
1,
0,
0,
0,
0,
0
] | 2 | hard | 0.222 | {
"trial_gpt4o_0": null,
"trial_gpt4o_1": {
"file_source": "Magpie-Filter-89K_sanitized_prepared1_results_combined.jsonl",
"solution_code": "import xml.etree.ElementTree as ET\nfrom deepdiff import DeepDiff\n\ndef compare_xml_files(file1, file2, output_file):\n \"\"\"\n Compares two XML files and stor... | trial_gpt4o_4 | {
"original_instruction": "",
"prompt_id": "00000393",
"row_id": 393,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_972']"
} | 0.529456 | Filter_393 | I | [
"compare_elements",
"compare_xml"
] | 2 | [
[
"compare_xml",
"compare_elements"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | b42ebfb02fe3c917243deb0364af28f1b832a3d7 | 225ddcef5816ae0dd27f4c71f3123392882c2e0a | |||
v1.0 | instruct | Filter | Filter_952_I | def is_prime(n):
if n < 2:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
def find_primes_in_range(n):
primes = []
for i in range(2, n + 1):
if is_prime(i):
primes.append(i)
return primes
def is_prime_sub... | def is_prime(n):
if n < 2:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
def find_primes_in_range(n):
primes = []
for i in range(2, n + 1):
if is_prime(i):
primes.append(i)
return primes
def is_prime_sub... | from solution import is_prime, find_primes_in_range, is_prime_subset, largest_prime_subset
def test_is_prime():
assert is_prime(2) == True
assert is_prime(4) == False
assert is_prime(13) == True
assert is_prime(1) == False
assert is_prime(0) == False
def test_find_primes_in_range():
assert fin... | [
{
"docstring": null,
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": null,
"function_declaration": "def find_primes_in_range(n):",
"function_name": "find_primes_in_range",
"parameter_list": "(n)"
},
{
"doc... | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n if n < 2:\n return False\n for i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n return False\n return True\n\ndef find_primes_in_range(... | trial_gpt4o_8 | {
"original_instruction": "",
"prompt_id": "00000952",
"row_id": 952,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_2755']"
} | 0.724187 | Filter_952 | I | [
"is_prime",
"find_primes_in_range",
"is_prime_subset",
"largest_prime_subset"
] | 4 | [
[
"find_primes_in_range",
"is_prime"
],
[
"largest_prime_subset",
"find_primes_in_range"
],
[
"largest_prime_subset",
"is_prime_subset"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | e3d125c042c82af6179cccbf5c4dd16be4ed5a5a | 8bc7bd6d7bab4d66c21b4ec06042b345b6a6a303 | |||
v1.0 | instruct | Filter | Filter_971_I | import os
import time
import datetime
import csv
# Given a list of paths or directories, returns a list of files that match the specified extension
def get_files_with_extension(directory, extension):
file_list = []
for root, dirs, files in os.walk(directory):
for file in files:
if file.ends... | import os
import time
import datetime
import csv
def get_files_with_extension(directory, extension):
file_list = []
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith(extension):
file_list.append(os.path.join(root, file))
return file_list
d... | import os
import unittest
from solution import *
def create_test_directory_with_csv_files(test_dir, num_files):
if not os.path.exists(test_dir):
os.makedirs(test_dir)
for i in range(num_files):
file_path = os.path.join(test_dir, f"test{i+1}.csv")
with open(file_path, 'w', newline='') as... | [
{
"docstring": null,
"function_declaration": "def get_files_with_extension(directory, extension):",
"function_name": "get_files_with_extension",
"parameter_list": "(directory, extension)"
},
{
"docstring": null,
"function_declaration": "def read_csv_file(file_path):",
"function_name"... | [
0,
0,
0,
0,
1,
0,
0,
1,
0,
0
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import os\nimport time\nimport datetime\nimport csv\n\ndef get_files_with_extension(directory, extension):\n file_list = []\n for root, dirs, files in os.walk(directory):\n for fi... | trial_gpt4o_4 | {
"original_instruction": "",
"prompt_id": "00000971",
"row_id": 971,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_2810']"
} | 0.677896 | Filter_971 | I | [
"get_files_with_extension",
"read_csv_file",
"write_date_to_csv_files",
"modify_csv_files"
] | 4 | [
[
"modify_csv_files",
"get_files_with_extension"
],
[
"modify_csv_files",
"write_date_to_csv_files"
],
[
"write_date_to_csv_files",
"read_csv_file"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | ce0183cee006eac76e5607297f64fd5a9766cdb6 | 4ae89f7ec0e7538e7a698021579a53f09bfc6fe5 | |||
v1.0 | instruct | Filter | Filter_1005_I | import numpy as np
def roll_dice():
return np.random.randint(1,7)
def game_round():
player_roll = roll_dice()
computer_roll = roll_dice()
print(f'Player roll: {player_roll}')
print(f'Computer roll: {computer_roll}')
return player_roll, computer_roll
def play_game(n_rounds):
... | import numpy as np
def roll_dice():
return np.random.randint(1, 7)
def game_round():
player_roll = roll_dice()
computer_roll = roll_dice()
return player_roll, computer_roll
def play_game(n_rounds):
player_score = 0
computer_score = 0
rounds = [game_round() for _ in range(n... | from solution import roll_dice, game_round, play_game
import pytest
def test_roll_dice():
for _ in range(100):
assert 1 <= roll_dice() <= 6
def test_game_round():
for _ in range(100):
player_roll, computer_roll = game_round()
assert 1 <= player_roll <= 6
assert 1 <= computer_ro... | [
{
"docstring": null,
"function_declaration": "def roll_dice():",
"function_name": "roll_dice",
"parameter_list": "()"
},
{
"docstring": null,
"function_declaration": "def game_round():",
"function_name": "game_round",
"parameter_list": "()"
},
{
"docstring": null,
"fu... | [
0,
0,
0,
0,
0,
0,
0,
0,
1
] | 1 | hard | 0.111 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import numpy as np\n\ndef roll_dice():\n \"\"\"\n Simulate rolling a six-sided die and return a number between 1 and 6 (inclusive).\n \"\"\"\n return np.random.randint(1, 7)\n ... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00001005",
"row_id": 1005,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_2924']"
} | 0.619619 | Filter_1005 | I | [
"roll_dice",
"game_round",
"play_game"
] | 3 | [
[
"game_round",
"roll_dice"
],
[
"play_game",
"game_round"
]
] | 2 | [] | false | [] | false | pytest | true | [
"numpy"
] | false | bea117b586f0e59cd789957fa14a8d658cf9fa25 | dc63bc4b87aa58a3a9d5bc947d820b8d3631883f | |||
v1.0 | instruct | Filter | Filter_1114_I | from tkinter import Tk, Label, Button, Entry
import tkinter as tk
from tkinter import filedialog
import os
import csv
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
def open_file():
root = Tk()
root.title('Open file')
label = Label(root, text= "Select a file")
label.pack()
b... | from tkinter import Tk, Label, Button, Entry
import tkinter as tk
from tkinter import filedialog
import pandas as pd
def open_file():
root = Tk()
root.title('Open file')
label = Label(root, text= "Select a file")
label.pack()
def browse_files():
filename = filedialog.askopenfilename()
... | import pytest
import pandas as pd
from unittest.mock import patch, mock_open, MagicMock
from solution import load_file, open_file
# Mock CSV data
MOCK_CSV_CONTENT = """A,B,C
1,2,3
4,5,6
7,8,9
"""
def test_load_file():
with patch("builtins.open", mock_open(read_data=MOCK_CSV_CONTENT)):
df = pd.read_csv("m... | [
{
"docstring": null,
"function_declaration": "def open_file():",
"function_name": "open_file",
"parameter_list": "()"
},
{
"docstring": null,
"function_declaration": "def load_file(filename):",
"function_name": "load_file",
"parameter_list": "(filename)"
},
{
"docstring":... | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from tkinter import Tk, Label, Button, Entry\nimport tkinter as tk\nfrom tkinter import filedialog\nimport pandas as pd\n\ndef open_file():\n def browse_files():\n filename = filedia... | trial_gpt4o_6 | {
"original_instruction": "",
"prompt_id": "00001114",
"row_id": 1114,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_3292']"
} | 0.459618 | Filter_1114 | I | [
"open_file",
"load_file",
"main"
] | 3 | [
[
"open_file",
"load_file"
]
] | 1 | [] | false | [] | false | pytest | true | [
"pandas"
] | false | ad8af67a7273c0e0a3fc67c328948a9cf463dc4d | 43f4274dd31aca34078715b5e6f9786081a84f15 | |||
v1.0 | instruct | Filter | Filter_1217_I | This project aims to develop a Python script that compares the performance of different machine learning algorithms on different datasets. The script should be able to:
1. Load a dataset from a CSV file
2. Split the dataset into training and testing sets
3. Select and train a machine learning model on the training set... | import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
def load_dataset(csv_file):
"""
Load a dataset from a CSV file.
Parameters:
csv_file (str): Path to the CSV file
Returns:
pandas.DataFrame: Loaded dataset
"""
re... | import pandas as pd
from sklearn.datasets import load_iris, load_wine
from sklearn.tree import DecisionTreeClassifier
from sklearn.svm import SVC
from solution import (load_dataset, split_dataset, train_model, evaluate_model,
compare_models, compare_datasets)
def test_load_dataset():
# Assu... | [
{
"docstring": "Load a dataset from a CSV file.\n\nParameters:\ncsv_file (str): Path to the CSV file\n\nReturns:\npandas.DataFrame: Loaded dataset",
"function_declaration": "def load_dataset(csv_file):",
"function_name": "load_dataset",
"parameter_list": "(csv_file)"
},
{
"docstring": "Split... | [
0,
0,
0,
0,
0,
1,
0,
1,
0,
1
] | 3 | hard | 0.3 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import pandas as pd\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.metrics import accuracy_score\nfrom sklearn.linear_model import LogisticRegression\nfrom sklearn.tree im... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00001217",
"row_id": 1217,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_3642']"
} | 0.454617 | Filter_1217 | I | [
"load_dataset",
"split_dataset",
"train_model",
"evaluate_model",
"compare_models",
"compare_datasets"
] | 6 | [
[
"compare_datasets",
"evaluate_model"
],
[
"compare_datasets",
"split_dataset"
],
[
"compare_datasets",
"train_model"
],
[
"compare_models",
"evaluate_model"
],
[
"compare_models",
"train_model"
]
] | 5 | [] | false | [] | false | pytest | true | [
"pandas",
"sklearn"
] | false | 8aaa85fafb944ec8236784b3e602982bb3ddd273 | 606792202d1ac997778ab9c41f6d12935b883199 | |||
v1.0 | instruct | Filter | Filter_1624_I | def create_sequence(s):
sequence = []
for i in range(1, s+1):
if i == 1:
sequence.append(i)
else:
sequence.append(sequence[i-2] + sequence[i-3])
return sequence
def look_and_say(n):
sequence = create_sequence(n)
result = ""
count = 1
for i in range(le... | def look_and_say_sequence(n):
if n == 1:
return "1"
def next_sequence(s):
result = []
i = 0
while i < len(s):
count = 1
while i + 1 < len(s) and s[i] == s[i + 1]:
i += 1
count += 1
result.append(str(count))
... | from solution import look_and_say_sequence, create_look_and_say_sequence_up_to, calculate_length_up_to
def test_look_and_say_sequence():
assert look_and_say_sequence(1) == "1"
assert look_and_say_sequence(2) == "11"
assert look_and_say_sequence(3) == "21"
assert look_and_say_sequence(4) == "1211"
a... | [
{
"docstring": null,
"function_declaration": "def look_and_say_sequence(n):",
"function_name": "look_and_say_sequence",
"parameter_list": "(n)"
},
{
"docstring": null,
"function_declaration": "def create_look_and_say_sequence_up_to(n):",
"function_name": "create_look_and_say_sequence... | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def create_sequence(s):\n sequence = []\n for i in range(1, s + 1):\n if i == 1:\n sequence.append(i)\n else:\n sequence.append(sequence[i - 2] + sequ... | trial_gpt4o_8 | {
"original_instruction": "",
"prompt_id": "00001624",
"row_id": 1624,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_5047']"
} | 0.603602 | Filter_1624 | I | [
"look_and_say_sequence",
"create_look_and_say_sequence_up_to",
"calculate_length_up_to"
] | 3 | [
[
"calculate_length_up_to",
"create_look_and_say_sequence_up_to"
],
[
"create_look_and_say_sequence_up_to",
"look_and_say_sequence"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 76fc7592cc18f10984aa6a17be059c325d2cab0e | 8f1ad37a0b4dbce1be70e6c10bb5d02830a38c6d | |||
v1.0 | instruct | Filter | Filter_1835_I | from bs4 import BeautifulSoup
import requests
def get.wordcount(url):
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
text = soup.get_text()
wordcount = len(text.split())
return wordcount
url = "http://example.com"
print(get.wordcount(url))
I want to add a feature ... | import requests
from bs4 import BeautifulSoup
class RobotsTxtException(Exception):
pass
def get_robots(url):
try:
response = requests.get(f"{url}/robots.txt", allow_redirects=True)
if response.status_code == 200:
return response.text
else:
return None
except... | from solution import get_wordcount, RobotsTxtException
import requests
from unittest.mock import patch
def test_get_wordcount_valid_url():
url = "http://example.com"
with patch('requests.get') as mock_get:
class MockResponse:
status_code = 200
text = "Hello world! This is a test... | [] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
1
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import requests\nfrom bs4 import BeautifulSoup\n\nclass RobotsTxtException(Exception):\n pass\n\ndef get_robots(url):\n try:\n r = requests.get(f\"{url}/robots.txt\", allow_redire... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00001835",
"row_id": 1835,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_5747']"
} | 0.614693 | Filter_1835 | I | [
"get_robots",
"is_scraping_allowed",
"get_wordcount"
] | 3 | [
[
"get_wordcount",
"is_scraping_allowed"
],
[
"is_scraping_allowed",
"get_robots"
]
] | 2 | [] | false | [
"RobotsTxtException"
] | true | pytest | true | [
"bs4",
"requests"
] | false | fcb2f280314d6b3b10271e8d929207e4557edfad | 5fa32c7038a4d98168549660de7cf1aa7b4141e2 | |||
v1.0 | instruct | Filter | Filter_1996_I | from itertools import chain
from itertools import combinations
def all_pairs(lst):
return list(chain.from_iterable([combinations(lst, r) for r in range(2, len(lst)+1)]))
def main():
print(all_pairs([1, 2, 3, 4]))
if __name__ == "__main__":
main()
This code generates all possible combinations of a list (n... | from itertools import chain, combinations
def all_pairs(lst):
return list(chain.from_iterable([combinations(lst, r) for r in range(2, len(lst)+1)]))
def determine_status(pair, cache):
if pair in cache:
return cache[pair]
if len(pair) == 2:
# Determine status for 2-element pair
if ... | from solution import evaluate_pairs
def test_evaluate_pairs():
results = evaluate_pairs([1, 2, 3])
assert results[(1, 2)] == 'good'
assert results[(1, 3)] == 'good'
assert results[(2, 3)] == 'good'
assert results[(1, 2, 3)] == 'good'
results = evaluate_pairs([2, 1, 3])
assert results[(2, 1... | [
{
"docstring": null,
"function_declaration": "def all_pairs(lst):",
"function_name": "all_pairs",
"parameter_list": "(lst)"
},
{
"docstring": null,
"function_declaration": "def determine_status(pair, cache):",
"function_name": "determine_status",
"parameter_list": "(pair, cache)"... | [
0,
0,
0,
0,
1,
0,
0,
0,
1,
1
] | 3 | hard | 0.3 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from itertools import chain, combinations\n\ndef determine_status(pair, status_cache):\n \"\"\"\n Determines the status of the pair and utilizes the status_cache to\n avoid redundant ... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00001996",
"row_id": 1996,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_6321']"
} | 0.669306 | Filter_1996 | I | [
"all_pairs",
"determine_status",
"evaluate_pairs",
"main"
] | 4 | [
[
"evaluate_pairs",
"all_pairs"
],
[
"evaluate_pairs",
"determine_status"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | ec343c84fabad4f9d99094fc372e2a59a03497f1 | c5d03701ae24d6137b98265cab158cb572f3285a | |||
v1.0 | instruct | Filter | Filter_2036_I | import collections
from collections import defaultdict
import math
import sys
def create_chain_dict():
ch = {}
with open('wordlist.txt', 'r') as wordlist:
for line in wordlist:
line = line.strip().lower()
ch[line] = 0
return ch
def create_chain():
chain = collections.de... | import collections
def create_chain(wordlist):
chain = collections.defaultdict(list)
for word in wordlist:
word = word.strip().lower()
if len(word) == 3:
chain[''.join(sorted(word))].append(word)
return chain
def solve(word, chain):
sorted_word = ''.join(sorted(word))
r... | from solution import create_chain, solve, get_word_chain
def test_create_chain():
wordlist = ["cat", "act", "tab", "bat", "tat", "rat"]
expected_chain = {
'act': ['cat', 'act'],
'abt': ['tab', 'bat'],
'art': ['rat'],
'att': ['tat']
}
assert create_chain(wordlist) == expe... | [
{
"docstring": null,
"function_declaration": "def create_chain(wordlist):",
"function_name": "create_chain",
"parameter_list": "(wordlist)"
},
{
"docstring": null,
"function_declaration": "def solve(word, chain):",
"function_name": "solve",
"parameter_list": "(word, chain)"
},
... | [
0,
0,
0,
0,
1,
1,
1,
0,
1
] | 4 | medium | 0.444 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import collections\n\ndef create_chain_dict():\n \"\"\"\n Reads words from 'wordlist.txt' and create a dictionary ch where keys\n are words and values are 0.\n \"\"\"\n ch = {}\... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00002036",
"row_id": 2036,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_6446']"
} | 0.554079 | Filter_2036 | I | [
"create_chain",
"solve",
"get_word_chain"
] | 3 | [
[
"get_word_chain",
"create_chain"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 57ec282a539ba1818c119234fe35af5423f69af7 | 72d69cce0efba7d985a35d01c582baa930395728 | |||
v1.0 | instruct | Filter | Filter_2040_I | import os
import sys
import time
import datetime
import csv
import pandas as pd
# Function to check if a file exists
def check_file(file_name):
if os.path.isfile(file_name):
return True
else:
return False
# Function to create a new csv file
def create_csv_file(file_name):
if not check_file... | import os
import sys
import time
import datetime
import pandas as pd
# Function to check if a file exists
def check_file(file_name):
if os.path.isfile(file_name):
return True
else:
return False
# Function to create a new csv file
def create_csv_file(file_name):
if not check_file(file_name)... | import os
import pandas as pd
import datetime
from solution import check_file, create_csv_file, append_row
def test_check_file(tmpdir):
# Creating a temporary directory to use for the test
temp_dir = tmpdir.mkdir("sub")
temp_file = temp_dir.join("temp.csv")
# File does not exist initially
assert no... | [
{
"docstring": null,
"function_declaration": "def check_file(file_name):",
"function_name": "check_file",
"parameter_list": "(file_name)"
},
{
"docstring": null,
"function_declaration": "def create_csv_file(file_name):",
"function_name": "create_csv_file",
"parameter_list": "(fil... | [
0,
0,
0,
1,
1,
0,
1,
0,
1,
1
] | 5 | medium | 0.5 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import os\nimport time\nimport datetime\nimport pandas as pd\n\n# Function to check if a file exists\ndef check_file(file_name):\n return os.path.isfile(file_name)\n\n# Function to create a... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00002040",
"row_id": 2040,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_6453']"
} | 0.705695 | Filter_2040 | I | [
"check_file",
"create_csv_file",
"append_row"
] | 3 | [
[
"append_row",
"check_file"
],
[
"create_csv_file",
"check_file"
]
] | 2 | [] | false | [] | false | pytest | true | [
"pandas"
] | false | 136b558bb2de7bd855b7b171d27fc5ee5fac7ac4 | c9c1fee99a2daf831c169a52be7dd30e4396d739 | |||
v1.0 | instruct | Filter | Filter_2091_I | This problem is similar to leetcode 53. Maximum subarray
Given that we have a 2D array where each element is either 1 or 0. Find the maximum sum of a submatrix in a given 2D array.
Here is the idea to solve this problem by using the maximum subarray technique. If we fix the left and right boundary of the subarray, we c... | def maxSubMatrixSum(nums):
if not nums:
return 0
if not nums[0]:
return 0
m, n = len(nums), len(nums[0])
res = 0 # Initialize to 0 to correctly handle cases where the maximum sum is 0
for left in range(n): # fix the left boundary
row_sum = [0] * m
for right in rang... | def test_maxSubMatrixSum():
assert maxSubMatrixSum([[0, 0], [0, 0]]) == 0
assert maxSubMatrixSum([[1, 0], [0, 0]]) == 1
assert maxSubMatrixSum([[1, -1], [-1, 1]]) == 1
assert maxSubMatrixSum([[1, 1], [1, 1]]) == 4
assert maxSubMatrixSum([[0, 1], [1, 0]]) == 2
assert maxSubMatrixSum([[1, 0, 1], [... | [
{
"docstring": null,
"function_declaration": "def maxSubMatrixSum(nums):",
"function_name": "maxSubMatrixSum",
"parameter_list": "(nums)"
},
{
"docstring": null,
"function_declaration": "def maxSubarraySum(nums):",
"function_name": "maxSubarraySum",
"parameter_list": "(nums)"
}... | [
0,
0,
0,
0,
0,
0,
1,
0,
0
] | 1 | hard | 0.111 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def maxSubMatrixSum(nums):\n if not nums:\n return 0\n if not nums[0]:\n return 0\n\n m, n = len(nums), len(nums[0])\n res = float('-inf')\n for left in range(n): ... | trial_gpt4o_6 | {
"original_instruction": "",
"prompt_id": "00002091",
"row_id": 2091,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_6660']"
} | 0.650791 | Filter_2091 | I | [
"maxSubMatrixSum",
"maxSubarraySum"
] | 2 | [
[
"maxSubMatrixSum",
"maxSubarraySum"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 2b04c3fbad8837461224582940f9b4e9736310b3 | 6d79360842f3d0b70e1fb1a9bcc3e330066ce945 | |||
v1.0 | instruct | Filter | Filter_2166_I | import random
def shuffle_deck(deck):
random.shuffle(deck)
return deck
def draw_card(deck):
return deck.pop()
def calculate_score(hand):
scores = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, 'J': 10, 'Q': 10, 'K': 10, 'A': 11}
score = 0
number_of_aces = 0
for... | # The solution code takes care of simulating a basic Blackjack game involving shuffling the deck,
# handling a user's hand with hit/stand operations, calculating scores,
# and determining the winner between the player and dealer.
import random
def shuffle_deck(deck):
"""
Shuffles the given deck of cards.
... | import pytest
from solution import shuffle_deck, draw_card, calculate_score, hit, determine_winner
def test_shuffle_deck():
deck = [(rank, suit) for suit in ['Hearts', 'Diamonds', 'Clubs', 'Spades']
for rank in ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']]
shuffled_deck = shu... | [
{
"docstring": "Shuffles the given deck of cards.",
"function_declaration": "def shuffle_deck(deck):",
"function_name": "shuffle_deck",
"parameter_list": "(deck)"
},
{
"docstring": "Draws a card from the given deck.",
"function_declaration": "def draw_card(deck):",
"function_name": "... | [
0,
0,
0,
0,
1,
0,
0,
1,
0,
0
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\n\ndef shuffle_deck(deck):\n random.shuffle(deck)\n return deck\n\ndef draw_card(deck):\n return deck.pop()\n\ndef calculate_score(hand):\n scores = {'2': 2, '3': 3, ... | trial_gpt4o_7 | {
"original_instruction": "",
"prompt_id": "00002166",
"row_id": 2166,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_6893']"
} | 0.662495 | Filter_2166 | I | [
"shuffle_deck",
"draw_card",
"calculate_score",
"hit",
"stand",
"determine_winner"
] | 6 | [
[
"determine_winner",
"calculate_score"
],
[
"hit",
"draw_card"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 5c9b7fc71d6c34fdb3da04da0a12a11b93f2c3e5 | 1f92767a6742742d342bb83fc7079ef3cee80070 | |||
v1.0 | instruct | Filter | Filter_2172_I | This program is about creating a simple command-line version of the popular game Hangman.
**Hangman Game in Python**
=====================================
### Game Description
Hangman is a guessing game where one player thinks of a word, and the other player tries to guess the word by suggesting letters. For each in... | import random
HANGMAN_PICS = ['''
+---+
| |
|
|
|
|
=========''', '''
+---+
| |
O |
|
|
|
=========''', '''
+---+
| |
O |
| |
|
|
=========''', '''
+---+
| |
O |
/| |
|
|
=========''', '''
+---+
| |
O ... | import pytest
from solution import getRandomWord, displayBoard, WORDS
def test_getRandomWord():
# Ensure that the word is actually from the WORDS list
for _ in range(100):
word = getRandomWord(WORDS)
assert word in WORDS
def test_displayBoard_correctLetters(capsys):
HANGMAN_PICS = ['''
... | [
{
"docstring": null,
"function_declaration": "def getRandomWord(wordList):",
"function_name": "getRandomWord",
"parameter_list": "(wordList)"
},
{
"docstring": null,
"function_declaration": "def displayBoard(HANGMAN_PICS, missedLetters, correctLetters, secretWord):",
"function_name":... | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\n\nHANGMAN_PICS = ['''\n +---+\n | |\n |\n |\n |\n |\n=========''', '''\n +---+\n | |\n O |\n |\n |\n |\n=========''', '''\n +---+\... | trial_gpt4o_8 | {
"original_instruction": "",
"prompt_id": "00002172",
"row_id": 2172,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_6905']"
} | 0.464857 | Filter_2172 | I | [
"getRandomWord",
"displayBoard",
"getGuess",
"playAgain",
"hangman"
] | 5 | [
[
"hangman",
"displayBoard"
],
[
"hangman",
"getGuess"
],
[
"hangman",
"getRandomWord"
],
[
"hangman",
"playAgain"
]
] | 4 | [] | false | [] | false | pytest | true | [] | true | eb5bf02e08f4f786338fec9f18e28bb9426c458f | bd6bad6a297adfef48b8b451bab4cc7f920b10bc | |||
v1.0 | instruct | Filter | Filter_2239_I | def is_prime(n):
if n <= 1:
return False
if n == 2:
return True
for i in range(2,n):
if n % i == 0:
return False
return True
def count_prime_divisors(n):
count = 0
for i in range(2, n+1):
if n % i == 0 and is_prime(i):
count += 1
retur... | def is_prime(n):
"""
Returns True if n is a prime number, else False.
"""
if n <= 1:
return False
if n == 2:
return True
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
def count_prime_divisors(n):
"""
Returns the count... | from solution import is_prime, count_prime_divisors, integer_right_triangles, count_right_triangles_with_prime_divisors
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
def test_count_prim... | [
{
"docstring": "Returns True if n is a prime number, else False.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Returns the count of prime divisors of n.",
"function_declaration": "def count_prime_divisors(n):",
"... | [
0,
0,
0,
0,
0,
1,
1,
0,
0,
0
] | 2 | hard | 0.2 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n == 2:\n return True\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n retu... | trial_gpt4o_6 | {
"original_instruction": "",
"prompt_id": "00002239",
"row_id": 2239,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_7102']"
} | 0.560387 | Filter_2239 | I | [
"is_prime",
"count_prime_divisors",
"integer_right_triangles",
"count_right_triangles_with_prime_divisors"
] | 4 | [
[
"count_prime_divisors",
"is_prime"
],
[
"count_right_triangles_with_prime_divisors",
"count_prime_divisors"
],
[
"count_right_triangles_with_prime_divisors",
"integer_right_triangles"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | 1313dc73160d3fe5a18c4c5c389d338768ea1c19 | 471a6f6cd5ff24c19f7634ee780833d97ca79b8a | |||
v1.0 | instruct | Filter | Filter_2327_I | import random
def get_monster_type():
return random.choice(['fire', 'ice', 'poison'])
def get_monster_name():
monsters = {
'fire': ['Dragon', 'Phoenix', 'Magma Beast'],
'ice': ['Yeti', 'Frost Giant', 'Ice Golem'],
'poison': ['Snake', 'Scorpion', 'Toad']
}
monster_type = get_monster_type()
return... | import random
def get_monster_type():
return random.choice(['fire', 'ice', 'poison'])
def get_monster_name():
monsters = {
'fire': ['Dragon', 'Phoenix', 'Magma Beast'],
'ice': ['Yeti', 'Frost Giant', 'Ice Golem'],
'poison': ['Snake', 'Scorpion', 'Toad']
}
monster_type = get_mon... | import pytest
from solution import get_monster_type, get_monster_name, monster_encounter
def test_get_monster_type():
for _ in range(100):
monster_type = get_monster_type()
assert monster_type in ['fire', 'ice', 'poison']
def test_get_monster_name():
monster_types = ['fire', 'ice', 'poison']
... | [
{
"docstring": null,
"function_declaration": "def get_monster_type():",
"function_name": "get_monster_type",
"parameter_list": "()"
},
{
"docstring": null,
"function_declaration": "def get_monster_name():",
"function_name": "get_monster_name",
"parameter_list": "()"
},
{
... | [
0,
0,
0,
0,
1,
1,
1,
1,
1,
1
] | 6 | medium | 0.6 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\n\ndef get_monster_type():\n return random.choice(['fire', 'ice', 'poison'])\n\ndef get_monster_name():\n monsters = {\n 'fire': ['Dragon', 'Phoenix', 'Magma Beast']... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00002327",
"row_id": 2327,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_7418']"
} | 0.531891 | Filter_2327 | I | [
"get_monster_type",
"get_monster_name",
"monster_encounter"
] | 3 | [
[
"get_monster_name",
"get_monster_type"
],
[
"monster_encounter",
"get_monster_name"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 74b3888489242acae2014587069701ffaa35e2af | a78a856ce36c85ba4b7332a6e51176fb060cf6e3 | |||
v1.0 | instruct | Filter | Filter_2419_I | This code is for a simple rock-paper-scissors game. I'd like to modify it to be a best-of-three series. How can I do that? | import random
def get_computer_choice():
"""Randomly returns 'rock', 'paper', or 'scissors'."""
return random.choice(['rock', 'paper', 'scissors'])
def determine_winner(player_choice, computer_choice):
"""Determines the winner of a rock-paper-scissors game.
Returns 'player', 'computer', or 'tie'."""
... | from solution import determine_winner, get_computer_choice, best_of_three
def test_determine_winner():
assert determine_winner('rock', 'scissors') == 'player'
assert determine_winner('scissors', 'paper') == 'player'
assert determine_winner('paper', 'rock') == 'player'
assert determine_winner('scissors'... | [
{
"docstring": "Randomly returns 'rock', 'paper', or 'scissors'.",
"function_declaration": "def get_computer_choice():",
"function_name": "get_computer_choice",
"parameter_list": "()"
},
{
"docstring": "Determines the winner of a rock-paper-scissors game.\nReturns 'player', 'computer', or 't... | [
0,
0,
0,
1,
0,
0,
1,
0,
0,
1
] | 3 | hard | 0.3 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\n\ndef rps_game():\n \"\"\"\n This function plays a best-of-three Rock-Paper-Scissors game between the user and the computer.\n \"\"\"\n # Define possible moves\n ... | trial_gpt4o_6 | {
"original_instruction": "",
"prompt_id": "00002419",
"row_id": 2419,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_7723']"
} | 0.453365 | Filter_2419 | I | [
"get_computer_choice",
"determine_winner",
"best_of_three"
] | 3 | [
[
"best_of_three",
"determine_winner"
],
[
"best_of_three",
"get_computer_choice"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | adf504446c0eefc51397f323c83cf304261be3e5 | 611250d00896984f92c537563d3ab8df96d010ef | |||
v1.0 | instruct | Filter | Filter_2496_I | Implement a program that simulates a currency exchange system. The exchange rates should be predefined. The user should be able to choose the source and target currencies, and enter an amount to be exchanged. The system should display the amount in the target currency and also ask if the user wants to make another tran... | # Define the exchange rates
exchange_rates = {
'USD': {'EUR': 0.88, 'GBP': 0.76, 'JPY': 109.37},
'EUR': {'USD': 1.14, 'GBP': 0.86, 'JPY': 124.27},
'GBP': {'USD': 1.32, 'EUR': 1.16, 'JPY': 143.73},
'JPY': {'USD': 0.0091, 'EUR': 0.0081, 'GBP': 0.0070}
}
def get_exchange_rate(source_currency, target_curre... | import pytest
from solution import get_exchange_rate, exchange_currency
def test_get_exchange_rate_usd_to_eur():
assert get_exchange_rate('USD', 'EUR') == 0.88
def test_get_exchange_rate_eur_to_usd():
assert get_exchange_rate('EUR', 'USD') == 1.14
def test_exchange_currency_usd_to_eur():
assert exchange_... | [
{
"docstring": "Get the exchange rate for a given source and target currency.",
"function_declaration": "def get_exchange_rate(source_currency, target_currency):",
"function_name": "get_exchange_rate",
"parameter_list": "(source_currency, target_currency)"
},
{
"docstring": "Exchange a given... | [
0,
0,
0,
1,
1,
0,
0,
0,
1
] | 3 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "# Define the exchange rates\nexchange_rates = {\n 'USD': {'EUR': 0.88, 'GBP': 0.76, 'JPY': 109.37},\n 'EUR': {'USD': 1.14, 'GBP': 0.86, 'JPY': 124.27},\n 'GBP': {'USD': 1.32, 'EUR': 1... | trial_gpt4o_3 | {
"original_instruction": "",
"prompt_id": "00002496",
"row_id": 2496,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_8008']"
} | 0.633008 | Filter_2496 | I | [
"get_exchange_rate",
"exchange_currency"
] | 2 | [
[
"exchange_currency",
"get_exchange_rate"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 61f0e74beee1a15cb07fdde112ebfffcdcc1962f | 9d2f2e4dd6d83b67c309e2529629850f0aa854bc | |||
v1.0 | instruct | Filter | Filter_2580_I | import re
import time
from PIL import Image, ImageDraw, ImageFont
import os
# Define constants
FONT_SIZE = 24
DIMENSION = 400
# Define image processing function
def process_image(image_path, filename):
# Get the original image
try:
img = Image.open(image_path)
except Exception as e:
print(... | import re
import time
import argparse
from PIL import Image, ImageDraw, ImageFont
import os
# Define constants
FONT_SIZE = 24
DIMENSION = 400
# Define image processing function
def process_image(image_path, filename):
# Get the original image
try:
img = Image.open(image_path)
except Exception as e... | import os
import tempfile
import shutil
from PIL import Image
from solution import process_image, process_images
def test_process_image():
with tempfile.TemporaryDirectory() as temp_dir:
# Create a temporary image
img_path = os.path.join(temp_dir, "temp_image.png")
img = Image.new("RGB", (1... | [
{
"docstring": null,
"function_declaration": "def process_image(image_path, filename):",
"function_name": "process_image",
"parameter_list": "(image_path, filename)"
},
{
"docstring": null,
"function_declaration": "def process_images(directory):",
"function_name": "process_images",
... | [
0,
0,
0,
0,
0,
0,
1,
0,
0,
0
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import re\nimport time\nfrom PIL import Image, ImageDraw, ImageFont\nimport os\nimport argparse\n\n# Define constants\nFONT_SIZE = 24\nDIMENSION = 400\n\n# Define image processing function\nde... | trial_gpt4o_6 | {
"original_instruction": "",
"prompt_id": "00002580",
"row_id": 2580,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_8295']"
} | 0.58572 | Filter_2580 | I | [
"process_image",
"process_images",
"main"
] | 3 | [
[
"process_images",
"process_image"
]
] | 1 | [] | false | [] | false | pytest | true | [
"PIL"
] | false | 30815abe75db850de034f7b04e97a9eb460834bf | 88df11f8caaa6589a78e6e942e444cfc4b45c8e3 | |||
v1.0 | instruct | Filter | Filter_2641_I | def build_knapsack_matrix(items, capacity):
n = len(items)
dp = [[0 for _ in range(capacity + 1)] for _ in range(n + 1)]
for i in range(1, n + 1):
weight, value = items[i - 1]
for j in range(1, capacity + 1):
if weight > j:
dp[i][j] = dp[i - 1][j]
els... | def build_knapsack_matrix(items, capacity):
"""
Builds the DP matrix to solve the knapsack problem.
Args:
items (list of tuples): Each tuple contains two integers (weight, value).
capacity (int): The maximum weight capacity of the knapsack.
Returns:
list of list of int: A 2D list r... | import pytest
from solution import build_knapsack_matrix, knapsack
def test_knapsack():
items = [(2, 6), (2, 3), (6, 5), (1, 8), (4, 5), (2, 4), (3, 7), (4, 3), (5, 4), (2, 9), (4, 4)]
capacity = 10
assert knapsack(items, capacity) == 34
def test_knapsack_small():
items = [(1, 1), (2, 2), (3, 3)]
... | [
{
"docstring": "Builds the DP matrix to solve the knapsack problem.\n\nArgs:\nitems (list of tuples): Each tuple contains two integers (weight, value).\ncapacity (int): The maximum weight capacity of the knapsack.\n\nReturns:\nlist of list of int: A 2D list representing the DP matrix.",
"function_declaratio... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1
] | 1 | hard | 0.1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def build_knapsack_matrix(items, capacity):\n \"\"\"\n Builds the knapsack matrix for the given items and capacity.\n \n Parameters:\n items (list of tuples): A list where each ... | trial_gpt4o_9 | {
"original_instruction": "",
"prompt_id": "00002641",
"row_id": 2641,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_8515']"
} | 0.556197 | Filter_2641 | I | [
"build_knapsack_matrix",
"knapsack"
] | 2 | [
[
"knapsack",
"build_knapsack_matrix"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | f708726227f4a04e93a7651a54828e461489cb36 | abb2849aa83883b00085068d2bcf16e8ca8e939d | |||
v1.0 | instruct | Filter | Filter_2659_I | def binary_search(arr, target):
left, right = 0, len(arr) - 1
while left <= right:
mid = (left + right) // 2
if arr[mid] == target:
return mid
elif arr[mid] < target:
left = mid + 1
else:
right = mid - 1
return -1
def find_pivot(arr):
... | def binary_search(arr, target):
"""
Perform binary search on a sorted array.
Returns the index of the target if found, else -1.
"""
left, right = 0, len(arr) - 1
while left <= right:
mid = (left + right) // 2
if arr[mid] == target:
return mid
elif arr[mid] < t... | from solution import binary_search, find_pivot, search_in_rotated_array
def test_binary_search():
assert binary_search([1, 2, 3, 4, 5], 3) == 2
assert binary_search([1, 2, 3, 4, 5], 1) == 0
assert binary_search([1, 2, 3, 4, 5], 5) == 4
assert binary_search([1, 2, 3, 4, 5], 6) == -1
def test_find_pivot... | [
{
"docstring": "Perform binary search on a sorted array.\nReturns the index of the target if found, else -1.",
"function_declaration": "def binary_search(arr, target):",
"function_name": "binary_search",
"parameter_list": "(arr, target)"
},
{
"docstring": "Find the pivot point in a rotated s... | [
0,
0,
0,
0,
1,
1,
1,
0,
1,
0
] | 4 | medium | 0.4 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def binary_search(arr, target):\n left, right = 0, len(arr) - 1\n while left <= right:\n mid = (left + right) // 2\n if arr[mid] == target:\n return mid\n ... | trial_gpt4o_4 | {
"original_instruction": "",
"prompt_id": "00002659",
"row_id": 2659,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_8549']"
} | 0.590561 | Filter_2659 | I | [
"binary_search",
"find_pivot",
"search_in_rotated_array"
] | 3 | [
[
"search_in_rotated_array",
"binary_search"
],
[
"search_in_rotated_array",
"find_pivot"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 71ef8a0f14f2499ef23447d55e83efb3b871a8a0 | b73a4600225646444ee9b4f32ca4cc76f4afa179 | |||
v1.0 | instruct | Filter | Filter_2679_I | `freeconv` is a tool that allows you to map one feature in your code to another feature in a different file.
However, `freeconv` needs help with the correct usage. Here is a sample usage of `freeconv`:
```
freeconv -i input.txt -m mapping.txt -o output.txt
```
Let's say we want to map the method `myMethod` in `file1... | import re
import argparse
def parse_mapping_file(mapping_file):
"""
Parses the mapping file and returns a list of mappings.
Each mapping is a tuple (input_file, input_method, output_file, output_method).
"""
mappings = []
with open(mapping_file, 'r') as f:
for line in f:
inp... | import os
from solution import parse_mapping_file, parse_input_file, replace_method_name, write_output_file, freeconv
def create_temp_file(filename, content):
with open(filename, 'w') as f:
f.write(content)
def remove_temp_file(filename):
os.remove(filename)
def test_parse_mapping_file():
map... | [
{
"docstring": "Parses the mapping file and returns a list of mappings.\nEach mapping is a tuple (input_file, input_method, output_file, output_method).",
"function_declaration": "def parse_mapping_file(mapping_file):",
"function_name": "parse_mapping_file",
"parameter_list": "(mapping_file)"
},
... | [
0,
0,
0,
0,
0,
1,
0,
1,
1,
1
] | 4 | medium | 0.4 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import re\nimport argparse\nfrom collections import defaultdict\n\ndef parse_mapping_file(mapping_file):\n mappings = []\n with open(mapping_file, 'r') as f:\n for line in f:\n ... | trial_gpt4o_5 | {
"original_instruction": "",
"prompt_id": "00002679",
"row_id": 2679,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_8606']"
} | 0.368018 | Filter_2679 | I | [
"parse_mapping_file",
"parse_input_file",
"replace_method_name",
"write_output_file",
"freeconv"
] | 5 | [
[
"freeconv",
"parse_input_file"
],
[
"freeconv",
"parse_mapping_file"
],
[
"freeconv",
"replace_method_name"
],
[
"freeconv",
"write_output_file"
]
] | 4 | [] | false | [] | false | pytest | true | [] | true | 2a3fcb150fed254efbae35c63ae97b7a7f4744e1 | 0975e78256df9ea39b383fac2525c68a4efc0ba3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.