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_85038_I
I want to create a text-based adventure game using Python. I have limited coding experience and am looking for a straightforward approach. Could you provide me a simple example code structure, and explain the key elements involved?
def start_game(): """Starts the text-based adventure game.""" print("Welcome to the Adventure!") choice = input("You find yourself in a dark forest. Do you go left or right? (left/right): ").lower() if choice == 'left': left_path() elif choice == 'right': right_path() else: ...
import pytest from solution import start_game, left_path, right_path, end_game def test_start_game_left(monkeypatch): monkeypatch.setattr('builtins.input', lambda _: 'left') start_game() # Expect the function left_path to be called and print "You chose the left path and encounter a friendly elf." def ...
[ { "docstring": "Starts the text-based adventure game.", "function_declaration": "def start_game():", "function_name": "start_game", "parameter_list": "()" }, { "docstring": "Handles the left path scenario.", "function_declaration": "def left_path():", "function_name": "left_path", ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def main():\n print(\"Welcome to the Adventure Game!\")\n print(\"You find yourself in a dark forest. There are paths to the north, east, and west.\")\n choice = input(\"Which directi...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00085038", "row_id": 85038, "seed_ids": "['gemma-2-27b-it_174501']" }
0.407671
Filter_85038
I
[ "start_game", "left_path", "right_path", "end_game" ]
4
[ [ "left_path", "end_game" ], [ "right_path", "end_game" ], [ "start_game", "end_game" ], [ "start_game", "left_path" ], [ "start_game", "right_path" ] ]
5
[]
false
[]
false
pytest
true
[]
true
d8035c290b39b9ec2b32a3dd7e89f29f50c7b3da
e59cea1cd3ad1a98db01f2d2d85adaf347dbc860
v1.0
instruct
Filter
Filter_85062_I
* Create an example of a Python function called `sum_primes` which takes one argument: * `nums`: A list of integers. * The function should return the sum of all the prime numbers in the list. * You should use a helper function `is_prime` to determine if a number is prime. ```python def sum_primes(nums): """ ...
def is_prime(n): """ Checks if a number is prime. Args: n: An integer to check for primality. Returns: True if n is a prime number, False otherwise. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i ...
def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == False def test_sum_primes(): assert sum_prim...
[ { "docstring": "Checks if a number is prime.\n\nArgs:\n n: An integer to check for primality.\n\nReturns:\n True if n is a prime number, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Calculates the...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determines if a number is prime.\n \n Args:\n n: An integer.\n \n Returns:\n True if the number is prime, False otherwise.\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00085062", "row_id": 85062, "seed_ids": "['gemma-2-27b-it_174573']" }
0.704176
Filter_85062
I
[ "is_prime", "sum_primes" ]
2
[ [ "sum_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
false
[]
true
82e43a733bb56361aa6c54255112b018e9cad117
26bf3427756504384978c4477562d51759e35e0b
v1.0
instruct
Filter
Filter_85085_I
Title: Project Euler Problem 1 Solution in Python
def sum_of_multiples(limit): """ Returns the sum of all the multiples of 3 or 5 below the given limit. """ total = 0 for i in range(limit): if i % 3 == 0 or i % 5 == 0: total += i return total # Function to solve Project Euler Problem 1 specifically def euler_problem_1(): ...
from solution import sum_of_multiples, euler_problem_1 def test_sum_of_multiples_below_10(): assert sum_of_multiples(10) == 23 def test_sum_of_multiples_below_20(): assert sum_of_multiples(20) == 78 def test_sum_of_multiples_below_50(): assert sum_of_multiples(50) == 543 def test_euler_problem_1(): ...
[ { "docstring": "Returns the sum of all the multiples of 3 or 5 below the given limit.", "function_declaration": "def sum_of_multiples(limit):", "function_name": "sum_of_multiples", "parameter_list": "(limit)" }, { "docstring": null, "function_declaration": "def euler_problem_1():", "...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def euler_problem_1(limit):\n \"\"\"\n Solves Project Euler Problem 1.\n Finds the sum of all multiples of 3 or 5 below the given limit.\n \n Parameters:\n limit (int): The u...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00085085", "row_id": 85085, "seed_ids": "['gemma-2-27b-it_174637']" }
0.521324
Filter_85085
I
[ "sum_of_multiples", "euler_problem_1" ]
2
[ [ "euler_problem_1", "sum_of_multiples" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9d3e9f66e4f5f06d59f9058c2b79ca811a6164fa
eab10c7d2ae36acf5b5683297898f9f6fca8fb6a
v1.0
instruct
Filter
Filter_85093_I
This is a difficult challenge, but I hope you can help me. I'm working on a game where players need to create codes to unlock doors. These codes have a specific format: **They consist of 4 characters, with each character being either a letter (A-Z) or a digit (0-9).** For example: **A1B3** is a valid code, but **A1B...
import random import string def generate_code(): """ Generates a random valid code consisting of 4 characters, each character being either a letter (A-Z) or a digit (0-9). There must be at least one letter and no repeating letters. """ while True: code = ''.join(random.choices(string.as...
from solution import generate_code, is_valid_code import pytest def test_is_valid_code_valid(): assert is_valid_code("A1B2") == True assert is_valid_code("Z3Y8") == True def test_is_valid_code_repeating_letters(): assert is_valid_code("AA12") == False assert is_valid_code("A1A2") == False def te...
[ { "docstring": "Generates a random valid code consisting of 4 characters,\neach character being either a letter (A-Z) or a digit (0-9).\nThere must be at least one letter and no repeating letters.", "function_declaration": "def generate_code():", "function_name": "generate_code", "parameter_list": "...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport string\n\ndef generate_code():\n \"\"\"\n Generates a random valid code consisting of 4 characters,\n each character being either a letter (A-Z) or a digit (0-9)...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00085093", "row_id": 85093, "seed_ids": "['gemma-2-27b-it_174652']" }
0.595894
Filter_85093
I
[ "generate_code", "is_valid_code" ]
2
[ [ "generate_code", "is_valid_code" ] ]
1
[]
false
[]
false
pytest
true
[]
true
e060bf17dccadb6d90a654eee6fc9ca39b503b21
2be054cabc6761e9c2d832656b8912d52e114e8e
v1.0
instruct
Filter
Filter_85120_I
Given these functions: ```python def foo(x): return x*2 def bar(x): return (x)**2 ``` Write a new function `baz` that takes an argument `x` and returns the sum of calling `foo` and `bar` on `x`. ```python def baz(x): return foo(x) + bar(x) ``` Can you explain how this solution works?
def foo(x): return x * 2 def bar(x): return x ** 2 def baz(x): return foo(x) + bar(x)
from solution import foo, bar, baz def test_foo(): assert foo(2) == 4 assert foo(-3) == -6 assert foo(0) == 0 def test_bar(): assert bar(2) == 4 assert bar(-3) == 9 assert bar(0) == 0 def test_baz(): assert baz(2) == 8 # 2*2 + 2**2 = 4 + 4 = 8 assert baz(-3) == 3 # 2*(-3) + (-3)**2 =...
[ { "docstring": null, "function_declaration": "def foo(x):", "function_name": "foo", "parameter_list": "(x)" }, { "docstring": null, "function_declaration": "def bar(x):", "function_name": "bar", "parameter_list": "(x)" }, { "docstring": null, "function_declaration": "...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def foo(x):\n \"\"\"\n Returns the double of x.\n \"\"\"\n return x * 2\n\ndef bar(x):\n \"\"\"\n Returns the square of x.\n \"\"\"\n return x**2\n\ndef baz(x):\n \"...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00085120", "row_id": 85120, "seed_ids": "['gemma-2-27b-it_174722']" }
0.564295
Filter_85120
I
[ "foo", "bar", "baz" ]
3
[ [ "baz", "bar" ], [ "baz", "foo" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c2c653598f98e8fe290dd9407d7409024c8ac3c2
ce0893ff268f7583ca0cff9fe9daa377dd20ad29
v1.0
instruct
Filter
Filter_85122_I
Here's my problem: I'm trying to create a program that detects changes in a directory and notifies me via email when a.txt changes. I want to use **Python** for this project. Here are the specific requirements I need help with: - **Directory Monitoring:** The program should continuously monitor a specific direc...
import os import time import smtplib from email.message import EmailMessage from hashlib import md5 def send_email_notification(to_email, from_email, subject, body, smtp_server, smtp_port, smtp_user, smtp_pass): msg = EmailMessage() msg.set_content(body) msg['Subject'] = subject msg['From'] = from_emai...
import os import tempfile import pytest from unittest.mock import patch from solution import monitor_directory, send_email_notification, get_file_checksum def test_get_file_checksum(): with tempfile.NamedTemporaryFile(delete=False) as tmp_file: tmp_file.write(b"hello world") tmp_file.seek(0) ...
[ { "docstring": null, "function_declaration": "def send_email_notification(to_email, from_email, subject, body, smtp_server, smtp_port, smtp_user, smtp_pass):", "function_name": "send_email_notification", "parameter_list": "(to_email, from_email, subject, body, smtp_server, smtp_port, smtp_user, smtp...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\nimport time\nimport smtplib\nfrom email.message import EmailMessage\nfrom hashlib import md5\n\ndef send_email_notification(to_email, from_email, subject, body, smtp_server, smtp_po...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00085122", "row_id": 85122, "seed_ids": "['gemma-2-27b-it_174724']" }
0.483339
Filter_85122
I
[ "send_email_notification", "get_file_checksum", "monitor_directory" ]
3
[ [ "monitor_directory", "get_file_checksum" ], [ "monitor_directory", "send_email_notification" ] ]
2
[]
false
[]
false
pytest
true
[]
true
69d96906e63a4c7c792b242154a6bfd95cc637cc
fd2afa2bdaaa46eabf4bac5e1ef4e80249b16862
v1.0
instruct
Filter
Filter_85125_I
This is a Python problem. You are given a list of positive integers. For each integer in the list, you need to find its corresponding Fibonacci number. For example: ``` Input: [1, 2, 3, 5, 8] Output: [1, 1, 2, 5, 21] ``` ```python def fibonacci_sequence(n): """ This function returns a list containing the Fibona...
def fibonacci(n): """ Returns the nth Fibonacci number. """ if n == 1 or n == 2: return 1 a, b = 1, 1 for _ in range(n - 2): a, b = b, a + b return b def find_fibonacci_numbers(input_list): """ This function takes a list of integers and returns a new list where each ...
from solution import find_fibonacci_numbers def test_find_fibonacci_numbers_basic(): assert find_fibonacci_numbers([1, 2, 3, 5, 8]) == [1, 1, 2, 5, 21] def test_find_fibonacci_numbers_single_element(): assert find_fibonacci_numbers([1]) == [1] assert find_fibonacci_numbers([10]) == [55] def test_find_fib...
[ { "docstring": "Returns the nth Fibonacci number.", "function_declaration": "def fibonacci(n):", "function_name": "fibonacci", "parameter_list": "(n)" }, { "docstring": "This function takes a list of integers and returns a new list where each element is the corresponding Fibonacci number.", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def fibonacci_number(n):\n \"\"\"\n Returns the nth Fibonacci number.\n \"\"\"\n if n == 1 or n == 2:\n return 1\n a, b = 1, 1\n for _ in range(3, n + 1):\n a, ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00085125", "row_id": 85125, "seed_ids": "['gemma-2-27b-it_174730']" }
0.741515
Filter_85125
I
[ "fibonacci", "find_fibonacci_numbers" ]
2
[ [ "find_fibonacci_numbers", "fibonacci" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cc1bfebeabd4b4943750ebef1f6de5f9dc551129
05b9cede800660edfcd29cf3287bfbfbfc30fdce
v1.0
instruct
Filter
Filter_85135_I
You are given a task to design a simple text-based adventure game. The player starts at their home. The game should have at least three locations and the ability to move between them. The player should be able to interact with objects in each location. **Locations:** * **Home:** * Objects: Desk, Book, Door. The p...
inventory = [] # Function to display the current location def show_location(location): if location == "home": print("You are at home.") print("You see a desk, a book, and a door.") elif location == "park": print("You are at the park.") print("You see a bench, a tree, and a pon...
def test_show_location(): from io import StringIO import sys output = StringIO() sys.stdout = output show_location("home") assert output.getvalue() == "You are at home.\nYou see a desk, a book, and a door.\n" output = StringIO() sys.stdout = output show_location("park") ...
[ { "docstring": null, "function_declaration": "def show_location(location):", "function_name": "show_location", "parameter_list": "(location)" }, { "docstring": null, "function_declaration": "def interact(object, location):", "function_name": "interact", "parameter_list": "(object...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "inventory = []\n\n# Function to display the current location\ndef show_location(location):\n if location == \"home\":\n print(\"You are at home.\")\n print(\"You see a desk, a...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00085135", "row_id": 85135, "seed_ids": "['gemma-2-27b-it_174758']" }
0.417896
Filter_85135
I
[ "show_location", "interact", "run_game" ]
3
[ [ "run_game", "interact" ], [ "run_game", "show_location" ] ]
2
[]
false
[]
false
pytest
false
[]
true
cc0272d01962c4c4fa2e1b89a7647a7d6d6297dd
f0f5969f386e98e277e5887e7dcb548cc614fe45
v1.0
instruct
Filter
Filter_85140_I
Write a python script to compare the execution time of two different sorting algorithms: Merge Sort and Bubble Sort for arrays of varying sizes.
import time import random def bubble_sort(arr): """ Bubble Sort algorithm implementation. """ 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 merge_sort(arr): """ Merg...
from solution import bubble_sort, merge_sort, measure_execution_time, compare_sorts import random def test_bubble_sort(): assert bubble_sort([64, 34, 25, 12, 22, 11, 90]) == [11, 12, 22, 25, 34, 64, 90] assert bubble_sort([4, 3, 2, 1]) == [1, 2, 3, 4] assert bubble_sort([1, 2, 3, 4]) == [1, 2, 3, 4] as...
[ { "docstring": "Bubble Sort algorithm implementation.", "function_declaration": "def bubble_sort(arr):", "function_name": "bubble_sort", "parameter_list": "(arr)" }, { "docstring": "Merge Sort algorithm implementation.", "function_declaration": "def merge_sort(arr):", "function_name"...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import time\n\ndef merge_sort(arr):\n \"\"\"\n Merge sort algorithm.\n \"\"\"\n if len(arr) > 1:\n mid = len(arr) // 2\n L = arr[:mid]\n R = arr[mid:]\n\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00085140", "row_id": 85140, "seed_ids": "['gemma-2-27b-it_174777']" }
0.473538
Filter_85140
I
[ "bubble_sort", "merge_sort", "measure_execution_time", "compare_sorts" ]
4
[ [ "compare_sorts", "bubble_sort" ], [ "compare_sorts", "measure_execution_time" ], [ "compare_sorts", "merge_sort" ] ]
3
[]
false
[]
false
pytest
true
[]
true
d37c5356864a10563672ce571b0c9e816a666510
7e81f8c0d590c6500986f8a7fa35e43ed7601fd5
v1.0
instruct
Filter
Filter_85153_I
Write a Python function to efficiently find the longest palindrome substring within a given string. Example: ```python def longest_palindrome(text): """Finds the longest palindrome substring within a given string. Args: text: The string to search. Returns: The longest palindrome substrin...
def longest_palindrome(text): """ Finds the longest palindrome substring within a given string. Args: text: The string to search. Returns: The longest palindrome substring found. """ if len(text) == 0: return "" start = 0 end = 0 for i in range...
from solution import longest_palindrome def test_longest_palindrome_example1(): assert longest_palindrome("babad") in ["bab", "aba"] def test_longest_palindrome_example2(): assert longest_palindrome("cbbd") == "bb" def test_longest_palindrome_single_character(): assert longest_palindrome("a") == "a" def...
[ { "docstring": "Finds the longest palindrome substring within a given string.\n\nArgs:\n text: The string to search.\n \nReturns:\n The longest palindrome substring found.", "function_declaration": "def longest_palindrome(text):", "function_name": "longest_palindrome", "parameter_list": "(t...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def longest_palindrome(text):\n \"\"\"\n Finds the longest palindrome substring within a given string.\n\n Args:\n text: The string to search.\n\n Returns:\n The long...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00085153", "row_id": 85153, "seed_ids": "['gemma-2-27b-it_174801']" }
0.766757
Filter_85153
I
[ "longest_palindrome", "expand_around_center" ]
2
[ [ "longest_palindrome", "expand_around_center" ] ]
1
[]
false
[]
false
pytest
true
[]
true
91749e9aec40b4a63684fa4942ce05752cb9838d
bd198c2afa654a8304457960d6c46ac7fb207f23
v1.0
instruct
Filter
Filter_85193_I
This question is about the 4x4 sliding tile puzzle famously known as the 15-puzzle. **The Problem:** Given a starting configuration of the 15-puzzle, determine if it can be solved and demonstrate a solution by listing the sequence of moves required. **Input:** You will be given a string representation of the confi...
import heapq def manhattan_distance(board, size): distance = 0 for i in range(len(board)): if board[i] == 0: continue x, y = divmod(i, size) goal_x, goal_y = divmod(board[i] - 1, size) distance += abs(x - goal_x) + abs(y - goal_y) return distance def flatten_boa...
from solution import solve_15_puzzle, is_solvable, manhattan_distance def test_solvable_puzzle(): board_str = "1 2 3 4 5 6 7 8 9 10 11 0 13 14 15 12" solvability, moves = solve_15_puzzle(board_str) assert solvability == "Solvable" assert len(moves) > 0 def test_unsolvable_puzzle(): board_str = "1 ...
[ { "docstring": null, "function_declaration": "def manhattan_distance(board, size):", "function_name": "manhattan_distance", "parameter_list": "(board, size)" }, { "docstring": null, "function_declaration": "def flatten_board(board):", "function_name": "flatten_board", "parameter_...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from heapq import heappop, heappush\n\ndef is_solvable(puzzle):\n \"\"\"\n Determines if a 15-puzzle is solvable. A puzzle is solvable if the number of inversions\n plus the row of th...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00085193", "row_id": 85193, "seed_ids": "['gemma-2-27b-it_174916']" }
0.588594
Filter_85193
I
[ "manhattan_distance", "flatten_board", "is_solvable", "a_star_search", "parse_input", "solve_15_puzzle" ]
6
[ [ "a_star_search", "flatten_board" ], [ "a_star_search", "manhattan_distance" ], [ "is_solvable", "flatten_board" ], [ "solve_15_puzzle", "a_star_search" ], [ "solve_15_puzzle", "is_solvable" ], [ "solve_15_puzzle", "parse_input" ] ]
6
[ "parse_input" ]
false
[]
false
pytest
true
[]
true
9cb0c9259e5ef51dec6ee4ea194c6638bb82600b
d8de6211a18ff8280d3b55d9aef8abaccbef3c1c
v1.0
instruct
Filter
Filter_85234_I
Design a "magic 8 ball" program. The user will ask a yes/no question and the Magic 8 Ball will provide a random response from a set of predefined answers. Requirements: The program should greet the user. It should prompt the user to ask a yes/no question. It should provide a random response from...
import random def get_random_response(): responses = [ "It is certain", "It is decidedly so", "Without a doubt", "Yes definitely", "You may rely on it", "As I see it, yes", "Most likely", "Outlook good", "Yes", "Signs point to yes", ...
import pytest from solution import get_random_response, magic_8_ball def test_get_random_response(): possible_responses = [ "It is certain", "It is decidedly so", "Without a doubt", "Yes definitely", "You may rely on it", "As I see it, yes", "Most likely", ...
[ { "docstring": null, "function_declaration": "def get_random_response():", "function_name": "get_random_response", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def magic_8_ball():", "function_name": "magic_8_ball", "parameter_list": "()" } ]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef get_magic_8_ball_response():\n responses = [\n \"It is certain\",\n \"It is decidedly so\",\n \"Without a doubt\",\n \"Yes definitely\",\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00085234", "row_id": 85234, "seed_ids": "['gemma-2-27b-it_175064']" }
0.490296
Filter_85234
I
[ "get_random_response", "magic_8_ball" ]
2
[ [ "magic_8_ball", "get_random_response" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6a46005b0036c8d667933ffa8e68d45ad4d80e8a
8e86d38016f7294e55473c17bd83f81873fc3123
v1.0
instruct
Filter
Filter_85242_I
This question is from the book "Cracking the Coding Interview" by Gayle Laakmann McDowell **Problem:** Design an algorithm to find the first common ancestor of two nodes in a binary tree. Note that there can be duplicate nodes. **My Approach & Code (Python):** ```python class TreeNode: def __init__(self, val=0,...
class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def find_first_common_ancestor(root, node1, node2): if not exists_in_tree(root, node1) or not exists_in_tree(root, node2): return None return _find_first_com...
import pytest from solution import TreeNode, find_first_common_ancestor def test_common_ancestor_both_present(): # Construct the following tree: # 1 # / \ # 2 3 # / \ # 4 5 root = TreeNode(1) root.left = TreeNode(2) root.right = TreeNode(3) root.left.left...
[]
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\n\ndef find_first_common_ancestor(root, nod...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00085242", "row_id": 85242, "seed_ids": "['gemma-2-27b-it_175088']" }
0.520697
Filter_85242
I
[ "find_first_common_ancestor", "_find_first_common_ancestor_helper", "exists_in_tree" ]
3
[ [ "find_first_common_ancestor", "_find_first_common_ancestor_helper" ], [ "find_first_common_ancestor", "exists_in_tree" ] ]
2
[]
false
[ "TreeNode" ]
true
pytest
true
[]
true
108b98a44168461e190181b236dbf69a6840e15d
10d8c8a729529195f19a368ed570c4ba62b9fbc8
v1.0
instruct
Filter
Filter_85248_I
```python import os def walk(path): for root, dirs, files in os.walk(path): yield root, dirs, files def count_files(path): total_files = 0 # Use the 'walk' function to iterate through directories and subdirectories for root, dirs, files in walk(path): total_files += len(files) re...
import os def walk(path): for root, dirs, files in os.walk(path): yield root, dirs, files def count_files(path): total_files = 0 for root, dirs, files in walk(path): total_files += len(files) return total_files
import os from unittest.mock import patch from solution import walk, count_files # Test for the walk function def test_walk(): path = 'test_path' os_walk_output = [ ('test_path', ['dir1', 'dir2'], ['file1', 'file2']), ('test_path/dir1', [], ['file3']), ('test_path/dir2', [], ['file4', ...
[ { "docstring": null, "function_declaration": "def walk(path):", "function_name": "walk", "parameter_list": "(path)" }, { "docstring": null, "function_declaration": "def count_files(path):", "function_name": "count_files", "parameter_list": "(path)" } ]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\n\ndef walk(path):\n for root, dirs, files in os.walk(path):\n yield root, dirs, files\n\ndef count_files(path):\n total_files = 0\n\n # Use the 'walk' function to it...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00085248", "row_id": 85248, "seed_ids": "['gemma-2-27b-it_175111']" }
0.608324
Filter_85248
I
[ "walk", "count_files" ]
2
[ [ "count_files", "walk" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c7131cd3d8816922164a2be7289bacf8adaee980
d6a56407a6f10c50ecd1875d11ccc48ad1cd2c20
v1.0
instruct
Filter
Filter_85280_I
This program is designed to simulate the evolution of a population of organisms over time. The program takes into account factors like mutation, natural selection, and genetic drift. ## Code Structure This program uses the following Python libraries: * `random`: For generating random numbers and making random select...
import random import copy def generate_initial_population(population_size, genome_length): """ Generates the initial population with random binary genomes. """ return [[random.randint(0, 1) for _ in range(genome_length)] for _ in range(population_size)] def fitness_function(genome): """ Calcul...
from solution import generate_initial_population, fitness_function, select_parents, mutate, evolutionary_simulation def test_generate_initial_population(): population = generate_initial_population(10, 5) assert len(population) == 10 assert all(len(genome) == 5 for genome in population) def test_fitness_fu...
[ { "docstring": "Generates the initial population with random binary genomes.", "function_declaration": "def generate_initial_population(population_size, genome_length):", "function_name": "generate_initial_population", "parameter_list": "(population_size, genome_length)" }, { "docstring": "C...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport copy\n\ndef generate_initial_population(population_size, genome_length):\n return [[random.choice([0, 1]) for _ in range(genome_length)] for _ in range(population_size...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00085280", "row_id": 85280, "seed_ids": "['gemma-2-27b-it_175220']" }
0.419304
Filter_85280
I
[ "generate_initial_population", "fitness_function", "select_parents", "mutate", "evolutionary_simulation" ]
5
[ [ "evolutionary_simulation", "fitness_function" ], [ "evolutionary_simulation", "generate_initial_population" ], [ "evolutionary_simulation", "mutate" ], [ "evolutionary_simulation", "select_parents" ], [ "select_parents", "fitness_function" ] ]
5
[]
false
[]
false
pytest
true
[]
true
b16b67311b9a7d2daa198dce6b1dfea6a9233af3
fce17c970bd33b9fe80bf1683f846904de8865ab
v1.0
instruct
Filter
Filter_85285_I
This code is for a simple Blackjack game ```python import random # Define suits and ranks suits = ("Hearts", "Diamonds", "Spades", "Clubs") ranks = ("Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King", "Ace") # Dictionary for card values values = { "Two": 2, "Three": 3...
import random # Define suits and ranks suits = ("Hearts", "Diamonds", "Spades", "Clubs") ranks = ("Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King", "Ace") # Dictionary for card values values = { "Two": 2, "Three": 3, "Four": 4, "Five": 5, "Six": 6, "Seven": 7, "E...
import pytest from solution import deal_card, calculate_hand_value, is_bust def test_deal_card(): card = deal_card() assert card[0] in suits assert card[1] in ranks def test_calculate_hand_value_no_ace(): hand = [("Hearts", "Two"), ("Diamonds", "Three")] assert calculate_hand_value(hand) == 5 def...
[ { "docstring": "Returns a random card from the deck.", "function_declaration": "def deal_card():", "function_name": "deal_card", "parameter_list": "()" }, { "docstring": "Calculates the value of a hand of cards.", "function_declaration": "def calculate_hand_value(hand):", "function_n...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\n# Define suits and ranks\nsuits = (\"Hearts\", \"Diamonds\", \"Spades\", \"Clubs\")\nranks = (\"Two\", \"Three\", \"Four\", \"Five\", \"Six\", \"Seven\", \"Eight\", \"Nine\", ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00085285", "row_id": 85285, "seed_ids": "['gemma-2-27b-it_175229']" }
0.644062
Filter_85285
I
[ "deal_card", "calculate_hand_value", "is_bust", "game" ]
4
[ [ "game", "calculate_hand_value" ], [ "game", "deal_card" ], [ "game", "is_bust" ], [ "is_bust", "calculate_hand_value" ] ]
4
[]
false
[]
false
pytest
true
[]
true
1af02d8566d2ee2a1461239e793db266095590ca
5ccaadb9c2432b3829391af2e1928d0171eff60c
v1.0
instruct
Filter
Filter_85313_I
These are some of the problems with my Python code: * I'm unsure how to use the `random` module to create randomized text. * I want to implement a simple AI chatbot, but I don't know how to make it respond based on keywords. Here's some code I have so far: ```python """This code will hopefully be a simple chatbot. ...
import random def greet(): """Greets the user.""" print("Hello there!") def get_random_response(): """Provides a random generic response.""" responses = ["Interesting!", "Tell me more.", "I see.", "Hmm..."] return random.choice(responses) def respond_to_input(user_input): """Responds based on...
from solution import respond_to_input, get_random_response import pytest def test_greet(capsys): greet() captured = capsys.readouterr() assert captured.out == "Hello there!\n" def test_respond_to_input_hi(): assert respond_to_input("hi") == "Hey there!" def test_respond_to_input_hello(): assert r...
[ { "docstring": "Greets the user.", "function_declaration": "def greet():", "function_name": "greet", "parameter_list": "()" }, { "docstring": "Provides a random generic response.", "function_declaration": "def get_random_response():", "function_name": "get_random_response", "para...
[ 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 greet():\n \"\"\"Greets the user.\"\"\"\n print(\"Hello there!\")\n\ndef get_random_greeting():\n \"\"\"Returns a random greeting text.\"\"\"\n greetings = [\"...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00085313", "row_id": 85313, "seed_ids": "['gemma-2-27b-it_175330']" }
0.571369
Filter_85313
I
[ "greet", "get_random_response", "respond_to_input" ]
3
[ [ "respond_to_input", "get_random_response" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7add5da7f207acce0613a802c23a8475354b4385
74ed2ab164bf5acd4d6e40e8fdf712f746bda5cb
v1.0
instruct
Filter
Filter_85320_I
The main function `solve_sudoku` takes a 9x9 Sudoku grid as input, represented as a list of lists. It recursively solves the Sudoku puzzle by finding the first empty cell, filling it with possible numbers, and checking if it leads to a valid solution.
def is_valid(board, row, col, num): # Check the row for x in range(9): if board[row][x] == num: return False # Check the column for x in range(9): if board[x][col] == num: return False # Check the 3x3 grid start_row, start_col = 3 * (row // 3), 3 * (col ...
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": null, "function_declaration": "def is_valid(board, row, col, num):", "function_name": "is_valid", "parameter_list": "(board, row, col, num)" }, { "docstring": null, "function_declaration": "def solve_sudoku(board):", "function_name": "solve_sudoku", "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 is_valid(board, row, col, num):\n for i in range(9):\n if board[row][i] == num or board[i][col] == num:\n return False\n\n start_row, start_col = 3 * (row // 3), 3 ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00085320", "row_id": 85320, "seed_ids": "['gemma-2-27b-it_175348']" }
0.470273
Filter_85320
I
[ "is_valid", "solve_sudoku", "find_empty" ]
3
[ [ "solve_sudoku", "find_empty" ], [ "solve_sudoku", "is_valid" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6caadabc5c3e8cd42e2ab2574ea4aae8a1b972c2
9903125be6b2febb1cd25a64fa70b9ab6d641d44
v1.0
instruct
Filter
Filter_85332_I
Please provide an example of a code snippet that reads a list of numbers from a file and calculates the average.
def read_numbers_from_file(file_path): """ Reads a list of numbers from the specified file and returns them as a list of floats. Args: - file_path (str): The path to the file containing numbers. Returns: - list of float: The list of numbers read from the file. """ with open(fil...
import tempfile import os from solution import read_numbers_from_file, calculate_average, average_from_file def test_read_numbers_from_file(): with tempfile.NamedTemporaryFile(delete=False, mode='w+t') as tmpfile: tmpfile.writelines(["1.0\n", "2.0\n", "3.0\n"]) tmpfile.seek(0) file_path = t...
[ { "docstring": "Reads a list of numbers from the specified file and returns them as a list of floats.\n\nArgs:\n- file_path (str): The path to the file containing numbers.\n\nReturns:\n- list of float: The list of numbers read from the file.", "function_declaration": "def read_numbers_from_file(file_path):"...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_average_from_file(file_path):\n \"\"\"\n Reads a list of numbers from a file and calculates the average.\n Each line in the file should contain a single number.\n\n A...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00085332", "row_id": 85332, "seed_ids": "['gemma-2-27b-it_175396']" }
0.547641
Filter_85332
I
[ "read_numbers_from_file", "calculate_average", "average_from_file" ]
3
[ [ "average_from_file", "calculate_average" ], [ "average_from_file", "read_numbers_from_file" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fd279a6082c15374be194e8d2e9b5680a0cc2637
fcce15388fed8e3262a77b7ebf43567565281ea7
v1.0
instruct
Filter
Filter_85356_I
This code creates a program which sorts a list of integers in descending order using a merge sort algorithm.
def merge_sort_descending(arr): """ Sorts a list of integers in descending order using the merge sort algorithm. """ if len(arr) <= 1: return arr mid = len(arr) // 2 left_half = arr[:mid] right_half = arr[mid:] left_sorted = merge_sort_descending(left_half) right_so...
from solution import merge_sort_descending def test_merge_sort_descending_empty(): assert merge_sort_descending([]) == [] def test_merge_sort_descending_single_element(): assert merge_sort_descending([1]) == [1] def test_merge_sort_descending_sorted_list(): assert merge_sort_descending([5, 4, 3, 2, 1]) =...
[ { "docstring": "Sorts a list of integers in descending order using the merge sort algorithm.", "function_declaration": "def merge_sort_descending(arr):", "function_name": "merge_sort_descending", "parameter_list": "(arr)" }, { "docstring": "Merges two lists in descending order.", "functi...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_sort_descending(arr):\n \"\"\"\n Sorts a list of integers in descending order using the merge sort algorithm.\n \"\"\"\n if len(arr) <= 1:\n return arr\n\n def ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00085356", "row_id": 85356, "seed_ids": "['gemma-2-27b-it_175448']" }
0.636909
Filter_85356
I
[ "merge_sort_descending", "merge_descending" ]
2
[ [ "merge_sort_descending", "merge_descending" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ada57cb6e8ec763701eb27103e3d398ec81cf024
7cf8b7c6cf4df513fb4b11335812944b4c99ed3d
v1.0
instruct
Filter
Filter_85377_I
This is the code I have so far: ```python def add(x, y): """Adds two numbers.""" return x + y def subtract(x, y): """Subtracts two numbers.""" return x - y def multiply(x, y): """Multiplies two numbers.""" return x * y def divide(x, y): """Divides two numbers.""" if y == 0: return "Division by z...
def add(x, y): """Adds two numbers.""" return x + y def subtract(x, y): """Subtracts two numbers.""" return x - y def multiply(x, y): """Multiplies two numbers.""" return x * y def divide(x, y): """Divides two numbers.""" if y == 0: return "Division by zero error!" else: return x / y def c...
from solution import add, subtract, multiply, divide # Tests for add function def test_add_positive_numbers(): assert add(10, 5) == 15 def test_add_negative_numbers(): assert add(-10, -5) == -15 def test_add_mixed_sign_numbers(): assert add(-10, 5) == -5 # Tests for subtract function def test_subtract_p...
[ { "docstring": "Adds two numbers.", "function_declaration": "def add(x, y):", "function_name": "add", "parameter_list": "(x, y)" }, { "docstring": "Subtracts two numbers.", "function_declaration": "def subtract(x, y):", "function_name": "subtract", "parameter_list": "(x, y)" },...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def add(x, y):\n \"\"\"Adds two numbers.\"\"\"\n return x + y\n\ndef subtract(x, y):\n \"\"\"Subtracts two numbers.\"\"\"\n return x - y\n\ndef multiply(x, y):\n \"\"\"Multiplies two numb...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00085377", "row_id": 85377, "seed_ids": "['gemma-2-27b-it_175504']" }
0.679204
Filter_85377
I
[ "add", "subtract", "multiply", "divide", "calculator" ]
5
[ [ "calculator", "add" ], [ "calculator", "divide" ], [ "calculator", "multiply" ], [ "calculator", "subtract" ] ]
4
[]
false
[]
false
pytest
true
[]
true
fedd7a05a15d052dc808adb864ef956ef41b89e5
b97ae0ae173073e4ac0edbd6734c731a7659fa0b
v1.0
instruct
Filter
Filter_85411_I
I'm trying to add a bit of automation to my workflow. I have a CSV file named 'data.csv'. The first column of this file contains names. I want to use Python to: 1. Read the names from the CSV file. 2. Iterate over each name, and for each name, a. Generate a random email address based on the name (e.g., firstname...
import csv def generate_email(name): """Generates a random email address from a name.""" first, last = name.split() domain = '@example.com' return f"{first.lower()}.{last.lower()}{domain}" def process_csv(file_name): # Read the CSV file and process the names with open(file_name, newline='') as...
import os import csv from solution import generate_email, process_csv def setup_module(module): """Set up a test CSV file""" with open('test_data.csv', 'w', newline='') as csvfile: writer = csv.writer(csvfile) writer.writerow(['Name']) writer.writerow(['John Doe']) writer.writer...
[ { "docstring": "Generates a random email address from a name.", "function_declaration": "def generate_email(name):", "function_name": "generate_email", "parameter_list": "(name)" }, { "docstring": null, "function_declaration": "def process_csv(file_name):", "function_name": "process_...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import csv\n\ndef generate_email(name):\n \"\"\"Generates a random email address from a name.\"\"\"\n first, last = name.split()\n domain = '@example.com'\n return f\"{first.lower(...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00085411", "row_id": 85411, "seed_ids": "['gemma-2-27b-it_175589']" }
0.663187
Filter_85411
I
[ "generate_email", "process_csv" ]
2
[ [ "process_csv", "generate_email" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1fdea1e9855e3024a2c1a3a0d079313e2af8945a
14e188393b7218c93e6ba8532e8350164b3816bb
v1.0
instruct
Filter
Filter_85445_I
This is a continuation of the previous conversation. Please create a text adventure game in Python using the concepts we previously discussed. Let's keep things simple for now: * Only two rooms: a "Living Room" and a "Kitchen". * In Living Room: User can see a "TV" * In Kitchen: User can see a "Fridge" * The us...
class Room: def __init__(self, name, description, exits): self.name = name self.description = description self.exits = exits def __str__(self): return f"{self.description}\nExits: {', '.join(self.exits)}" def move_to_room(current_room, direction): if direction in current_ro...
from solution import Room, move_to_room, living_room, kitchen def test_move_to_room(): assert move_to_room(living_room, "NORTH") == kitchen assert move_to_room(kitchen, "SOUTH") == living_room assert move_to_room(living_room, "EAST") == living_room # Invalid direction for simplicity def test_room_descrip...
[]
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class Room:\n def __init__(self, name, description, exits):\n self.name = name\n self.description = description\n self.exits = exits\n\n def __str__(self):\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00085445", "row_id": 85445, "seed_ids": "['gemma-2-27b-it_175684']" }
0.4584
Filter_85445
I
[ "move_to_room", "play_game" ]
2
[ [ "play_game", "move_to_room" ] ]
1
[]
false
[ "Room" ]
true
pytest
true
[]
true
8bb1bc9d0f569be1761c9ad1db8b42f36fbf8837
d39d512e3db503d92950fbc9743ba1fcf3729f6e
v1.0
instruct
Filter
Filter_85484_I
The following code defines a function `sum_all_primes` that aims to calculate the sum of all prime numbers within a given range (inclusive).
def is_prime(n): """ Returns whether a number n is prime. """ if n <= 1: return False if n <= 3: return True if n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 re...
from solution import sum_all_primes def test_sum_all_primes_basic(): assert sum_all_primes(1, 10) == 17 # Primes are 2, 3, 5, 7 def test_sum_all_primes_single_prime(): assert sum_all_primes(13, 13) == 13 # 13 is a prime def test_sum_all_primes_no_primes(): assert sum_all_primes(14, 16) == 0 # No prim...
[ { "docstring": "Returns whether a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers within the range [start, end] inclusive.", "function_declaration": "def sum_all_...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if the number `n` is a prime.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n % 3 == 0:\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00085484", "row_id": 85484, "seed_ids": "['gemma-2-27b-it_175793']" }
0.598969
Filter_85484
I
[ "is_prime", "sum_all_primes" ]
2
[ [ "sum_all_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fbee997d0500c6c1da4fec38be636ff16588d321
28656278bd77711957b640ed50270b39752b6e2c
v1.0
instruct
Filter
Filter_85500_I
I want to create a program that simulates a simple slot machine. Here are the requirements: 1. **Symbols:** The slot machine should have three reels, each with the following symbols: * Cherry (C) * Orange (O) * Plum (P) * Bell (B) * Seven (S) * Bonus (BO) 2. **Paytable:** * Three Cherries: 10 credits * Three Oran...
import random symbols = ['C', 'O', 'P', 'B', 'S', 'BO'] paytable = { 'CCC': 10, 'OOO': 5, 'PPP': 3, 'BBB': 2, 'SSS': 100, 'BOBOBO': 50 } def spin_reels(): return ''.join(random.choices(symbols, k=3)) def calculate_winnings(reels): if reels in paytable: return paytable[reels] ...
from solution import spin_reels, calculate_winnings def test_spin_reels(): result = spin_reels() assert len(result) == 3 assert all(symbol in ['C', 'O', 'P', 'B', 'S', 'BO'] for symbol in result) def test_calculate_winnings(): assert calculate_winnings('CCC') == 10 assert calculate_winnings('OOO')...
[ { "docstring": null, "function_declaration": "def spin_reels():", "function_name": "spin_reels", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def calculate_winnings(reels):", "function_name": "calculate_winnings", "parameter_list": "(reels)" }, { ...
[ 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\nsymbols = ['C', 'O', 'P', 'B', 'S', 'BO']\npaytable = {\n 'CCC': 10,\n 'OOO': 5,\n 'PPP': 3,\n 'BBB': 2,\n 'SSS': 100,\n 'BOBOBO': 50\n}\n\ndef spin_reels():...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00085500", "row_id": 85500, "seed_ids": "['gemma-2-27b-it_175836']" }
0.576576
Filter_85500
I
[ "spin_reels", "calculate_winnings", "play_slot_machine" ]
3
[ [ "play_slot_machine", "calculate_winnings" ], [ "play_slot_machine", "spin_reels" ] ]
2
[]
false
[]
false
pytest
true
[]
true
726088b62b21c03cbd6e1ec3147e0a25db01f4b3
64103ef6678a6a0c6f738ba4d5b03f760efd430f
v1.0
instruct
Filter
Filter_85509_I
You're given a list of positive integers. For each integer, output its corresponding Fibonacci number. For example: Input: `[1, 2, 3, 20]` Output: `[1, 1, 2, 6765]` **Notes:** * The Fibonacci sequence starts with 0 and 1. * Each subsequent number is the sum of the two preceding ones. **Can you write the Python ...
def fibonacci(n): """ Returns the nth Fibonacci number. """ if n == 1: return 1 elif n == 2: return 1 a, b = 1, 1 for _ in range(n - 2): a, b = b, a + b return b def get_fibonacci_list(nums): """ Given a list of positive integers, returns a list of corres...
from solution import fibonacci, get_fibonacci_list def test_fibonacci(): assert fibonacci(1) == 1 assert fibonacci(2) == 1 assert fibonacci(3) == 2 assert fibonacci(4) == 3 assert fibonacci(5) == 5 assert fibonacci(20) == 6765 assert fibonacci(30) == 832040 def test_get_fibonacci_list(): ...
[ { "docstring": "Returns the nth Fibonacci number.", "function_declaration": "def fibonacci(n):", "function_name": "fibonacci", "parameter_list": "(n)" }, { "docstring": "Given a list of positive integers, returns a list of corresponding Fibonacci numbers.", "function_declaration": "def g...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def fibonacci(n):\n \"\"\"\n Returns the nth Fibonacci number.\n \"\"\"\n if n <= 0:\n raise ValueError(\"Input should be a positive integer\")\n elif n == 1:\n re...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00085509", "row_id": 85509, "seed_ids": "['gemma-2-27b-it_175876']" }
0.710432
Filter_85509
I
[ "fibonacci", "get_fibonacci_list" ]
2
[ [ "get_fibonacci_list", "fibonacci" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9fd1d060efb981a78c977bdc52d258f1c5ac3fad
7175b0da3e07ccfd0602bfb00349aa6989ba34ff
v1.0
instruct
Filter
Filter_85523_I
This is a bit of a strange request, but I'd like to see a Python code for the game rock paper scissors. The key feature I want is for the user to play multiple rounds against the computer, choosing whether they want to continue after each round. ```python import random def get_player_choice(): """Prompts the playe...
import random def get_player_choice(): """Prompts the player to enter their choice and validates the input.""" while True: choice = input("Enter your choice (rock, paper, scissors): ").lower() if choice in ["rock", "paper", "scissors"]: return choice def get_computer_choice...
from solution import get_player_choice, get_computer_choice, determine_winner def test_get_player_choice(monkeypatch): monkeypatch.setattr('builtins.input', lambda _: "rock") assert get_player_choice() == "rock" monkeypatch.setattr('builtins.input', lambda _: "paper") assert get_player_choice() == "pa...
[ { "docstring": "Prompts the player to enter their choice and validates the input.", "function_declaration": "def get_player_choice():", "function_name": "get_player_choice", "parameter_list": "()" }, { "docstring": "Randomly selects a choice for the computer.", "function_declaration": "d...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef get_player_choice():\n \"\"\"Prompts the player to enter their choice and validates the input.\"\"\"\n while True:\n # Prompt user for input\n choice =...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00085523", "row_id": 85523, "seed_ids": "['gemma-2-27b-it_175914']" }
0.493711
Filter_85523
I
[ "get_player_choice", "get_computer_choice", "determine_winner", "play_round", "main" ]
5
[ [ "play_round", "determine_winner" ], [ "play_round", "get_computer_choice" ], [ "play_round", "get_player_choice" ] ]
3
[]
false
[]
false
pytest
true
[]
true
c75f3887470457949c83affd17c33b103d11c28b
af2cf5bb0eb3249ff26a1e6134728542eec65224
v1.0
instruct
Filter
Filter_85562_I
I want to create a simple interactive fiction game where the player can choose from a few options at each stage and the story progresses based on their choices. I'm looking for a basic structure and some example code snippets to get me started. ## Here's a basic outline of the game: * **Scenario:** The player is ex...
def start_game(): """ Starts the game and handles the main game loop. """ print("You find yourself at the edge of a dark forest.") while True: direction = input("Which direction do you want to go? (north/south/east/west): ").strip().lower() if direction in ["north", "south", "east", ...
import pytest from solution import process_choice def test_process_choice_north(): assert process_choice("north") == False def test_process_choice_south(): assert process_choice("south") == False def test_process_choice_east(): assert process_choice("east") == False def test_process_choice_west(): a...
[ { "docstring": "Starts the game and handles the main game loop.", "function_declaration": "def start_game():", "function_name": "start_game", "parameter_list": "()" }, { "docstring": "Processes the player's direction choice.\n\nParameters:\ndirection (str): The direction chosen by the player...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def start_game():\n print(\"You find yourself at the edge of a dark forest.\")\n print(\"Which direction do you want to go?\")\n choice = input(\"Enter your choice (north/south/east/w...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00085562", "row_id": 85562, "seed_ids": "['gemma-2-27b-it_176004']" }
0.402773
Filter_85562
I
[ "start_game", "process_choice" ]
2
[ [ "start_game", "process_choice" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3cdfefd2bc3c44417ae2ec90d104ac9d996cd84f
3a38ba0f1d451d3fd206110ed4c0c0ebd189fba9
v1.0
instruct
Filter
Filter_85586_I
I need help creating a Python script that can perform basic mathematical operations (addition, subtraction, multiplication, and division) based on user input.
def add(a, b): """ Returns the sum of a and b. """ return a + b def subtract(a, b): """ Returns the result of subtracting b from a. """ return a - b def multiply(a, b): """ Returns the product of a and b. """ return a * b def divide(a, b): """ Returns the resul...
from solution import add, subtract, multiply, divide, calculate def test_add(): assert add(2, 3) == 5 assert add(-1, 1) == 0 assert add(0, 0) == 0 def test_subtract(): assert subtract(3, 2) == 1 assert subtract(-1, 1) == -2 assert subtract(0, 0) == 0 def test_multiply(): assert multiply(2...
[ { "docstring": "Returns the sum of a and b.", "function_declaration": "def add(a, b):", "function_name": "add", "parameter_list": "(a, b)" }, { "docstring": "Returns the result of subtracting b from a.", "function_declaration": "def subtract(a, b):", "function_name": "subtract", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def add(a, b):\n \"\"\"\n Returns the sum of a and b.\n \"\"\"\n return a + b\n\ndef subtract(a, b):\n \"\"\"\n Returns the difference when b is subtracted from a.\n \"\"\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00085586", "row_id": 85586, "seed_ids": "['gemma-2-27b-it_176061']" }
0.594416
Filter_85586
I
[ "add", "subtract", "multiply", "divide", "calculate" ]
5
[ [ "calculate", "add" ], [ "calculate", "divide" ], [ "calculate", "multiply" ], [ "calculate", "subtract" ] ]
4
[]
false
[]
false
pytest
true
[]
true
f269eae908ead8f219b2a465357731bbc7e517d2
eb93eea55b03c86bba0eeb04c7bac8383b7eea85
v1.0
instruct
Filter
Filter_85602_I
Concept: The concept is to create a simple game where the player types in a word and the program determines if it is a palindrome. Functionality: 1. Input: The program prompts the user to enter a word. 2. Processing: The program checks if the word is a palindrome (reads the same backward as forward). 3. Output: The ...
def is_palindrome(word): """ Checks if the given word is a palindrome. Args: word (str): The word to check. Returns: bool: True if the word is a palindrome, False otherwise. """ # Convert word to lowercase to make the check case-insensitive word = word.lower() return wo...
from solution import is_palindrome def test_is_palindrome_true(): assert is_palindrome("racecar") == True assert is_palindrome("madam") == True assert is_palindrome("radar") == True def test_is_palindrome_false(): assert is_palindrome("hello") == False assert is_palindrome("world") == False as...
[ { "docstring": "Checks if the given word is a palindrome.\n\nArgs:\nword (str): The word to check.\n\nReturns:\nbool: True if the word is a palindrome, False otherwise.", "function_declaration": "def is_palindrome(word):", "function_name": "is_palindrome", "parameter_list": "(word)" }, { "do...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(word):\n \"\"\"\n Checks if the given word is a palindrome.\n \n Args:\n word (str): The word to check.\n \n Returns:\n bool: True if the word is a pa...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00085602", "row_id": 85602, "seed_ids": "['gemma-2-27b-it_176134']" }
0.731432
Filter_85602
I
[ "is_palindrome", "check_palindrome" ]
2
[ [ "check_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7a85ad292bc5e1fddf94a3133ef1d47ca13a3eba
590084c1a0de93d83e3ebdf406030dbc6b7960c0
v1.0
instruct
Filter
Filter_85663_I
My question is about a specific example of an algorithm to solve the closest pair problem in two dimensions. Let's say we have a set of points in 2D space. The problem is to find the pair of points that are closest to each other. Here's an example of a set of points: ```python points = [(2, 3), (12, 30), (40, 50), (...
import math def distance(point1, point2): return math.sqrt((point1[0] - point2[0]) ** 2 + (point1[1] - point2[1]) ** 2) def closest_pair(points): def closest_pair_recursive(points_sorted_x, points_sorted_y): if len(points_sorted_x) <= 3: return brute_force(points_sorted_x) ...
from solution import closest_pair def test_closest_pair_example(): points = [(2, 3), (12, 30), (40, 50), (5, 1), (12, 10), (3, 4)] p1, p2, dist = closest_pair(points) assert sorted([p1, p2]) == sorted([(2, 3), (3, 4)]) assert math.isclose(dist, math.sqrt(2), rel_tol=1e-9) def test_closest_pair_empty()...
[ { "docstring": null, "function_declaration": "def distance(point1, point2):", "function_name": "distance", "parameter_list": "(point1, point2)" }, { "docstring": null, "function_declaration": "def closest_pair(points):", "function_name": "closest_pair", "parameter_list": "(points...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef distance(point1, point2):\n return math.sqrt((point1[0] - point2[0]) ** 2 + (point1[1] - point2[1]) ** 2)\n\ndef closest_pair(points):\n def closest_pair_recursive(poi...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00085663", "row_id": 85663, "seed_ids": "['gemma-2-27b-it_176324']" }
0.57694
Filter_85663
I
[ "distance", "closest_pair" ]
2
[ [ "closest_pair", "distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0ae68b8841100cd56ce4115e58e88c65b8e60b4c
b1a72c99cf898b03aedc4d13f170013ad417b0b2
v1.0
instruct
Filter
Filter_85667_I
Function: - The function should take a list of integers as input. - It should identify and return the largest prime number within the list. - If no prime numbers are found in the list, the function should return -1. 2. Prime Number Definition: - A prime number is a natural number greater than 1 that ha...
def is_prime(n): """ Helper function to check if a number is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def find_largest_...
from solution import find_largest_prime def test_find_largest_prime_with_mixed_numbers(): assert find_largest_prime([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 7 def test_find_largest_prime_with_no_primes(): assert find_largest_prime([10, 12, 14, 16]) == -1 def test_find_largest_prime_with_single_prime(): assert...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the largest prime number in the list.\nIf no prime number is found, returns -1.", "function_declara...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_largest_prime(numbers):\n \"\"\"\n Returns the largest prime number in a list of integers.\n If no prime numbers are found, returns -1.\n \"\"\"\n def is_prime(n):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00085667", "row_id": 85667, "seed_ids": "['gemma-2-27b-it_176344']" }
0.708237
Filter_85667
I
[ "is_prime", "find_largest_prime" ]
2
[ [ "find_largest_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4dcb4538ac495b7913c3894964af22589c714707
bee4451f03dcbedaa38e4a4ccd7a0c2a249366a2
v1.0
instruct
Filter
Filter_85743_I
This seems like a fun project! I'm pretty new to programming, and I'd love to learn how to make a simple text-based game in Python. Could you give me a step-by-step guide?
def start_game(): print("Welcome to the text-based adventure game!") print("You find yourself in a dark forest.") def choose_path(): print("You can go 'left' or 'right'.") choice = input("Which path do you choose? ").strip().lower() return choice def encounter(choice): if choice == "left": ...
import builtins from solution import start_game, choose_path, encounter def test_start_game(capsys): start_game() captured = capsys.readouterr() assert "Welcome to the text-based adventure game!" in captured.out assert "You find yourself in a dark forest." in captured.out def test_choose_path_left(mon...
[ { "docstring": null, "function_declaration": "def start_game():", "function_name": "start_game", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def choose_path():", "function_name": "choose_path", "parameter_list": "()" }, { "docstring": null, ...
[ 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 number_guessing_game():\n \"\"\"\n This function runs a simple number guessing game where the user\n has to guess a number between 1 and 10.\n \"\"\"\n targ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00085743", "row_id": 85743, "seed_ids": "['gemma-2-27b-it_176596']" }
0.470154
Filter_85743
I
[ "start_game", "choose_path", "encounter", "play_game" ]
4
[ [ "play_game", "choose_path" ], [ "play_game", "encounter" ], [ "play_game", "start_game" ] ]
3
[]
false
[]
false
pytest
true
[]
true
975b98d5fb2cba5bd8d5e1dc0a602b3a814ed9dd
d6d7f8368c2a0e76476480d1fd274ac371008f89
v1.0
instruct
Filter
Filter_85774_I
Here's a problem I'm facing: I need to write a Python code that takes a list of strings as input and outputs a new list containing only the strings that are palindromes. A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward, ignoring spaces, punctuation, and ...
def is_palindrome(text): """ Helper function that checks if a given text is a palindrome. Ignores spaces, punctuation, and capitalization. """ import re # Remove all non-alphanumeric characters and convert to lower case text = re.sub(r'[^A-Za-z0-9]', '', text).lower() return text == text...
from solution import is_palindrome, get_palindromes def test_is_palindrome(): assert is_palindrome("A man a plan a canal Panama") assert is_palindrome("racecar") assert not is_palindrome("hello") assert is_palindrome("No lemon no melon") assert is_palindrome("12321") assert not is_palindrome("1...
[ { "docstring": "Helper function that checks if a given text is a palindrome.\nIgnores spaces, punctuation, and capitalization.", "function_declaration": "def is_palindrome(text):", "function_name": "is_palindrome", "parameter_list": "(text)" }, { "docstring": "Returns a list of strings that ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(text):\n \"\"\"\n Check if the given text is a palindrome, ignoring spaces, punctuation, and capitalization.\n \"\"\"\n text = ''.join(filter(str.isalnum, text))....
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00085774", "row_id": 85774, "seed_ids": "['gemma-2-27b-it_176683']" }
0.765987
Filter_85774
I
[ "is_palindrome", "get_palindromes" ]
2
[ [ "get_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
14ff11c242a080e090882a400a02a7b46d2848a7
b57e727076524ad5778996907324443523c9f1ac
v1.0
instruct
Filter
Filter_85819_I
The following program simulates a simple game of Blackjack. ```python import random suits = ["Hearts", "Diamonds", "Spades", "Clubs"] ranks = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"] def get_card(): suit = random.choice(suits) rank = random.choice(ranks) return (rank...
import random suits = ["Hearts", "Diamonds", "Spades", "Clubs"] ranks = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"] def get_card(): suit = random.choice(suits) rank = random.choice(ranks) return (rank, suit) def get_hand_value(hand): hand_value = 0 ace_count = 0...
from solution import get_card, get_hand_value def test_get_card(): card = get_card() assert len(card) == 2 rank, suit = card assert rank in ["2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"] assert suit in ["Hearts", "Diamonds", "Spades", "Clubs"] def test_get_hand_val...
[ { "docstring": null, "function_declaration": "def get_card():", "function_name": "get_card", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def get_hand_value(hand):", "function_name": "get_hand_value", "parameter_list": "(hand)" }, { "docstring":...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\nsuits = [\"Hearts\", \"Diamonds\", \"Spades\", \"Clubs\"]\nranks = [\"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"Jack\", \"Queen\", \"King\", \"Ace\"]\n\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00085819", "row_id": 85819, "seed_ids": "['gemma-2-27b-it_176845']" }
0.579398
Filter_85819
I
[ "get_card", "get_hand_value", "play_blackjack" ]
3
[ [ "play_blackjack", "get_card" ], [ "play_blackjack", "get_hand_value" ] ]
2
[]
false
[]
false
pytest
true
[]
true
9919fe3bf46c29f2194c8ec6badbbb72a951c9a3
769f936f816ae97f733c7aa53c9ed456a04d20a9
v1.0
instruct
Filter
Filter_85835_I
Background: The "Two Truths and a Lie" game is a classic party icebreaker. Players share three "facts" about themselves: two truths and one lie. The other players attempt to guess which statement is the lie. Task: Create a fun and engaging chatbot that plays "Two Truths and a Lie." Features: Introduces itself: T...
import random def generate_statements(difficulty="easy"): """ Generates two truths and one lie based on the selected difficulty. """ truths = ["I have a pet cat", "I can ride a bicycle", "I have visited France"] lies = ["I am a professional athlete", "I own a private jet", "I speak 10 languages flu...
from solution import generate_statements, play_round, play_game def test_generate_statements(): statements, lie = generate_statements() assert len(statements) == 3 assert lie in statements def test_play_round(monkeypatch): inputs = iter(["1"]) monkeypatch.setattr('builtins.input', lambda _: next(i...
[ { "docstring": "Generates two truths and one lie based on the selected difficulty.", "function_declaration": "def generate_statements(difficulty='easy'):", "function_name": "generate_statements", "parameter_list": "(difficulty='easy')" }, { "docstring": null, "function_declaration": "def...
[ 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 generate_statements(difficulty=\"easy\"):\n \"\"\"\n Generates two truths and one lie based on the selected difficulty.\n \"\"\"\n truths = [\"I have a pet cat...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00085835", "row_id": 85835, "seed_ids": "['gemma-2-27b-it_176902']" }
0.43973
Filter_85835
I
[ "generate_statements", "play_round", "play_game" ]
3
[ [ "play_game", "play_round" ], [ "play_round", "generate_statements" ] ]
2
[]
false
[]
false
pytest
true
[]
true
7edf1a0db56d9aed399b35905ffcebbe201e50fb
c5306ae0c34cdab287b82367956747818d799688
v1.0
instruct
Filter
Filter_85857_I
This Python code segment aims to create a simple text-based adventure game. The game presents the player with a series of choices, and their decisions determine the course of the story. Code: ```python def start_game(): print("You awake in a dark forest. You don't remember how you got here.") print("You can see ...
def start_game(): print("You awake in a dark forest. You don't remember how you got here.") print("You can see a faint path to the north and a shimmering river to the east.") choice = input("Do you go north (n) or east (e)? ") if choice.lower() == 'n': go_north() elif choice.lower() == ...
def test_start_game(capsys, monkeypatch): inputs = iter(['n', 'a', 'rewind', 'e', 'b']) monkeypatch.setattr('builtins.input', lambda _: next(inputs)) start_game() captured = capsys.readouterr() assert "You awake in a dark forest." in captured.out assert "You walk north and encounter a ...
[ { "docstring": null, "function_declaration": "def start_game():", "function_name": "start_game", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def go_north():", "function_name": "go_north", "parameter_list": "()" }, { "docstring": null, "func...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def start_game():\n \"\"\"\n Starts the text-based adventure game.\n The player makes choices to determine the course of the story.\n \"\"\"\n print(\"You awake in a dark forest...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00085857", "row_id": 85857, "seed_ids": "['gemma-2-27b-it_176953']" }
0.493932
Filter_85857
I
[ "start_game", "go_north", "go_east" ]
3
[ [ "start_game", "go_east" ], [ "start_game", "go_north" ] ]
2
[]
false
[]
false
pytest
false
[]
true
820866b397d9afdd66ded3ea7af997eeb7ed442f
16b4a2dcb6f42b574724911dc13cc76102f2f1bc
v1.0
instruct
Filter
Filter_85858_I
Goal: Write a Python program that identifies all prime numbers within a user-specified range.
def is_prime(n): """ Returns True if n is a prime number, else False. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def primes_in_range(start, end): """ Returns a list of all prime numbers within the r...
from solution import is_prime, primes_in_range def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(13) == True assert is_prime(20) == False def test_primes_in_range_standard(): assert primes_in_range(10, 20) == [11, 13, 17, 19]...
[ { "docstring": "Returns True if n is a prime number, else False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of all prime numbers within the range [start, end].", "function_declaration": "def primes_...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determines if a number is prime.\n Returns True if n is a prime number, else False.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00085858", "row_id": 85858, "seed_ids": "['gemma-2-27b-it_176963']" }
0.710068
Filter_85858
I
[ "is_prime", "primes_in_range" ]
2
[ [ "primes_in_range", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b96a5d51e249f36e9da5630372a46af952e50c2a
ff0676678924ec739740ede0b6bfecf489d5e272
v1.0
instruct
Filter
Filter_85891_I
This code is supposed to simulate a simple dice roll. Write some Python code that can roll a single six-sided die. ```python import random def roll_die(): """Rolls a single six-sided die.""" # Code to generate a random number between 1 and 6. # Return the result. # Example usage result = roll_die() print(f"You...
import random def roll_die(): """ Rolls a single six-sided die and returns the result. """ return random.randint(1, 6) def roll_dice(num_dice): """ Rolls a specified number of six-sided dice. Parameters: - num_dice (int): The number of dice to roll. Returns: - list: A list co...
from solution import roll_die, roll_dice def test_roll_die(): result = roll_die() assert result in [1, 2, 3, 4, 5, 6] def test_roll_dice_zero(): result = roll_dice(0) assert result == [] def test_roll_dice_one(): result = roll_dice(1) assert len(result) == 1 assert result[0] in [1, 2, 3, ...
[ { "docstring": "Rolls a single six-sided die and returns the result.", "function_declaration": "def roll_die():", "function_name": "roll_die", "parameter_list": "()" }, { "docstring": "Rolls a specified number of six-sided dice.\n\nParameters:\n- num_dice (int): The number of dice to roll.\n...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef roll_die():\n \"\"\"Rolls a single six-sided die.\"\"\"\n return random.randint(1, 6)\n\ndef roll_dice(num_dice):\n \"\"\"Rolls a specified number of six-sided di...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00085891", "row_id": 85891, "seed_ids": "['gemma-2-27b-it_177047']" }
0.623485
Filter_85891
I
[ "roll_die", "roll_dice" ]
2
[ [ "roll_dice", "roll_die" ] ]
1
[]
false
[]
false
pytest
true
[]
true
64e4ce5b0b2308f684eba13c83615b6c94e1adb4
f675e3b6cc599ad436e2d60c585516cfd32f3dfd
v1.0
instruct
Filter
Filter_85921_I
Here's a coding challenge: **The Challenge:** Write a function that takes a positive integer `n` as input and returns the sum of all the prime numbers less than or equal to `n`. **Example:** ``` sum_of_primes(10) == 17
def is_prime(num): """ Helper function to check if a number is prime. """ if num <= 1: return False if num == 2: return True if num % 2 == 0: return False for i in range(3, int(num**0.5) + 1, 2): if num % i == 0: return False return True def s...
from solution import sum_of_primes def test_sum_of_primes_10(): assert sum_of_primes(10) == 17 def test_sum_of_primes_1(): assert sum_of_primes(1) == 0 def test_sum_of_primes_2(): assert sum_of_primes(2) == 2 def test_sum_of_primes_20(): assert sum_of_primes(20) == 77 def test_sum_of_primes_edge_ca...
[ { "docstring": "Helper function to check if a number is prime.", "function_declaration": "def is_prime(num):", "function_name": "is_prime", "parameter_list": "(num)" }, { "docstring": "Returns the sum of all prime numbers less than or equal to n.", "function_declaration": "def sum_of_pri...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(num):\n \"\"\"\n Checks if a number is prime.\n \"\"\"\n if num <= 1:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00085921", "row_id": 85921, "seed_ids": "['gemma-2-27b-it_177146']" }
0.663932
Filter_85921
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0a05a6715928cca6be7449d1e00cf5fd1a08fde8
f3bc34fee873e6ae246200fb6377da30880ee70e
v1.0
instruct
Filter
Filter_85947_I
This is what I have so far ```python def calculate_fuel_required(mass): fuel = mass // 3 - 2 return fuel def calculate_total_fuel(modules): required_fuel = 0 for module in modules: required_fuel += calculate_fuel_required(module) return required_fuel modules = [ 100756, 140887, 54477, 92...
def calculate_fuel_required(mass): """ Calculate the fuel required for the given mass, including the fuel for the added fuel recursively. """ fuel = mass // 3 - 2 if fuel <= 0: return 0 else: return fuel + calculate_fuel_required(fuel) def calculate_total_fuel(modules): """ ...
from solution import calculate_fuel_required, calculate_total_fuel def test_calculate_fuel_required(): assert calculate_fuel_required(12) == 2 assert calculate_fuel_required(14) == 2 assert calculate_fuel_required(1969) == 966 assert calculate_fuel_required(100756) == 50346 def test_calculate_total_fu...
[ { "docstring": "Calculate the fuel required for the given mass, including the fuel for the added fuel recursively.", "function_declaration": "def calculate_fuel_required(mass):", "function_name": "calculate_fuel_required", "parameter_list": "(mass)" }, { "docstring": "Calculate the total fue...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_fuel_required(mass):\n \"\"\"\n Calculate the fuel required for the given mass, including the fuel for the added fuel recursively.\n \"\"\"\n fuel = mass // 3 - 2\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00085947", "row_id": 85947, "seed_ids": "['gemma-2-27b-it_177212']" }
0.501359
Filter_85947
I
[ "calculate_fuel_required", "calculate_total_fuel" ]
2
[ [ "calculate_total_fuel", "calculate_fuel_required" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ea1c60c6e70d74bb7a935142a46237d872547d00
af59219ff84eefc380db7ec0b28012bc85b6de05
v1.0
instruct
Filter
Filter_85954_I
What is a simple program to print the Fibonacci sequence using recursion?
def fibonacci(n): """ Returns the n-th Fibonacci number using recursion. """ if n <= 0: return "Input must be a positive integer" elif n == 1: return 0 elif n == 2: return 1 else: return fibonacci(n - 1) + fibonacci(n - 2) def get_fibonacci_sequence(n): ...
from solution import fibonacci, get_fibonacci_sequence def test_fibonacci_base_cases(): assert fibonacci(1) == 0 assert fibonacci(2) == 1 def test_fibonacci_recursive_cases(): assert fibonacci(3) == 1 assert fibonacci(4) == 2 assert fibonacci(5) == 3 assert fibonacci(6) == 5 def test_fibonacc...
[ { "docstring": "Returns the n-th Fibonacci number using recursion.", "function_declaration": "def fibonacci(n):", "function_name": "fibonacci", "parameter_list": "(n)" }, { "docstring": "Returns a list of the first n Fibonacci numbers.", "function_declaration": "def get_fibonacci_sequenc...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def fibonacci(n):\n \"\"\"\n Returns the nth Fibonacci number using recursion.\n \n :param n: the index in the Fibonacci sequence\n :return: the nth Fibonacci number\n \"\"\"...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00085954", "row_id": 85954, "seed_ids": "['gemma-2-27b-it_177227']" }
0.671941
Filter_85954
I
[ "fibonacci", "get_fibonacci_sequence" ]
2
[ [ "get_fibonacci_sequence", "fibonacci" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fb363a2e972858f4d82624c052a6c021a1234216
2d762b46f8a0afe20ee49cb5486127cf626bb063
v1.0
instruct
Filter
Filter_86011_I
I want to learn how to write code for a simple game in Python, but I don't know where to start. I imagine a text-based adventure game where the player makes choices that affect the story. Here's a basic idea: * The player wakes up in a dark forest. * They can choose to go north, east, west, or south. * Each directi...
def start_game(): """ Starts the text-based adventure game. """ print("You wake up in a dark forest. You can go north, east, west, or south.") decision = input("Which direction do you want to go? ").strip().lower() while decision not in ['north', 'east', 'west', 'south']: print("Invalid ...
import pytest from io import StringIO from unittest.mock import patch from solution import start_game, go_north, go_east, go_west, go_south def test_go_north(): with patch('builtins.print') as mock_print: go_north() mock_print.assert_called_once_with("You went north and encountered a monster. Game ...
[ { "docstring": "Starts the text-based adventure game.", "function_declaration": "def start_game():", "function_name": "start_game", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def go_north():", "function_name": "go_north", "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 welcome_message():\n \"\"\"\n Displays a welcome message to the player.\n \"\"\"\n print(\"Welcome to the Adventure Game!\")\n print(\"You find yourself in a dark forest. Yo...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00086011", "row_id": 86011, "seed_ids": "['gemma-2-27b-it_177403']" }
0.40079
Filter_86011
I
[ "start_game", "go_north", "go_east", "go_west", "go_south" ]
5
[ [ "start_game", "go_east" ], [ "start_game", "go_north" ], [ "start_game", "go_south" ], [ "start_game", "go_west" ] ]
4
[]
false
[]
false
pytest
true
[]
true
ff1152e08114614095360f9f82f5bb613d215873
8db6304a76ad1b604c5a4e2802c4307dd93e9485
v1.0
instruct
Filter
Filter_86023_I
Here is the code for a simple text-based adventure game: ```python def show_intro(): print("You find yourself standing in a dark forest.") print("There is a path to the north and a cave to the east.") def show_options(): print("\nWhat do you want to do?") print("1. Go north") print("2. Go east") print("3....
class Room: def __init__(self, description): self.description = description self.paths = {} def connect(self, direction, room): self.paths[direction] = room def show_intro(current_room): print(current_room.description) for direction in current_room.paths: print(f"To the...
from solution import Room def test_room_description(): room = Room("A small, cozy room.") assert room.description == "A small, cozy room." def test_room_connections(): room1 = Room("Room 1") room2 = Room("Room 2") room1.connect("north", room2) assert "north" in room1.paths assert room1.pat...
[]
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class Room:\n def __init__(self, description):\n self.description = description\n self.paths = {}\n\n def connect(self, direction, room):\n self.paths[direction] = r...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00086023", "row_id": 86023, "seed_ids": "['gemma-2-27b-it_177425']" }
0.422256
Filter_86023
I
[ "show_intro", "show_options", "get_player_choice", "game_loop" ]
4
[ [ "game_loop", "get_player_choice" ], [ "game_loop", "show_intro" ], [ "game_loop", "show_options" ] ]
3
[]
false
[ "Room" ]
true
pytest
true
[]
true
e7f9e9683ee58924d46c10a1a15b537bea3eac1b
edc2f9eaca83c64cf671f0a1a27a1bc5cc49e31f
v1.0
instruct
Filter
Filter_86043_I
This code demonstrates building and querying an inverted index for a corpus of text documents: ```python import re from collections import defaultdict def tokenize(text): """Splits text into individual words, ignoring punctuation and converting to lowercase.""" return re.findall(r"\b\w+\b", text.lower()) def bui...
import re from collections import defaultdict def tokenize(text): """ Splits text into individual words, ignoring punctuation and converting to lowercase. """ return re.findall(r"\b\w+\b", text.lower()) def build_inverted_index(corpus): """ Constructs an inverted index from a corpus of text do...
import pytest from solution import tokenize, build_inverted_index, query_inverted_index def test_tokenize(): assert tokenize("Hello, World!") == ["hello", "world"] assert tokenize("Python's great.") == ["python", "s", "great"] assert tokenize("123 easy as 456.") == ["123", "easy", "as", "456"] def tes...
[ { "docstring": "Splits text into individual words, ignoring punctuation and converting to lowercase.", "function_declaration": "def tokenize(text):", "function_name": "tokenize", "parameter_list": "(text)" }, { "docstring": "Constructs an inverted index from a corpus of text documents.", ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\nfrom collections import defaultdict\n\ndef tokenize(text):\n \"\"\"Splits text into individual words, ignoring punctuation and converting to lowercase.\"\"\"\n return re.findall(r...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00086043", "row_id": 86043, "seed_ids": "['gemma-2-27b-it_177490']" }
0.493744
Filter_86043
I
[ "tokenize", "build_inverted_index", "query_inverted_index" ]
3
[ [ "build_inverted_index", "tokenize" ], [ "query_inverted_index", "tokenize" ] ]
2
[]
false
[]
false
pytest
true
[]
true
46da6e4ce24d6df753a207a566ae5352bbf85ed5
ab8c76de36a958bbd69778f764d93abb1fca47b8
v1.0
instruct
Filter
Filter_86076_I
Write a program that simulates a lottery ticket purchase. Requirements: - The program should generate 6 random unique numbers between 1 and 49 (inclusive). These numbers represent the lottery ticket. - The user should be able to choose how many tickets they want to purchase. - The program should display the generated...
import random def generate_ticket(): """ Generates a single lottery ticket with 6 unique random numbers between 1 and 49 (inclusive). """ numbers = random.sample(range(1, 50), 6) return sorted(numbers) def generate_tickets(count): """ Generates a list of lottery tickets. Parameter...
from solution import generate_ticket, generate_tickets def test_generate_ticket_length(): ticket = generate_ticket() assert len(ticket) == 6, "Each ticket should contain 6 numbers" def test_generate_ticket_uniqueness(): ticket = generate_ticket() assert len(ticket) == len(set(ticket)), "Each ticket sh...
[ { "docstring": "Generates a single lottery ticket with 6 unique random numbers between 1 and 49 (inclusive).", "function_declaration": "def generate_ticket():", "function_name": "generate_ticket", "parameter_list": "()" }, { "docstring": "Generates a list of lottery tickets.\n\nParameters:\n...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef generate_ticket():\n \"\"\"\n Generates a single lottery ticket with 6 unique random numbers between 1 and 49 (inclusive).\n \"\"\"\n numbers = random.sample(r...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00086076", "row_id": 86076, "seed_ids": "['gemma-2-27b-it_177589']" }
0.452877
Filter_86076
I
[ "generate_ticket", "generate_tickets", "main" ]
3
[ [ "generate_tickets", "generate_ticket" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1e1a8fde7c62e1ca6eb24d3004d7357fb105e75b
211be611f244a40d4128ff6de7f499640c41f170
v1.0
instruct
Filter
Filter_86139_I
These are the rules of a game: * **Two player game.** * **Each player takes turns placing a marker on a 3x3 grid.** * **The first player to get three of their markers in a row, column, or diagonal wins.** * **If the grid is filled without a winner, the game is a draw.** This is classic Tic-Tac-Toe. Write a Python ...
def print_board(board): """Prints the current state of the board.""" for row in board: print("|" + "|".join(row) + "|") def get_player_move(player, board): """Gets the player's move and validates it.""" while True: try: row, col = map(int, input(f"Player {player}, enter your...
def test_print_board(capsys): board = [["X", "O", "X"], ["O", "X", "O"], ["X", "O", "X"]] print_board(board) captured = capsys.readouterr() expected_output = "|X|O|X|\n|O|X|O|\n|X|O|X|\n" assert captured.out == expected_output def test_check_win(): winning_board_row = [["X", "X", "X"], [" ", "...
[ { "docstring": "Prints the current state of the board.", "function_declaration": "def print_board(board):", "function_name": "print_board", "parameter_list": "(board)" }, { "docstring": "Gets the player's move and validates it.", "function_declaration": "def get_player_move(player, board...
[ 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 current state of the board.\"\"\"\n for row in board:\n print(\"|\" + \"|\".join(row) + \"|\")\n\ndef get_player_move(player, board):\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00086139", "row_id": 86139, "seed_ids": "['gemma-2-27b-it_177750']" }
0.597636
Filter_86139
I
[ "print_board", "get_player_move", "check_win", "is_draw", "play_game" ]
5
[ [ "play_game", "check_win" ], [ "play_game", "get_player_move" ], [ "play_game", "is_draw" ], [ "play_game", "print_board" ] ]
4
[]
false
[]
false
pytest
false
[]
true
659e5430e611e788df191e8fee761d7ac3657040
aba52c9a885b498ec099b48e6b666ddcee633249
v1.0
instruct
Filter
Filter_86140_I
This seems kind of complex: ```python def collatz(number): if number % 2 == 0: return number // 2 else: return 3 * number + 1 def generate_sequence(number): sequence = [number] while number != 1: number = collatz(number) sequence.append(number) return sequence print(generate_sequence(10)) `...
def collatz(number): """ Perform one step in the Collatz sequence. If the number is even, return number // 2; If the number is odd, return 3 * number + 1. """ if number % 2 == 0: return number // 2 else: return 3 * number + 1 def generate_sequence(number): """ Genera...
from solution import collatz, generate_sequence def test_collatz_even(): assert collatz(8) == 4 def test_collatz_odd(): assert collatz(5) == 16 def test_generate_sequence(): assert generate_sequence(10) == [10, 5, 16, 8, 4, 2, 1] def test_generate_sequence_single_step(): assert generate_sequence(1) ...
[ { "docstring": "Perform one step in the Collatz sequence.\nIf the number is even, return number // 2;\nIf the number is odd, return 3 * number + 1.", "function_declaration": "def collatz(number):", "function_name": "collatz", "parameter_list": "(number)" }, { "docstring": "Generate the Colla...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def collatz(number):\n \"\"\"\n Apply the Collatz function to a given number.\n \n If the number is even, divide it by 2.\n If the number is odd, return 3 * number + 1.\n \"\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00086140", "row_id": 86140, "seed_ids": "['gemma-2-27b-it_177751']" }
0.638742
Filter_86140
I
[ "collatz", "generate_sequence" ]
2
[ [ "generate_sequence", "collatz" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bfeac430f5493659f9e8d53e21c0ededf5c20ea4
d9539c7ac383383ff6dcbb3345311c091fdc9f03
v1.0
instruct
Filter
Filter_86180_I
This is a code snippet that should return the kth smallest element in an unsorted array: ```python import heapq def find_kth_smallest(nums, k): """ Finds the kth smallest element in an unsorted array. Args: nums: The unsorted array of numbers. k: The kth smallest element to find. Returns: The kt...
def partition(arr, left, right, pivot_index): pivot_value = arr[pivot_index] arr[pivot_index], arr[right] = arr[right], arr[pivot_index] # Move pivot to end store_index = left for i in range(left, right): if arr[i] < pivot_value: arr[store_index], arr[i] = arr[i], arr[store_index] ...
def test_find_kth_smallest(): assert find_kth_smallest([3, 1, 2, 1, 4, 5], 3) == 2 def test_single_element(): assert find_kth_smallest([7], 1) == 7 def test_larger_k(): assert find_kth_smallest([4, 2, 9, 7, 3], 4) == 7 def test_all_elements_equal(): assert find_kth_smallest([1, 1, 1, 1, 1], 3) ==...
[ { "docstring": null, "function_declaration": "def partition(arr, left, right, pivot_index):", "function_name": "partition", "parameter_list": "(arr, left, right, pivot_index)" }, { "docstring": null, "function_declaration": "def quickselect(arr, left, right, k):", "function_name": "q...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def partition(arr, low, high):\n pivot = arr[high]\n i = low - 1\n\n for j in range(low, high):\n if arr[j] < pivot:\n i += 1\n arr[i], arr[j] = arr[j], a...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00086180", "row_id": 86180, "seed_ids": "['gemma-2-27b-it_177855']" }
0.659186
Filter_86180
I
[ "partition", "quickselect", "find_kth_smallest" ]
3
[ [ "find_kth_smallest", "quickselect" ], [ "quickselect", "partition" ] ]
2
[]
false
[]
false
pytest
false
[]
true
00ffb25d72d50f1d7e540e74d40b4cb9609a8a9c
b3d33754e7763511a5e0515ddb1a7e1b93ef364a
v1.0
instruct
Filter
Filter_86251_I
This is the code for generating a Fibonacci sequence. ```python def fibonacci(n): a, b = 0, 1 for i in range(n): yield a a, b = b, a + b for x in fibonacci(10): print(x) ``` This code effectively generates the Fibonacci sequence up to the nth term. **However, I'm curious if there are any alternative w...
def fibonacci_memo(n, memo=None): """ Returns the first n Fibonacci numbers using recursion with memoization. """ if memo is None: memo = {} if n in memo: return memo[n] if n <= 1: return n memo[n] = fibonacci_memo(n-1, memo) + fibonacci_memo(n-2, memo) return mem...
from solution import generate_fibonacci_sequence def test_generate_fibonacci_sequence(): assert generate_fibonacci_sequence(0) == [] assert generate_fibonacci_sequence(1) == [0] assert generate_fibonacci_sequence(2) == [0, 1] assert generate_fibonacci_sequence(5) == [0, 1, 1, 2, 3] assert generate_...
[ { "docstring": "Returns the first n Fibonacci numbers using recursion with memoization.", "function_declaration": "def fibonacci_memo(n, memo=None):", "function_name": "fibonacci_memo", "parameter_list": "(n, memo=None)" }, { "docstring": "Returns a list of the first n Fibonacci numbers.", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def fibonacci_recursive(n, a=0, b=1):\n \"\"\"\n Generates the Fibonacci sequence up to the nth term using recursion.\n :param n: Number of terms in the Fibonacci sequence to generate...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00086251", "row_id": 86251, "seed_ids": "['gemma-2-27b-it_178072']" }
0.628485
Filter_86251
I
[ "fibonacci_memo", "generate_fibonacci_sequence" ]
2
[ [ "generate_fibonacci_sequence", "fibonacci_memo" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dcacdebc7bf6e7300422c26c1f50da6d30af2bfc
5ed6ec93466650f4d2ea705a0999ffb3ce4b8534
v1.0
instruct
Filter
Filter_86281_I
These are the rules for a simple card game: **Card Values:** * Ace: 11 * Face cards (Jack, Queen, King): 10 * Number cards: Face value **Game Play:** * **Dealing:** - Each player is dealt two cards face down. - The dealer receives one card face down and one card face up. * **Player Turn:** The player must ...
import random # Define the card values CARD_VALUES = { "Ace": 11, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8, "9": 9, "10": 10, "Jack": 10, "Queen": 10, "King": 10, } # Function to create and shuffle a deck def create_shuffled_deck(): deck = [] f...
from solution import ( create_shuffled_deck, calculate_hand_value, player_turn, dealer_turn, determine_winner, simulate_game ) def test_create_shuffled_deck(): deck = create_shuffled_deck() assert len(deck) == 52 assert isinstance(deck, list) for card in deck: assert card["rank"] in CAR...
[ { "docstring": null, "function_declaration": "def create_shuffled_deck():", "function_name": "create_shuffled_deck", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def calculate_hand_value(hand):", "function_name": "calculate_hand_value", "parameter_list"...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\n# Define the card values\ncard_values = {\n \"Ace\": 11, \"2\": 2, \"3\": 3, \"4\": 4, \"5\": 5, \"6\": 6, \"7\": 7,\n \"8\": 8, \"9\": 9, \"10\": 10, \"Jack\": 10, \"Qu...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00086281", "row_id": 86281, "seed_ids": "['gemma-2-27b-it_178156']" }
0.5932
Filter_86281
I
[ "create_shuffled_deck", "calculate_hand_value", "player_turn", "dealer_turn", "determine_winner", "simulate_game" ]
6
[ [ "dealer_turn", "calculate_hand_value" ], [ "determine_winner", "calculate_hand_value" ], [ "player_turn", "calculate_hand_value" ], [ "simulate_game", "create_shuffled_deck" ], [ "simulate_game", "dealer_turn" ], [ "simulate_game", "determine_win...
7
[]
false
[]
false
pytest
true
[]
true
4ccf67f81499d05a6047ba8f27d673117bffef16
49d786127b82698e53291ff9ec975a20debe918e
v1.0
instruct
Filter
Filter_86316_I
Design a simple guessing game in Python where the computer randomly chooses a number between 1 and 100 and the player has to guess it.
import random def guessing_game(random_number, guess): """ Function to simulate the guessing part of the game. Parameters: - random_number (int): The number chosen by the computer. - guess (int): The player's guess. Returns: - str: A hint about whether the guess was too low, too h...
from solution import guessing_game def test_guess_too_low(): assert guessing_game(50, 25) == "Too low" def test_guess_too_high(): assert guessing_game(50, 75) == "Too high" def test_guess_correct(): assert guessing_game(50, 50) == "Correct"
[ { "docstring": "Function to simulate the guessing part of the game.\n\nParameters:\n- random_number (int): The number chosen by the computer.\n- guess (int): The player's guess.\n\nReturns:\n- str: A hint about whether the guess was too low, too high, or correct.", "function_declaration": "def guessing_game...
[ 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 guessing_game():\n number_to_guess = random.randint(1, 100)\n guess = None\n attempts = 0\n while guess != number_to_guess:\n guess = int(input(\"Enter ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00086316", "row_id": 86316, "seed_ids": "['gemma-2-27b-it_178258']" }
0.493243
Filter_86316
I
[ "guessing_game", "run_game" ]
2
[ [ "run_game", "guessing_game" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a27cf0bed611030081c4290b19a75166739c7b5a
0c4452fddf9e515edcb9b2dc3996c587ff00b765
v1.0
instruct
Filter
Filter_86368_I
Objective: To create a program that simulates rolling a pair of dice and calculates the sum of the roll. Programming Language: Python ```python import random def roll_dice(): """Simulates rolling a pair of dice and returns the sum.""" die1 = random.randint(1, 6) die2 = random.randint(1, 6) return die1 + die...
import random def roll_dice(): """Simulates rolling a pair of dice and returns the sum.""" die1 = random.randint(1, 6) die2 = random.randint(1, 6) return die1 + die2 def simulate_rolls(): while True: sum_of_roll = roll_dice() print(f"You rolled a {sum_of_roll}") roll_again ...
import pytest from solution import roll_dice def test_roll_dice_within_bounds(): for _ in range(100): # Test multiple times to ensure consistency. result = roll_dice() assert 2 <= result <= 12 # Minimum sum is 2 (1+1), and maximum is 12 (6+6). @pytest.mark.parametrize("num_rolls", [10, 100, 1000...
[ { "docstring": "Simulates rolling a pair of dice and returns the sum.", "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def simulate_rolls():", "function_name": "simulate_rolls", "pa...
[ 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 rolling a pair of dice and returns the sum.\"\"\"\n die1 = random.randint(1, 6)\n die2 = random.randint(1, 6)\n return die1 + di...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00086368", "row_id": 86368, "seed_ids": "['gemma-2-27b-it_178390']" }
0.631961
Filter_86368
I
[ "roll_dice", "simulate_rolls" ]
2
[ [ "simulate_rolls", "roll_dice" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f7e4d15467a509c49004c850d81e827a60445df7
b8e9195fa1a5baa3a27748530318f9f7e823bc02
v1.0
instruct
Filter
Filter_86389_I
Here's a Python function to find the highest palindrome number less than or equal to a given input number.
def is_palindrome(n): """ Check if a given integer n is a palindrome. """ str_n = str(n) return str_n == str_n[::-1] def highest_palindrome(n): """ Finds the highest palindrome number less than or equal to n. """ for num in range(n, -1, -1): if is_palindrome(num): ...
from solution import is_palindrome, highest_palindrome def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(0) == True assert is_palindrome(1221) == True assert is_palindrome(-121) == False assert is_palindrome(1234321) == True def...
[ { "docstring": "Check if a given integer n is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Finds the highest palindrome number less than or equal to n.", "function_declaration": "def highest_...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_highest_palindrome(n):\n \"\"\"\n Finds the highest palindrome number less than or equal to the given number n.\n \"\"\"\n while n >= 0:\n if str(n) == str(n)[::-1]...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00086389", "row_id": 86389, "seed_ids": "['gemma-2-27b-it_178446']" }
0.731931
Filter_86389
I
[ "is_palindrome", "highest_palindrome" ]
2
[ [ "highest_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3c5469425ef1fcd605bdffc99c551b88f3d5264a
6d4228d1ca4eae8fab2186cf47a09a2f472cce04
v1.0
instruct
Filter
Filter_86502_I
This is the code for a game. ```python def game(): secret_number = 7 guess = int(input("Guess a number between 1 and 10: ")) if guess == secret_number: print("You guessed it! You win!") else: print("Try again!") game() ``` This code asks the user to guess a secret number. The secret...
def get_user_guess(): return int(input("Guess a number between 1 and 10: ")) def check_guess(secret_number, guess): if guess == secret_number: return "You guessed it! You win!" else: return "Try again!" def game(): secret_number = 7 guess = get_user_guess() result = check_guess...
from solution import get_user_guess, check_guess, game def test_check_guess_correct(): assert check_guess(7, 7) == "You guessed it! You win!" def test_check_guess_incorrect(): assert check_guess(7, 5) == "Try again!" assert check_guess(7, 10) == "Try again!" def test_game(monkeypatch): inputs = iter(...
[ { "docstring": null, "function_declaration": "def get_user_guess():", "function_name": "get_user_guess", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def check_guess(secret_number, guess):", "function_name": "check_guess", "parameter_list": "(secret_num...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def check_guess(secret_number, guess):\n \"\"\"\n Checks if the guessed number is equal to the secret number.\n\n Parameters:\n secret_number (int): The predefined secret number.\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00086502", "row_id": 86502, "seed_ids": "['gemma-2-27b-it_178742']" }
0.543269
Filter_86502
I
[ "get_user_guess", "check_guess", "game" ]
3
[ [ "game", "check_guess" ], [ "game", "get_user_guess" ] ]
2
[]
false
[]
false
pytest
true
[]
true
fccf2037c32caa286a54be818a219eb1c385795c
07e15a5066a715aff3fe72d9c1cf27a3f5cd6882
v1.0
instruct
Filter
Filter_86505_I
**Please note**: * This code is for educational purposes. * I understand the risks associated with using this code and takes full responsibility for any consequences. * I will use this code ethically and responsibly. **Please provide me with Python code that:** 1. Reads a text file containing a list of emails. 2. C...
import re def is_valid_email(email): """ Validates an email address by checking if it contains "@" and ".". Args: email (str): The email address to validate. Returns: bool: True if valid, False otherwise. """ # A basic check for email validity using regex return bo...
import os from solution import clean_emails, is_valid_email def test_is_valid_email(): assert is_valid_email("test@example.com") == True assert is_valid_email("invalid-email") == False assert is_valid_email("another@test.co.uk") == True assert is_valid_email("no-at-symbol.com") == False assert is_v...
[ { "docstring": "Validates an email address by checking if it contains \"@\" and \".\".\n\nArgs:\n email (str): The email address to validate.\n\nReturns:\n bool: True if valid, False otherwise.", "function_declaration": "def is_valid_email(email):", "function_name": "is_valid_email", "paramete...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\n\ndef is_valid_email(email):\n return re.match(r\"[^@]+@[^@]+\\.[^@]+\", email) is not None\n\ndef clean_emails(input_file, output_file):\n \"\"\"\n Reads a text file of em...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00086505", "row_id": 86505, "seed_ids": "['gemma-2-27b-it_178747']" }
0.570907
Filter_86505
I
[ "is_valid_email", "clean_emails" ]
2
[ [ "clean_emails", "is_valid_email" ] ]
1
[]
false
[]
false
pytest
true
[]
true
f77eee117ca484745f625928091c1bd459868877
65300cc22b42c16c7a388abb654a0a33d7906203
v1.0
instruct
Filter
Filter_86512_I
This is what I'm aiming for: **Objective:** To create a Python program that calculates the average grade for each student based on their scores in different subjects. Here are the some additional requirements: ***Input:** The program should take the following inputs: * Number of students * Number of subjec...
def calculate_average_grades(num_students, num_subjects, scores): """ Calculate average grades for a list of students based on their scores in different subjects. Args: num_students (int): Number of students. num_subjects (int): Number of subjects. scores (list of list of int): A 2D list wh...
from solution import calculate_average_grades, display_averages def test_calculate_average_grades(): num_students = 2 num_subjects = 3 scores = [ [70, 80, 90], [60, 60, 60] ] expected = [(1, 80.0), (2, 60.0)] result = calculate_average_grades(num_students, num_subjects, scores) ...
[ { "docstring": "Calculate average grades for a list of students based on their scores in different subjects.\n\nArgs:\nnum_students (int): Number of students.\nnum_subjects (int): Number of subjects.\nscores (list of list of int): A 2D list where each sublist contains scores of a student in all subjects.\n\nRet...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_average_grades(num_students, num_subjects, scores):\n \"\"\"\n Calculate average grades for a list of students based on their scores in different subjects.\n \n Args:...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00086512", "row_id": 86512, "seed_ids": "['gemma-2-27b-it_178768']" }
0.676462
Filter_86512
I
[ "calculate_average_grades", "display_averages", "run_program" ]
3
[ [ "run_program", "calculate_average_grades" ], [ "run_program", "display_averages" ] ]
2
[]
false
[]
false
pytest
true
[]
true
ff7f94e1de0b06d34b98753fedc091653ddbde09
2535863d89a1e5b4695c6556ee445056bcd5de3e
v1.0
instruct
Filter
Filter_86527_I
This code is meant to simulate a simple dice rolling game between two players. ```python # This function simulates rolling a single six-sided die. def roll_die(): import random return random.randint(1, 6) # This function allows each player to roll the die and compares the results. def play_round(): ...
def roll_die(): import random return random.randint(1, 6) def play_round(): player1_roll = roll_die() player2_roll = roll_die() print(f"Player 1 rolled a {player1_roll}.") print(f"Player 2 rolled a {player2_roll}.") if player1_roll > player2_roll: print("Player 1 wins the round!") ...
from solution import roll_die, play_round def test_roll_die(): for _ in range(100): # test multiple times to cover randomness roll = roll_die() assert 1 <= roll <= 6 def test_play_round_tie(monkeypatch): def mock_roll_die(): return 3 monkeypatch.setattr('solution.roll_die', m...
[ { "docstring": null, "function_declaration": "def roll_die():", "function_name": "roll_die", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def play_round():", "function_name": "play_round", "parameter_list": "()" }, { "docstring": null, "func...
[ 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_die():\n \"\"\"\n Simulate rolling a six-sided die.\n \"\"\"\n return random.randint(1, 6)\n\ndef play_round():\n \"\"\"\n Simulate a round where ea...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00086527", "row_id": 86527, "seed_ids": "['gemma-2-27b-it_178802']" }
0.544962
Filter_86527
I
[ "roll_die", "play_round", "play_game" ]
3
[ [ "play_game", "play_round" ], [ "play_round", "roll_die" ] ]
2
[]
false
[]
false
pytest
true
[]
true
4fb3909b499ddd3b7ab0a1dbc24d6587c08c8de8
da5d929e1db05c0c8bded8bbc84c2fd27c2d1f21
v1.0
instruct
Filter
Filter_86556_I
Understand the task: You are to build a basic text-based adventure game. This should involve the player making choices about their actions and experiencing the consequences of those choices. Your game should have: A Story: Some kind of narrative that ties the game together. Choices: Points at which the player must...
def intro(): """ The introductory part of the game that sets the scene for the player. """ return "You find yourself in a dark forest. You can see a path to the north and a faint light to the east." def choose_path(choice): """ Handles the player's choice of path. Parameters: - choice (...
from solution import intro, choose_path, play_game def test_intro(): assert intro() == "You find yourself in a dark forest. You can see a path to the north and a faint light to the east." def test_choose_path_north(): assert choose_path("north") == "You walk north and encounter a wild bear. You try to run but...
[ { "docstring": "The introductory part of the game that sets the scene for the player.", "function_declaration": "def intro():", "function_name": "intro", "parameter_list": "()" }, { "docstring": "Handles the player's choice of path.\nParameters:\n- choice (str): The player's choice of direct...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def intro():\n \"\"\"\n The introductory part of the game that sets the scene for the player.\n \"\"\"\n return \"You find yourself in a dark forest. You can see a path to the nort...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00086556", "row_id": 86556, "seed_ids": "['gemma-2-27b-it_178895']" }
0.468092
Filter_86556
I
[ "intro", "choose_path", "play_game" ]
3
[ [ "play_game", "choose_path" ], [ "play_game", "intro" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c964e56d0766d1a9c20b7d58d3856f90b776af56
2f90ebf5a3b2dabfa45050243c3e5920178fcc5d
v1.0
instruct
Filter
Filter_86601_I
This is my Python code for solving a Sudoku puzzle: ```python def solve_sudoku(board): """ Solves a Sudoku puzzle using backtracking. Args: board: A 9x9 list of lists representing the Sudoku puzzle. Returns: True if a solution is found, False otherwise. """ for row in range(9...
def solve_sudoku(board): """ Solves a Sudoku puzzle using backtracking. Args: board: A 9x9 list of lists representing the Sudoku puzzle. Returns: True if a solution is found, False otherwise. """ for row in range(9): for col in range(9): if board[row][col] ...
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": "Solves a Sudoku puzzle using backtracking.\n\nArgs:\n board: A 9x9 list of lists representing the Sudoku puzzle.\n\nReturns:\n True if a solution is found, False otherwise.", "function_declaration": "def solve_sudoku(board):", "function_name": "solve_sudoku", "parameter_list": ...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def solve_sudoku(board):\n \"\"\"\n Solves a Sudoku puzzle using backtracking.\n\n Args:\n board: A 9x9 list of lists representing the Sudoku puzzle.\n\n Returns:\n T...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00086601", "row_id": 86601, "seed_ids": "['gemma-2-27b-it_179017']" }
0.473629
Filter_86601
I
[ "solve_sudoku", "is_valid" ]
2
[ [ "solve_sudoku", "is_valid" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2f1a077c717cbd9cb4c66e59f55698835d26a5b9
6e4c10d133983a90bf78d6ebd757b4d649aed637
v1.0
instruct
Filter
Filter_86604_I
Write a Python code to implement a simple calculator. Let the code include functions for: Addition: `add(x, y)` Subtraction: `subtract(x, y)` Multiplication: `multiply(x, y)` Division: `divide(x, y)` The code should ask the user for input, perform the desired operation, and print the result. Part 2: Ho...
def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): if y == 0: raise ValueError("Cannot divide by zero!") return x / y def calculator(): operation = input("Enter operation (+, -, *, /): ") x = float(input("Enter first nu...
from solution import add, subtract, multiply, divide def test_add(): assert add(1, 2) == 3 assert add(-1, -1) == -2 assert add(1.5, 2.5) == 4.0 def test_subtract(): assert subtract(3, 2) == 1 assert subtract(-1, -1) == 0 assert subtract(2.5, 1.5) == 1.0 def test_multiply(): assert mul...
[ { "docstring": null, "function_declaration": "def add(x, y):", "function_name": "add", "parameter_list": "(x, y)" }, { "docstring": null, "function_declaration": "def subtract(x, y):", "function_name": "subtract", "parameter_list": "(x, y)" }, { "docstring": null, "fu...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def add(x, y):\n \"\"\"\n Returns the sum of x and y.\n \"\"\"\n return x + y\n\ndef subtract(x, y):\n \"\"\"\n Returns the difference of x and y.\n \"\"\"\n return x -...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00086604", "row_id": 86604, "seed_ids": "['gemma-2-27b-it_179023']" }
0.581408
Filter_86604
I
[ "add", "subtract", "multiply", "divide", "calculator" ]
5
[ [ "calculator", "add" ], [ "calculator", "divide" ], [ "calculator", "multiply" ], [ "calculator", "subtract" ] ]
4
[]
false
[]
false
pytest
true
[]
true
5c55561ff12f0301f78d382021670f7811929ed6
635bdc55f1c17baf3d15961ee94ed0beff80e0f3
v1.0
instruct
Filter
Filter_86606_I
I need help in structuring a Python program to find the least common multiple (LCM) of three numbers using the GCD (Greatest Common Divisor) as the foundation.
import math def lcm(a, b): """ Returns the least common multiple of a and b. """ return abs(a * b) // math.gcd(a, b) def lcm_of_three(a, b, c): """ Returns the least common multiple of three numbers a, b, and c. """ return lcm(lcm(a, b), c)
from solution import lcm_of_three def test_lcm_of_three_positive_numbers(): assert lcm_of_three(4, 5, 6) == 60 def test_lcm_of_three_with_one(): assert lcm_of_three(4, 5, 1) == 20 def test_lcm_of_three_same_numbers(): assert lcm_of_three(3, 3, 3) == 3 def test_lcm_of_three_with_zero(): assert lcm_of...
[ { "docstring": "Returns the least common multiple of a and b.", "function_declaration": "def lcm(a, b):", "function_name": "lcm", "parameter_list": "(a, b)" }, { "docstring": "Returns the least common multiple of three numbers a, b, and c.", "function_declaration": "def lcm_of_three(a, b...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef lcm(x, y):\n \"\"\"\n Returns the least common multiple of x and y.\n \"\"\"\n return abs(x * y) // math.gcd(x, y)\n\ndef lcm_of_three(a, b, c):\n \"\"\"\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00086606", "row_id": 86606, "seed_ids": "['gemma-2-27b-it_179026']" }
0.617473
Filter_86606
I
[ "lcm", "lcm_of_three" ]
2
[ [ "lcm_of_three", "lcm" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d6bdcb497ff47bcad6df5f418d1a015f568e897c
003335d539b393060d7c5b4c9e031b6dccc16bc5
v1.0
instruct
Filter
Filter_86617_I
Here's a problem I'm trying to solve: I want to create a script that automatically generates flashcards for vocabulary words from a text file. Here are the specifications: 1. **Input:** A text file containing a list of vocabulary words, one word per line. 2. **Output:** A text file containing flashcards in the foll...
import requests def get_definition_example(word): """ Retrieve the definition and example sentence for a given word. This mock function returns a default definition and example sentence. Implement actual API call or web scraping to get real data. """ return { "definition": f"Definition ...
import os def test_get_definition_example(): result = get_definition_example('testword') assert type(result) is dict assert 'definition' in result assert 'example' in result assert result['definition'] == 'Definition of testword' assert result['example'] == 'Example sentence using testword.' d...
[ { "docstring": "Retrieve the definition and example sentence for a given word.\nThis mock function returns a default definition and example sentence.\nImplement actual API call or web scraping to get real data.", "function_declaration": "def get_definition_example(word):", "function_name": "get_definiti...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import requests\n\ndef get_definition_example(word):\n \"\"\"\n Retrieve the definition and example sentence for a given word.\n This mock function returns a default definition and ex...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00086617", "row_id": 86617, "seed_ids": "['gemma-2-27b-it_179043']" }
0.531245
Filter_86617
I
[ "get_definition_example", "generate_flashcards" ]
2
[ [ "generate_flashcards", "get_definition_example" ] ]
1
[]
false
[]
false
pytest
false
[ "requests" ]
false
ba320172d6572bc11c19539d4aff37469875d214
3148ab28a143dbad15927f5b477db7beb8184e08
v1.0
instruct
Filter
Filter_86646_I
The following are the rules for a simple game: * **Players:** 2 players * **Objective:** To have the highest score at the end of the game. * **Gameplay:** * Each player rolls a six-sided die. * The player with the higher roll gets 1 point. * If the players roll the same number, no points are awarded. *...
import random def roll_die(): """Simulates rolling a six-sided die.""" return random.randint(1, 6) def play_game(): """Plays a game of the simple dice game.""" player1_score = 0 player2_score = 0 while player1_score < 5 and player2_score < 5: roll1 = roll_die() roll2 = roll_di...
from solution import roll_die, play_game def test_roll_die(): for _ in range(100): result = roll_die() assert 1 <= result <= 6 def test_play_game(): result = play_game() assert result in ['Player 1', 'Player 2'] def test_randomness_of_roll(): rolls = [roll_die() for _ in range(1000)] ...
[ { "docstring": "Simulates rolling a six-sided die.", "function_declaration": "def roll_die():", "function_name": "roll_die", "parameter_list": "()" }, { "docstring": "Plays a game of the simple dice game.", "function_declaration": "def play_game():", "function_name": "play_game", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef roll_die():\n \"\"\"Simulates rolling a six-sided die.\"\"\"\n return random.randint(1, 6)\n\ndef play_game():\n \"\"\"Plays a game of the simple dice game.\"\"\"...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00086646", "row_id": 86646, "seed_ids": "['gemma-2-27b-it_179123']" }
0.598157
Filter_86646
I
[ "roll_die", "play_game" ]
2
[ [ "play_game", "roll_die" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cfec394b0ca9f3df3c4182585023daa60eeba4f9
1c8014322817be63e0a205a767f7fa1bc75836b0
v1.0
instruct
Filter
Filter_86706_I
You have been tasked with designing a simple quiz game. **Requirements:** * **Language:** Python * **Functionality:** * The game should ask the player multiple-choice questions. * It should keep track of the player's score. * **Questions:** You can use the following sample questions, or come up with your o...
def ask_question(question, options, correct_option): """ Asks a multiple-choice question and checks if the player's answer is correct. Args: question (str): The question to ask. options (list): A list of possible answer options. correct_option (str): The correct answer option. Returns: ...
import builtins from solution import ask_question, quiz_game def mock_input(mock): builtins.input = lambda _: mock.pop(0) def test_ask_question_correct(): mock_input(["3"]) assert ask_question("What is the capital of France?", ["Berlin", "Madrid", "Paris", "Rome"], "Paris") def test_ask_question_inco...
[ { "docstring": "Asks a multiple-choice question and checks if the player's answer is correct.\n\nArgs:\nquestion (str): The question to ask.\noptions (list): A list of possible answer options.\ncorrect_option (str): The correct answer option.\n\nReturns:\nbool: True if the player's answer is correct, otherwise ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def quiz_game(answers):\n \"\"\"\n Conducts a simple quiz game and returns the score.\n \n Parameters:\n answers (list): A list of integers representing the player's answers.\n\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00086706", "row_id": 86706, "seed_ids": "['gemma-2-27b-it_179333']" }
0.418726
Filter_86706
I
[ "ask_question", "quiz_game" ]
2
[ [ "quiz_game", "ask_question" ] ]
1
[]
false
[]
false
pytest
true
[]
true
73acf1fc6f615e30c50d217743589f69421521de
5bf41221f49fabf4445dad819adf0dd0fe083ec4
v1.0
instruct
Filter
Filter_86722_I
**Task:** Write a Python script that does the following: 1. Reads a text file containing a list of words, one word per line. 2. Counts the frequency of each word in the file. 3. Prints the words and their frequencies in descending order of frequency (most frequent first). Here is an example text file (example.txt):...
from collections import Counter def count_words(filename): """ Counts the frequency of words in a text file. Args: filename: The name of the text file. Returns: A dictionary where keys are words and values are their frequencies. """ word_counts = Counter() with open(filena...
import pytest from collections import Counter from solution import count_words, print_word_frequencies def test_count_words(tmp_path): # Create a temporary file test_file = tmp_path / "test.txt" test_file.write_text("apple\nbanana\napple\norange\nbanana\napple\n") expected_result = Counter({'apple...
[ { "docstring": "Counts the frequency of words in a text file.\n\nArgs:\n filename: The name of the text file.\n\nReturns:\n A dictionary where keys are words and values are their frequencies.", "function_declaration": "def count_words(filename):", "function_name": "count_words", "parameter_lis...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\n\ndef count_words(filename):\n \"\"\"\n Counts the frequency of words in a text file.\n\n Args:\n filename (str): The name of the text file.\n\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00086722", "row_id": 86722, "seed_ids": "['gemma-2-27b-it_179387']" }
0.778536
Filter_86722
I
[ "count_words", "print_word_frequencies" ]
2
[ [ "print_word_frequencies", "count_words" ] ]
1
[]
false
[]
false
pytest
true
[]
true
01f9eae893dde88bbd94a35de5174ba34e1c8446
3b8acd8ae58fec3f29a762be8faf2e9e005fb1c7
v1.0
instruct
Filter
Filter_86730_I
1: Write a function that takes a list of strings as input and returns a new list containing only the strings that are palindromes.
def is_palindrome(s): """ Returns True if the string s is a palindrome, False otherwise. """ return s == s[::-1] def filter_palindromes(strings): """ Returns a list containing only the palindromes from the input list of strings. """ return [s for s in strings if is_palindrome(s)]
from solution import is_palindrome, filter_palindromes def test_is_palindrome(): assert is_palindrome("racecar") == True assert is_palindrome("hello") == False assert is_palindrome("madam") == True assert is_palindrome("12321") == True assert is_palindrome("12345") == False def test_filter_palindr...
[ { "docstring": "Returns True if the string s is a palindrome, False otherwise.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Returns a list containing only the palindromes from the input list of strings.", ...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def filter_palindromes(strings):\n \"\"\"\n Returns a list of strings that are palindromes from the input list.\n \n Parameters:\n strings (list of str): The list of strings to ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00086730", "row_id": 86730, "seed_ids": "['gemma-2-27b-it_179410']" }
0.693144
Filter_86730
I
[ "is_palindrome", "filter_palindromes" ]
2
[ [ "filter_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
712d0ec6dc6166135ca45947a34741c17e64bde6
ba0a1e228bf2b9f9dbf2119f6cf7ba79cb1f4b4b
v1.0
instruct
Filter
Filter_86733_I
I have a set of data points, and I want to fit a curve to them using Python. Here's the breakdown: **Data:** I have a list containing data points in the form of **(x, y)** tuples. Example: ```python data = [(1, 2), (2, 5), (3, 10), (4, 17), (5, 26)] ``` **Goal:** I want to find a mathematical function that best...
import numpy as np import matplotlib.pyplot as plt from scipy.optimize import curve_fit def curve_function(x, a, b, c): return a * x ** 2 + b * x + c def fit_curve(data): # Extract X and Y values from the data X = np.array([point[0] for point in data]) Y = np.array([point[1] for point in data]) #...
from solution import fit_curve, curve_function def test_fit_curve(): data = [(1, 2), (2, 5), (3, 10), (4, 17), (5, 26)] params = fit_curve(data) # Use params to create the fitted values for the data points fitted_y_values = [curve_function(point[0], *params) for point in data] # The actual y value...
[ { "docstring": null, "function_declaration": "def curve_function(x, a, b, c):", "function_name": "curve_function", "parameter_list": "(x, a, b, c)" }, { "docstring": null, "function_declaration": "def fit_curve(data):", "function_name": "fit_curve", "parameter_list": "(data)" }...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy.optimize import curve_fit\n\n# Step 1: Define the data points\ndata = [(1, 2), (2, 5), (3, 10), (4, 17), (5, 26)]\n\n# Step 2: E...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00086733", "row_id": 86733, "seed_ids": "['gemma-2-27b-it_179414']" }
0.695623
Filter_86733
I
[ "curve_function", "fit_curve", "plot_curve" ]
3
[ [ "fit_curve", "curve_function" ], [ "plot_curve", "curve_function" ] ]
2
[]
false
[]
false
pytest
true
[ "matplotlib", "numpy", "scipy" ]
false
479dc0c31821ae80e52063960ce92f1254a6417d
f129e92a2fed4cbf46a76a7aa32215bf942a00ad
v1.0
instruct
Filter
Filter_86766_I
This project aims to build a Python program for a simple text-based adventure game. Requirements: Game World: The game world will consist of a few interconnected rooms. Player Actions: Players can move between rooms using commands like "north", "south", "east", "west". Players can interact with objects in roo...
def initialize_game(): rooms = { 'forest_clearing': { 'description': 'You are standing in a dimly lit forest clearing.', 'exits': {'north': 'dark_forest'}, 'objects': ['wooden_chest'] }, 'dark_forest': { 'description': 'You are in a dark forest...
import pytest from solution import initialize_game, execute_command def test_initialize_game(): rooms, player = initialize_game() assert 'forest_clearing' in rooms assert player['current_location'] == 'forest_clearing' assert player['inventory'] == [] def test_movement_north(): rooms, player = ini...
[ { "docstring": null, "function_declaration": "def initialize_game():", "function_name": "initialize_game", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def execute_command(command, rooms, player):", "function_name": "execute_command", "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 create_world():\n return {\n \"Forest Clearing\": {\n \"description\": \"You are standing in a dimly lit forest clearing. There is a path to the north and a small wood...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00086766", "row_id": 86766, "seed_ids": "['gemma-2-27b-it_179510']" }
0.437766
Filter_86766
I
[ "initialize_game", "execute_command", "describe_current_location", "game_loop" ]
4
[ [ "game_loop", "describe_current_location" ], [ "game_loop", "execute_command" ], [ "game_loop", "initialize_game" ] ]
3
[]
false
[]
false
pytest
true
[]
true
a5ba403b2ae264481636465625eba729363e549f
d6f25e639b5c01b8035420ea661a94a1377fa6e4
v1.0
instruct
Filter
Filter_86784_I
I want to create a script that downloads webpages from a list of URLs stored in a text file, download them and save them locally as HTML files. ```python import urllib.request # Function to download a webpage def download_webpage(url, filename): try: response = urllib.request.urlopen(url) html = ...
import urllib.request import urllib.parse import os # Function to download a webpage def download_webpage(url, filename): try: response = urllib.request.urlopen(url) html = response.read().decode('utf-8') with open(filename, 'w', encoding='utf-8') as f: f.write(html) pri...
import urllib.request import pytest from solution import download_webpage, sanitize_filename def test_sanitize_filename(): assert sanitize_filename("https://www.example.com/") == "www.example.com_.html" assert sanitize_filename("https://www.example.com/page?query=test") == "www.example.com_page_query=test.html...
[ { "docstring": null, "function_declaration": "def download_webpage(url, filename):", "function_name": "download_webpage", "parameter_list": "(url, filename)" }, { "docstring": null, "function_declaration": "def sanitize_filename(url):", "function_name": "sanitize_filename", "para...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import urllib.request\nimport urllib.parse\nimport os\n\n# Function to download a webpage\ndef download_webpage(url, filename):\n try:\n response = urllib.request.urlopen(url)\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00086784", "row_id": 86784, "seed_ids": "['gemma-2-27b-it_179570']" }
0.618572
Filter_86784
I
[ "download_webpage", "sanitize_filename", "download_from_urls_file" ]
3
[ [ "download_from_urls_file", "download_webpage" ], [ "download_from_urls_file", "sanitize_filename" ] ]
2
[]
false
[]
false
pytest
true
[]
true
15dbc82e95aa595b4804899d13f1ec5d866365a2
59c2bfca2f1dcb9b37f9583721210bd71f6329a8
v1.0
instruct
Filter
Filter_86800_I
These are the rules of a simple dice game: * Roll two six-sided dice. * If the sum is 7 or 11, you win! * If the sum is 2, 3, or 12, you lose. * If the sum is anything else, that sum becomes your "point". * Roll the dice again. * If you roll your "point", you win! * If you roll a 7, you lose. *Keep rolling until yo...
import random def roll_dice(): """ Rolls two six-sided dice and returns their sum. """ return random.randint(1, 6) + random.randint(1, 6) def play_game(): """ Simulates a single game of the dice game. Returns True if the player wins, False if the player loses. """ initial_roll ...
from solution import roll_dice, play_game, simulate_games def test_roll_dice(): for _ in range(100): result = roll_dice() assert 2 <= result <= 12 def test_play_game(): # It's tricky to test play_game directly because of the randomness. # We'll run it multiple times and expect both...
[ { "docstring": "Rolls two six-sided dice and returns their sum.", "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": "Simulates a single game of the dice game.\nReturns True if the player wins, False if the player loses.", "...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef roll_dice():\n \"\"\"\n Simulates rolling two six-sided dice and returns their sum.\n \"\"\"\n return random.randint(1, 6) + random.randint(1, 6)\n\ndef play_g...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00086800", "row_id": 86800, "seed_ids": "['gemma-2-27b-it_179614']" }
0.583565
Filter_86800
I
[ "roll_dice", "play_game", "simulate_games" ]
3
[ [ "play_game", "roll_dice" ], [ "simulate_games", "play_game" ] ]
2
[]
false
[]
false
pytest
true
[]
true
44d54f994ad979ea84f4514dfe331a4320778960
34a574750d6f0658f691f4601d079e13cd2f42d1
v1.0
instruct
Filter
Filter_86849_I
This program reads an integer from the user and prints all the prime numbers that are less than or equal to that integer. This program works by iterating through all numbers from 2 to the input integer. For each number, it checks if it is prime by dividing it by all numbers from 2 to the square root of the number. If t...
import math def is_prime(n): """ Returns True if n is a prime number, otherwise False. """ 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: retu...
from solution import is_prime, primes_up_to def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-1) == False assert is_prime(29) == True ...
[ { "docstring": "Returns True if n is a prime number, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of all prime numbers less than or equal to n.", "function_declaration": "def primes_u...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Determines if a number is prime.\n \n Args:\n n (int): The number to check.\n \n Returns:\n bool: True if the number is prime, False otherwi...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00086849", "row_id": 86849, "seed_ids": "['gemma-2-27b-it_179759']" }
0.661774
Filter_86849
I
[ "is_prime", "primes_up_to" ]
2
[ [ "primes_up_to", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1b8d510629a8fd9f8387228b8d52517f52720f43
9694674c74b33b12cb54301c6e1cb5b0575460f5
v1.0
instruct
Filter
Filter_86857_I
There are n players participating in a knockout tournament. Every player has a unique id from 1 to n. In each round, the players are paired randomly If a player wins a round, they advance to the next round. If they lose, they are eliminated. Rounds continue until only one player remains, who is declared the champion. ...
import random def pair_players(players): """ Pairs players randomly for the round. If there is an odd number of players, one player will randomly get a bye to the next round. Args: players (list): List of player IDs. Returns: list: List of tuples, each containing a pair of player...
from solution import pair_players, simulate_matches, knockout_tournament def test_pair_players_even(): players = [1, 2, 3, 4] pairs, bye = pair_players(players) assert len(pairs) == 2 assert len(bye) == 0 for p1, p2 in pairs: assert p1 in [1, 2, 3, 4] and p2 in [1, 2, 3, 4] def test_pair_p...
[ { "docstring": "Pairs players randomly for the round. If there is an odd number of players, \none player will randomly get a bye to the next round.\n\nArgs:\nplayers (list): List of player IDs.\n\nReturns:\nlist: List of tuples, each containing a pair of player IDs.\nlist: List of player IDs who got a bye.", ...
[ 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 pair_players(players):\n \"\"\"\n Pairs players randomly for the round. If there is an odd number of players, \n one player will randomly get a bye to the next ro...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00086857", "row_id": 86857, "seed_ids": "['gemma-2-27b-it_179774']" }
0.446988
Filter_86857
I
[ "pair_players", "simulate_matches", "knockout_tournament" ]
3
[ [ "knockout_tournament", "pair_players" ], [ "knockout_tournament", "simulate_matches" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a20de21dab1ed0c41190d1d46afc1d99c38b816a
f25fa12776e50d37be50c99c287819c2d56b07d8
v1.0
instruct
Filter
Filter_86875_I
2D-Plot: The plot should show a 2D view of a 3D object rotating around the Y-axis. 3D-Plot: The rotating object should be displayed as a 3D object Please provide the Python code for both **2D projection** and **3D plot** implementations in Matplotlib. **Notes:** * Use Matplotlib's ** `animation` module** to create...
import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import matplotlib.animation as animation import numpy as np def generate_cube(): """ Generate coordinates for a cube. """ # Create a 3D array of points points = np.array([[-1, -1, -1], [ 1, -1, -1], ...
from solution import generate_cube, animate_cube_2d, animate_cube_3d def test_generate_cube(): points, edges = generate_cube() assert points.shape == (8, 3), "Cube should have 8 vertices with 3 dimensions each." assert len(edges) == 12, "Cube should have 12 edges." def test_animate_cube_2d(): # Check ...
[ { "docstring": "Generate coordinates for a cube.", "function_declaration": "def generate_cube():", "function_name": "generate_cube", "parameter_list": "()" }, { "docstring": "Create a 2D projection animation of a rotating cube.", "function_declaration": "def animate_cube_2d():", "fun...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d import Axes3D\nimport matplotlib.animation as animation\nimport numpy as np\n\n# Function to create a cube's vertices and edges\ndef ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00086875", "row_id": 86875, "seed_ids": "['gemma-2-27b-it_179825']" }
0.505259
Filter_86875
I
[ "generate_cube", "animate_cube_2d", "animate_cube_3d" ]
3
[ [ "animate_cube_2d", "generate_cube" ], [ "animate_cube_3d", "generate_cube" ] ]
2
[]
false
[]
false
pytest
true
[ "matplotlib", "mpl_toolkits", "numpy" ]
false
e22338983d014c0de226a5f2e588340bb735799b
4d83b5424e12e081ca9b3c4ba686d645bd2c1ed4
v1.0
instruct
Filter
Filter_86895_I
This problem statement describes a scenario where there are different types of fruit baskets, each containing a different combination of fruits. For example: * Basket 1: 2 Apples, 3 Bananas * Basket 2: 1 Apple, 2 Bananas, 1 Orange Here's the problem: You are given a list of fruit baskets containing various fruits. ...
def basket_weight(basket, fruit_weights): """ Calculate the total weight of a basket by summing the weights of its fruits. Args: basket (dict): A dictionary where keys are fruit names and values are quantities. fruit_weights (dict): A dictionary where keys are fruit names and values are their weigh...
from solution import basket_weight, find_heaviest_basket def test_basket_weight(): fruit_weights = {"Apple": 10, "Banana": 5, "Orange": 8} basket = {"Apple": 2, "Banana": 3} assert basket_weight(basket, fruit_weights) == 35 basket = {"Apple": 1, "Banana": 2, "Orange": 1} assert basket_weight(baske...
[ { "docstring": "Calculate the total weight of a basket by summing the weights of its fruits.\n\nArgs:\nbasket (dict): A dictionary where keys are fruit names and values are quantities.\nfruit_weights (dict): A dictionary where keys are fruit names and values are their weights.\n\nReturns:\nint: The total weight...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_max_weight_basket(baskets, fruit_weights):\n \"\"\"\n Finds the basket with the maximum combined weight.\n \n Parameters:\n baskets (list of dict): List of dictionaries...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00086895", "row_id": 86895, "seed_ids": "['gemma-2-27b-it_179908']" }
0.614691
Filter_86895
I
[ "basket_weight", "find_heaviest_basket" ]
2
[ [ "find_heaviest_basket", "basket_weight" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1ccfd201d96f5fc86db649ba09f3e85d5f067304
a8bb986ffb6f84e7d258cb4c3e629d9338e3a849
v1.0
instruct
Filter
Filter_86918_I
Create a Python program that takes a list of strings as input and returns a new list containing only the strings that are palindromes.
def is_palindrome(s): """ Returns True if the string s is a palindrome, False otherwise. """ return s == s[::-1] def filter_palindromes(strings): """ Filters a list of strings and returns a new list containing only the strings that are palindromes. """ return [s for s in strings if is_p...
from solution import filter_palindromes def test_no_palindromes(): assert filter_palindromes(["hello", "world", "python"]) == [] def test_all_palindromes(): assert filter_palindromes(["madam", "racecar", "level"]) == ["madam", "racecar", "level"] def test_mixed_strings(): assert filter_palindromes(["mada...
[ { "docstring": "Returns True if the string s is a palindrome, False otherwise.", "function_declaration": "def is_palindrome(s):", "function_name": "is_palindrome", "parameter_list": "(s)" }, { "docstring": "Filters a list of strings and returns a new list containing only the strings that are...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(s):\n \"\"\"\n Checks if a string is a palindrome.\n \"\"\"\n return s == s[::-1]\n\ndef filter_palindromes(strings):\n \"\"\"\n Filters palindromes from a ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00086918", "row_id": 86918, "seed_ids": "['gemma-2-27b-it_179961']" }
0.740228
Filter_86918
I
[ "is_palindrome", "filter_palindromes" ]
2
[ [ "filter_palindromes", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
551ead2f2d7d43625dec91e54a2a9b26f1130f5b
f0220c095bf6d2a186e30feaeb165941341aaa62
v1.0
instruct
Filter
Filter_86978_I
The game "Tic-Tac-Toe" is a strategy board game in which two players take turns placing their marks on a 3x3 grid. **Objective:** The goal of Tic-Tac-Toe is to be the first player to get three of their marks in a row **Rules:** * Two players take turns placing their marks (usually "X" and "O") on the grid. * Player...
import random def print_board(board): """ Prints the current state of the board. """ for row in board: print(" | ".join(row)) print("-" * 5) def check_winner(board, mark): """ Checks if there is a winner with the given mark. """ for row in board: if all([cell ==...
from solution import print_board, check_winner, get_empty_positions, make_move, is_board_full def test_check_winner_horizontal(): board = [ ["X", "X", "X"], [" ", "O", " "], ["O", " ", " "] ] assert check_winner(board, "X") == True def test_check_winner_vertical(): board = [ ...
[ { "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 with the given mark.", "function_declaration": "def check_winner(board, m...
[ 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 print_board(board):\n \"\"\"\n Prints the tic-tac-toe board.\n \"\"\"\n for row in board:\n print(\" | \".join(row))\n print(\"-\" * 5)\n\ndef ch...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00086978", "row_id": 86978, "seed_ids": "['gemma-2-27b-it_180110']" }
0.49307
Filter_86978
I
[ "print_board", "check_winner", "get_empty_positions", "make_move", "is_board_full", "user_move", "computer_move", "play_game" ]
8
[ [ "computer_move", "get_empty_positions" ], [ "computer_move", "make_move" ], [ "play_game", "check_winner" ], [ "play_game", "computer_move" ], [ "play_game", "is_board_full" ], [ "play_game", "print_board" ], [ "play_game", "user_move...
9
[]
false
[]
false
pytest
true
[]
true
d8d042b94629cc0eb15ada239ada4a02a94fbdcc
bf42cc3fdcbd8f9ad604ad618f404337d78030cd
v1.0
instruct
Filter
Filter_86980_I
Here are some basic rules of the game 2048: * The game occurs on a 4x4 grid. * Initially, two tiles with the value 2 are placed randomly on the grid. * Player uses arrow keys (up, down, left, right) to move all tiles on the grid in that direction. * Tiles merge if they have the same value and slide towards the directi...
import random def get_new_tile(): """Randomly returns either 2 or 4 (with the probabilities of 90% and 10% respectively).""" return 2 if random.random() < 0.9 else 4 def create_empty_board(): """Create starting 4x4 board filled with 0's representing empty cells.""" return [[0 for _ in range(4)] for _ ...
import random import pytest from solution import get_new_tile, create_empty_board, add_new_tile, move_left, move_right, move_up, move_down def test_get_new_tile(): # Check distribution samples = [get_new_tile() for _ in range(1000)] assert all(tile in [2, 4] for tile in samples) assert 0.8 <= samples....
[ { "docstring": "Randomly returns either 2 or 4 (with the probabilities of 90% and 10% respectively).", "function_declaration": "def get_new_tile():", "function_name": "get_new_tile", "parameter_list": "()" }, { "docstring": "Create starting 4x4 board filled with 0's representing empty cells....
[ 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_new_tile():\n \"\"\"Randomly returns a new tile with value 2 or 4 (90% chance for 2, 10% chance for 4).\"\"\"\n return 2 if random.random() < 0.9 else 4\n\ndef c...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00086980", "row_id": 86980, "seed_ids": "['gemma-2-27b-it_180119']" }
0.490998
Filter_86980
I
[ "get_new_tile", "create_empty_board", "add_new_tile", "compress_and_merge_row_left", "move_left", "reverse", "transpose", "move_right", "move_up", "move_down" ]
10
[ [ "add_new_tile", "get_new_tile" ], [ "move_down", "move_right" ], [ "move_down", "transpose" ], [ "move_left", "compress_and_merge_row_left" ], [ "move_right", "compress_and_merge_row_left" ], [ "move_right", "reverse" ], [ "move_up", ...
8
[]
false
[]
false
pytest
true
[]
true
edd106650bad2d8803407cd8750335e331a4ff54
a51ac430e9f6ce8400f820a5d8b88e48b5bbb489
v1.0
instruct
Filter
Filter_86998_I
This code: ```python def calculate_discount(price, discount_percentage): return price - (price * (discount_percentage / 100)) items = { 'apple': 1.0, 'banana': 0.5, 'orange': 0.75 } for item, price in items.items(): discount = calculate_discount(price, 10) print(f"{item}: Original price: ${price:.2f}, Di...
def calculate_discount(price, discount_percentage): """ Returns the price after applying the discount. """ return price - (price * (discount_percentage / 100)) items = { 'apple': 1.0, 'banana': 0.5, 'orange': 0.75 } def get_discounted_price(item_name, discount_percentage): """ Give...
from solution import calculate_discount, get_discounted_price import pytest def test_calculate_discount(): assert calculate_discount(100, 10) == 90 assert calculate_discount(50, 50) == 25 assert calculate_discount(0, 10) == 0 assert calculate_discount(100, 0) == 100 def test_get_discounted_price(): ...
[ { "docstring": "Returns the price after applying the discount.", "function_declaration": "def calculate_discount(price, discount_percentage):", "function_name": "calculate_discount", "parameter_list": "(price, discount_percentage)" }, { "docstring": "Given an item name and discount percentag...
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "Magpie-Filter-89K_sanitized_prepared1_results_combined.jsonl", "solution_code": "def calculate_discount(price, discount_percentage):\n \"\"\"\n Returns the price after applying the discount.\n \"\"\"\n return price - (price * (discount_...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00086998", "row_id": 86998, "seed_ids": "['gemma-2-27b-it_180178']" }
0.502953
Filter_86998
I
[ "calculate_discount", "get_discounted_price" ]
2
[ [ "get_discounted_price", "calculate_discount" ] ]
1
[]
false
[]
false
pytest
true
[]
true
66a39825a4dd74f98e54589c917baa31fd7b038f
f305d7cfdecd522e20283ca69a927178defa8ee8
v1.0
instruct
Filter
Filter_87018_I
Here are the rules to our simplified version of rock, paper, scissors: **Players take turns:** Player 1 goes first. **Options:** Paper covers Rock, Rock crushes Scissors, Scissors cuts Paper **Winning:** * The winner is the first player to win 3 rounds. * A round is won by choosing the option that defeats the op...
def determine_winner(player1_choice, player2_choice): """ Determines the winner of a single rock-paper-scissors round. Returns: - "Player 1" if Player 1 wins the round. - "Player 2" if Player 2 wins the round. - "Draw" if the round is a draw. """ winning_combinations = { 'rock': ...
from solution import determine_winner, play_game def test_determine_winner(): assert determine_winner('rock', 'scissors') == "Player 1" assert determine_winner('scissors', 'rock') == "Player 2" assert determine_winner('paper', 'rock') == "Player 1" assert determine_winner('rock', 'paper') == "Player 2"...
[ { "docstring": "Determines the winner of a single rock-paper-scissors round.\nReturns:\n- \"Player 1\" if Player 1 wins the round.\n- \"Player 2\" if Player 2 wins the round.\n- \"Draw\" if the round is a draw.", "function_declaration": "def determine_winner(player1_choice, player2_choice):", "function_...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def determine_winner(player1_choice, player2_choice):\n \"\"\"\n Determines the winner of a single round of Rock, Paper, Scissors.\n Returns 1 if Player 1 wins, 2 if Player 2 wins, 0 ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00087018", "row_id": 87018, "seed_ids": "['gemma-2-27b-it_180231']" }
0.484905
Filter_87018
I
[ "determine_winner", "play_game" ]
2
[ [ "play_game", "determine_winner" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4a30be2822380cdcdcacec0a33bb529411cf10ac
6058e249c9d6afe7bdcde2cf13dfd78579efaa58
v1.0
instruct
Filter
Filter_87042_I
This seems like a simple task, but it's proving more difficult than I thought. I need to write a Python program that reads a text file and counts the number of syllables in each word. There are pre-trained models that can do this, e.g., **textblob**. It's more of an exercise for me to learn how to do this from scra...
def count_syllables(word): """ Counts the number of syllables in a word. """ vowels = "aeiouy" count = 0 word = word.lower().strip(".:;?!,") # Handle punctuation gracefully if len(word) == 0: return 0 if word[0] in vowels: count += 1 for i in range(1, len(word)): ...
import pytest from solution import count_syllables def test_count_syllables_simple(): assert count_syllables("simple") == 2 assert count_syllables("test") == 1 assert count_syllables("syllable") == 3 assert count_syllables("count") == 1 def test_count_syllables_with_punctuation(): assert count_syl...
[ { "docstring": "Counts the number of syllables in a word.", "function_declaration": "def count_syllables(word):", "function_name": "count_syllables", "parameter_list": "(word)" }, { "docstring": "Reads a text file and counts the number of syllables in each word.", "function_declaration":...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_syllables(word):\n \"\"\"\n Count the number of syllables in a word.\n \n Args:\n word (str): The word to count syllables in.\n \n Returns:\n int:...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00087042", "row_id": 87042, "seed_ids": "['gemma-2-27b-it_180296']" }
0.659821
Filter_87042
I
[ "count_syllables", "analyze_text" ]
2
[ [ "analyze_text", "count_syllables" ] ]
1
[]
false
[]
false
pytest
true
[]
true
24686493b0618885fb64cb7c638dd31534054875
e801890bb6acaf1b67e1209cd3ad715a5a935e07
v1.0
instruct
Filter
Filter_87062_I
The problem set asks for a code solution for the following: **Problem:** You are a delivery person bringing groceries to people's homes. Your objective is to deliver all the groceries to their rightful owners as quickly as possible, optimizing for the shortest delivery path. You are provided with the following inpu...
from typing import List, Dict, Tuple def distance(start: Tuple[int, int], end: Tuple[int, int]) -> float: """ Calculates the Euclidean distance between two points start and end. """ return ((start[0] - end[0]) ** 2 + (start[1] - end[1]) ** 2) ** 0.5 def optimize_delivery_route(orders: List[Dict[str, T...
from solution import optimize_delivery_route def test_optimize_delivery_route_simple_case(): orders = [ {"order_id": 1, "location": (1, 2)}, {"order_id": 2, "location": (5, 3)}, {"order_id": 3, "location": (2, 1)} ] starting_location = (0, 0) assert optimize_delivery_route(order...
[ { "docstring": "Calculates the Euclidean distance between two points start and end.", "function_declaration": "def distance(start, end):", "function_name": "distance", "parameter_list": "(start, end)" }, { "docstring": "Returns the optimized delivery route based on the shortest delivery path...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def optimize_delivery_route(orders, starting_location):\n \"\"\"\n Returns the optimal order of deliveries based on the shortest path.\n \n :param orders: List of orders, where eac...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00087062", "row_id": 87062, "seed_ids": "['gemma-2-27b-it_180358']" }
0.605538
Filter_87062
I
[ "distance", "optimize_delivery_route" ]
2
[ [ "optimize_delivery_route", "distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bc465c26af8e36eaa3b249e4fd115600f05f23eb
bedb9175c917d2f926d3fd42082ef4cf8f94e3bc
v1.0
instruct
Filter
Filter_87066_I
This program reads a string from the user. Then, for each unique character in the string, it prints the count of that character.
def count_characters(s): """ Returns a dictionary with the count of each unique character in the string s. """ char_count = {} for char in s: if char in char_count: char_count[char] += 1 else: char_count[char] = 1 return char_count def print_character_cou...
from solution import count_characters, print_character_counts def test_count_empty_string(): assert count_characters("") == {} def test_count_single_character(): assert count_characters("a") == {"a": 1} def test_count_multiple_characters(): assert count_characters("abca") == {"a": 2, "b": 1, "c": 1} def...
[ { "docstring": "Returns a dictionary with the count of each unique character in the string s.", "function_declaration": "def count_characters(s):", "function_name": "count_characters", "parameter_list": "(s)" }, { "docstring": "Prints the count of each unique character in the string s.", ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_unique_characters(s):\n \"\"\"\n Prints the count of each unique character in the string s.\n \"\"\"\n character_count = {}\n for char in s:\n if char in charac...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00087066", "row_id": 87066, "seed_ids": "['gemma-2-27b-it_180368']" }
0.678109
Filter_87066
I
[ "count_characters", "print_character_counts" ]
2
[ [ "print_character_counts", "count_characters" ] ]
1
[]
false
[]
false
pytest
true
[]
true
cfd68e7aa8b4ec40a03639ef8df5352deaed2739
5a2e17bce47a6d91942db5ca7cb5ca150d7c881d
v1.0
instruct
Filter
Filter_87077_I
The following code defines a function to calculate permutations of a string. ```python import itertools def permutations(string): #Using itertools.permutations return list(itertools.permutations(string)) ``` The code relies on the `itertools.permutations` function to generate all possible permutations of the gi...
import itertools def permutations(string): """ Generate all permutations of the input string. Args: string (str): The input string to permute. Returns: list: A list of tuples with all permutations of the input string. """ return list(itertools.permutations(string)) def find_p...
from solution import permutations, find_permutation def test_permutations_length(): result = permutations('abc') assert len(result) == 6 assert ('a', 'b', 'c') in result assert ('c', 'b', 'a') in result def test_find_permutation_exists(): assert find_permutation('abc', 'bca') == True assert fi...
[ { "docstring": "Generate all permutations of the input string.\n\nArgs:\nstring (str): The input string to permute.\n\nReturns:\nlist: A list of tuples with all permutations of the input string.", "function_declaration": "def permutations(string):", "function_name": "permutations", "parameter_list":...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import itertools\n\ndef permutations(string):\n \"\"\"\n Generate all permutations of a string.\n :param string: Input string to permute.\n :return: List of all permutations as str...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00087077", "row_id": 87077, "seed_ids": "['gemma-2-27b-it_180398']" }
0.586249
Filter_87077
I
[ "permutations", "find_permutation" ]
2
[ [ "find_permutation", "permutations" ] ]
1
[]
false
[]
false
pytest
true
[]
true
41efe35de8a6b69d7229772fde40cb66590f5101
69248d6d1e4e9b77f166bc4e2dd9e2c490c69adc
v1.0
instruct
Filter
Filter_87101_I
Here's what we want to do: * Generate a text file containing 10 random passwords. * **Each password should be 12 characters long and contain:** * At least one uppercase letter. * At least one lowercase letter. * At least one number. * At least one special character (!@
import random import string def generate_password(): """ Generate a 12-character password that contains at least one lowercase letter, one uppercase letter, one digit, and one special character. """ password_chars = [ random.choice(string.ascii_lowercase), random.choice(string.ascii...
from solution import generate_password, generate_passwords_file import os def test_generate_password_length(): password = generate_password() assert len(password) == 12 def test_generate_password_contains_uppercase(): password = generate_password() assert any(c.isupper() for c in password) def test_g...
[ { "docstring": "Generate a 12-character password that contains at least one lowercase letter,\none uppercase letter, one digit, and one special character.", "function_declaration": "def generate_password():", "function_name": "generate_password", "parameter_list": "()" }, { "docstring": "Gen...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport string\n\ndef generate_password():\n \"\"\"\n Generate a random password 12 characters long containing at least one \n uppercase letter, one lowercase letter, on...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00087101", "row_id": 87101, "seed_ids": "['gemma-2-27b-it_180465']" }
0.642717
Filter_87101
I
[ "generate_password", "generate_passwords_file" ]
2
[ [ "generate_passwords_file", "generate_password" ] ]
1
[]
false
[]
false
pytest
true
[]
true
bef4c86d8cc186dba1576b47ed4d69238524b0d8
35c2ca1c8276c31db692ca8d56d3f7069c3c0291
v1.0
instruct
Filter
Filter_87135_I
. Write a Python code snippet that reads from a file, counts the occurrences of each word, and then prints the five most frequent words.
from collections import Counter def count_words_in_file(file_path): """ Reads a file, counts the occurrences of each word, and returns the five most frequent words. Parameters: file_path (str): The path to the file to be read. Returns: list: A list of tuples, each containing a word an...
from solution import count_words_in_file, print_most_frequent_words import tempfile def test_count_words_in_file(): test_text = "apple orange orange banana banana banana" with tempfile.NamedTemporaryFile(delete=False, mode='w+') as temp_file: temp_file.write(test_text) temp_file_path = temp_fil...
[ { "docstring": "Reads a file, counts the occurrences of each word, and returns the five most frequent words.\n\nParameters:\nfile_path (str): The path to the file to be read.\n\nReturns:\nlist: A list of tuples, each containing a word and its frequency, with the most frequent words first.", "function_declar...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\n\ndef count_words(file_path):\n \"\"\"\n Reads from the specified file and counts the occurrences of each word,\n then prints the five most frequent w...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00087135", "row_id": 87135, "seed_ids": "['gemma-2-27b-it_180549']" }
0.710541
Filter_87135
I
[ "count_words_in_file", "print_most_frequent_words" ]
2
[ [ "print_most_frequent_words", "count_words_in_file" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7f417e13b0c743f73f4cf3b584880398685d4244
6ff30b53b7d2e623694cc3c391c637efdf790e86
v1.0
instruct
Filter
Filter_87151_I
Problem Statement: You are given a list of tuples, each representing a point in a 2-dimensional space. Write a function that takes this list as input and returns the area of the convex hull of these points. Explanation: The convex hull of a set of points is the smallest convex polygon that contains all the points. ...
from itertools import combinations def cross(o, a, b): """ Cross product of the vectors OA and OB. A positive cross product indicates a counter-clockwise turn, a negative one indicates a clockwise turn, and zero indicates a collinear point. """ return (a[0] - o[0]) * (b[1] - o[1]) - (a[1]...
from solution import calculate_convex_hull_area def test_simple_case(): points = [(0, 0), (1, 5), (5, 1), (4, 4)] assert calculate_convex_hull_area(points) == 16 def test_square(): points = [(0, 0), (0, 2), (2, 0), (2, 2)] assert calculate_convex_hull_area(points) == 4 def test_triangle(): points...
[ { "docstring": "Cross product of the vectors OA and OB.\nA positive cross product indicates a counter-clockwise turn, \na negative one indicates a clockwise turn, \nand zero indicates a collinear point.", "function_declaration": "def cross(o, a, b):", "function_name": "cross", "parameter_list": "(o,...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from typing import List, Tuple\n\ndef calculate_convex_hull_area(points: List[Tuple[int, int]]) -> float:\n \"\"\"\n Calculate the area of the convex hull for a given list of 2D points.\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00087151", "row_id": 87151, "seed_ids": "['gemma-2-27b-it_180596']" }
0.486852
Filter_87151
I
[ "cross", "convex_hull", "polygon_area", "calculate_convex_hull_area" ]
4
[ [ "calculate_convex_hull_area", "convex_hull" ], [ "calculate_convex_hull_area", "polygon_area" ], [ "convex_hull", "cross" ] ]
3
[]
false
[]
false
pytest
true
[]
true
41cc940d94335b2b17f14dc6731e2fd4d62aff02
12e566c25fb23b8fb0befa09a8f0d30c8f9a0252
v1.0
instruct
Filter
Filter_87152_I
For the questions related to programming: Use Python as the programming language. Assume all necessary standard libraries are imported. Questions: 1. Write a function called `reverse_string` that takes a string as input and returns the reversed version of that string. 2. Write a function called `is_palindrome...
def reverse_string(s): """ Returns the reversed version of the input string s. """ return s[::-1] def is_palindrome(s): """ Returns True if the input string s is a palindrome, False otherwise. """ return s == reverse_string(s) def is_palindrome_case_insensitive(s): """ Returns ...
from solution import reverse_string, is_palindrome, is_palindrome_case_insensitive def test_reverse_string(): assert reverse_string("hello") == "olleh" assert reverse_string("abcd") == "dcba" assert reverse_string("") == "" assert reverse_string("a") == "a" def test_is_palindrome(): assert is_pali...
[ { "docstring": "Returns the reversed version 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_declarati...
[ 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 Reverses the input string s.\n \"\"\"\n return s[::-1]\n\ndef is_palindrome(s):\n \"\"\"\n Checks if the input string s is a palindrome.\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00087152", "row_id": 87152, "seed_ids": "['gemma-2-27b-it_180602']" }
0.738663
Filter_87152
I
[ "reverse_string", "is_palindrome", "is_palindrome_case_insensitive" ]
3
[ [ "is_palindrome", "reverse_string" ], [ "is_palindrome_case_insensitive", "reverse_string" ] ]
2
[]
false
[]
false
pytest
true
[]
true
96d701b7f87fb62780f6765f06b68246e7a8609f
b696c077ae70156296d35704963731a1f8be74c3
v1.0
instruct
Filter
Filter_87155_I
The problem I'm trying to solve is: I need to find the most common **word-pair** in a given text. **Here's what I've tried so far:** 1. **Splitting the text into words and iterating:** ```python from collections import Counter text = "This is a simple text This text has text here" words = text.lower().s...
import re from collections import Counter def preprocess_text(text): """ Preprocess the text by converting to lowercase and removing punctuation. """ text = text.lower() text = re.sub(r'[^\w\s]', '', text) # Remove punctuation return text def most_common_word_pair(text): """ Returns t...
from solution import preprocess_text, most_common_word_pair def test_preprocess_text(): assert preprocess_text("Hello, World!") == "hello world" assert preprocess_text("It's a-test!") == "its atest" def test_most_common_word_pair(): text = "This is a simple text This text has text here" assert most_co...
[ { "docstring": "Preprocess the text by converting to lowercase and removing punctuation.", "function_declaration": "def preprocess_text(text):", "function_name": "preprocess_text", "parameter_list": "(text)" }, { "docstring": "Returns the most common word pair in the given text, regardless o...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from collections import Counter\nimport re\n\ndef most_common_word_pair(text):\n # Remove punctuation and convert to lowercase\n text = re.sub(r'[^\\w\\s]', '', text).lower()\n words ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00087155", "row_id": 87155, "seed_ids": "['gemma-2-27b-it_180608']" }
0.739592
Filter_87155
I
[ "preprocess_text", "most_common_word_pair" ]
2
[ [ "most_common_word_pair", "preprocess_text" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1751ef7793242f7e03a328c0361833bc00eed87b
16fbe02c04053335e6a433efff0fa378e5a808ab
v1.0
instruct
Filter
Filter_87204_I
This program aims to simulate the classic card game 'War', played between two players. Here's how War works: 1. **Card Ranking:** Cards are ranked from Ace (highest), King, Queen, Jack, 10, 9, ..., 2 (lowest). 2. **Gameplay:** * Each player starts with half the deck of cards shuffled randomly. * Players simultane...
import random def create_deck(): """Creates a standard 52-card deck.""" suits = ["Hearts", "Diamonds", "Spades", "Clubs"] ranks = ["Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"] deck = [(rank, suit) for rank in ranks for suit in suits] return deck def shuffle(deck): ...
from solution import create_deck, shuffle, deal, card_value, compare_cards, war_game def test_create_deck(): deck = create_deck() assert len(deck) == 52 assert ("Ace", "Hearts") in deck assert ("King", "Diamonds") in deck assert ("2", "Clubs") in deck assert ("10", "Spades") in deck def test_s...
[ { "docstring": "Creates a standard 52-card deck.", "function_declaration": "def create_deck():", "function_name": "create_deck", "parameter_list": "()" }, { "docstring": "Shuffles the deck of cards.", "function_declaration": "def shuffle(deck):", "function_name": "shuffle", "para...
[ 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 create_deck():\n \"\"\"Creates a standard 52-card deck.\"\"\"\n suits = [\"Hearts\", \"Diamonds\", \"Spades\", \"Clubs\"]\n ranks = [\"Ace\", \"2\", \"3\", \"4\",...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00087204", "row_id": 87204, "seed_ids": "['gemma-2-27b-it_180751']" }
0.571357
Filter_87204
I
[ "create_deck", "shuffle", "deal", "card_value", "compare_cards", "war_game" ]
6
[ [ "compare_cards", "card_value" ], [ "war_game", "compare_cards" ], [ "war_game", "create_deck" ], [ "war_game", "deal" ], [ "war_game", "shuffle" ] ]
5
[]
false
[]
false
pytest
true
[]
true
bc796eabb18c3a6759722a58a6af088ac90475f9
27fda207298f493bed63d10aaa5d29ee8e68baa8
v1.0
instruct
Filter
Filter_87248_I
This is a code for finding the nth prime number. ```python 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 find_nth_prime(n): count = 0 num = 2 while count < n: if is_prime(num): ...
def is_prime(n): """ Determines if a number n is prime. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False for i in range(3, int(n**0.5) + 1, 2): if n % i == 0: return False return True def find_nth_prime(n): ""...
from solution import is_prime, find_nth_prime # Tests for is_prime function def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(5) == True assert is_prime(4) == False assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-1) == False ...
[ { "docstring": "Determines if a number n is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Finds the nth prime number efficiently.", "function_declaration": "def find_nth_prime(n):", "function_name": "find_...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def sieve_nth_prime(n):\n \"\"\"\n Returns the nth prime number using the Sieve of Eratosthenes algorithm.\n \"\"\"\n if n < 1:\n raise ValueError(\"n must be a positive int...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00087248", "row_id": 87248, "seed_ids": "['gemma-2-27b-it_180862']" }
0.687733
Filter_87248
I
[ "is_prime", "find_nth_prime" ]
2
[ [ "find_nth_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
93fd5f9212101471a54b17738781277d0c701eac
871255a2bbde980c89d0667b897a1e2f6a32ee07
v1.0
instruct
Filter
Filter_87262_I
This is a coding challenge where you need to translate an array of strings representing Roman numerals to their integer representations. **Example:** ``` romanToInt(["III", "IV", "IX", "LVIII", "MCMXCIV"]) ``` Should return: ``` [3, 4, 9, 58, 1994] ``` **Rules:** * Your solution should be written in Python. * Yo...
def romanToInt(s): """ Convert a single Roman numeral string to an integer. """ roman = { 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000 } s = s.upper() # Handle lowercase by converting to uppercase total = 0 prev_value = 0 for char in s: ...
from solution import romanToInt, romanArrayToInt def test_single_roman_1(): assert romanToInt("I") == 1 def test_single_roman_4(): assert romanToInt("IV") == 4 def test_single_roman_9(): assert romanToInt("IX") == 9 def test_single_roman_58(): assert romanToInt("LVIII") == 58 def test_single_roman_...
[ { "docstring": "Convert a single Roman numeral string to an integer.", "function_declaration": "def romanToInt(s):", "function_name": "romanToInt", "parameter_list": "(s)" }, { "docstring": "Convert an array of Roman numeral strings to their integer representations.", "function_declarati...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def roman_to_int(s):\n \"\"\"\n Converts a single Roman numeral string to an integer.\n \"\"\"\n roman_values = {\n 'I': 1, 'V': 5, 'X': 10, 'L': 50, \n 'C': 100, 'D'...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00087262", "row_id": 87262, "seed_ids": "['gemma-2-27b-it_180907']" }
0.718011
Filter_87262
I
[ "romanToInt", "romanArrayToInt" ]
2
[ [ "romanArrayToInt", "romanToInt" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d7c2cec98cb3c23c8841bb1c468e68c93bedf362
17f6925c4a90676471eae54b68c0cfdb312b18dd
v1.0
instruct
Filter
Filter_87267_I
This is a recipe for brownies: **Ingredients:** * 1/2 cup (1 stick) unsalted butter, softened * 1 cup granulated sugar * 2 large eggs * 1 teaspoon pure vanilla extract * 1/2 cup unsweetened cocoa powder * 1/2 cup all-purpose flour * 1/4 teaspoon salt * 1/2 cup chocolate chips **Instructions:** 1. Preheat oven to 35...
import re def parse_ingredient_amount(amount_str): frac_map = { "1/2": 0.5, "1/3": 1/3, "1/4": 0.25, "1/8": 0.125, "2/3": 2/3, "3/4": 0.75, "3/8": 0.375, "2/5": 0.4, "3/5": 0.6, "4/5": 0.8, "5/6": 5/6 } for frac, val in frac_map.items(): amount_str = amount_str.replace(...
from solution import scale_recipe def test_half_recipe(): expected = { "butter": "0.25 cup", "sugar": "0.5 cup", "eggs": "1.0 large", "vanilla": "0.5 teaspoon", "cocoa": "0.25 cup", "flour": "0.25 cup", "salt": "0.125 teaspoon", "chocolate_chips": "0....
[ { "docstring": null, "function_declaration": "def parse_ingredient_amount(amount_str):", "function_name": "parse_ingredient_amount", "parameter_list": "(amount_str)" }, { "docstring": null, "function_declaration": "def scale_ingredient(amount_str, factor):", "function_name": "scale_i...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def scale_recipe(scale_factor):\n \"\"\"\n Scales the recipe by the given scale factor.\n \"\"\"\n recipe = {\n \"unsalted butter\": \"1/2 cup\",\n \"granulated sugar...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00087267", "row_id": 87267, "seed_ids": "['gemma-2-27b-it_180916']" }
0.483178
Filter_87267
I
[ "parse_ingredient_amount", "scale_ingredient", "scale_recipe" ]
3
[ [ "scale_ingredient", "parse_ingredient_amount" ], [ "scale_recipe", "scale_ingredient" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5f0e89bc3dd6156c9f25437dec22c7cd2cb29690
00f3f9dad24f2b80373f7f7d1c9d767730a152e9
v1.0
instruct
Filter
Filter_87302_I
For a 2D game, I'm trying to generate random dungeon rooms (using an 2D array). ```python import random # Dungeon parameters room_size = 5 # Size of each room # Function to generate a room def generate_room(size): # Create a 2D array of the specified size, filled with '.' (empty space) room = [['.' for _ in...
import random # Dungeon parameters room_size = 5 # Size of each room # Function to generate a room def generate_room(size): # Create a 2D array of the specified size, filled with '.' (empty space) room = [['.' for _ in range(size)] for _ in range(size)] # Code to add walls (e.g., 'W' characters) wou...
from solution import generate_room, assemble_dungeon def test_generate_room(): room = generate_room(5) assert len(room) == 5 assert all(len(row) == 5 for row in room) assert all(cell == '.' for row in room for cell in row) def test_assemble_dungeon_size(): width, height = 10, 15 dungeon = asse...
[ { "docstring": null, "function_declaration": "def generate_room(size):", "function_name": "generate_room", "parameter_list": "(size)" }, { "docstring": "Assembles a dungeon composed of multiple rooms.\n\nParameters:\n- width: Total width of the dungeon in terms of cells.\n- height: Total hei...
[ 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\n# Dungeon parameters\nroom_size = 5 # Size of each room\n\n# Function to generate a room\ndef generate_room(size):\n # Create a 2D array of the specified size, filled with...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00087302", "row_id": 87302, "seed_ids": "['gemma-2-27b-it_181020']" }
0.612583
Filter_87302
I
[ "generate_room", "assemble_dungeon" ]
2
[ [ "assemble_dungeon", "generate_room" ] ]
1
[]
false
[]
false
pytest
true
[]
true
08b4d6b06fca51f12238d77f6ee8d815b5a2b812
53b89ef6a49c90b228fb8f324557403725331628
v1.0
instruct
Filter
Filter_87341_I
We will develop a program in Python that sorts a list of numbers using the HeapSort algorithm.
def heapify(arr, n, i): """ Helper function to maintain the heap property of a subtree with node i at root """ largest = i # Initialize largest as root left = 2 * i + 1 # left = 2*i + 1 right = 2 * i + 2 # right = 2*i + 2 # If left child is larger than root if left < n and arr[i] ...
from solution import heap_sort def test_heap_sort_empty(): assert heap_sort([]) == [] def test_heap_sort_single_element(): assert heap_sort([1]) == [1] def test_heap_sort_sorted(): assert heap_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5] def test_heap_sort_reverse_sorted(): assert heap_sort([5, 4, 3, 2,...
[ { "docstring": "Helper function to maintain the heap property of a subtree with node i at root", "function_declaration": "def heapify(arr, n, i):", "function_name": "heapify", "parameter_list": "(arr, n, i)" }, { "docstring": "Main function to sort an array using HeapSort algorithm", "fu...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def heapify(arr, n, i):\n \"\"\"\n Converts the subtree rooted at index i into a max heap, assuming that \n the subtrees are already heaps.\n \"\"\"\n largest = i\n left = 2 ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00087341", "row_id": 87341, "seed_ids": "['gemma-2-27b-it_181141']" }
0.638289
Filter_87341
I
[ "heapify", "heap_sort" ]
2
[ [ "heap_sort", "heapify" ] ]
1
[]
false
[]
false
pytest
true
[]
true
20e32811ae96161546a1d47679cbfbc899a10ee4
36db82586ddd1bafaacdc32a2365304ac275d940
v1.0
instruct
Filter
Filter_87350_I
[Text Description of a 3D Object]The object is a cube, which is completely filled with miniature versions of itself. The mini cubes inside are all facing the same direction, and they are arranged in a perfect grid. Each mini cube is also filled with identical miniature cubes, and so on. This pattern continues infinite...
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D def create_fractal_cube(level, size=1.0, position=(0, 0, 0)): """ Creates the vertices of a fractal cube up to a certain level of detail. Args: - level (int): The depth of the fractal. - size (float): Th...
from solution import create_fractal_cube def test_single_level_fractal(): result = create_fractal_cube(level=0, size=1.0, position=(0, 0, 0)) assert result == [(0, 0, 0)] def test_two_level_fractal(): result = create_fractal_cube(level=1, size=1.0, position=(0, 0, 0)) expected_positions = [ (-...
[ { "docstring": "Creates the vertices of a fractal cube up to a certain level of detail.\n\nArgs:\n- level (int): The depth of the fractal.\n- size (float): The size of the initial cube.\n- position (tuple): The position of the center of the cube.\n\nReturns:\n- A list of tuples, where each tuple represents the ...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d import Axes3D\n\ndef create_fractal_cube(level, size=1.0, position=(0, 0, 0)):\n \"\"\"\n Creates the verti...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00087350", "row_id": 87350, "seed_ids": "['gemma-2-27b-it_181160']" }
0.355391
Filter_87350
I
[ "create_fractal_cube", "animate_fractal_cube", "draw_cube" ]
3
[ [ "animate_fractal_cube", "create_fractal_cube" ], [ "animate_fractal_cube", "draw_cube" ] ]
2
[]
false
[]
false
pytest
true
[ "matplotlib", "mpl_toolkits", "numpy" ]
false
6987db56cb74c4afc67c6dd79e10187e69f395b8
e3c5196de66d7c5125fec329c1ae33410e702653
v1.0
instruct
Filter
Filter_87371_I
My goal is build. to build an AI that can solve a variety of logic puzzles. I'm starting with Sudoku. **Current Steps:** 1. **Represent Sudoku as Data:** I'll use a 2D array (list of lists) to store Sudoku grid. 2. **Implement Backtracking Algorithm:** Backtracking is a classic algorithm for solving Sudoku. * Sta...
def is_valid(board, row, col, num): """ Check if num can be placed at board[row][col] following Sudoku rules. """ for i in range(9): if board[row][i] == num or board[i][col] == num: return False start_row, start_col = 3 * (row // 3), 3 * (col // 3) for i in range(start_r...
from solution import is_valid, find_empty_location, solve_sudoku def test_is_valid(): board = [ [5, 3, 0, 0, 7, 0, 0, 0, 0], [6, 0, 0, 1, 9, 5, 0, 0, 0], [0, 9, 8, 0, 0, 0, 0, 6, 0], [8, 0, 0, 0, 6, 0, 0, 0, 3], [4, 0, 0, 8, 0, 3, 0, 0, 1], [7, 0, 0, 0, 2, 0, 0, 0, 6...
[ { "docstring": "Check if num can be placed at board[row][col] following Sudoku rules.", "function_declaration": "def is_valid(board, row, col, num):", "function_name": "is_valid", "parameter_list": "(board, row, col, num)" }, { "docstring": "Find an empty location in the Sudoku board.\nRetur...
[ 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 \"\"\"\n Check if num can be placed on board[row][col]\n \"\"\"\n # Check row\n for c in range(9):\n if board[row][c] == num:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00087371", "row_id": 87371, "seed_ids": "['gemma-2-27b-it_181218']" }
0.500315
Filter_87371
I
[ "is_valid", "find_empty_location", "solve_sudoku" ]
3
[ [ "solve_sudoku", "find_empty_location" ], [ "solve_sudoku", "is_valid" ] ]
2
[]
false
[]
false
pytest
true
[]
true
1cdf1e1792a4f8023b99afb16797d710cf2b243d
58cb29285ff0b75b664ddf7d81567bb2900e2611
v1.0
instruct
Filter
Filter_87378_I
```python from random import randint def roll_dice(sides): return randint(1, sides) # Main game loop while True: input("Press Enter to roll a die...") # Generate a random number result = roll_dice(6) # Print the result print(f"You rolled a {result}") ``` This script simulates rolling a six-sided die....
from random import randint def roll_dice(sides): """Generate a random number between 1 and the number of sides on the die.""" return randint(1, sides) def choose_sides(): """Ask the user to input the number of sides for the die.""" while True: user_input = input("How many sides should the die ...
from solution import roll_dice def test_roll_dice(): sides = 6 results = [roll_dice(sides) for _ in range(1000)] for result in results: assert 1 <= result <= 6 def test_roll_dice_different_sides(): sides = 20 results = [roll_dice(sides) for _ in range(1000)] for result in results: ...
[ { "docstring": "Generate a random number between 1 and the number of sides on the die.", "function_declaration": "def roll_dice(sides):", "function_name": "roll_dice", "parameter_list": "(sides)" }, { "docstring": "Ask the user to input the number of sides for the die.", "function_declar...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from random import randint\n\ndef roll_dice(sides):\n return randint(1, sides)\n\ndef main():\n while True:\n user_input = input(\"How many sides should the die have? (Enter 'q' t...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00087378", "row_id": 87378, "seed_ids": "['gemma-2-27b-it_181231']" }
0.521009
Filter_87378
I
[ "roll_dice", "choose_sides", "main_game_loop" ]
3
[ [ "main_game_loop", "choose_sides" ], [ "main_game_loop", "roll_dice" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6dd12086a0708d28da2256c9762438fac2dec9fa
c14df2e8f8621cf3de4e7a68a3185a0b6867f706
v1.0
instruct
Filter
Filter_87383_I
This script will be used to simulate coin flips. ```python import random def flip_coin(): """Simulates a coin flip and returns the result as 'Heads' or 'Tails'. Returns: str: 'Heads' or 'Tails' """ if random.randint(0, 1) == 0: return 'Heads' else: return 'Tails' # Example usage: times_t...
import random def flip_coin(): """ Simulates a coin flip and returns the result as 'Heads' or 'Tails'. Returns: str: 'Heads' or 'Tails' """ if random.randint(0, 1) == 0: return 'Heads' else: return 'Tails' def simulate_coin_flips(num_flips): """ Simulates flipp...
import pytest from solution import flip_coin, simulate_coin_flips def test_flip_coin(): results = [flip_coin() for _ in range(1000)] heads_count = results.count('Heads') tails_count = results.count('Tails') assert heads_count + tails_count == 1000 assert abs(heads_count - tails_count) < 100 # Roug...
[ { "docstring": "Simulates a coin flip and returns the result as 'Heads' or 'Tails'.\n\nReturns:\n str: 'Heads' or 'Tails'", "function_declaration": "def flip_coin():", "function_name": "flip_coin", "parameter_list": "()" }, { "docstring": "Simulates flipping a coin a specified number of t...
[ 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 flip_coin():\n \"\"\"\n Simulates a coin flip and returns the result as 'Heads' or 'Tails'.\n\n Returns:\n str: 'Heads' or 'Tails'\n \"\"\"\n if rand...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00087383", "row_id": 87383, "seed_ids": "['gemma-2-27b-it_181245']" }
0.481258
Filter_87383
I
[ "flip_coin", "simulate_coin_flips" ]
2
[ [ "simulate_coin_flips", "flip_coin" ] ]
1
[]
false
[]
false
pytest
true
[]
true
724c9d9c3cd005bccdd4ae6bbecf1349be5c5877
2005664b89954e6445b900b06160258cc44312d4
v1.0
instruct
Filter
Filter_87447_I
This code defines two functions: * **`calculate_price()`**: This function takes two arguments: * `cost`: This represents the base cost of an item. * `tax_percentage`: This represents the decimal form of the tax percentage to be applied. The function calculates the final price of the item by adding...
def calculate_price(cost, tax_percentage): """Calculates the final price of an item including tax.""" tax_amount = cost * tax_percentage return cost + tax_amount def print_receipt(item_name, cost, tax_percentage): """Prints a formatted receipt for an item.""" price = calculate_price(cost, tax_perce...
from io import StringIO import sys import pytest from solution import calculate_price, print_receipt def test_calculate_price_no_tax(): assert calculate_price(100, 0) == 100 def test_calculate_price_with_tax(): assert calculate_price(100, 0.1) == 110 def test_calculate_price_high_tax(): assert calculate_...
[ { "docstring": "Calculates the final price of an item including tax.", "function_declaration": "def calculate_price(cost, tax_percentage):", "function_name": "calculate_price", "parameter_list": "(cost, tax_percentage)" }, { "docstring": "Prints a formatted receipt for an item.", "functi...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_price(cost, tax_percentage):\n \"\"\"Calculates the final price of an item including tax.\"\"\"\n tax_amount = cost * tax_percentage\n return cost + tax_amount\n\ndef pr...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00087447", "row_id": 87447, "seed_ids": "['gemma-2-27b-it_181473']" }
0.460969
Filter_87447
I
[ "calculate_price", "print_receipt" ]
2
[ [ "print_receipt", "calculate_price" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c4989b472402682df962b95070f27f3925dfe800
f9b3979c261f2ae30b7df1461715e3d23deff389