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_475_I
# Give me an extension of the existing Python code to add a new functionality of generating a report based on the existing repository on a specific date. Here is an existing Python code that generates a report for a specific month: ```python import calendar import datetime from typing import List from dataclasses imp...
import calendar import datetime from typing import List from dataclasses import dataclass @dataclass class Commit: date: datetime.date changes: int @dataclass class Repository: commits: List[Commit] def get_commits_for_month(commits: List[Commit], month: int, year: int) -> List[Commit]: return [commi...
from solution import Commit, Repository, generate_report_for_date import datetime def test_generate_report_for_date_single_commit(): commits = [Commit(date=datetime.date(2022, 1, 1), changes=10)] report = generate_report_for_date(commits, datetime.date(2022, 1, 1)) expected_report = "Report for 2022-01-01:...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_report_for_date(commits: List[Commit], date: datetime.date) -> str:\n commits_for_date = get_commits_for_date(commits, date)\n num_commits = len(commits_for_date)\n total...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00000475", "row_id": 475, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1237']" }
0.488496
Filter_475
I
[ "get_commits_for_month", "get_commits_for_date", "generate_report", "generate_report_for_date", "main" ]
5
[ [ "generate_report", "get_commits_for_month" ], [ "generate_report_for_date", "get_commits_for_date" ] ]
2
[]
false
[ "Commit", "Repository" ]
true
pytest
true
[]
true
3208d46d374bec35951af4489498701c6c341eb4
6a02691e38456158ecfba74f27c54e43f7978a3b
v1.0
instruct
Filter
Filter_490_I
def merge_sort(arr): if len(arr) <= 1: return arr mid = len(arr) // 2 left = merge_sort(arr[:mid]) right = merge_sort(arr[mid:]) return merge(left, right) def merge(left, right): result = [] i = j = 0 while i < len(left) and j < len(right): if left[i] <= right[j]: ...
def merge_sort(arr): """ Sorts an array in ascending order using the merge sort algorithm. Parameters: arr (list): The list of elements to be sorted. Returns: list: The sorted list. """ if len(arr) <= 1: return arr mid = len(arr) // 2 left = merge_sort(arr[:mid]) ...
from solution import merge_sort def test_merge_sort_with_unsorted_array(): assert merge_sort([6, 5, 3, 1, 8, 7, 2, 4]) == [1, 2, 3, 4, 5, 6, 7, 8] def test_merge_sort_with_empty_array(): assert merge_sort([]) == [] def test_merge_sort_with_single_element_array(): assert merge_sort([1]) == [1] def test_m...
[ { "docstring": "Sorts an array in ascending order using the merge sort algorithm.\n\nParameters:\narr (list): The list of elements to be sorted.\n\nReturns:\nlist: The sorted list.", "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }, { ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def merge_sort(arr):\n \"\"\"\n Sorts an array using the merge sort algorithm.\n \n Parameters:\n arr (list): The list to be sorted.\n \n Returns:\n list: A...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000490", "row_id": 490, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1283']" }
0.633631
Filter_490
I
[ "merge_sort", "merge" ]
2
[ [ "merge_sort", "merge" ] ]
1
[]
false
[]
false
pytest
true
[]
true
73fa7df252722a8013432a23b84b3adf597606ad
669ce2b372b90afd4c810ccb4ff0265da627d33b
v1.0
instruct
Filter
Filter_498_I
### Problem You are given a list of strings in which each string represents a URL. The URLs have the following format: <protocol>://<domain>/<path>, where <protocol> is either "http" or "https," <domain> is any sequence of alphanumeric characters, dots, and underscores, and <path> is any sequence of alphanumeric charac...
import re def extract_domain(url): """ Extracts the domain from a given URL using regular expression. Args: url (str): A single URL string. Returns: str: The domain extracted from the URL. """ match = re.match(r'https?://([^/]+)/.*', url) return match.group(1) if m...
from solution import get_missing_domains def test_get_missing_domains(): # Test case 1 urls = ["http://example.com/path/to/resource", "https://example.com/path/to/another/resource", "http://test.com/path/to/resource"] all_possible_domains = ["example.com", "test.com", "another.com"] expected_missing = ...
[ { "docstring": "Extracts the domain from a given URL using regular expression.\n\nArgs:\n url (str): A single URL string.\n\nReturns:\n str: The domain extracted from the URL.", "function_declaration": "def extract_domain(url):", "function_name": "extract_domain", "parameter_list": "(url)" }...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\nfrom urllib.parse import urlparse\n\ndef get_missing_domains(urls, all_possible_domains):\n \"\"\"\n This function takes a list of URLs as input, extracts the domains from the...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000498", "row_id": 498, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1304']" }
0.713093
Filter_498
I
[ "extract_domain", "get_missing_domains" ]
2
[ [ "get_missing_domains", "extract_domain" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9cf515c575683f1eea94cbed934cfd0a9a8a2f38
7128cdbc8b441138626884164ac455dcb6854785
v1.0
instruct
Filter
Filter_501_I
import math def calculate_total_area_of_circles(radius): total_area = math.pi * radius ** 2 return total_area radius = float(input("Enter the radius of the circle: ")) print("The area of the circle is", calculate_total_area_of_circles(radius)) This program calculates the area of a single circle. I need to ex...
import math def calculate_area_of_circle(radius): """ Returns the area of a circle given its radius. """ return math.pi * radius ** 2 def calculate_total_area_of_circles(radii): """ Returns the total area of multiple circles given a list of radii. """ total_area = 0 for radius in r...
from solution import calculate_area_of_circle, calculate_total_area_of_circles def test_calculate_area_of_circle(): assert math.isclose(calculate_area_of_circle(1), math.pi, rel_tol=1e-9) assert math.isclose(calculate_area_of_circle(0), 0, rel_tol=1e-9) assert math.isclose(calculate_area_of_circle(2), 4 * ...
[ { "docstring": "Returns the area of a circle given its radius.", "function_declaration": "def calculate_area_of_circle(radius):", "function_name": "calculate_area_of_circle", "parameter_list": "(radius)" }, { "docstring": "Returns the total area of multiple circles given a list of radii.", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef calculate_area_of_circle(radius):\n \"\"\"\n Returns the area of a circle given its radius.\n \"\"\"\n return math.pi * radius ** 2\n\ndef calculate_total_area_o...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00000501", "row_id": 501, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1315']" }
0.469038
Filter_501
I
[ "calculate_area_of_circle", "calculate_total_area_of_circles" ]
2
[ [ "calculate_total_area_of_circles", "calculate_area_of_circle" ] ]
1
[]
false
[]
false
pytest
true
[]
true
0f390cde319e5a139120aa761cdf0fc09fc36b38
479ea44e8607a9e29ce9e41ccc97e79b751e17c5
v1.0
instruct
Filter
Filter_506_I
def factorial(n): if n == 0: return 1 else: return n * factorial(n - 1) def sum_factorials(numbers): return sum(factorial(n) for n in numbers) numbers = [1, 2, 3, 4, 5] result = sum_factorials(numbers) print(result)
def factorial(n): """ Returns the factorial of a non-negative integer n. """ if n == 0: return 1 else: return n * factorial(n - 1) def sum_factorials(numbers): """ Returns the sum of the factorials of a list of non-negative integers. """ return sum(factorial(n) for n...
from solution import factorial, sum_factorials def test_factorial_base_case(): assert factorial(0) == 1 def test_factorial_recursive_case(): assert factorial(1) == 1 assert factorial(2) == 2 assert factorial(3) == 6 assert factorial(4) == 24 assert factorial(5) == 120 def test_sum_factorials_...
[ { "docstring": "Returns the factorial of a non-negative integer n.", "function_declaration": "def factorial(n):", "function_name": "factorial", "parameter_list": "(n)" }, { "docstring": "Returns the sum of the factorials of a list of non-negative integers.", "function_declaration": "def ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def factorial(n):\n \"\"\"\n Returns the factorial of n.\n \"\"\"\n if n == 0:\n return 1\n else:\n return n * factorial(n - 1)\n\ndef sum_factorials(numbers):\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000506", "row_id": 506, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1327']" }
0.730861
Filter_506
I
[ "factorial", "sum_factorials" ]
2
[ [ "sum_factorials", "factorial" ] ]
1
[]
false
[]
false
pytest
true
[]
true
83e0fff694ac1aac8719924e9bceaf98e925c889
e4633e6c5b8a33975130a018ab4956449d214eb3
v1.0
instruct
Filter
Filter_528_I
# Problem You are given a grid of squares, where some of the squares are filled with water. The grid can be represented as a 2D array where 0s are water squares and 1s are land squares. The goal is to count the number of islands in the grid. # Example Input: ``` [ [1, 1, 1, 1, 0], [1, 1, 0, 1, 0], [1, 1, 0, 0, 0...
def numIslands(grid): if not grid: return 0 count = 0 for i in range(len(grid)): for j in range(len(grid[0])): if grid[i][j] == 1: dfs(grid, i, j) count += 1 return count def dfs(grid, i, j): if i < 0 or j < 0 or i >= len(grid) or j >= le...
from solution import numIslands def test_numIslands_single_island(): grid = [ [1, 1, 1, 1, 0], [1, 1, 0, 1, 0], [1, 1, 0, 0, 0], [0, 0, 0, 0, 0] ] assert numIslands(grid) == 1 def test_numIslands_multiple_islands(): grid = [ [1, 1, 0, 0, 0], [1, 1, 0, 0,...
[ { "docstring": null, "function_declaration": "def numIslands(grid):", "function_name": "numIslands", "parameter_list": "(grid)" }, { "docstring": null, "function_declaration": "def dfs(grid, i, j):", "function_name": "dfs", "parameter_list": "(grid, i, j)" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def numIslands(grid):\n if not grid:\n return 0\n\n count = 0\n for i in range(len(grid)):\n for j in range(len(grid[0])):\n if grid[i][j] == 1:\n ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00000528", "row_id": 528, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1384']" }
0.604478
Filter_528
I
[ "numIslands", "dfs" ]
2
[ [ "numIslands", "dfs" ] ]
1
[]
false
[]
false
pytest
true
[]
true
18780975427f796bf8a307674b149182b9a18c50
7c22f10c9b6136699bfe2f8534d79cc15491a9ae
v1.0
instruct
Filter
Filter_529_I
import datetime import math import re def calculate_age(born): today = datetime.date.today() return today.year - born.year - ((today.month, today.day) < (born.month, born.day)) def parse_date_from_string(date_string): return datetime.datetime.strptime(date_string, '%Y-%m-%d').date() def check_password_st...
import datetime import math import re def calculate_age(born): today = datetime.date.today() return today.year - born.year - ((today.month, today.day) < (born.month, born.day)) def parse_date_from_string(date_string): return datetime.datetime.strptime(date_string, '%Y-%m-%d').date() def check_password_st...
import datetime from solution import calculate_age, parse_date_from_string, is_password_strong, is_password_weak, calculate_square_root def test_calculate_age(): born = datetime.date(1995, 12, 17) assert calculate_age(born) == datetime.datetime.now().year - 1995 - (datetime.datetime.now().timetuple().tm_yday <...
[ { "docstring": null, "function_declaration": "def calculate_age(born):", "function_name": "calculate_age", "parameter_list": "(born)" }, { "docstring": null, "function_declaration": "def parse_date_from_string(date_string):", "function_name": "parse_date_from_string", "parameter_...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import datetime\nimport math\nimport re\n\ndef calculate_age(born):\n today = datetime.date.today()\n return today.year - born.year - ((today.month, today.day) < (born.month, born.day))\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00000529", "row_id": 529, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1386']" }
0.567134
Filter_529
I
[ "calculate_age", "parse_date_from_string", "check_password_strength", "is_password_strong", "is_password_weak", "calculate_square_root" ]
6
[ [ "is_password_strong", "check_password_strength" ], [ "is_password_weak", "check_password_strength" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b80ad96146aa8f7e4cc6ab8f90afec5c8b5b5dac
7fab5ef0ad4512d83cc0266e2892c0fd7f65a7fb
v1.0
instruct
Filter
Filter_556_I
def check_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 largest_prime_factor(n): max_prime_factor = None for i in range(2, n + 1): if n % i == 0 and check_prime(i): max_prime_factor =...
def check_prime(n): """ Returns True if the number is prime, 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 largest_prime_factor(n): """ Returns the largest prime factor of the given num...
from solution import check_prime, largest_prime_factor, largest_prime_factor_sieve, largest_prime_factor_iterative def test_check_prime(): assert check_prime(2) == True assert check_prime(3) == True assert check_prime(4) == False assert check_prime(29) == True assert check_prime(1) == False ass...
[ { "docstring": "Returns True if the number is prime, else False.", "function_declaration": "def check_prime(n):", "function_name": "check_prime", "parameter_list": "(n)" }, { "docstring": "Returns the largest prime factor of the given number n.", "function_declaration": "def largest_prim...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def check_prime(n):\n \"\"\"\n Returns True if n is a prime number, otherwise False.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n i...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000556", "row_id": 556, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1455']" }
0.737221
Filter_556
I
[ "check_prime", "largest_prime_factor", "largest_prime_factor_sieve", "largest_prime_factor_iterative" ]
4
[ [ "largest_prime_factor", "check_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1284fab8e3dcdc2242f154f6ae35f2afeb9f5278
12f95888213685abe7eeae9da141e0b96830e596
v1.0
instruct
Filter
Filter_563_I
def intersection(lst1, lst2): return [value for value in lst1 if value in lst2] def union(lst1, lst2): return lst1 + [value for value in lst2 if value not in lst1] def difference(lst1, lst2): return [value for value in lst1 if value not in lst2] def symmetric_difference(lst1, lst2): return union(diff...
def intersection(lst1, lst2): """ Returns a list containing all elements that are in both lst1 and lst2. """ return [value for value in lst1 if value in lst2] def union(lst1, lst2): """ Returns a list containing all unique elements that are in lst1 or lst2. """ return lst1 + [value for ...
from solution import intersection, union, difference, symmetric_difference def test_intersection(): assert intersection([1, 2, 3], [2, 3, 4]) == [2, 3] assert intersection([1, 2, 3], [4, 5, 6]) == [] assert intersection([], [1, 2, 3]) == [] assert intersection([1, 2, 3], []) == [] def test_union(): ...
[ { "docstring": "Returns a list containing all elements that are in both lst1 and lst2.", "function_declaration": "def intersection(lst1, lst2):", "function_name": "intersection", "parameter_list": "(lst1, lst2)" }, { "docstring": "Returns a list containing all unique elements that are in lst...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def intersection(lst1, lst2):\n \"\"\"\n Returns a list containing all elements that are in both lst1 and lst2.\n \"\"\"\n return [value for value in lst1 if value in lst2]\n\ndef ...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00000563", "row_id": 563, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1479']" }
0.579171
Filter_563
I
[ "intersection", "union", "difference", "symmetric_difference" ]
4
[ [ "symmetric_difference", "difference" ], [ "symmetric_difference", "union" ] ]
2
[]
false
[]
false
pytest
true
[]
true
50029a47c30ee4ad51b0963a900ae671add6cbca
f0baf48f9446056608d4f378d78e6fa054e8cdec
v1.0
instruct
Filter
Filter_596_I
def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False return True def gcd(a, b): while b: a, b = b, a % b ...
def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False return True def gcd(a, b): while b: a, b = b, a % b ...
from solution import is_prime, gcd, example_function import pytest def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(11) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-3) == False def tes...
[ { "docstring": null, "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def gcd(a, b):", "function_name": "gcd", "parameter_list": "(a, b)" }, { "docstring": null, "function...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n max_divisor = int(n**0.5) + 1\n for d in range(3, ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000596", "row_id": 596, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1597']" }
0.747717
Filter_596
I
[ "is_prime", "gcd", "example_function" ]
3
[ [ "example_function", "gcd" ], [ "example_function", "is_prime" ] ]
2
[]
false
[]
false
pytest
true
[]
true
554eec8e864878ba740a6ba80b802dd18bc5d76a
a11737e3b4b9c379508e1a3a3545e95cdda858d7
v1.0
instruct
Filter
Filter_607_I
def largest_number(nums): nums.sort(reverse=True) return int("".join(map(str, nums))) print(largest_number([3, 6, 9])) print(largest_number([10, 3])) print(largest_number([1, 2, 3])) print(largest_number([5, 5, 5]))
from functools import cmp_to_key def compare(x, y): return (y + x > x + y) - (y + x < x + y) def largest_number(nums): if not nums: return '0' # Convert the integers in the list to strings nums_str = map(str, nums) # Sort the list based on the custom comparator nums_str_sorte...
from solution import largest_number def test_single_digit_nums(): assert largest_number([3, 6, 9]) == "963" def test_mixed_digit_nums(): assert largest_number([10, 3]) == "310" def test_ascending_order_nums(): assert largest_number([1, 2, 3]) == "321" def test_same_digit_nums(): assert largest_numbe...
[ { "docstring": null, "function_declaration": "def compare(x, y):", "function_name": "compare", "parameter_list": "(x, y)" }, { "docstring": null, "function_declaration": "def largest_number(nums):", "function_name": "largest_number", "parameter_list": "(nums)" } ]
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from functools import cmp_to_key\n\ndef compare(x, y):\n return (y + x > x + y) - (y + x < x + y)\n\ndef largest_number(nums):\n if not nums:\n return '0'\n \n # Convert the...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00000607", "row_id": 607, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1631']" }
0.759436
Filter_607
I
[ "compare", "largest_number" ]
2
[ [ "largest_number", "compare" ] ]
1
[]
false
[]
false
pytest
true
[]
true
77de8c787e2850c6ff39df78575add2cb36f90c1
dc9a912ab91799acde1df83a8fe57334aeef0cbd
v1.0
instruct
Filter
Filter_613_I
We have a function that returns a random number between two values, inclusive. The function is already implemented and we should not modify it. The range of the values is not known to us. The function is called `getRandomNumber(a, b)`. We need to write another function that generates a random number within a given rang...
import random def getRandomNumber(a, b): """ This function is assumed to generate a random number between a and b inclusive. Here we simulate some returns for illustration due to the lack of actual implementation details. """ if a > b: raise ValueError("Invalid range: a should not be great...
from solution import getRandomNumberInRange, getRandomNumber def test_getRandomNumberInRange_normal_case(monkeypatch): def mock_getRandomNumber(a, b): return 5 monkeypatch.setattr('solution.getRandomNumber', mock_getRandomNumber) result = getRandomNumberInRange(1, 10) assert result ==...
[ { "docstring": "This function is assumed to generate a random number between a and b inclusive. \nHere we simulate some returns for illustration due to the lack of actual implementation details.", "function_declaration": "def getRandomNumber(a, b):", "function_name": "getRandomNumber", "parameter_li...
[ 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 getRandomNumber(a, b):\n \"\"\"\n This function is assumed to generate a random number between a and b inclusive. \n Here we simulate some returns for illustratio...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00000613", "row_id": 613, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1651']" }
0.502435
Filter_613
I
[ "getRandomNumber", "getRandomNumberInRange" ]
2
[ [ "getRandomNumberInRange", "getRandomNumber" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c9043ff5cabb3ca5701ff60696bfca95bb407d02
29c8ba024727334c07a61646743670100f882afc
v1.0
instruct
Filter
Filter_624_I
This is the quicksort algorithm in Python, implemented as a recursive function: ```python def quicksort(arr): if len(arr) <= 1: return arr pivot = arr[len(arr) // 2] left = [x for x in arr if x < pivot] middle = [x for x in arr if x == pivot] right = [x for x in arr if x > pivot] retu...
def partition(arr, low, high): pivot = arr[high] i = low - 1 for j in range(low, high): if arr[j] <= pivot: i += 1 arr[i], arr[j] = arr[j], arr[i] arr[i + 1], arr[high] = arr[high], arr[i + 1] return i + 1 def quicksort_in_place(arr, low=0, high=None): if high ...
from solution import quicksort_in_place def test_quicksort_empty_list(): assert quicksort_in_place([]) == [] def test_quicksort_single_element(): assert quicksort_in_place([1]) == [1] def test_quicksort_two_elements(): assert quicksort_in_place([2, 1]) == [1, 2] assert quicksort_in_place([1, 2]) == [...
[ { "docstring": null, "function_declaration": "def partition(arr, low, high):", "function_name": "partition", "parameter_list": "(arr, low, high)" }, { "docstring": null, "function_declaration": "def quicksort_in_place(arr, low=0, high=None):", "function_name": "quicksort_in_place", ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def quicksort_inplace(arr, low=0, high=None):\n if high is None:\n high = len(arr) - 1\n\n if low < high:\n pi = partition(arr, low, high)\n quicksort_inplace(arr, l...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000624", "row_id": 624, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1679']" }
0.403061
Filter_624
I
[ "partition", "quicksort_in_place" ]
2
[ [ "quicksort_in_place", "partition" ] ]
1
[]
false
[]
false
pytest
true
[]
true
8ecf6fb01df43b04c8a9fa3e41d6ab0dd1c3fc08
7c93f6664a42cb05b6be127a449b3e90a65c168e
v1.0
instruct
Filter
Filter_627_I
def is_prime(n): """Check if a number is prime.""" if n < 2: return False for i in range(2, n): if n % i == 0: return False return True def sum_primes(n): """Return the sum of all prime numbers up to n.""" return sum(i for i in range(2, n) if is_prime(i)) print(sum_...
def is_prime(n): """ Check if a number is prime. Args: n (int): The number to check. Returns: bool: True if the number is prime, False otherwise. """ if n < 2: return False for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False ret...
from solution import is_prime, sum_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(5) == True assert is_prime(10) == False assert is_prime(13) == True assert is_prime(1) == False def test_sum_primes(): assert...
[ { "docstring": "Check if a number is prime.\n\nArgs:\nn (int): The number to check.\n\nReturns:\nbool: True if the number is prime, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Return the sum of all pri...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"Check if a number is prime.\"\"\"\n if n < 2:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000627", "row_id": 627, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1685']" }
0.82416
Filter_627
I
[ "is_prime", "sum_primes" ]
2
[ [ "sum_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
07864180259286c3ca63496bcfdf3c8c0ea52b75
7d885e744cf26509f40e11b5482b5cbcb2d23bdb
v1.0
instruct
Filter
Filter_630_I
def is_prime(n): """Returns True if n is a prime number, False otherwise.""" if n <= 1: return False for i in range(2, n): if n % i == 0: return False return True def filter_primes(numbers): """Returns a list of prime numbers from the input list.""" return [n for n i...
def is_prime(n): """Returns True if n is a prime number, False otherwise.""" if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def filter_primes(numbers): """Returns a list of prime numbers from the input list.""" ret...
from solution import is_prime, filter_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(-5) == False assert is_prime(0) == False assert is_prime(1) == Fal...
[ { "docstring": "Returns True if n is a prime number, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns a list of prime numbers from the input list.", "function_declaration": "def filter_primes(nu...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Returns True if n is a prime number, False otherwise.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000630", "row_id": 630, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1697']" }
0.831044
Filter_630
I
[ "is_prime", "filter_primes" ]
2
[ [ "filter_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
41a3b02c1227052b46d67109a4442b5ef752731b
ebb9d109e8298a96716586476910df57f8395bd9
v1.0
instruct
Filter
Filter_631_I
import sys def write_file(filename): with open(filename, 'w') as f: f.write("Hello, World!") def read_file(filename): with open(filename, 'r') as f: return f.read() def read_write_example(): filename = "test.txt" write_file(filename) print(read_file(filename)) if __name__ == "__m...
import sys def write_file(filename, text): """ Writes the provided text to the specified file. """ with open(filename, 'w') as f: f.write(text) def read_file(filename): """ Reads the contents of the specified file and returns it. """ with open(filename, 'r') as f: retur...
import os import pytest from solution import write_file, read_file def test_write_and_read_file(): filename = "test_file.txt" text = "Sample text for testing." # Write the text to the file write_file(filename, text) # Read the text back from the file result = read_file(filename) ...
[ { "docstring": "Writes the provided text to the specified file.", "function_declaration": "def write_file(filename, text):", "function_name": "write_file", "parameter_list": "(filename, text)" }, { "docstring": "Reads the contents of the specified file and returns it.", "function_declara...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sys\n\ndef write_file(filename, text):\n \"\"\"\n Writes the provided text to the specified file.\n \"\"\"\n with open(filename, 'w') as f:\n f.write(text)\n\ndef rea...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00000631", "row_id": 631, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1700']" }
0.425341
Filter_631
I
[ "write_file", "read_file", "read_write_example" ]
3
[ [ "read_write_example", "read_file" ], [ "read_write_example", "write_file" ] ]
2
[]
false
[]
false
pytest
true
[]
true
c1be961c56b57b60b2934a537cb5f845135905c0
06e2cc5974b82e7e1114460d013c9aea163b28cf
v1.0
instruct
Filter
Filter_635_I
### Create a "Time Machine" program #### Program Requirements - Time travel is possible, going back in time - Travel back in time to visit any historical date - Allow users to interact with the time machine in a conversational way #### Program Structure ```markdown # Time Machine Program ## Step 1: Get the user's desi...
import datetime def get_user_date(): """ Gets the user's desired date for time travel. """ date_input = input("Please enter a date to travel back in time (YYYY-MM-DD): ") return date_input def validate_date(date_input): """ Validates the user's date to ensure it is in the past and in the c...
import datetime from unittest.mock import patch, MagicMock from solution import get_user_date, validate_date, prepare_time_machine, send_user_back_in_time, interact_with_user, handle_user_action, end_program, time_machine_program def test_validate_date_valid_past_date(): assert validate_date("2020-01-01") == True ...
[ { "docstring": "Gets the user's desired date for time travel.", "function_declaration": "def get_user_date():", "function_name": "get_user_date", "parameter_list": "()" }, { "docstring": "Validates the user's date to ensure it is in the past and in the correct format.", "function_declara...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import datetime\n\ndef get_user_date():\n date_input = input(\"Please enter a date to travel back in time (YYYY-MM-DD): \")\n return date_input\n\ndef validate_date(date_input):\n try...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000635", "row_id": 635, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1732']" }
0.41262
Filter_635
I
[ "get_user_date", "validate_date", "prepare_time_machine", "send_user_back_in_time", "interact_with_user", "handle_user_action", "end_program", "time_machine_program" ]
8
[ [ "interact_with_user", "handle_user_action" ], [ "send_user_back_in_time", "interact_with_user" ], [ "time_machine_program", "end_program" ], [ "time_machine_program", "get_user_date" ], [ "time_machine_program", "prepare_time_machine" ], [ "time_mach...
7
[]
false
[]
false
pytest
true
[]
true
c09feb12d4dcf69d7540f58fa17f0184c51dbf4f
4145652d33d52b98a928018d9ed860857b28e1dc
v1.0
instruct
Filter
Filter_694_I
def greet(name: str) -> str: """Return a personalized greeting message.""" return f"Hello, {name}!" def sum_numbers(numbers: list[int]) -> int: """Return the sum of a list of numbers.""" return sum(numbers) def is_prime(n: int) -> bool: """Check if a number is prime.""" if n <= 1: retu...
def greet(name: str) -> str: """Return a personalized greeting message.""" return f"Hello, {name}!" def sum_numbers(numbers: list[int]) -> int: """Return the sum of a list of numbers.""" return sum(numbers) def is_prime(n: int) -> bool: """Check if a number is prime.""" if n <= 1: retu...
from solution import greet, sum_numbers, is_prime, get_primes def test_greet(): assert greet("John") == "Hello, John!" assert greet("Alice") == "Hello, Alice!" assert greet("") == "Hello, !" def test_sum_numbers(): assert sum_numbers([1, 2, 3, 4, 5]) == 15 assert sum_numbers([-1, 1, 1]) == 1 a...
[ { "docstring": "Return a personalized greeting message.", "function_declaration": "def greet(name):", "function_name": "greet", "parameter_list": "(name)" }, { "docstring": "Return the sum of a list of numbers.", "function_declaration": "def sum_numbers(numbers):", "function_name": "...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def greet(name: str) -> str:\n \"\"\"Return a personalized greeting message.\"\"\"\n return f\"Hello, {name}!\"\n\ndef sum_numbers(numbers: list[int]) -> int:\n \"\"\"Return the sum o...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00000694", "row_id": 694, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1947']" }
0.734994
Filter_694
I
[ "greet", "sum_numbers", "is_prime", "get_primes" ]
4
[ [ "get_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
a2805b93fbff86655315ec35b317085190dada48
47b69dcd2d1a7c605879995b39d1bf397786ed1a
v1.0
instruct
Filter
Filter_697_I
def is_prime(n): """Check if a number is prime.""" if n <= 1: return False for i in range(2, n): if n % i == 0: return False return True def primes_up_to_n(n): """Return a list of all prime numbers up to n.""" return [i for i in range(2, n+1) if is_prime(i)] def is_...
def is_prime(n): """Check if a number is prime.""" if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def primes_up_to_n(n): """Return a list of all prime numbers up to n.""" return [i for i in range(2, n+1) if is_prim...
from solution import is_prime, primes_up_to_n, is_prime_list_match def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(29) == True assert is_prime(1) == False def test_primes_up_to_n(): assert primes_up_to_n(10) == [2, 3, 5, 7]...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Return a list of all prime numbers up to n.", "function_declaration": "def primes_up_to_n(n):", "function_name": "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 Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n re...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000697", "row_id": 697, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1952']" }
0.721958
Filter_697
I
[ "is_prime", "primes_up_to_n", "is_prime_list_match" ]
3
[ [ "primes_up_to_n", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
297d3fe2a48fe460786d5a6300150324e9da92ca
978617e0cd97ad79fe3116231625da86d2eac70b
v1.0
instruct
Filter
Filter_703_I
def intersection_of_rules(): rule1 = '2-4,6-8' rule2 = '3-5,7-9' def parse_rule(rule): return [list(map(int, interval.split('-'))) for interval in rule.split(',')] parsed_rules = list(map(parse_rule, [rule1, rule2])) print(parsed_rules)
def parse_rule(rule): """ Parses a rule string of ranges into a list of tuples """ return [tuple(map(int, interval.split('-'))) for interval in rule.split(',')] def find_intersection(range1, range2): """ Finds the intersection of two ranges """ start = max(range1[0], range2[0]) end ...
def test_intersection_of_rules(): rule1 = '2-4,6-8' rule2 = '3-5,7-9' assert intersection_of_rules(rule1, rule2) == [(3, 4), (7, 8)] def test_intersection_no_overlap(): rule1 = '1-2,10-12' rule2 = '3-5,13-15' assert intersection_of_rules(rule1, rule2) == [] def test_intersection_partial_overla...
[ { "docstring": "Parses a rule string of ranges into a list of tuples", "function_declaration": "def parse_rule(rule):", "function_name": "parse_rule", "parameter_list": "(rule)" }, { "docstring": "Finds the intersection of two ranges", "function_declaration": "def find_intersection(range...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def parse_rule(rule):\n return [list(map(int, interval.split('-'))) for interval in rule.split(',')]\n\ndef intersect_intervals(interval1, interval2):\n start = max(interval1[0], interva...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00000703", "row_id": 703, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1972']" }
0.569068
Filter_703
I
[ "parse_rule", "find_intersection", "intersection_of_rules" ]
3
[ [ "intersection_of_rules", "find_intersection" ], [ "intersection_of_rules", "parse_rule" ] ]
2
[]
false
[]
false
pytest
false
[]
true
114856acd524ae52697cd856b08f1dc5aa3eaea1
cc3c7ec53602c217f626e1906daac4130fad9b10
v1.0
instruct
Filter
Filter_704_I
import random def roll_dice(): roll = random.randint(1,6) return roll player_score = 0 computer_score = 0 while True: user_input = input("Press Enter to roll or type 'q' to quit: ") if user_input.lower() == 'q': break player_roll = roll_dice() print("You rolled a", player_roll) playe...
import random def roll_dice(): return random.randint(1, 6) def game(): player_score = 0 computer_score = 0 while True: user_input = input("Press 'r' to roll, 'h' to hold, or 'q' to quit: ") if user_input.lower() == 'q': break elif user_input.lower() == 'r': ...
from solution import roll_dice def test_roll_dice(): rolls = [roll_dice() for _ in range(1000)] assert all(1 <= roll <= 6 for roll in rolls) assert len(set(rolls)) == 6 # Expect all values 1 through 6 to appear def test_game(): # The game function primarily deals with inputs/outputs and is not easily...
[ { "docstring": null, "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def game():", "function_name": "game", "parameter_list": "()" } ]
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef roll_dice():\n return random.randint(1, 6)\n\nplayer_score = 0\ncomputer_score = 0\n\nwhile True:\n user_input = input(\"Press 'r' to roll the dice, 'h' to hold your...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00000704", "row_id": 704, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1975']" }
0.42591
Filter_704
I
[ "roll_dice", "game" ]
2
[ [ "game", "roll_dice" ] ]
1
[]
false
[]
false
pytest
true
[]
true
990894fb0a121b2894fe2eba0cc7698651653223
abf1ea13f0be39e26918022c67d75a5ae9f5415d
v1.0
instruct
Filter
Filter_709_I
def create_lotto_stars(): """Generate 2 random lotto star numbers between 1 and 12 (inclusive)""" return [random.randint(1, 12), random.randint(1, 12)] def create_lotto_numbers(): """Generate 5 random lotto numbers between 1 and 50 (inclusive), ensuring that the numbers are unique and in ascending ...
import random def create_lotto_stars(): """Generate 2 random lotto star numbers between 1 and 12 (inclusive)""" return random.sample(range(1, 13), 2) def create_lotto_numbers(): """Generate 5 random lotto numbers between 1 and 50 (inclusive), ensuring that the numbers are unique and in ascending or...
from solution import create_lotto_stars, create_lotto_numbers, generate_lotto_ticket def test_create_lotto_stars(): stars = create_lotto_stars() assert len(stars) == 2 assert stars[0] != stars[1] assert all(1 <= star <= 12 for star in stars) def test_create_lotto_numbers(): numbers = create_lotto_...
[ { "docstring": "Generate 2 random lotto star numbers between 1 and 12 (inclusive)", "function_declaration": "def create_lotto_stars():", "function_name": "create_lotto_stars", "parameter_list": "()" }, { "docstring": "Generate 5 random lotto numbers between 1 and 50 (inclusive),\nensuring th...
[ 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 create_lotto_stars():\n \"\"\"\n Generate 2 random lotto star numbers between 1 and 12 (inclusive).\n Ensures that the star numbers are unique and in ascending or...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000709", "row_id": 709, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_1996']" }
0.546521
Filter_709
I
[ "create_lotto_stars", "create_lotto_numbers", "generate_lotto_ticket" ]
3
[ [ "generate_lotto_ticket", "create_lotto_numbers" ], [ "generate_lotto_ticket", "create_lotto_stars" ] ]
2
[]
false
[]
false
pytest
true
[]
true
160312fc4604a050b352ac7aa5131e009824e909
a55abc23d46e262f717bc82cd6ec64f2498344f6
v1.0
instruct
Filter
Filter_711_I
from datetime import datetime from datetime import timezone def get_current_date(): return datetime.now(timezone.utc) def get_current_day_of_week(): current_date = get_current_date() return current_date.weekday() def main(): print("This program prints the day of week for the current date.") print...
from datetime import datetime, timezone def get_current_date(): return datetime.now(timezone.utc) def get_current_day_of_week(): current_date = get_current_date() return current_date.weekday() def get_day_name(day_number): """ Converts a day number (0 for Monday, 6 for Sunday) to the correspondin...
from solution import get_day_name def test_get_day_name(): assert get_day_name(0) == "Monday" assert get_day_name(1) == "Tuesday" assert get_day_name(2) == "Wednesday" assert get_day_name(3) == "Thursday" assert get_day_name(4) == "Friday" assert get_day_name(5) == "Saturday" assert get_day...
[ { "docstring": null, "function_declaration": "def get_current_date():", "function_name": "get_current_date", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def get_current_day_of_week():", "function_name": "get_current_day_of_week", "parameter_list": "()"...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from datetime import datetime, timezone\n\ndef get_current_date():\n return datetime.now(timezone.utc)\n\ndef get_current_day_of_week():\n current_date = get_current_date()\n return c...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00000711", "row_id": 711, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2000']" }
0.690115
Filter_711
I
[ "get_current_date", "get_current_day_of_week", "get_day_name", "main" ]
4
[ [ "get_current_day_of_week", "get_current_date" ] ]
1
[]
false
[]
false
pytest
true
[]
true
3c21487031ef0e1cacd8a3849e8d55c5328104fa
bef798ebdb30f10734b36532bb0e5548bff9ed2a
v1.0
instruct
Filter
Filter_716_I
Here is the Python program that I have written to solve the problem: ```python def find_min_max(n, arr): min_val = min(arr) max_val = max(arr) return min_val, max_val n = int(input()) arr = list(map(int, input().split())) min_val, max_val = find_min_max(n, arr) print("Min Val:", min_val) print("Max Val:",...
def my_min(arr): """ A function to find the minimum value in a list using a loop. """ min_val = arr[0] for num in arr[1:]: if num < min_val: min_val = num return min_val def my_max(arr): """ A function to find the maximum value in a list using a loop. """ max...
from solution import my_min, my_max, find_min_max def test_my_min_single_element(): assert my_min([1]) == 1 assert my_min([-100]) == -100 def test_my_min_multiple_elements(): assert my_min([1, 2, 3, 4, 5]) == 1 assert my_min([5, 4, 3, 2, 1]) == 1 assert my_min([10, 100, 30, 20]) == 10 assert m...
[ { "docstring": "A function to find the minimum value in a list using a loop.", "function_declaration": "def my_min(arr):", "function_name": "my_min", "parameter_list": "(arr)" }, { "docstring": "A function to find the maximum value in a list using a loop.", "function_declaration": "def m...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def find_min(arr):\n min_val = arr[0]\n for num in arr:\n if num < min_val:\n min_val = num\n return min_val\n\ndef find_max(arr):\n max_val = arr[0]\n for num...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000716", "row_id": 716, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2011']" }
0.665863
Filter_716
I
[ "my_min", "my_max", "find_min_max" ]
3
[ [ "find_min_max", "my_max" ], [ "find_min_max", "my_min" ] ]
2
[]
false
[]
false
pytest
true
[]
true
df9a03c2416505f2a820ae7abc2f5074c4cfff7e
fb4b016950b9a303ff795fc26b9f81e3c2a7fe67
v1.0
instruct
Filter
Filter_717_I
import math def is_prime(n): if n < 2: return False for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: return False return True def count_primes(n): count = 0 for i in range(2, n + 1): if is_prime(i): count += 1 return count def nth_prime(...
import math def is_prime(n): """ Helper function to determine if n is a prime number. """ if n < 2: return False for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: return False return True def prime_factors(n): """ Helper function to find prime factors...
from solution import list_prime_factors def test_prime_factors_single_number(): assert list_prime_factors([28]) == [[2, 2, 7]] def test_prime_factors_multiple_numbers(): assert list_prime_factors([12, 15, 21]) == [[2, 2, 3], [3, 5], [3, 7]] def test_prime_factors_no_factors(): assert list_prime_factors([...
[ { "docstring": "Helper function to determine if n is a prime number.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Helper function to find prime factors of a single number n.", "function_declaration": "def prime_fact...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef is_prime(n):\n \"\"\"\n Check if a number is a prime number.\n \"\"\"\n if n < 2:\n return False\n for i in range(2, int(math.sqrt(n)) + 1):\n i...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000717", "row_id": 717, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2014']" }
0.755577
Filter_717
I
[ "is_prime", "prime_factors", "list_prime_factors" ]
3
[ [ "list_prime_factors", "prime_factors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7cd6cb05a88feb4f9222d1abbb919f798946475c
ae0b250f05f981b086c38886e08aac58e2b3f327
v1.0
instruct
Filter
Filter_723_I
This program is a model for the game "Jeopardy." The user plays the role of the contestant, and the program provides clues to the questions. The program randomly selects a category and dollar amount, and the contestant responds with a question that answers the clue. If the contestant responds correctly, they earn the d...
import random # Define the categories and clues categories = { "History": [ {"clue": "The French Revolution began in this year", "response": "What is 1789?"}, {"clue": "He was the first President of the United States", "response": "Who is George Washington?"}, {"clue": "In 1492, he sailed t...
from solution import select_random_clue, update_score, process_response def test_select_random_clue(): category, clue = select_random_clue({ "History": [{"clue": "Sample clue?", "response": "Sample response?"}] }) assert category == "History" assert clue["clue"] == "Sample clue?" assert clu...
[ { "docstring": null, "function_declaration": "def select_random_clue(categories):", "function_name": "select_random_clue", "parameter_list": "(categories)" }, { "docstring": null, "function_declaration": "def update_score(is_correct, score, amount):", "function_name": "update_score",...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport time\n\n# Define the categories and clues\ncategories = {\n \"History\": [\n {\"clue\": \"The French Revolution began in this year\", \"response\": \"What is 17...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00000723", "row_id": 723, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2042']" }
0.536395
Filter_723
I
[ "select_random_clue", "update_score", "process_response", "play_game" ]
4
[ [ "play_game", "process_response" ], [ "play_game", "select_random_clue" ], [ "play_game", "update_score" ] ]
3
[]
false
[]
false
pytest
true
[]
true
56f42fced1381b22e45885318cecae7f75e7aa9f
32d43b5bcae73b25ab5e1dc165c26752c80a7a3d
v1.0
instruct
Filter
Filter_733_I
import random ... I want to write a program where users can play a simple lottery game. The user can choose between 6 numbers from a pool of 45. After that, I want to choose 7 random numbers from the same pool and display them. The user's numbers and the lottery numbers are compared to see how many numbers match. Her...
import random class DuplicateError(Exception): pass def get_user_numbers(): user_numbers = [] for _ in range(6): while True: try: number = int(input("Enter a number between 1 and 45: ")) if number < 1 or number > 45: raise ValueError(...
import pytest from solution import generate_lottery_numbers, choose_power_ball, count_matching_numbers, display_results def test_generate_lottery_numbers(): results = generate_lottery_numbers() assert len(results) == 7 assert len(set(results)) == 7 # Ensure all numbers are unique assert all(1 <= n <= ...
[]
[ 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\nclass DuplicateError(Exception):\n pass\n\ndef get_user_numbers():\n user_numbers = []\n for _ in range(6):\n while True:\n try:\n nu...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00000733", "row_id": 733, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2073']" }
0.523748
Filter_733
I
[ "get_user_numbers", "generate_lottery_numbers", "choose_power_ball", "count_matching_numbers", "display_results", "play_lottery" ]
6
[ [ "play_lottery", "choose_power_ball" ], [ "play_lottery", "count_matching_numbers" ], [ "play_lottery", "display_results" ], [ "play_lottery", "generate_lottery_numbers" ], [ "play_lottery", "get_user_numbers" ] ]
5
[]
false
[ "DuplicateError" ]
true
pytest
true
[]
true
055ff830aa699095bd8af242be743b2f1e834aff
c79ffc2d0b8228e6f4e9436cd944469750a19c5b
v1.0
instruct
Filter
Filter_753_I
import math import heapq def calculate_median(nums): heap = [] for num in nums: heapq.heappush(heap, num) n = len(heap) if n % 2 == 1: return heap[n/2] else: return (heap[n/2] + heap[n/2 - 1]) / 2.0 def solve(nums): h1 = [] h2 = [] for num in nums: if nu...
import heapq def calculate_median(nums): nums.sort() n = len(nums) if n % 2 == 1: return nums[n//2] else: return (nums[n//2] + nums[n//2 - 1]) / 2.0 def solve(nums): low = [] # Max heap (inverted min-heap) for the smaller half high = [] # Min heap for the larger half for ...
from solution import solve def test_even_number_of_elements(): assert solve([1, 2, 3, 4]) == 2.5 def test_odd_number_of_elements(): assert solve([1, 2, 3, 4, 5]) == 3 def test_identical_elements(): assert solve([3, 3, 3, 3]) == 3 def test_negative_elements(): assert solve([-1, -2, -3, -4]) == -2.5 ...
[ { "docstring": null, "function_declaration": "def calculate_median(nums):", "function_name": "calculate_median", "parameter_list": "(nums)" }, { "docstring": null, "function_declaration": "def solve(nums):", "function_name": "solve", "parameter_list": "(nums)" }, { "docst...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import heapq\n\ndef calculate_median(nums):\n \"\"\"\n Helper function to calculate the median of a list of numbers.\n \"\"\"\n nums.sort()\n n = len(nums)\n if n % 2 == 1:\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00000753", "row_id": 753, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2139']" }
0.678511
Filter_753
I
[ "calculate_median", "solve", "main" ]
3
[ [ "solve", "calculate_median" ] ]
1
[]
false
[]
false
pytest
true
[]
true
fe4e5f5e59728756a151f3ee6238973c7f236cba
f41ed559f6f788b583de8836ffc31a7cbf267046
v1.0
instruct
Filter
Filter_765_I
def format_address(address, country): if address is None or address.strip() == '': return '' if country is None or country.strip() == '': return address street = address.split('\n')[0] postal_code = address.split('\n')[-1] city_state = address.split('\n')[1].split(', ')[0] ...
def format_address(address, country): if address is None or address.strip() == '': return '' if country is None or country.strip() == '': return address street = address.split('\n')[0] city_state = address.split('\n')[1] postal_code = address.split('\n')[2] return f'{street...
from solution import format_address, get_addresses, get_address, format_addresses def test_format_address_with_valid_data(): address = "123 Street\nCity,State\n12345" country = "Country" formatted = format_address(address, country) expected = "123 Street\nCity,State\n12345\nCountry" assert formatte...
[ { "docstring": null, "function_declaration": "def format_address(address, country):", "function_name": "format_address", "parameter_list": "(address, country)" }, { "docstring": null, "function_declaration": "def get_addresses(data):", "function_name": "get_addresses", "parameter...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def format_address(address, country):\n \"\"\"\n Formats the address string with the given country.\n \"\"\"\n if address is None or address.strip() == '':\n return ''\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000765", "row_id": 765, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2174']" }
0.566562
Filter_765
I
[ "format_address", "get_addresses", "get_address", "format_addresses" ]
4
[ [ "format_addresses", "format_address" ], [ "format_addresses", "get_address" ], [ "get_address", "get_addresses" ] ]
3
[]
false
[]
false
pytest
true
[]
true
e66d9866fc69fa1455350966386186a72ca5ebc7
9173a98c3a75195f08fe54b83c78dba63fe661fa
v1.0
instruct
Filter
Filter_781_I
def is_prime(n): if n <= 1: return False for i in range(2, n): if n % i == 0: return False return True def sum_of_primes(n): return sum([num for num in range(2, n) if is_prime(num)]) print(sum_of_primes(10))
def is_prime(n): """ Returns True if the number n is prime, otherwise 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 sum_of_primes(n): """ Returns the sum of all prime numbers less than n. ...
from solution import is_prime, sum_of_primes def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(17) == True assert is_prime(18) == False assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == Fal...
[ { "docstring": "Returns True if the number n is prime, otherwise False.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Returns the sum of all prime numbers less than n.", "function_declaration": "def sum_of_primes(n):...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is prime.\n \n Args:\n n (int): The number to check.\n \n Returns:\n bool: True if the number is prime, False otherwise.\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000781", "row_id": 781, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2239']" }
0.832784
Filter_781
I
[ "is_prime", "sum_of_primes" ]
2
[ [ "sum_of_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dde56940d20b75c6769a91a1502a86f8cdc34ad6
95543c68016983ba58efe6e8fd00e059af1d446c
v1.0
instruct
Filter
Filter_788_I
python implementation of Cosine Similarity between two vectors here is a simple implementation of the Cosine Similarity in python: ``` import math def magnitude(vector): return math.sqrt(sum(i**2 for i in vector)) def cosineSimilarity(vector1, vector2): dotProduct = sum(a * b for a, b in zip(vector1, vector2...
import math def magnitude(vector): return math.sqrt(sum(i**2 for i in vector)) def cosine_similarity(vector1, vector2): if len(vector1) != len(vector2): raise ValueError("Vectors must be of the same length") dot_product = sum(a * b for a, b in zip(vector1, vector2)) magnitude1 = magnitude(vect...
from solution import cosine_similarity def test_cosine_similarity_same_vectors(): vector1 = [1, 2, 3] vector2 = [1, 2, 3] assert cosine_similarity(vector1, vector2) == 1.0 def test_cosine_similarity_orthogonal_vectors(): vector1 = [1, 0, 0] vector2 = [0, 1, 0] assert cosine_similarity(vector1,...
[ { "docstring": null, "function_declaration": "def magnitude(vector):", "function_name": "magnitude", "parameter_list": "(vector)" }, { "docstring": null, "function_declaration": "def cosine_similarity(vector1, vector2):", "function_name": "cosine_similarity", "parameter_list": "(...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\n\ndef magnitude(vector):\n return math.sqrt(sum(i**2 for i in vector))\n\ndef cosine_similarity(vector1, vector2):\n # Check if both vectors are of the same length\n if l...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000788", "row_id": 788, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2255']" }
0.538234
Filter_788
I
[ "magnitude", "cosine_similarity" ]
2
[ [ "cosine_similarity", "magnitude" ] ]
1
[]
false
[]
false
pytest
true
[]
true
834651aa5a504bd2010f7b3b386316e61d653e2f
a318699b26072b9b0480809e05815a4f32a586a4
v1.0
instruct
Filter
Filter_797_I
def calculate_median(numbers): sorted_numbers = sorted(numbers) length = len(sorted_numbers) if length % 2 == 0: median = (sorted_numbers[length // 2] + sorted_numbers[length // 2 - 1]) / 2 else: median = sorted_numbers[length // 2] return median def get_median(numbers): if not ...
def calculate_median(numbers): """ Calculate the median of a list of numbers. Parameters: numbers (list of int/float): The list of numbers to calculate the median. Returns: float: The median of the list. """ sorted_numbers = sorted(numbers) length = len(sorted_numbers) if l...
def test_empty_list(): assert get_median([]) == 0 def test_single_element(): assert get_median([5]) == 5 def test_two_elements(): assert get_median([5, 1]) == 3 def test_odd_number_of_elements(): assert get_median([1, 3, 5]) == 3 assert get_median([3, 1, 4, 5, 2]) == 3 def test_even_number_of_el...
[ { "docstring": "Calculate the median of a list of numbers.\n\nParameters:\nnumbers (list of int/float): The list of numbers to calculate the median.\n\nReturns:\nfloat: The median of the list.", "function_declaration": "def calculate_median(numbers):", "function_name": "calculate_median", "parameter...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_median(numbers):\n sorted_numbers = sorted(numbers)\n length = len(sorted_numbers)\n if length % 2 == 0:\n median = (sorted_numbers[length // 2] + sorted_numbers[...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000797", "row_id": 797, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2296']" }
0.862096
Filter_797
I
[ "calculate_median", "get_median" ]
2
[ [ "get_median", "calculate_median" ] ]
1
[]
false
[]
false
pytest
false
[]
true
ab5ff45ed150ae4815f47d748e3e9abe93bffc2c
bbfd13d0847a9005c3f361e2f4c1699b0edfbc71
v1.0
instruct
Filter
Filter_804_I
# Creating a simple text-based game in Python Creating a simple text-based game can be a great way to learn the basics of game development, and Python is an ideal language for beginners. In this response, we'll walk through the process of creating a simple text-based adventure game using Python. ### Game Concept Our...
import sys # Define a dictionary to store game locations locations = { 'home': { 'description': 'You are at home.', 'choices': ['go to forest', 'go to cave', 'stay home'] }, 'forest': { 'description': 'You are in the forest.', 'choices': ['go to cave', 'go to mountain', 'ret...
from solution import handle_input, print_location, locations def test_handle_input(): assert handle_input('home', 'go to forest') == 'forest' assert handle_input('forest', 'go to mountain') == 'mountain' assert handle_input('cave', 'go to mountain') == 'mountain' assert handle_input('mountain', 'return...
[ { "docstring": "Prints the description and choices for the current location.", "function_declaration": "def print_location(location):", "function_name": "print_location", "parameter_list": "(location)" }, { "docstring": "Determines the next location based on the player's choice.\n\nParameter...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "# game.py\n\n# Define a dictionary to store game locations\nlocations = {\n 'home': {\n 'description': 'You are at home.',\n 'choices': ['go to forest', 'go to cave', 'stay ho...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000804", "row_id": 804, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2315']" }
0.478278
Filter_804
I
[ "print_location", "handle_input", "play_game" ]
3
[ [ "play_game", "handle_input" ], [ "play_game", "print_location" ] ]
2
[ "handle_input" ]
false
[]
false
pytest
true
[]
true
db1758188fede95cc500f84e9a240f90cb39226a
967a113178f71f3e0488b558000763e584035da3
v1.0
instruct
Filter
Filter_810_I
import os def encrypt(text, key): result = "" for char in text: if char.isalpha(): ascii_offset = 97 if char.islower() else 65 result += chr((ord(char) - ascii_offset + key) % 26 + ascii_offset) else: result += char return result def decrypt(text, key): ...
def encrypt(text, key): result = "" for char in text: if char.isalpha(): ascii_offset = 97 if char.islower() else 65 result += chr((ord(char) - ascii_offset + key) % 26 + ascii_offset) else: result += char return result def decrypt(text, key): return ...
def test_encrypt_lowercase(): assert encrypt("hello", 3) == "khoor" def test_encrypt_uppercase(): assert encrypt("HELLO", 3) == "KHOOR" def test_encrypt_mixed_case(): assert encrypt("HelloWorld", 4) == "LippsAsvph" def test_encrypt_with_non_alpha(): assert encrypt("hello, world!", 5) == "mjqqt, btwqi...
[ { "docstring": null, "function_declaration": "def encrypt(text, key):", "function_name": "encrypt", "parameter_list": "(text, key)" }, { "docstring": null, "function_declaration": "def decrypt(text, key):", "function_name": "decrypt", "parameter_list": "(text, key)" } ]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def encrypt(text, key):\n \"\"\"\n Encrypts the given text using Caesar Cipher with the specified key.\n \"\"\"\n result = \"\"\n for char in text:\n if char.isalpha():\n...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00000810", "row_id": 810, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2338']" }
0.721906
Filter_810
I
[ "encrypt", "decrypt" ]
2
[ [ "decrypt", "encrypt" ] ]
1
[]
false
[]
false
pytest
false
[]
true
61fa0d7f0205e580adb95360fbee61b1ee4f77f3
015df82607a74b0936eb77757463857f2d284344
v1.0
instruct
Filter
Filter_832_I
import random def roll_dice(): return random.randint(1, 6) def calculate_sum(num_rolls): total = 0 for _ in range(num_rolls): total += roll_dice() return total def main(): num_rolls = int(input("Enter the number of rolls: ")) print("The sum of the rolls is: ", calculate_sum(num_rolls)...
import random def roll_dice(): return random.randint(1, 6) def calculate_sum(num_rolls): total = 0 for _ in range(num_rolls): total += roll_dice() return total def calculate_average(num_rolls): total = sum(roll_dice() for _ in range(num_rolls)) return total / num_rolls def calculate_...
import pytest from solution import roll_dice, calculate_sum, calculate_average, calculate_median def test_roll_dice(): result = roll_dice() assert 1 <= result <= 6 def test_calculate_sum(monkeypatch): monkeypatch.setattr('random.randint', lambda x, y: 3) assert calculate_sum(3) == 9 def test_calculat...
[ { "docstring": null, "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def calculate_sum(num_rolls):", "function_name": "calculate_sum", "parameter_list": "(num_rolls)" }, { "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 roll_dice():\n return random.randint(1, 6)\n\ndef calculate_sum(num_rolls):\n total = 0\n for _ in range(num_rolls):\n total += roll_dice()\n return tot...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00000832", "row_id": 832, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2397']" }
0.636952
Filter_832
I
[ "roll_dice", "calculate_sum", "calculate_average", "calculate_median", "main" ]
5
[ [ "calculate_average", "roll_dice" ], [ "calculate_median", "roll_dice" ], [ "calculate_sum", "roll_dice" ] ]
3
[]
false
[]
false
pytest
true
[]
true
efbfade9540243f815cb95a59f3bacfafe393a12
c48dbdb47e93b2cd056f1d353fbc352c60f086d1
v1.0
instruct
Filter
Filter_847_I
import random def guess_game(): print("Guess a number between 1 and 100") number_to_guess = random.randint(1, 100) guess = None while guess != number_to_guess: guess = int(input("Enter your guess: ")) if guess < number_to_guess: print("Too low!") elif guess > number_...
import random def get_user_name(): """ Prompts the user for their name and returns it. """ return input("Please enter your name: ") def guess_game(user_name): """ Runs a number guessing game where a user guesses a number between 1 and 100. Keeps track of the number of guesses. """ ...
import pytest from unittest.mock import patch from solution import get_user_name, guess_game, play_game @patch('builtins.input', return_value='TestUser') def test_get_user_name(mock_input): assert get_user_name() == 'TestUser' def test_guess_game_correct_guess(): user_name = 'TestUser' with patch('builtin...
[ { "docstring": "Prompts the user for their name and returns it.", "function_declaration": "def get_user_name():", "function_name": "get_user_name", "parameter_list": "()" }, { "docstring": "Runs a number guessing game where a user guesses a number between 1 and 100.\nKeeps track of the numbe...
[ 1, 0 ]
1
medium
0.5
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef get_user_name():\n \"\"\"\n Prompts the user for their name and returns it.\n \"\"\"\n return input(\"Please enter your name: \")\n\ndef guess_game(user_name):...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00000847", "row_id": 847, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2444']" }
0.596408
Filter_847
I
[ "get_user_name", "guess_game", "play_game" ]
3
[ [ "play_game", "get_user_name" ], [ "play_game", "guess_game" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2a15eb302a842e5c98908ae14b6c8dbd5955c3b1
17ad9181950a79b1406094d803df5d0358474e85
v1.0
instruct
Filter
Filter_874_I
```python import random def create_dice(): """Create a single six-sided die.""" return {"sides": 6} def roll_dice(dice): """Roll a single die.""" return random.randint(1, dice["sides"]) def roll_multiple_dice(num_dice, sides=6): """Roll multiple dice with the same number of sides.""" return [...
import random def create_dice(): """Create a single six-sided die.""" return {"sides": 6} def roll_dice(dice): """Roll a single die.""" return random.randint(1, dice["sides"]) def roll_multiple_dice(num_dice, sides=6): """Roll multiple dice with the same number of sides.""" return [random.ran...
from solution import roll_with_advantage, roll_with_disadvantage def test_roll_with_advantage(): results = [roll_with_advantage() for _ in range(100)] assert all(1 <= result <= 6 for result in results), "Results should be within 1 to 6" higher_count = sum(result == 6 for result in results) assert highe...
[ { "docstring": "Create a single six-sided die.", "function_declaration": "def create_dice():", "function_name": "create_dice", "parameter_list": "()" }, { "docstring": "Roll a single die.", "function_declaration": "def roll_dice(dice):", "function_name": "roll_dice", "parameter_l...
[ 0, 1 ]
1
medium
0.5
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "Magpie-Filter-89K_sanitized_prepared1_results_combined.jsonl", "solution_code": "import random\n\ndef create_dice():\n \"\"\"Create a single six-sided die.\"\"\"\n return {\"sides\": 6}\n\ndef roll_dice(dice):\n \"\"\"Roll a single die.\"\...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000874", "row_id": 874, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2535']" }
0.555646
Filter_874
I
[ "create_dice", "roll_dice", "roll_multiple_dice", "roll_custom_dice", "roll_percentile_dice", "roll_with_advantage", "roll_with_disadvantage" ]
7
[ [ "roll_with_advantage", "create_dice" ], [ "roll_with_advantage", "roll_dice" ], [ "roll_with_disadvantage", "create_dice" ], [ "roll_with_disadvantage", "roll_dice" ] ]
4
[]
false
[]
false
pytest
true
[]
true
6e35f43da41bb9783b8257b8466ba19a8454e46e
b4dc029cffe09f334c828c22676da8de086518a2
v1.0
instruct
Filter
Filter_889_I
def intersection(lst1, lst2): return [value for value in lst1 if value in lst2] def union(lst1, lst2): return lst1 + [value for value in lst2 if value not in lst1] def difference(lst1, lst2): return [value for value in lst1 if value not in lst2] def symmetric_difference(lst1, lst2): return difference...
def intersection(lst1, lst2): return [value for value in lst1 if value in lst2] def union(lst1, lst2): return list(set(lst1) | set(lst2)) def difference(lst1, lst2): return [value for value in lst1 if value not in lst2] def symmetric_difference(lst1, lst2): return list(set(lst1) ^ set(lst2)) def is_...
from solution import intersection, union, difference, symmetric_difference, is_subset, is_superset, is_disjoint def test_intersection(): assert intersection([1, 2, 3], [2, 3, 4]) == [2, 3] assert intersection([1, 2, 3], [4, 5, 6]) == [] assert intersection([1, 2, 3], []) == [] assert intersection([], [...
[ { "docstring": null, "function_declaration": "def intersection(lst1, lst2):", "function_name": "intersection", "parameter_list": "(lst1, lst2)" }, { "docstring": null, "function_declaration": "def union(lst1, lst2):", "function_name": "union", "parameter_list": "(lst1, lst2)" }...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def intersection(lst1, lst2):\n \"\"\"\n Returns the intersection of two lists.\n Elements common to both lists are included.\n \"\"\"\n return [value for value in lst1 if value...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000889", "row_id": 889, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2564']" }
0.577646
Filter_889
I
[ "intersection", "union", "difference", "symmetric_difference", "is_subset", "is_superset", "is_disjoint" ]
7
[ [ "is_disjoint", "intersection" ] ]
1
[]
false
[]
false
pytest
true
[]
true
887c84c04111d56bc60128267c5f2214f3c1cf11
c277c79611db7d1f5e142242a007cb0bc8fbad32
v1.0
instruct
Filter
Filter_908_I
import random from operator import mul def load_deck(): suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] numbers = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King'] deck = [(number, suit) for suit in suits for number in numbers] return deck def calculate_hand_value(hand):...
import random def load_deck(): suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] numbers = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King'] deck = [(number, suit) for suit in suits for number in numbers] return deck def calculate_hand_value(hand): values = {'Ace': 11,...
from solution import * import random def test_load_deck(): deck = load_deck() assert len(deck) == 52 assert ('Ace', 'Hearts') in deck assert ('King', 'Spades') in deck def test_calculate_hand_value(): hand = [('Ace', 'Hearts'), ('10', 'Diamonds')] assert calculate_hand_value(hand) == 21 h...
[ { "docstring": null, "function_declaration": "def load_deck():", "function_name": "load_deck", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def calculate_hand_value(hand):", "function_name": "calculate_hand_value", "parameter_list": "(hand)" }, { ...
[ 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 load_deck():\n suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades']\n numbers = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King']\n deck...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000908", "row_id": 908, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2609']" }
0.659056
Filter_908
I
[ "load_deck", "calculate_hand_value", "deal_initial_cards", "hit", "check_blackjack", "check_bust" ]
6
[ [ "check_blackjack", "calculate_hand_value" ], [ "check_bust", "calculate_hand_value" ] ]
2
[]
false
[]
false
pytest
true
[]
true
6c26a454e1f2dc58fd39b19fa16d22619d9ccb09
39a43715873143dab5a021e6704aaaead421ef86
v1.0
instruct
Filter
Filter_914_I
import requests from bs4 import BeautifulSoup def get_html(url): resp = requests.get(url) return resp.text def get_content(html): bs = BeautifulSoup(html, "html.parser") return bs def get_articles(bs): articles = bs.find_all("div", {"class": "article"}) return articles def get_links(articles...
import requests from bs4 import BeautifulSoup def get_html(url): resp = requests.get(url) return resp.text def get_content(html): bs = BeautifulSoup(html, "html.parser") return bs def get_articles(bs): articles = bs.find_all("div", {"class": "article"}) return articles def get_links(articles...
import pytest from solution import get_html, get_content, get_articles, get_links, get_article_content, find_shortest_and_longest_articles def test_get_html(monkeypatch): class MockResponse: def __init__(self, text): self.text = text def mock_get(url): return MockResponse("mock...
[]
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import requests\nfrom bs4 import BeautifulSoup\n\ndef get_html(url):\n resp = requests.get(url)\n return resp.text\n\ndef get_content(html):\n bs = BeautifulSoup(html, \"html.parser\"...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000914", "row_id": 914, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2626']" }
0.619812
Filter_914
I
[ "get_html", "get_content", "get_articles", "get_links", "get_article_content", "find_shortest_and_longest_articles", "main" ]
7
[ [ "find_shortest_and_longest_articles", "get_article_content" ], [ "get_article_content", "get_content" ], [ "get_article_content", "get_html" ] ]
3
[]
false
[]
false
pytest
true
[ "bs4", "requests" ]
false
c63300c9e2d470e9c12165b6b845631b40cc71b3
91b34df6fec9387bc7f96ee02fe86ae9cc52f42c
v1.0
instruct
Filter
Filter_918_I
# Problem = Can you create a Python program that can play a game of Rock Paper Scissors. The program will allow two players to play against each other, and the program will determine who wins the game. Here is an example of what the program should do: ``` Player 1: Rock Player 2: Paper Player 2 wins! ``` or ``` Pla...
class Player: def __init__(self, name): self.name = name self.wins = 0 self.losses = 0 self.ties = 0 def win(self): self.wins += 1 def lose(self): self.losses += 1 def tie(self): self.ties += 1 def __str__(self): return f"{self.name...
from solution import Player, decide_winner def test_decide_winner_tie(): assert decide_winner("rock", "rock") == "Tie" assert decide_winner("paper", "paper") == "Tie" assert decide_winner("scissors", "scissors") == "Tie" def test_decide_winner_player1(): assert decide_winner("rock", "scissors") == "Pl...
[]
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class Player:\n def __init__(self, name):\n self.name = name\n self.wins = 0\n self.losses = 0\n self.ties = 0\n\n def win(self):\n self.wins += 1\n\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00000918", "row_id": 918, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2648']" }
0.591547
Filter_918
I
[ "decide_winner", "rock_paper_scissors" ]
2
[ [ "rock_paper_scissors", "decide_winner" ] ]
1
[]
false
[ "Player" ]
true
pytest
true
[]
true
e083b1cd5b1cd03930311e204b76e246e25e9f1a
b16eb193bd3ac321773cff6749697460bd99d3e3
v1.0
instruct
Filter
Filter_930_I
import random import time def choose_random_word(): list_of_words = ["apple", "banana", "cherry", "date", "elderberry"] selected_word = random.choice(list_of_words) return selected_word def guess_the_word(): word = choose_random_word() attempts = 5 guessed = False print("Welcome to the gues...
import random import time def choose_random_word(): list_of_words = ["apple", "banana", "cherry", "date", "elderberry"] selected_word = random.choice(list_of_words) return selected_word def guess_the_word(): word = choose_random_word() attempts = 5 guessed = False print("Welcome to the gue...
from solution import choose_random_word, guess_the_word def test_choose_random_word(): word = choose_random_word() assert word in ["apple", "banana", "cherry", "date", "elderberry"] def test_guess_the_word(monkeypatch): inputs = iter(["wrong", "wrong", "wrong", "wrong", "apple"]) monkeypatch.setattr('...
[ { "docstring": null, "function_declaration": "def choose_random_word():", "function_name": "choose_random_word", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def guess_the_word():", "function_name": "guess_the_word", "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\nimport time\n\ndef choose_random_word():\n list_of_words = [\"apple\", \"banana\", \"cherry\", \"date\", \"elderberry\"]\n selected_word = random.choice(list_of_words)\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000930", "row_id": 930, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2684']" }
0.517638
Filter_930
I
[ "choose_random_word", "guess_the_word" ]
2
[ [ "guess_the_word", "choose_random_word" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ffe118125e31e872011e1e7582fef03a5ccdc57e
d4729d70a215f645095904e7eb3e6c0e2049cd60
v1.0
instruct
Filter
Filter_937_I
import csv import time from datetime import datetime # function to generate CSV file with random data def generate_csv(header, rows): with open('data.csv', 'w', newline='') as csvfile: writer = csv.writer(csvfile) writer.writerow(header) for _ in range(rows): writer.writerow([f"...
import csv import time from datetime import datetime # function to generate CSV file with random data def generate_csv(header, rows): with open('data.csv', 'w', newline='') as csvfile: writer = csv.writer(csvfile) writer.writerow(header) for _ in range(rows): writer.writerow([f"...
import os import csv from solution import generate_csv, get_time, log_data def test_generate_csv(): header = ["column1", "column2", "column3"] rows = 5 file_name = generate_csv(header, rows) assert os.path.exists(file_name) with open(file_name, 'r') as csvfile: reader = csv.reade...
[ { "docstring": null, "function_declaration": "def generate_csv(header, rows):", "function_name": "generate_csv", "parameter_list": "(header, rows)" }, { "docstring": null, "function_declaration": "def get_time():", "function_name": "get_time", "parameter_list": "()" }, { ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import csv\n\ndef generate_csv(header, rows):\n \"\"\"\n Generates a CSV file with the specified header and number of rows.\n \n Parameters:\n header (list): The header row ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00000937", "row_id": 937, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2700']" }
0.671206
Filter_937
I
[ "generate_csv", "get_time", "log_data" ]
3
[ [ "log_data", "generate_csv" ], [ "log_data", "get_time" ] ]
2
[]
false
[]
false
pytest
true
[]
true
3fa86427663147c5ec4ab963458d740cad50fd15
99b81a9e505c8b4c05da847741e4057f6f66dd78
v1.0
instruct
Filter
Filter_942_I
This project uses the following libraries: pandas, numpy and matplotlib. I created a function to generate random numbers and plot them against a range of numbers from 0 to 100. ```python import pandas as pd import numpy as np import matplotlib.pyplot as plt def generate_random_numbers(): return np.random.rand(100)...
import pandas as pd import numpy as np import matplotlib.pyplot as plt def generate_random_numbers(): return np.random.rand(100) def plot_random_numbers_with_customizations(): # create a range from 0 to 100 x = np.arange(0, 100) # generate random numbers y = generate_random_numbers() # creat...
import matplotlib.pyplot as plt import numpy as np from solution import generate_random_numbers, plot_random_numbers_with_customizations def test_generate_random_numbers(): random_numbers = generate_random_numbers() assert len(random_numbers) == 100 assert np.all((random_numbers >= 0) & (random_numbers <= ...
[ { "docstring": null, "function_declaration": "def generate_random_numbers():", "function_name": "generate_random_numbers", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def plot_random_numbers_with_customizations():", "function_name": "plot_random_numbers_wi...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\n\ndef generate_random_numbers():\n return np.random.rand(100)\n\ndef create_plot():\n # create a range from 0 to...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000942", "row_id": 942, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2717']" }
0.682302
Filter_942
I
[ "generate_random_numbers", "plot_random_numbers_with_customizations" ]
2
[ [ "plot_random_numbers_with_customizations", "generate_random_numbers" ] ]
1
[]
false
[]
false
pytest
true
[ "matplotlib", "numpy", "pandas" ]
false
d7c20d6a64013045e33379f81e4da35ff89fe77d
c0f8f8c5b6cf8155a6dc7306fad8b7f6f7c1b972
v1.0
instruct
Filter
Filter_944_I
from bs4 import BeautifulSoup import requests def crawl(url): response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') links = soup.find_all('a') for link in links: if link.has_attr('href'): href = link['href'] print(href) url = "https://www.digik...
from bs4 import BeautifulSoup import requests import time def is_valid_link(url): # This is a basic check. You may want to add more checks based on your requirements. return url.startswith('http') or url.startswith('/') def get_absolute_url(base, link): if link.startswith('http'): return link ...
from solution import is_valid_link, get_absolute_url, crawl def test_is_valid_link(): assert is_valid_link('http://example.com') == True assert is_valid_link('https://example.com') == True assert is_valid_link('/path') == True assert is_valid_link('javascript:void(0)') == False def test_get_absolute_u...
[ { "docstring": null, "function_declaration": "def is_valid_link(url):", "function_name": "is_valid_link", "parameter_list": "(url)" }, { "docstring": null, "function_declaration": "def get_absolute_url(base, link):", "function_name": "get_absolute_url", "parameter_list": "(base, ...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "from bs4 import BeautifulSoup\nimport requests\n\ndef crawl(url, visited=None):\n if visited is None:\n visited = set()\n\n if url in visited:\n return\n \n visited.a...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00000944", "row_id": 944, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2722']" }
0.681221
Filter_944
I
[ "is_valid_link", "get_absolute_url", "crawl" ]
3
[ [ "crawl", "get_absolute_url" ], [ "crawl", "is_valid_link" ] ]
2
[]
false
[]
false
pytest
true
[ "bs4", "requests" ]
false
432268b86f3aa223d57564a85d58421045a2689a
8549ed5acaf2e5629b669ce59431ad49e4b73191
v1.0
instruct
Filter
Filter_950_I
# Developing a Prototype for a Smart Farm ====================================== ## Overview This project involves designing and implementing a prototype for a smart farm using IoT sensors and a Python-based backend. The goal is to create a system that can monitor and control various parameters of a farm, such as tem...
import sqlite3 import random # Simulating sensor data from datetime import datetime # Connect to database conn = sqlite3.connect('sensor_data.db') cursor = conn.cursor() # Create table if not exists cursor.execute(''' CREATE TABLE IF NOT EXISTS sensor_data (id INTEGER PRIMARY KEY, temperature REAL, humidity ...
import sqlite3 from solution import read_temperature, read_humidity, read_soil_moisture def test_read_temperature_range(): temp = read_temperature() assert 15 <= temp <= 25, f"Temperature {temp} is out of range" def test_read_humidity_range(): humidity = read_humidity() assert 30 <= humidity <= 80, f"...
[ { "docstring": null, "function_declaration": "def read_temperature():", "function_name": "read_temperature", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def read_humidity():", "function_name": "read_humidity", "parameter_list": "()" }, { "docst...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sqlite3\nimport time\n\n# Example read sensor data functions\ndef read_temperature(pin):\n # In a real implementation, read from the sensor connected to the \"pin\"\n return 25.0\...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00000950", "row_id": 950, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2744']" }
0.3706
Filter_950
I
[ "read_temperature", "read_humidity", "read_soil_moisture", "collect_and_store_data" ]
4
[ [ "collect_and_store_data", "read_humidity" ], [ "collect_and_store_data", "read_soil_moisture" ], [ "collect_and_store_data", "read_temperature" ] ]
3
[]
false
[]
false
pytest
true
[]
true
7efef80c6557e181fe18fc4515001c0a96d4c4cf
e8fb97c47e3e124b97eb2696c8e4c478b496ac9a
v1.0
instruct
Filter
Filter_996_I
### Overview The goal of this project is to create a simple text-based adventure game. The game will allow the user to make choices and exploring a world that will lead to multiple endings. ### Technical Details * The game will be built using Python. * The game will be contained within a single file for simplicity...
# Game Data rooms = { 1: "You are in a dark room. There is a door to the north.", 2: "You are in a bright room. There is a door to the south, and a key on the floor.", 3: "You are in a hallway. There is a door to the east and west.", 4: "You are in a treasure room. There is a door to the west.", 5: ...
from solution import move_player, take_item, use_item, talk_to_npc, make_choice, game_state def test_move_player_north(): game_state["current_room"] = 1 move_player("north") assert game_state["current_room"] == 2 def test_move_player_south(): game_state["current_room"] = 2 move_player("south") ...
[ { "docstring": null, "function_declaration": "def move_player(direction):", "function_name": "move_player", "parameter_list": "(direction)" }, { "docstring": null, "function_declaration": "def take_item(item):", "function_name": "take_item", "parameter_list": "(item)" }, { ...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sys\n\n# Game Data\nrooms = {\n \"Room 1\": \"You are in a dark room. There is a door to the north.\",\n \"Room 2\": \"You are in a bright room. There is a door to the south and a...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00000996", "row_id": 996, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2902']" }
0.48643
Filter_996
I
[ "move_player", "take_item", "use_item", "talk_to_npc", "get_player_choice", "make_choice", "game_loop" ]
7
[ [ "game_loop", "get_player_choice" ], [ "game_loop", "make_choice" ], [ "game_loop", "move_player" ], [ "game_loop", "take_item" ], [ "game_loop", "talk_to_npc" ], [ "game_loop", "use_item" ], [ "use_item", "move_player" ] ]
7
[]
false
[]
false
pytest
true
[]
true
12275e308b5815ea95a8f800a9ff283c76dc0a3e
15a340bffd39df8d685ad1186aecc38747f2fdac
v1.0
instruct
Filter
Filter_999_I
import math import time def get_prime_factors(n): factors = [] while n % 2 == 0: factors.append(2) n = n // 2 # n is now odd for i in range(3, int(math.sqrt(n)) + 1, 2): while n % i == 0: factors.append(i) n = n // i if n > 1: factors.append(n...
import math import time def get_prime_factors(n): factors = [] while n % 2 == 0: factors.append(2) n = n // 2 # n is now odd for i in range(3, int(math.sqrt(n)) + 1, 2): while n % i == 0: factors.append(i) n = n // i if n > 1: factors.append(n...
from solution import get_prime_factors, prime_factors_in_range def test_get_prime_factors_single_prime(): assert get_prime_factors(13) == [13] def test_get_prime_factors_composite(): assert get_prime_factors(315) == [3, 3, 5, 7] def test_prime_factors_in_range(): result = prime_factors_in_range(10, 15) ...
[ { "docstring": null, "function_declaration": "def get_prime_factors(n):", "function_name": "get_prime_factors", "parameter_list": "(n)" }, { "docstring": null, "function_declaration": "def prime_factors_in_range(start, end):", "function_name": "prime_factors_in_range", "parameter...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import math\nimport time\n\ndef get_prime_factors(n):\n factors = []\n while n % 2 == 0:\n factors.append(2)\n n = n // 2\n # n is now odd\n for i in range(3, int(mat...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00000999", "row_id": 999, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2908']" }
0.69914
Filter_999
I
[ "get_prime_factors", "prime_factors_in_range", "main" ]
3
[ [ "prime_factors_in_range", "get_prime_factors" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dd09a0e035b561e04e3ed4ab3442c056500b1865
60a627932371445bf486a8633bbab87ca6d650b7
v1.0
instruct
Filter
Filter_1026_I
import re import random def check_password(password): length_error = "length should be between 8-16 characters" if len(password) < 8 or len(password) > 16: return length_error has_digit = any(char.isdigit() for char in password) if not has_digit: return "Password should have at least o...
import re import random def check_password(password): """ Checks if the given password adheres to the specified criteria. Returns relevant error messages or 'valid'. """ length_error = "length should be between 8-16 characters" if len(password) < 8 or len(password) > 16: return length_e...
from solution import check_password, generate_password_with_check def test_generate_password_with_valid_length(): result = generate_password_with_check(10) assert "Password is:" in result assert "valid" in result def test_generate_password_with_short_length(): result = generate_password_with_check(5) ...
[ { "docstring": "Checks if the given password adheres to the specified criteria.\nReturns relevant error messages or 'valid'.", "function_declaration": "def check_password(password):", "function_name": "check_password", "parameter_list": "(password)" }, { "docstring": null, "function_decl...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\nimport random\n\ndef check_password(password):\n length_error = \"Length should be between 8-16 characters.\"\n if len(password) < 8 or len(password) > 16:\n return len...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001026", "row_id": 1026, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2982']" }
0.55688
Filter_1026
I
[ "check_password", "generate_password_with_check" ]
2
[ [ "generate_password_with_check", "check_password" ] ]
1
[]
false
[]
false
pytest
true
[]
true
b7749f5988d3c7f08748b4dcfa31e3247b6616d9
de77ea48efea86e71e6b81292192925003cf79cf
v1.0
instruct
Filter
Filter_1031_I
class Node: def __init__(self, data = None): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def insert(self, data): if not self.head: self.head = Node(data) else: cur = self.head while cur...
class Node: def __init__(self, data=None): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def insert(self, data): if not self.head: self.head = Node(data) else: cur = self.head while cur.n...
from solution import LinkedList, sort def test_sort_linked_list(): lst = LinkedList() lst.insert(5) lst.insert(3) lst.insert(8) lst.insert(4) lst.insert(2) sorted_head = sort(lst.head) sorted_values = [] current = sorted_head while current: sorted_values.append(current....
[]
[ 1, 1 ]
2
easy
1
{ "trial_gpt4o_0": null, "trial_gpt4o_1": { "file_source": "Magpie-Filter-89K_sanitized_prepared1_results_combined.jsonl", "solution_code": "class Node:\n def __init__(self, data=None):\n self.data = data\n self.next = None\n\nclass LinkedList:\n def __init__(self):\n self.head = ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001031", "row_id": 1031, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_2999']" }
0.480438
Filter_1031
I
[ "merge_links", "sort", "get_middle" ]
3
[ [ "sort", "get_middle" ], [ "sort", "merge_links" ] ]
2
[]
false
[ "Node", "LinkedList" ]
true
pytest
true
[]
true
2bfbad467db0dec8dd03f32ee4fab680c0350507
7836e9b03bef7891f834f3b4219ff8fa9f905ec7
v1.0
instruct
Filter
Filter_1044_I
import os import sys import hashlib path = 'path/to/dir' for filename in os.listdir(path): file_path = os.path.join(path, filename) if os.path.isfile(file_path): with open(file_path, 'rb') as file_to_check: file_hash = hashlib.md5(file_to_check.read()).hexdigest() print(file_pat...
import os import hashlib def calculate_md5(file_path): """ Calculate the MD5 hash of the file specified by file_path. """ with open(file_path, 'rb') as file_to_check: return hashlib.md5(file_to_check.read()).hexdigest() def hash_directory(directory): """ Traverse directories and subdir...
import os import tempfile import hashlib from solution import calculate_md5, hash_directory def create_temp_file(directory, filename, content): """ Create a temporary file with the specified content. """ file_path = os.path.join(directory, filename) with open(file_path, 'w') as temp_file: t...
[ { "docstring": "Calculate the MD5 hash of the file specified by file_path.", "function_declaration": "def calculate_md5(file_path):", "function_name": "calculate_md5", "parameter_list": "(file_path)" }, { "docstring": "Traverse directories and subdirectories to calculate MD5 hashes for each ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\nimport hashlib\n\ndef hash_files_in_directory(directory):\n \"\"\"\n Calculates the MD5 hash for all files in the specified directory and its subdirectories.\n \"\"\"\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001044", "row_id": 1044, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3047']" }
0.705058
Filter_1044
I
[ "calculate_md5", "hash_directory" ]
2
[ [ "hash_directory", "calculate_md5" ] ]
1
[]
false
[]
false
pytest
true
[]
true
17e4411cbe36a41d1b674ffa9ed43bdd8e223977
f50bfa8734c614dcc4b7619704e2fe8e3098775e
v1.0
instruct
Filter
Filter_1045_I
function `create_object` returns a dictionary with a specified `key` value from a list of key-value pairs. ```python def create_object(pairs): obj = {} for key, value in pairs: obj.update({key: value}) return obj ``` Here's how to use it: ```python pairs = [('name', 'John'), ('age', 30), ('city'...
def create_object(pairs): """ Create a dictionary from a list of key-value pairs. Args: pairs (list): A list of key-value pairs (tuples). Returns: dict: A dictionary created from the key-value pairs. """ obj = {} for key, value in pairs: obj.update({key: value}) return ...
from solution import create_object, repeat_string, repeat_strings def test_create_object(): pairs = [('name', 'John'), ('age', 30), ('city', 'New York')] expected = {'name': 'John', 'age': 30, 'city': 'New York'} assert create_object(pairs) == expected def test_repeat_string(): assert repeat_string('a...
[ { "docstring": "Create a dictionary from a list of key-value pairs.\n\nArgs:\npairs (list): A list of key-value pairs (tuples).\n\nReturns:\ndict: A dictionary created from the key-value pairs.", "function_declaration": "def create_object(pairs):", "function_name": "create_object", "parameter_list":...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def create_object(pairs):\n obj = {}\n for key, value in pairs:\n obj.update({key: value})\n return obj\n\ndef repeat_string(s, n):\n return s * n\n\ndef repeat_strings(pair...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001045", "row_id": 1045, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3051']" }
0.545729
Filter_1045
I
[ "create_object", "repeat_string", "repeat_strings" ]
3
[ [ "repeat_strings", "create_object" ], [ "repeat_strings", "repeat_string" ] ]
2
[]
false
[]
false
pytest
true
[]
true
7fbd90c3b479d7a0026e56e87657fa7d804ee0e0
c48793fec0d1f7270f32bc12e2b98268f590a6f4
v1.0
instruct
Filter
Filter_1060_I
import re import datetime def calculate_age(dob): today = datetime.date.today() age = today.year - dob.year - ((today.month, today.day) < (dob.month, dob.day)) return age def validate_dob(dob): try: datetime.datetime.strptime(dob, '%d-%m-%Y') return True except ValueError: ...
import re import datetime def calculate_age(dob): today = datetime.date.today() age = today.year - dob.year - ((today.month, today.day) < (dob.month, dob.day)) return age def validate_dob(dob): try: datetime.datetime.strptime(dob, '%d-%m-%Y') return True except ValueError: ...
import datetime from solution import calculate_age, validate_dob, extract_dob def test_calculate_age(): dob = datetime.date(1990, 1, 1) today = datetime.date.today() expected_age = today.year - dob.year - ((today.month, today.day) < (dob.month, dob.day)) assert calculate_age(dob) == expected_age def t...
[ { "docstring": null, "function_declaration": "def calculate_age(dob):", "function_name": "calculate_age", "parameter_list": "(dob)" }, { "docstring": null, "function_declaration": "def validate_dob(dob):", "function_name": "validate_dob", "parameter_list": "(dob)" }, { "d...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import re\nimport datetime\n\ndef calculate_age(dob):\n today = datetime.date.today()\n age = today.year - dob.year - ((today.month, today.day) < (dob.month, dob.day))\n return age\n\...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001060", "row_id": 1060, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3099']" }
0.596921
Filter_1060
I
[ "calculate_age", "validate_dob", "extract_dob", "get_dob", "calculate", "main" ]
6
[ [ "calculate", "calculate_age" ], [ "calculate", "get_dob" ], [ "get_dob", "validate_dob" ] ]
3
[]
false
[]
false
pytest
true
[]
true
1b535edceeb70de62d40c5cab6803af69b1973f5
7c95cca886b8b93e4a26ad57f8b5e310c343ccd2
v1.0
instruct
Filter
Filter_1063_I
import random as r import time import os def roll_dice(): return r.randint(1, 6) def roll_multiple_dice(num_dice): return [roll_dice() for _ in range(num_dice)] def roll_until_sum_reached(num_dice, target_sum): total = 0 num_rolls = 0 while total < target_sum: rolls = roll_multiple_dice(n...
import random as r import csv def roll_dice(): return r.randint(1, 6) def roll_multiple_dice(num_dice): return [roll_dice() for _ in range(num_dice)] def roll_until_sum_reached(num_dice, target_sum): total = 0 num_rolls = 0 results = [] while total < target_sum: rolls = roll_multiple_...
from solution import roll_until_sum_reached import csv import os def test_roll_until_sum_reached(): num_dice, target_sum = 3, 10 num_rolls, results = roll_until_sum_reached(num_dice, target_sum) assert os.path.exists('roll_results.csv'), "CSV file not created" with open('roll_results.csv', ne...
[ { "docstring": null, "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def roll_multiple_dice(num_dice):", "function_name": "roll_multiple_dice", "parameter_list": "(num_dice)" }, ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import csv\nimport random as r\nimport os\nimport time\n\ndef roll_dice():\n return r.randint(1, 6)\n\ndef roll_multiple_dice(num_dice):\n return [roll_dice() for _ in range(num_dice)]\n...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001063", "row_id": 1063, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3108']" }
0.604698
Filter_1063
I
[ "roll_dice", "roll_multiple_dice", "roll_until_sum_reached" ]
3
[ [ "roll_multiple_dice", "roll_dice" ], [ "roll_until_sum_reached", "roll_multiple_dice" ] ]
2
[]
false
[]
false
pytest
true
[]
true
cbcac09b3add9e94a6cb7815a3a40ff1e7e7027e
97e40cb05c639de48962fb52ce18b24a91c83ca2
v1.0
instruct
Filter
Filter_1074_I
import math import numpy as np def is_prime(n): if n <= 1: return False if n == 2: return True if n % 2 == 0: return False sqrt_n = math.isqrt(n) for i in range(3, sqrt_n + 1, 2): if n % i == 0: return False return True def find_all_primes(n): pr...
def is_prime(n): """ Check if a number is prime. Args: n (int): The number to check. Returns: bool: True if the number is prime, False otherwise. """ if n <= 1: return False if n == 2: return True if n % 2 == 0: return False sqrt_n = int(n**0...
from solution import is_prime, find_all_primes def test_is_prime(): assert not is_prime(0) assert not is_prime(1) assert is_prime(2) assert is_prime(3) assert not is_prime(4) assert is_prime(5) assert is_prime(29) assert not is_prime(30) def test_find_all_primes(): assert find_all_...
[ { "docstring": "Check if a number is prime.\n\nArgs:\nn (int): The number to check.\n\nReturns:\nbool: True if the number is prime, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Find the first n prime nu...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is prime.\n \n Args:\n n (int): The number to check.\n \n Returns:\n bool: True if the number is prime, False otherwise.\n...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001074", "row_id": 1074, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3144']" }
0.730094
Filter_1074
I
[ "is_prime", "find_all_primes" ]
2
[ [ "find_all_primes", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
66552b250df26f0c7f87aee83e0ae08d826a5edf
82a5c1d1ec4a743a63e869741722a9deee40b9a0
v1.0
instruct
Filter
Filter_1080_I
import math x = 0 # initial value of x iterations = 0 # number of iterations epsilon = 0.00001 # small value def compute_derivative(f, x): # calculate the derivative of f at x using the limit definition h = 0.00001 # small change in x return (f(x + h) - f(x - h)) / (2 * h) def f(x): return x ** 3...
def compute_derivative(f, x): """ Calculates the derivative of the function f at x using the limit definition. """ h = 0.00001 # small change in x return (f(x + h) - f(x - h)) / (2 * h) def f(x): """ The function for which we are finding the root. """ return x ** 3 - 2 * x - 5 def...
from solution import newton_method, f, compute_derivative def test_newton_method_convergence(): root, iterations = newton_method() assert abs(f(root)) < 0.0001, "Root does not satisfy the equation f(x) = 0" assert iterations < 1000, "Exceeded the maximum number of iterations" def test_newton_method_initia...
[ { "docstring": "Calculates the derivative of the function f at x using the limit definition.", "function_declaration": "def compute_derivative(f, x):", "function_name": "compute_derivative", "parameter_list": "(f, x)" }, { "docstring": "The function for which we are finding the root.", "...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def compute_derivative(f, x):\n \"\"\"\n Calculates the derivative of the function f at x using the limit definition.\n \"\"\"\n h = 0.00001 # small change in x\n return (f(x +...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001080", "row_id": 1080, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3165']" }
0.499497
Filter_1080
I
[ "compute_derivative", "f", "newton_method" ]
3
[ [ "newton_method", "compute_derivative" ], [ "newton_method", "f" ] ]
2
[]
false
[]
false
pytest
true
[]
true
b754b295609fac7b46200d4dd6a7a22a633d3490
d172b29def421030577cb36a32783e98138f6f37
v1.0
instruct
Filter
Filter_1103_I
import random import math def calculate_distance(point1, point2): return math.sqrt((point2[0] - point1[0])**2 + (point2[1] - point1[1])**2) def generate_random_point(): return (random.randint(-100, 100), random.randint(-100, 100)) def generate_cluster(points, k): # Select k random points from the list of...
import random import math def calculate_distance(point1, point2): return math.sqrt((point2[0] - point1[0])**2 + (point2[1] - point1[1])**2) def generate_random_point(): return (random.randint(-100, 100), random.randint(-100, 100)) def generate_cluster(points, k, max_iterations=100): centroids = random.sa...
from solution import generate_cluster, generate_random_point import random def test_generate_clusters_length(): points = [generate_random_point() for _ in range(100)] k = 5 clusters = generate_cluster(points, k) assert len(clusters) == k, "Should create k clusters" def test_generate_clusters_no_empty_...
[ { "docstring": null, "function_declaration": "def calculate_distance(point1, point2):", "function_name": "calculate_distance", "parameter_list": "(point1, point2)" }, { "docstring": null, "function_declaration": "def generate_random_point():", "function_name": "generate_random_point"...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport math\n\ndef calculate_distance(point1, point2):\n return math.sqrt((point2[0] - point1[0])**2 + (point2[1] - point1[1])**2)\n\ndef generate_random_point():\n return...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001103", "row_id": 1103, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3253']" }
0.708085
Filter_1103
I
[ "calculate_distance", "generate_random_point", "generate_cluster" ]
3
[ [ "generate_cluster", "calculate_distance" ] ]
1
[]
false
[]
false
pytest
true
[]
true
902b30b43b72ff8cd0e6c7c82578ebc954d8bf19
edf4a6d55d04f849803345e222c5288287873343
v1.0
instruct
Filter
Filter_1105_I
def is_palindrome(n): return str(n) == str(n)[::-1] def main(): max_palindrome = 0 for i in range(999, 99, -1): for j in range(i, 99, -1): product = i * j if is_palindrome(product) and product > max_palindrome: max_palindrome = product print(max_palindrom...
def is_palindrome(n): """ Check if a number is a palindrome. """ return str(n) == str(n)[::-1] def find_largest_palindrome(): """ Returns the largest palindrome made from the product of two 3-digit numbers. """ max_palindrome = 0 for i in range(999, 99, -1): for j in range(i...
from solution import is_palindrome, find_largest_palindrome def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(1001) == True assert is_palindrome(1221) == True assert is_palindrome(12321) == True def test_find_largest_palindrome(): ...
[ { "docstring": "Check if a number is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Returns the largest palindrome made from the product of two 3-digit numbers.", "function_declaration": "def f...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n \"\"\"\n Checks if the given number is a palindrome.\n\n Args:\n n (int): The number to check.\n\n Returns:\n bool: True if the number is a pa...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001105", "row_id": 1105, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3260']" }
0.693658
Filter_1105
I
[ "is_palindrome", "find_largest_palindrome" ]
2
[ [ "find_largest_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
20897361acc03480e8b8cebc8b0d0af95389c8e9
161c411a17a41ad03152acadf9d98841bb311a7d
v1.0
instruct
Filter
Filter_1112_I
import os import re def get_elements(file_path): with open(file_path, 'r') as f: content = f.read() # Use regular expression to get all lines that contain 'Element' followed by four digits pattern = re.compile('Element\s+(\d{4})') elements = pattern.findall(content) return elements def get...
import os import re def get_elements(file_path): with open(file_path, 'r') as f: content = f.read() # Use regular expression to get all lines that contain 'Element' followed by four digits pattern = re.compile('Element\s+(\d{4})') elements = pattern.findall(content) return elements def get...
import os import tempfile import pytest from solution import get_elements, get_elements_from_files_in_directory def test_get_elements(): content = "Element 1234\nSome other text\nElement 5678" with tempfile.NamedTemporaryFile(delete=False, mode='w', suffix='.txt') as temp_file: file_name = temp_file.na...
[ { "docstring": null, "function_declaration": "def get_elements(file_path):", "function_name": "get_elements", "parameter_list": "(file_path)" }, { "docstring": null, "function_declaration": "def get_elements_from_files_in_directory(directory_path):", "function_name": "get_elements_fr...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\nimport re\n\ndef get_elements(file_path):\n with open(file_path, 'r') as f:\n content = f.read()\n # Use regular expression to get all lines that contain 'Element' foll...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001112", "row_id": 1112, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3282']" }
0.644444
Filter_1112
I
[ "get_elements", "get_elements_from_files_in_directory", "main" ]
3
[ [ "get_elements_from_files_in_directory", "get_elements" ] ]
1
[]
false
[]
false
pytest
true
[]
true
37d41d7c1015373aaa07b021c24b3e106560a406
0a35e42bb660a5132f8e6df1c0faafd1b9be4b0b
v1.0
instruct
Filter
Filter_1137_I
import random import time def guess_number_game(): number_to_guess = random.randint(1, 100) guess = None attempts = 0 start_time = time.time() while guess != number_to_guess: guess = input("Guess a number between 1 and 100: ") guess = int(guess) attempts += 1 if gue...
import random import time def guess_number_game_logic(number_to_guess, guess): """ Returns a hint 'too low', 'too high', or 'correct' based on the guess. """ if guess < number_to_guess: return "too low" elif guess > number_to_guess: return "too high" else: return "correc...
from solution import guess_number_game_logic def test_guess_number_game_logic_low(): assert guess_number_game_logic(50, 30) == "too low" def test_guess_number_game_logic_high(): assert guess_number_game_logic(50, 70) == "too high" def test_guess_number_game_logic_correct(): assert guess_number_game_logic...
[ { "docstring": "Returns a hint 'too low', 'too high', or 'correct' based on the guess.", "function_declaration": "def guess_number_game_logic(number_to_guess, guess):", "function_name": "guess_number_game_logic", "parameter_list": "(number_to_guess, guess)" }, { "docstring": null, "funct...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport time\n\ndef guess_number_game(input_function=input, print_function=print):\n number_to_guess = random.randint(1, 100)\n guess = None\n attempts = 0\n start_ti...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001137", "row_id": 1137, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3365']" }
0.610482
Filter_1137
I
[ "guess_number_game_logic", "guess_number_game" ]
2
[ [ "guess_number_game", "guess_number_game_logic" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d7787886f7db01321c16d595a1af615360286f3d
4682cc041987e515aa2b2416fcfef43bd8669850
v1.0
instruct
Filter
Filter_1151_I
def check_prime(n): """Check if a number is prime.""" if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False return True def is_prime...
def check_prime(n): """Check if a number is prime.""" if n <= 1: return False if n == 2: return True if n % 2 == 0: return False max_divisor = int(n**0.5) + 1 for d in range(3, max_divisor, 2): if n % d == 0: return False return True def is_prime_...
from solution import check_prime, is_prime_list def test_check_prime_negative_numbers(): assert not check_prime(-1) assert not check_prime(-5) assert not check_prime(-10) def test_check_prime_non_primes(): assert not check_prime(0) assert not check_prime(1) assert not check_prime(4) assert...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def check_prime(n):", "function_name": "check_prime", "parameter_list": "(n)" }, { "docstring": "Take a list of numbers and return a list of their prime status.", "function_declaration": "def is_prime_list(num_list):"...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def check_prime(n):\n \"\"\"Check if a number is prime.\"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True\n if n % 2 == 0:\n return False\n max_d...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001151", "row_id": 1151, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3421']" }
0.828269
Filter_1151
I
[ "check_prime", "is_prime_list", "main" ]
3
[ [ "is_prime_list", "check_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
32e9c94670ccf8309a2a739be776160a109bd49b
9dc2a06d6fd710a080517ba6ad1af43a84a4bc27
v1.0
instruct
Filter
Filter_1170_I
import os import sys import json def get_data(): with open('products.json') as f: data = json.load(f) return data def calculate_total_price(data): total_price = 0 for product in data: total_price += product['price'] return total_price def get_total_price(): data = get_data() ...
def get_data(): # Raw data representation of products.json data = [ {"name": "Product1", "price": 1000}, {"name": "Product2", "price": 2000}, {"name": "Product3", "price": 3000} ] return data def calculate_total_price(data): total_price = 0 for product in data: t...
from solution import get_data, calculate_total_price, get_total_price def test_get_data(): assert get_data() == [ {"name": "Product1", "price": 1000}, {"name": "Product2", "price": 2000}, {"name": "Product3", "price": 3000} ] def test_calculate_total_price(): data = [ {"nam...
[ { "docstring": null, "function_declaration": "def get_data():", "function_name": "get_data", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def calculate_total_price(data):", "function_name": "calculate_total_price", "parameter_list": "(data)" }, { ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def get_data():\n # Raw data representation of products.json\n data = [\n {\"name\": \"Product1\", \"price\": 1000},\n {\"name\": \"Product2\", \"price\": 2000},\n {...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001170", "row_id": 1170, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3481']" }
0.588106
Filter_1170
I
[ "get_data", "calculate_total_price", "get_total_price", "main" ]
4
[ [ "get_total_price", "calculate_total_price" ], [ "get_total_price", "get_data" ] ]
2
[]
false
[]
false
pytest
true
[]
true
2458ade13d23489c842539da84b5aa7ae29c6fe2
fd80ba3f58967e2899dfa4cb5ece014b9987cdae
v1.0
instruct
Filter
Filter_1171_I
def calculate_histogram(bin_values, bin_edges): hist = [] for i in range(1, len(bin_edges)): bin_width = bin_edges[i] - bin_edges[i-1] hist_val = bin_values[i-1] / bin_width hist.append(hist_val) return hist def find_bin_index(bin_edges, x): idx = 0 while idx < len(bin_edg...
def calculate_histogram(bin_values, bin_edges): """ Given bin values and bin edges, calculates the histogram. Parameters: bin_values (list of float): The list of values in each bin. bin_edges (list of float): The list of bin edges. Returns: list of float: The histogram values. """ ...
def test_calculate_histogram(): bin_values = [10, 20, 30] bin_edges = [0, 1, 2, 3] expected_hist = [10, 20, 30] assert calculate_histogram(bin_values, bin_edges) == expected_hist bin_values = [5, 15, 25] bin_edges = [0, 2, 4, 6] expected_hist = [2.5, 7.5, 12.5] assert calculate_histogra...
[ { "docstring": "Given bin values and bin edges, calculates the histogram.\n\nParameters:\nbin_values (list of float): The list of values in each bin.\nbin_edges (list of float): The list of bin edges.\n\nReturns:\nlist of float: The histogram values.", "function_declaration": "def calculate_histogram(bin_va...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_histogram(bin_values, bin_edges):\n \"\"\"\n Calculates histogram values based on bin_values and bin_edges.\n \n Parameters:\n bin_values (list): Values correspond...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001171", "row_id": 1171, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3482']" }
0.72363
Filter_1171
I
[ "calculate_histogram", "find_bin_index", "distribute_value" ]
3
[ [ "distribute_value", "find_bin_index" ] ]
1
[]
false
[]
false
pytest
false
[]
true
db629fe7a3bc102ffd774f05796b0ea9965e27e1
444e8d3f7712251b55a4c899eb0ad320b8d980c6
v1.0
instruct
Filter
Filter_1184_I
# Given a list of lists, determine if the elements in each sublist are sorted in ascending order. Here is the example of lists of lists: ``` [[1, 2, 3], [4, 5, 6, 7], [7, 6, 5, 4], [1, 2, 3, 4, 5, 6]] ``` The expected answer for the above example is: `[True, True, False, True]` Here is my Python code: ```python def...
def is_sorted(sublist): """ Checks if the elements in the given sublist are sorted in ascending order. """ return sublist == sorted(sublist) def check_sublists_sorted(lists): """ Returns a list of booleans indicating whether each sublist in the input list of lists is sorted in ascending or...
from solution import is_sorted, check_sublists_sorted def test_is_sorted(): assert is_sorted([1, 2, 3]) == True assert is_sorted([3, 2, 1]) == False assert is_sorted([1, 1, 1]) == True assert is_sorted([]) == True def test_check_sublists_sorted(): assert check_sublists_sorted([[1, 2, 3], [4, 5, 6,...
[ { "docstring": "Checks if the elements in the given sublist are sorted in ascending order.", "function_declaration": "def is_sorted(sublist):", "function_name": "is_sorted", "parameter_list": "(sublist)" }, { "docstring": "Returns a list of booleans indicating whether each sublist in the inp...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def are_sublists_sorted(lists_of_lists):\n \"\"\"\n Determines if each sublist in 'lists_of_lists' is sorted in ascending order.\n \n Arguments:\n lists_of_lists -- a list conta...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001184", "row_id": 1184, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3532']" }
0.655416
Filter_1184
I
[ "is_sorted", "check_sublists_sorted" ]
2
[ [ "check_sublists_sorted", "is_sorted" ] ]
1
[]
false
[]
false
pytest
true
[]
true
1e2aa107c700265cf7aa535452dd2a012cc41d41
41980fac40336e598aeb5a47130df92acd16eec2
v1.0
instruct
Filter
Filter_1191_I
# Day 8 of 100 Days of Code Challenge **Day 8: Rock, Paper, Scissors Project** ===================================== ### Project Overview Create a Rock, Paper, Scissors game where the user can play against the computer. The game should keep track of the score and allow the user to play again. ### Code ```python im...
import random def determine_winner(user_choice, computer_choice): """ Determines the winner of the rock, paper, scissors game. """ if user_choice == computer_choice: return "tie" elif user_choice == "rock": return "win" if computer_choice == "scissors" else "lose" elif user_choi...
from solution import determine_winner, play_rps import pytest def test_determine_winner_tie(): assert determine_winner("rock", "rock") == "tie" assert determine_winner("paper", "paper") == "tie" assert determine_winner("scissors", "scissors") == "tie" def test_determine_winner_rock(): assert determine...
[ { "docstring": "Determines the winner of the rock, paper, scissors game.", "function_declaration": "def determine_winner(user_choice, computer_choice):", "function_name": "determine_winner", "parameter_list": "(user_choice, computer_choice)" }, { "docstring": "Plays a single round of rock, p...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef get_computer_choice():\n \"\"\"Returns the computer's choice\"\"\"\n return random.choice([\"rock\", \"paper\", \"scissors\"])\n\ndef determine_winner(user_choice, c...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001191", "row_id": 1191, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3562']" }
0.615821
Filter_1191
I
[ "determine_winner", "play_rps" ]
2
[ [ "play_rps", "determine_winner" ] ]
1
[]
false
[]
false
pytest
true
[]
true
dfd7074d40a9a9c0518f9ae49ed98221b1e1816a
b231b022ba37e329bf09dbd533051a34c74d6102
v1.0
instruct
Filter
Filter_1192_I
# How do you use a Dictionary in Python to find words that are one edit away from a given word?
def is_one_edit_away(word1, word2): """ Check if word1 and word2 are one edit away. """ len1, len2 = len(word1), len(word2) if abs(len1 - len2) > 1: return False i = j = alterations = 0 while i < len1 and j < len2: if word1[i] != word2[j]: if alterations == 1: ...
from solution import is_one_edit_away, find_one_edit_words def test_is_one_edit_away(): assert is_one_edit_away("cat", "bat") == True assert is_one_edit_away("cat", "cats") == True assert is_one_edit_away("cat", "cut") == True assert is_one_edit_away("cat", "cast") == True assert is_one_edit_away("...
[ { "docstring": "Check if word1 and word2 are one edit away.", "function_declaration": "def is_one_edit_away(word1, word2):", "function_name": "is_one_edit_away", "parameter_list": "(word1, word2)" }, { "docstring": "Finds all words in a given dictionary that are one edit away from the word."...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_one_edit_away(word1, word2):\n \"\"\"\n Check if word1 and word2 are one edit away.\n \"\"\"\n len1, len2 = len(word1), len(word2)\n if abs(len1 - len2) > 1:\n ret...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001192", "row_id": 1192, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3565']" }
0.568403
Filter_1192
I
[ "is_one_edit_away", "find_one_edit_words" ]
2
[ [ "find_one_edit_words", "is_one_edit_away" ] ]
1
[]
false
[]
false
pytest
true
[]
true
80c747dc12fa88fa13933f9a0775bbc212fc3cb7
b49a1667d659411399523431e90db613c4a3cd72
v1.0
instruct
Filter
Filter_1218_I
import os import json def _pip_installed_packages(): # Your code here def _pip_install(package): # Your code here def _pip_uninstall(package): # Your code here def main(): packages = _pip_installed_packages() # Example usage of packages: print(packages) # Example usage of installation:...
import subprocess def _pip_installed_packages(): try: output = subprocess.check_output(["pip", "freeze"]) packages = output.decode("utf-8").splitlines() package_dict = {} for package in packages: package_name, package_version = package.split("==") package_dic...
import subprocess from solution import _pip_installed_packages, _pip_install, _pip_uninstall, _reinstall_original_packages def test_pip_installed_packages(monkeypatch): def mock_check_output(cmd): return b"package1==1.0.0\npackage2==2.0.0\n" monkeypatch.setattr(subprocess, 'check_output', mock_check_ou...
[ { "docstring": null, "function_declaration": "def _pip_installed_packages():", "function_name": "_pip_installed_packages", "parameter_list": "()" }, { "docstring": "Installs the given package using pip.\nIf an error occurs, it tries to revert to the original state.", "function_declaratio...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import subprocess\n\ndef _pip_installed_packages():\n \"\"\"\n Returns a dictionary of installed pip packages with their versions.\n \"\"\"\n try:\n output = subprocess.chec...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001218", "row_id": 1218, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3643']" }
0.597146
Filter_1218
I
[ "_pip_installed_packages", "_pip_install", "_reinstall_original_packages", "_pip_uninstall", "main" ]
5
[ [ "_pip_install", "_pip_installed_packages" ], [ "_pip_install", "_reinstall_original_packages" ], [ "_pip_uninstall", "_pip_installed_packages" ], [ "_pip_uninstall", "_reinstall_original_packages" ] ]
4
[]
false
[]
false
pytest
true
[]
true
4c94b797892fcc86da0cc208ad37c00ff43eebd8
97627e9bbd15ecdbd5857c6adf16601b9725f7bd
v1.0
instruct
Filter
Filter_1225_I
This is a long question, so please bear with me. I have a data structure in which each object has a `region_id` that corresponds to a specific geographic region. I want to write a function that takes an object of this type, and returns an object of the same type, but with the `region_id` transformed to a different reg...
def transform_region_id(obj, mapping_dict, unknown_region_id): """ Transforms the region_id of a given object based on a mapping dictionary. If the region_id is not found in the mapping_dict, the unknown_region_id is used. Parameters: - obj: dict, object containing the key 'region_id'. - mappin...
from solution import transform_region_id, transform_region_ids def test_transform_region_id(): mapping_dict = {1: 10, 2: 20, 3: 30} unknown_region_id = 99 obj = {"name": "John", "region_id": 1} new_obj = transform_region_id(obj, mapping_dict, unknown_region_id) assert new_obj["region_id"] == 10 ...
[ { "docstring": "Transforms the region_id of a given object based on a mapping dictionary.\nIf the region_id is not found in the mapping_dict, the unknown_region_id is used.\n\nParameters:\n- obj: dict, object containing the key 'region_id'.\n- mapping_dict: dict, a dictionary mapping original region_ids to new ...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def transform_region_id(obj, mapping_dict, unknown_region_id):\n transformed_obj = obj.copy() # Make a copy of the object\n if \"region_id\" in transformed_obj:\n transformed_obj...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001225", "row_id": 1225, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3673']" }
0.560361
Filter_1225
I
[ "transform_region_id", "transform_region_ids" ]
2
[ [ "transform_region_ids", "transform_region_id" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9a7c95340f3e9c3b0c68344f6e5199647a305545
c4c4736fc1b944d518deb097abe89f55c1ea8a17
v1.0
instruct
Filter
Filter_1233_I
import random def generate_random_sequence(length): return [random.randint(0, 1) for _ in range(length)] def find_subsequence(sequence, subsequence): for i in range(len(sequence) - len(subsequence) + 1): if sequence[i:i+len(subsequence)] == subsequence: return i return -1 def main(): ...
def kmp_preprocess(pattern): """ Preprocess the pattern array based on proper prefixes which are also suffixes. :param pattern: List[int] representing the pattern. :return: List[int] representing the longest prefix which is also suffix array. """ lps = [0] * len(pattern) length = 0 i = 1...
from solution import find_subsequence def test_find_subsequence_present(): sequence = [1, 2, 3, 4, 5, 6, 7, 8, 9] subsequence = [4, 5, 6] assert find_subsequence(sequence, subsequence) == 3 def test_find_subsequence_not_present(): sequence = [1, 2, 3, 4, 5, 6, 7, 8, 9] subsequence = [7, 6] ass...
[ { "docstring": "Preprocess the pattern array based on proper prefixes which are also suffixes.\n:param pattern: List[int] representing the pattern.\n:return: List[int] representing the longest prefix which is also suffix array.", "function_declaration": "def kmp_preprocess(pattern):", "function_name": "...
[ 0, 0, 1 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def kmp_preprocess(subsequence):\n \"\"\"\n Preprocess the subsequence to create the partial match table.\n \"\"\"\n lps = [0] * len(subsequence)\n length = 0 # length of the p...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001233", "row_id": 1233, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3694']" }
0.498802
Filter_1233
I
[ "kmp_preprocess", "find_subsequence" ]
2
[ [ "find_subsequence", "kmp_preprocess" ] ]
1
[]
false
[]
false
pytest
true
[]
true
6197890157e427a34b9d29af7ba5a2f7ee55dc22
49091263b42644969c4e9700b5cc33a5c0931e90
v1.0
instruct
Filter
Filter_1238_I
This program is intended to add personalized greetings to the end of the email. Here is the code: ```python def generate_greeting(name, email): greeting = f"Hi {name}, " signature = "\n\nBest regards,\n[Your Name]" full_greeting = f"{greeting}Please be advised that your email {email} has been received." ...
def extract_local_part(email): """ Extracts the local part of the email address before the '@' symbol. """ return email.split('@')[0] def generate_greeting(name, email): local_part = extract_local_part(email) greeting = f"Hi {name}, " signature = "\n\nBest regards,\n[Your Name]" full_gr...
from solution import extract_local_part, generate_greeting def test_extract_local_part(): assert extract_local_part("johndoe@example.com") == "johndoe" assert extract_local_part("alice.smith@company.org") == "alice.smith" assert extract_local_part("user123@domain.com") == "user123" assert extract_local...
[ { "docstring": "Extracts the local part of the email address before the '@' symbol.", "function_declaration": "def extract_local_part(email):", "function_name": "extract_local_part", "parameter_list": "(email)" }, { "docstring": null, "function_declaration": "def generate_greeting(name, ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_greeting(name, email):\n local_part = email.split('@')[0]\n greeting = f\"Hi {name}, \"\n signature = \"\\n\\nBest regards,\\n[Your Name]\"\n full_greeting = f\"{greet...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001238", "row_id": 1238, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3699']" }
0.493336
Filter_1238
I
[ "extract_local_part", "generate_greeting", "main" ]
3
[ [ "generate_greeting", "extract_local_part" ] ]
1
[]
false
[]
false
pytest
true
[]
true
84663fe1857ed6e04175098e9f56f1300d25da05
05609ae15e205b599491ac71d9131feb687bb01a
v1.0
instruct
Filter
Filter_1240_I
def match_parentheses(s): stack = [] for char in s: if char == '(': stack.append(char) elif char == ')': if stack and stack[-1] == '(': stack.pop() else: return False return not stack def is_valid(s): return match_paren...
def match_parentheses(s): """ Checks if the parentheses in the string are valid. A string containing just the characters '(' and ')' is valid if: - Every opening parenthesis '(' has a corresponding closing parenthesis ')' - Parentheses must be closed in the correct order Args: s (str):...
from solution import match_parentheses, is_valid def test_match_parentheses_empty_string(): assert match_parentheses("") == True def test_match_parentheses_single_pair(): assert match_parentheses("()") == True def test_match_parentheses_nested_pairs(): assert match_parentheses("(())") == True def test_m...
[ { "docstring": "Checks if the parentheses in the string are valid.\n\nA string containing just the characters '(' and ')' is valid if:\n- Every opening parenthesis '(' has a corresponding closing parenthesis ')'\n- Parentheses must be closed in the correct order\n\nArgs:\ns (str): The input string containing on...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def match_parentheses(s):\n stack = []\n for char in s:\n if char == '(':\n stack.append(char)\n elif char == ')':\n if stack and stack[-1] == '(':\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001240", "row_id": 1240, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3716']" }
0.814384
Filter_1240
I
[ "match_parentheses", "is_valid" ]
2
[ [ "is_valid", "match_parentheses" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d5fe9d06f93d63fdab49b7698925c4072929ba76
d4942e6ba25be1a27de3e8c52e114b57d644776c
v1.0
instruct
Filter
Filter_1248_I
import random def new_deck(): suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King', 'Ace'] deck = [{'Suit': suit, 'Rank': rank} for suit in suits for rank in ranks] random.shuffle(deck) return deck def draw_card(deck): ...
import random def new_deck(): suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades'] ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King', 'Ace'] deck = [{'Suit': suit, 'Rank': rank} for suit in suits for rank in ranks] random.shuffle(deck) return deck def draw_card(deck): ...
import pytest from solution import new_deck, draw_card, calculate_hand_value, hit, determine_winner def test_new_deck(): deck = new_deck() assert len(deck) == 52 assert isinstance(deck, list) assert all(isinstance(card, dict) for card in deck) def test_draw_card(): deck = new_deck() initial_de...
[ { "docstring": null, "function_declaration": "def new_deck():", "function_name": "new_deck", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def draw_card(deck):", "function_name": "draw_card", "parameter_list": "(deck)" }, { "docstring": null, ...
[ 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 new_deck():\n suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades']\n ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King', 'Ace']\n deck = ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001248", "row_id": 1248, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3730']" }
0.696412
Filter_1248
I
[ "new_deck", "draw_card", "calculate_hand_value", "hit", "determine_winner" ]
5
[ [ "determine_winner", "calculate_hand_value" ], [ "hit", "draw_card" ] ]
2
[]
false
[]
false
pytest
true
[]
true
5b8d9b920bb54de09d12ecf80c30a580b66a9024
d6a92f6aec9dc6662914b9cc8f7e1d09def587ab
v1.0
instruct
Filter
Filter_1249_I
def count_characters(word): count_dict = {} for char in word: if char in count_dict: count_dict[char] += 1 else: count_dict[char] = 1 return count_dict def most_frequent_character(word): char_count = count_characters(word) max_count = max(char_count.values())...
def count_characters(word): """ Returns a dictionary with the count of each character in the word. """ count_dict = {} for char in word: if char in count_dict: count_dict[char] += 1 else: count_dict[char] = 1 return count_dict def most_frequent_character...
from solution import count_characters, most_frequent_character, is_isogram def test_count_characters(): assert count_characters("test") == {'t': 2, 'e': 1, 's': 1} assert count_characters("isogram") == {'i': 1, 's': 1, 'o': 1, 'g': 1, 'r': 1, 'a': 1, 'm': 1} assert count_characters("") == {} assert cou...
[ { "docstring": "Returns a dictionary with the count of each character in the word.", "function_declaration": "def count_characters(word):", "function_name": "count_characters", "parameter_list": "(word)" }, { "docstring": "Returns a list of the most frequently occurring character(s) in the w...
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def count_characters(word):\n \"\"\"\n Returns a dictionary with the count of each character in the word.\n \"\"\"\n count_dict = {}\n for char in word:\n if char in coun...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001249", "row_id": 1249, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3734']" }
0.678139
Filter_1249
I
[ "count_characters", "most_frequent_character", "is_isogram" ]
3
[ [ "is_isogram", "count_characters" ], [ "most_frequent_character", "count_characters" ] ]
2
[]
false
[]
false
pytest
true
[]
true
edfe29cbb866cd8d2e723095cc81fe4efcedfbfe
e24d947acb923130c848f514f1a6cb1aee72814e
v1.0
instruct
Filter
Filter_1250_I
import os import sys def bruteForceSearch(pattern, text): for i in range(len(text)): match = True for j in range(len(pattern)): if text[i+j] != pattern[j]: match = False break if match: return i return -1 def findPattern(pattern, ...
def bruteForceSearch(pattern, text): """ Performs brute-force search for a pattern within a given text. :param pattern: The pattern to be searched. :param text: The text in which to search for the pattern. :return: The starting index of the first occurrence of the pattern in the text, or -1 if the ...
from solution import bruteForceSearch, findPattern def test_bruteForceSearch_pattern_at_start(): assert bruteForceSearch("abc", "abcdef") == 0 def test_bruteForceSearch_pattern_at_mid(): assert bruteForceSearch("abc", "xabcx") == 1 def test_bruteForceSearch_pattern_at_end(): assert bruteForceSearch("abc"...
[ { "docstring": "Performs brute-force search for a pattern within a given text.\n\n:param pattern: The pattern to be searched.\n:param text: The text in which to search for the pattern.\n:return: The starting index of the first occurrence of the pattern in the text, or -1 if the pattern is not found.", "func...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def bruteForceSearch(pattern, text):\n for i in range(len(text) - len(pattern) + 1):\n match = True\n for j in range(len(pattern)):\n if text[i+j] != pattern[j]:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001250", "row_id": 1250, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3735']" }
0.47823
Filter_1250
I
[ "bruteForceSearch", "findPattern" ]
2
[ [ "findPattern", "bruteForceSearch" ] ]
1
[]
false
[]
false
pytest
true
[]
true
68d704fb8daa05b5e934b9584d01b4b6f3251947
a55b031fb6ecd494c207d7cac841d3db3a2f343a
v1.0
instruct
Filter
Filter_1257_I
This is a Python solution for the Udemy course "100 Days of Code" Day 11.2 Challenge. ## Project: Blackjack Game ### Overview Create a simple Blackjack game. ### Requirements * Create a deck of 52 cards, without jokers. * Deal two cards to the player and two cards to the dealer. * The player can see both of t...
import random # Define a dictionary with card ranks and values card_values = { '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, 'J': 10, 'Q': 10, 'K': 10, 'A': 11 } # Define a function to create a deck def create_deck(): """Create a stan...
from solution import create_deck, calculate_total, deal_cards, dealer_turn def test_create_deck(): deck = create_deck() assert len(deck) == 52 suits = set(card['suit'] for card in deck) assert suits == {'Hearts', 'Diamonds', 'Clubs', 'Spades'} ranks = set(card['rank'] for card in deck) assert r...
[ { "docstring": "Create a standard deck of 52 cards without jokers.", "function_declaration": "def create_deck():", "function_name": "create_deck", "parameter_list": "()" }, { "docstring": "Calculate the total value of a hand of cards.", "function_declaration": "def calculate_total(hand):...
[ 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\ncard_values = {\n '2': 2,\n '3': 3,\n '4': 4,\n '5': 5,\n '6': 6,\n '7': 7,\n '8': 8,\n '9': 9,\n '10': 10,\n 'J': 10,\n 'Q': 10,\n 'K': 10...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001257", "row_id": 1257, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3755']" }
0.566451
Filter_1257
I
[ "create_deck", "calculate_total", "deal_cards", "dealer_turn", "play_game" ]
5
[ [ "dealer_turn", "calculate_total" ], [ "play_game", "calculate_total" ], [ "play_game", "create_deck" ], [ "play_game", "deal_cards" ], [ "play_game", "dealer_turn" ] ]
5
[]
false
[]
false
pytest
true
[]
true
dfdcb9439438a5e2c6f3e81e248f7cf2011ce414
7e96500374aab92be83f8759dcdfa5a284b0a1b3
v1.0
instruct
Filter
Filter_1267_I
This is the code I'm working on: ```python import random def generate_random_number(min_value, max_value): return random.randint(min_value, max_value) def ask_user_for_number(min_value, max_value): while True: user_number = input(f"Guess a number between {min_value} and {max_value}: ") try: ...
import random def generate_random_number(min_value, max_value): return random.randint(min_value, max_value) def ask_user_for_number(min_value, max_value): while True: user_number = input(f"Guess a number between {min_value} and {max_value}: ") try: user_number = int(user_number) ...
from solution import generate_random_number, ask_user_for_number, play_game from unittest.mock import patch import pytest def test_generate_random_number(): number = generate_random_number(1, 100) assert 1 <= number <= 100 @patch('builtins.input', side_effect=[50, 101, -1, "abc", 75]) def test_ask_user_for_nu...
[ { "docstring": null, "function_declaration": "def generate_random_number(min_value, max_value):", "function_name": "generate_random_number", "parameter_list": "(min_value, max_value)" }, { "docstring": null, "function_declaration": "def ask_user_for_number(min_value, max_value):", "f...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef generate_random_number(min_value, max_value):\n return random.randint(min_value, max_value)\n\ndef ask_user_for_number(min_value, max_value):\n while True:\n ...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001267", "row_id": 1267, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3785']" }
0.511235
Filter_1267
I
[ "generate_random_number", "ask_user_for_number", "play_game" ]
3
[ [ "play_game", "ask_user_for_number" ], [ "play_game", "generate_random_number" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a6af8613480355d966542fb596b67163efdf7804
5b73d5f91bb39ba3a193b42f7f6a4f0731c81306
v1.0
instruct
Filter
Filter_1272_I
I'm a beginner in machine learning, and I'm trying to implement the K-Means clustering algorithm. Can you provide a brief overview of the algorithm and some sample Python code to get me started?
import numpy as np def initialize_centroids(X, k): """ Randomly initialize the centroids by choosing k unique points from the dataset. """ indices = np.random.choice(X.shape[0], size=k, replace=False) return X[indices] def assign_clusters(X, centroids): """ Assign each data point to the ne...
import pytest from solution import initialize_centroids, assign_clusters, compute_centroids, k_means import numpy as np def test_initialize_centroids(): np.random.seed(42) X = np.array([[1, 2], [3, 4], [5, 6], [7, 8]]) k = 2 centroids = initialize_centroids(X, k) assert centroids.shape == (2, 2) ...
[ { "docstring": "Randomly initialize the centroids by choosing k unique points from the dataset.", "function_declaration": "def initialize_centroids(X, k):", "function_name": "initialize_centroids", "parameter_list": "(X, k)" }, { "docstring": "Assign each data point to the nearest centroid."...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\n\ndef k_means(X, k, max_iters=100):\n \"\"\"\n K-Means clustering algorithm.\n \n Parameters:\n - X: np.ndarray, input data of shape (n_samples, n_features)\...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001272", "row_id": 1272, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3807']" }
0.5866
Filter_1272
I
[ "initialize_centroids", "assign_clusters", "compute_centroids", "k_means" ]
4
[ [ "k_means", "assign_clusters" ], [ "k_means", "compute_centroids" ], [ "k_means", "initialize_centroids" ] ]
3
[]
false
[]
false
pytest
true
[ "numpy" ]
false
e943415da5f6f01cbc55e6b4afbf320005209a07
2ae12d65ec69f2a5d551f7e0c1db74c75b51f93f
v1.0
instruct
Filter
Filter_1273_I
import os def Filecontents(filterFile, filterpath): with open(filterFile) as f: for line in f: filter = line.strip() if filter in filterpath: return True return False def check_files_in_path(rootdirectory): for file in os.listdir(rootdirectory): if f...
import os def Filecontents(filterFile, filterpath): with open(filterFile) as f: for line in f: filter = line.strip() if filter in filterpath: return True return False def check_files_in_path(rootdirectory): for root, dirs, files in os.walk(rootdirectory): ...
import os from solution import check_files_in_path def test_check_files_in_path(monkeypatch, tmp_path): # Create a temporary directory with files and subdirectories for testing test_dir = tmp_path / "test_dir" test_dir.mkdir() sub_dir = test_dir / "sub_dir" sub_dir.mkdir() file1 = test_dir...
[ { "docstring": null, "function_declaration": "def Filecontents(filterFile, filterpath):", "function_name": "Filecontents", "parameter_list": "(filterFile, filterpath)" }, { "docstring": null, "function_declaration": "def check_files_in_path(rootdirectory):", "function_name": "check_f...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import os\n\ndef file_contains_filter(filter_file, filter_path):\n with open(filter_file) as f:\n filters = [line.strip() for line in f]\n with open(filter_path) as f:\n co...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001273", "row_id": 1273, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3813']" }
0.689947
Filter_1273
I
[ "Filecontents", "check_files_in_path" ]
2
[ [ "check_files_in_path", "Filecontents" ] ]
1
[]
false
[]
false
pytest
true
[]
true
163aeaf8c9827d86255ab715c7e5e0b20364c415
d229939b0091b7927ea0b3dabd814958be4b2741
v1.0
instruct
Filter
Filter_1285_I
import requests import json import random def get_quotes(): url = "https://type.fit/api/quotes" response = requests.get(url) quotes = json.loads(response.text) return quotes def random_quote(): quotes = get_quotes() quote = random.choice(quotes) return quote def main(): quote = random...
import requests import json import random def get_quotes(): url = "https://type.fit/api/quotes" response = requests.get(url) quotes = json.loads(response.text) return quotes def random_quote(): quotes = get_quotes() quote = random.choice(quotes) return quote def quote_of_the_day(): ur...
import requests import json import random from unittest.mock import patch from solution import get_quotes, random_quote, quote_of_the_day def test_get_quotes(): with patch('requests.get') as mock_get: mock_resp = mock_get.return_value mock_resp.text = json.dumps([{"text": "test quote", "author": "...
[ { "docstring": null, "function_declaration": "def get_quotes():", "function_name": "get_quotes", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def random_quote():", "function_name": "random_quote", "parameter_list": "()" }, { "docstring": null, ...
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import requests\nimport json\nimport random\n\ndef get_quotes():\n url = \"https://type.fit/api/quotes\"\n response = requests.get(url)\n quotes = json.loads(response.text)\n retur...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001285", "row_id": 1285, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3859']" }
0.415425
Filter_1285
I
[ "get_quotes", "random_quote", "quote_of_the_day", "main" ]
4
[ [ "random_quote", "get_quotes" ] ]
1
[]
false
[]
false
pytest
true
[ "requests" ]
false
fa618fdf78a4f55f5a041258c509b038a405a877
30d73286a8c1ca881c77b14c16da74725ca33ba4
v1.0
instruct
Filter
Filter_1296_I
import random # Create an empty dictionary to store the user's choices and computer's choices choices = {"rock": 0, "paper": 0, "scissors": 0} # Function to get computer's random choice def get_computer_choice(): return random.choice(list(choices.keys())) # Function to determine the winner def determine_winner(u...
import random # Create an empty dictionary to store the user's choices and computer's choices choices = {"rock": 0, "paper": 0, "scissors": 0} # Function to get computer's random choice def get_computer_choice(): return random.choice(list(choices.keys())) # Function to determine the winner def determine_winner(u...
from solution import determine_winner, play_game def test_determine_winner_tie(): assert determine_winner("rock", "rock") == "It's a tie!" assert determine_winner("paper", "paper") == "It's a tie!" assert determine_winner("scissors", "scissors") == "It's a tie!" def test_determine_winner_user_wins(): ...
[ { "docstring": null, "function_declaration": "def get_computer_choice():", "function_name": "get_computer_choice", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def determine_winner(user_choice, computer_choice):", "function_name": "determine_winner", "p...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef get_computer_choice(choices):\n \"\"\"\n Returns a random choice from the list of choices.\n \"\"\"\n return random.choice(choices)\n\ndef determine_winner(use...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001296", "row_id": 1296, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3893']" }
0.588777
Filter_1296
I
[ "get_computer_choice", "determine_winner", "play_game" ]
3
[ [ "play_game", "determine_winner" ], [ "play_game", "get_computer_choice" ] ]
2
[]
false
[]
false
pytest
true
[]
true
4901f0ffdd14ec73f5f857bbfe981b42310e37ff
9f04b4dfb590e744601e2e494724e36b5340240b
v1.0
instruct
Filter
Filter_1298_I
import io import os import datetime import time def get_current_time(): now = datetime.datetime.now() return now.strftime('%Y-%m-%d %H:%M:%S') print(get_current_time()) This is a simple function that prints out the current time in the format 'YYYY-MM-DD HH:MM:SS'. But how can I continuously print out the c...
import datetime import time def get_current_time(): """ Returns the current time formatted as 'YYYY-MM-DD HH:MM:SS'. """ now = datetime.datetime.now() return now.strftime('%Y-%m-%d %H:%M:%S') def print_current_time_continuously(): """ Continuously prints the current time every second. ...
import datetime from solution import get_current_time def test_get_current_time_format(): current_time = get_current_time() try: # Try to parse the current time with the expected format datetime.datetime.strptime(current_time, '%Y-%m-%d %H:%M:%S') except ValueError: assert False, "T...
[ { "docstring": "Returns the current time formatted as 'YYYY-MM-DD HH:MM:SS'.", "function_declaration": "def get_current_time():", "function_name": "get_current_time", "parameter_list": "()" }, { "docstring": "Continuously prints the current time every second.", "function_declaration": "d...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import datetime\nimport time\n\ndef get_current_time():\n \"\"\"\n Returns the current time formatted as 'YYYY-MM-DD HH:MM:SS'.\n \"\"\"\n now = datetime.datetime.now()\n return...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001298", "row_id": 1298, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_3904']" }
0.473413
Filter_1298
I
[ "get_current_time", "print_current_time_continuously" ]
2
[ [ "print_current_time_continuously", "get_current_time" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7dfd9ef1e0322613d7becb474d4e6f37c3a039d9
659ca09fdc5d996225b7cb25b3165b4578dfe265
v1.0
instruct
Filter
Filter_1335_I
import os import sys import readline def grep(text, pattern): for line_num, line in enumerate(text, start=1): if pattern in line: print(f"{line_num}: {line}") def main(): if len(sys.argv) != 3: print("Usage: python3 grep.py <pattern> <filename>") sys.exit(1) pattern = ...
import os import sys import readline def grep(text, pattern): result = [] for line_num, line in enumerate(text, start=1): if pattern in line: result.append(f"{line_num}: {line}") return result def search_files(pattern, filenames): results = {} for filename in filenames: ...
import tempfile from solution import grep, search_files def test_grep_found(): lines = ["hello world", "this is a test", "another test"] pattern = "test" expected = ["2: this is a test", "3: another test"] assert grep(lines, pattern) == expected def test_grep_not_found(): lines = ["hello world", "...
[ { "docstring": null, "function_declaration": "def grep(text, pattern):", "function_name": "grep", "parameter_list": "(text, pattern)" }, { "docstring": null, "function_declaration": "def search_files(pattern, filenames):", "function_name": "search_files", "parameter_list": "(patt...
[ 0, 1, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import sys\n\ndef grep(text, pattern, filename):\n for line_num, line in enumerate(text, start=1):\n if pattern in line:\n print(f\"{filename}:{line_num}: {line}\")\n\ndef...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001335", "row_id": 1335, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_4039']" }
0.597713
Filter_1335
I
[ "grep", "search_files", "main" ]
3
[ [ "search_files", "grep" ] ]
1
[]
false
[]
false
pytest
true
[]
true
628f02ac4e3690dd469a5b23bf3a144047212666
2c3101dd9b0a8e0944dbdfffef0e47861ec9c8e5
v1.0
instruct
Filter
Filter_1345_I
import random import time # Define a function to simulate a single spin of a slot machine def spin_slot_machine(): symbols = ["Cherry", "Orange", "Lemon", "Plum", "Watermelon", "Bar", "Seven"] return random.choice(symbols) # Define a function to simulate the spinning of the reels of a slot machine def spin_re...
import random def spin_slot_machine(): """ Simulate a single spin of a slot machine Returns a randomly chosen symbol from a predefined list. """ symbols = ["Cherry", "Orange", "Lemon", "Plum", "Watermelon", "Bar", "Seven"] return random.choice(symbols) def spin_reels(): """ Simulate th...
from solution import spin_slot_machine, spin_reels, determine_winner def test_all_reels_spin_different_symbols(): symbols = ["Cherry", "Orange", "Lemon", "Plum", "Watermelon", "Bar", "Seven"] results = [spin_slot_machine(), spin_slot_machine(), spin_slot_machine()] assert all(symbol in symbols for symbol i...
[ { "docstring": "Simulate a single spin of a slot machine\nReturns a randomly chosen symbol from a predefined list.", "function_declaration": "def spin_slot_machine():", "function_name": "spin_slot_machine", "parameter_list": "()" }, { "docstring": "Simulate the spinning of the reels of a slo...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nimport time\n\ndef spin_slot_machine():\n \"\"\"\n Simulates a single spin of a slot machine.\n \"\"\"\n symbols = [\"Cherry\", \"Orange\", \"Lemon\", \"Plum\", \"Wa...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001345", "row_id": 1345, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_4061']" }
0.626813
Filter_1345
I
[ "spin_slot_machine", "spin_reels", "determine_winner" ]
3
[ [ "spin_reels", "spin_slot_machine" ] ]
1
[]
false
[]
false
pytest
true
[]
true
ac9ebea3b52892eff5c241b5ea58a40ceb5e1559
bb5d1ccb1ec8b3a7e7bf08a78d506b3da557b1dd
v1.0
instruct
Filter
Filter_1358_I
This is a Python script that implements a binary search algorithm. The code should look like this: ```python def binary_search(arr, target): low = 0 high = len(arr) - 1 while low <= high: mid = (low + high) // 2 if arr[mid] == target: return mid elif arr[mid] < target:...
def binary_search(arr, target): low = 0 high = len(arr) - 1 while low <= high: mid = (low + high) // 2 if arr[mid] == target: return mid elif arr[mid] < target: low = mid + 1 else: high = mid - 1 return -1 def merge_sort(arr): if l...
from solution import binary_search, merge_sort, sorted_binary_search, merge def test_binary_search_found(): assert binary_search([1, 3, 5, 7], 5) == 2 def test_binary_search_not_found(): assert binary_search([1, 3, 5, 7], 4) == -1 def test_merge_sort(): assert merge_sort([3, 1, 4, 1, 5, 9, 2]) == [1, 1, ...
[ { "docstring": null, "function_declaration": "def binary_search(arr, target):", "function_name": "binary_search", "parameter_list": "(arr, target)" }, { "docstring": null, "function_declaration": "def merge_sort(arr):", "function_name": "merge_sort", "parameter_list": "(arr)" }...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def binary_search(arr, target):\n low = 0\n high = len(arr) - 1\n while low <= high:\n mid = (low + high) // 2\n if arr[mid] == target:\n return mid\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001358", "row_id": 1358, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_4118']" }
0.607066
Filter_1358
I
[ "binary_search", "merge_sort", "merge", "sorted_binary_search", "main" ]
5
[ [ "merge_sort", "merge" ], [ "sorted_binary_search", "binary_search" ], [ "sorted_binary_search", "merge_sort" ] ]
3
[]
false
[]
false
pytest
true
[]
true
dc313bdedd1e03d00c74281820ecac528283bba5
9af9de48adb8f6e4a11b953c922c64981ab2d23b
v1.0
instruct
Filter
Filter_1369_I
class Node: def __init__(self, data): self.data = data self.left = None self.right = None def find_paths(root, start, end): if not root: return [] if root.data == start: return find_path(root, end) return find_paths(root.left, start, end) + find_paths(root.right,...
class Node: def __init__(self, data): self.data = data self.left = None self.right = None def find_paths(root, start, end): """ Find all paths from node with value `start` to node with value `end`. """ if not root: return [] if root.data == start: return ...
from solution import Node, find_paths, find_path def test_empty_tree(): assert find_paths(None, 1, 2) == [] def test_single_node_tree(): root = Node(5) assert find_paths(root, 5, 5) == [[5]] def test_start_equals_end(): root = Node(5) root.left = Node(3) root.right = Node(8) assert find_p...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class Node:\n def __init__(self, data):\n self.data = data\n self.left = None\n self.right = None\n\ndef find_paths(root, start, end):\n if not root:\n return...
trial_gpt4o_1
{ "original_instruction": "", "prompt_id": "00001369", "row_id": 1369, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_4146']" }
0.515695
Filter_1369
I
[ "find_paths", "find_path" ]
2
[ [ "find_paths", "find_path" ] ]
1
[]
false
[ "Node" ]
true
pytest
true
[]
true
6867d7865b749a0c36ed15cdebb13a09fad576dc
9da1eb31daa3daa5e7f3a02a6084d87d6cde8db8
v1.0
instruct
Filter
Filter_1383_I
def is_prime(n): """Check if a number is prime. Args: n (int): The number to check. Returns: bool: True if the number is prime, False otherwise. """ if n <= 1: return False for i in range(2, n): if n % i == 0: return False return True def nth_p...
def is_prime(n): """Check if a number is prime. Args: n (int): The number to check. Returns: bool: True if the number is prime, False otherwise. """ if n <= 1: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return Tr...
from solution import is_prime, nth_prime def test_is_prime(): assert is_prime(2) == True assert is_prime(3) == True assert is_prime(4) == False assert is_prime(29) == True assert is_prime(1) == False assert is_prime(0) == False assert is_prime(-5) == False def test_nth_prime(): assert ...
[ { "docstring": "Check if a number is prime.\n\nArgs:\n n (int): The number to check.\n\nReturns:\n bool: True if the number is prime, False otherwise.", "function_declaration": "def is_prime(n):", "function_name": "is_prime", "parameter_list": "(n)" }, { "docstring": "Find the nth prim...
[ 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 \"\"\"Check 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 otherwise.\n \"...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001383", "row_id": 1383, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_4190']" }
0.879507
Filter_1383
I
[ "is_prime", "nth_prime" ]
2
[ [ "nth_prime", "is_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
abade9c9f400568533a3eef24f7579cb889b6964
b85de3b4053447114709d218b6ca7d137089bb43
v1.0
instruct
Filter
Filter_1389_I
import numpy as np import random def generate_expression(nums, ops): expression = '' for i in range(len(nums)): expression += str(nums[i]) if i < len(ops): expression += ' ' + ops[i] + ' ' return expression def generate_random_expression(nums): ops = ['+', '-', '*', '/'] ...
import numpy as np import random def generate_expression(nums, ops): expression = '' for i in range(len(nums)): expression += str(nums[i]) if i < len(nums) - 1: expression += ' ' + ops[i] + ' ' return expression def generate_random_expression(nums): ops = ['+', '-', '*', '/...
from solution import generate_expression, generate_random_expression, solve_expression def test_generate_expression(): nums = [1, 2, 3, 4] ops = ['+', '-', '*'] expected_expression = "1 + 2 - 3 * 4" assert generate_expression(nums, ops) == expected_expression def test_generate_random_expression(): ...
[ { "docstring": null, "function_declaration": "def generate_expression(nums, ops):", "function_name": "generate_expression", "parameter_list": "(nums, ops)" }, { "docstring": null, "function_declaration": "def generate_random_expression(nums):", "function_name": "generate_random_expre...
[ 1, 0, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import numpy as np\nimport random\n\ndef generate_expression(nums, ops):\n expression = ''\n for i in range(len(nums)):\n expression += str(nums[i])\n if i < len(nums) - 1:...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001389", "row_id": 1389, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_4235']" }
0.497701
Filter_1389
I
[ "generate_expression", "generate_random_expression", "solve_expression", "main" ]
4
[ [ "generate_random_expression", "generate_expression" ] ]
1
[]
false
[]
false
pytest
true
[ "numpy" ]
false
cfe542bc8315fb84e5f6012451eca5604ce10e9d
2d062ec5cbdd721d9b09c31f746cbdfffc023893
v1.0
instruct
Filter
Filter_1407_I
I've created a simple rock, paper, scissors game that is functional, but I want to make it better. I'm looking for ways to improve the game's AI. Currently, the AI is just random, but I want to add some strategy to it. **Current AI behavior:** * The AI chooses between Rock, Paper, or Scissors randomly. * The AI ...
import random from collections import defaultdict class SmartAI: def __init__(self): self.move_count = defaultdict(int) self.history = [] def detect_pattern(self): if len(self.history) < 3: return None if self.history[-1] == self.history[-2] == self.history[-3]: ...
from solution import SmartAI, determine_winner def test_smart_ai_initial_move(): ai = SmartAI() move = ai.get_smart_move() assert move in ['Rock', 'Paper', 'Scissors'] def test_pattern_recognition(): ai = SmartAI() ai.update_history('Rock') ai.update_history('Rock') ai.update_history('Rock...
[]
[ 1, 0, 0 ]
1
medium
0.333
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\nfrom collections import defaultdict\n\nclass SmartAI:\n def __init__(self):\n self.move_count = defaultdict(int)\n self.history = []\n\n def detect_pattern(s...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001407", "row_id": 1407, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_4288']" }
0.424483
Filter_1407
I
[ "determine_winner", "play_game" ]
2
[ [ "play_game", "determine_winner" ] ]
1
[]
false
[ "SmartAI" ]
true
pytest
true
[]
true
af7195f4f1cac1b19309af95f82d320c32a40bf7
8871ed8cb12b247c112c00b8c698e6c20bb2651b
v1.0
instruct
Filter
Filter_1427_I
def calculate_gcd(a, b): while b != 0: a, b = b, a % b return a def find_gcd_of_list(numbers): result = numbers[0] for num in numbers[1:]: result = calculate_gcd(result, num) return result numbers = [24, 30, 36] print(find_gcd_of_list(numbers))
def calculate_gcd(a, b): """ Calculate the greatest common divisor (GCD) of two numbers. """ while b != 0: a, b = b, a % b return a def find_gcd_of_list(numbers): """ Calculate the GCD of a list of numbers. """ result = numbers[0] for num in numbers[1:]: result =...
from solution import calculate_gcd, find_gcd_of_list def test_calculate_gcd(): assert calculate_gcd(24, 36) == 12 assert calculate_gcd(48, 18) == 6 assert calculate_gcd(101, 103) == 1 assert calculate_gcd(100, 25) == 25 def test_find_gcd_of_list(): assert find_gcd_of_list([24, 30, 36]) == 6 as...
[ { "docstring": "Calculate the greatest common divisor (GCD) of two numbers.", "function_declaration": "def calculate_gcd(a, b):", "function_name": "calculate_gcd", "parameter_list": "(a, b)" }, { "docstring": "Calculate the GCD of a list of numbers.", "function_declaration": "def find_gc...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def calculate_gcd(a, b):\n \"\"\"\n Returns the greatest common divisor (GCD) of a and b using the Euclidean algorithm.\n \"\"\"\n while b != 0:\n a, b = b, a % b\n retur...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001427", "row_id": 1427, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_4329']" }
0.764841
Filter_1427
I
[ "calculate_gcd", "find_gcd_of_list" ]
2
[ [ "find_gcd_of_list", "calculate_gcd" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2d7ea91bf87f528efb892c83eba3baf3fe74fc67
a2468d7dbe0553225a99e0ce942101f3ca9fdeef
v1.0
instruct
Filter
Filter_1463_I
def check_prime(n): """Check if a number is prime.""" if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def is_prime_number(num_list): """Check if all numbers in a list are prime.""" return all(check_prime(n) for n in ...
def check_prime(n): """ Check if a number is prime. """ if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True def is_prime_number(num_list): """ Check if all numbers in a list are prime. """ return all(chec...
from solution import check_prime, is_prime_number def test_check_prime(): assert check_prime(2) == True assert check_prime(3) == True assert check_prime(4) == False assert check_prime(17) == True assert check_prime(18) == False assert check_prime(19) == True assert check_prime(0) == False ...
[ { "docstring": "Check if a number is prime.", "function_declaration": "def check_prime(n):", "function_name": "check_prime", "parameter_list": "(n)" }, { "docstring": "Check if all numbers in a list are prime.", "function_declaration": "def is_prime_number(num_list):", "function_name...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def check_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n < 2:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001463", "row_id": 1463, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_4466']" }
0.887631
Filter_1463
I
[ "check_prime", "is_prime_number" ]
2
[ [ "is_prime_number", "check_prime" ] ]
1
[]
false
[]
false
pytest
true
[]
true
2f5247c4d654e19d088bcd0544ea16e6b3b4d73a
717393ed69bc625d5c3068d32cb04c36858270dc
v1.0
instruct
Filter
Filter_1472_I
import random def generate_random_ingredients(): ingredients = ["salt", "pepper", "flour", "eggs", "milk", "butter", "sugar", "vanilla"] random_ingredients = random.sample(ingredients, random.randint(2, 5)) return random_ingredients def generate_recipe(): ingredients = generate_random_ingredients() ...
import random def generate_random_ingredients(number_of_ingredients): """ Returns a list of a specific number of random ingredients. Args: number_of_ingredients (int): The number of ingredients to include. Returns: list: A list containing specific number of random ingredients. """...
from solution import generate_random_ingredients, generate_recipe def test_generate_random_ingredients(): ingredients = generate_random_ingredients(3) assert len(ingredients) == 3 assert len(set(ingredients)) == 3 # Ensure ingredients are unique all_ingredients = ["salt", "pepper", "flour", "eggs", "...
[ { "docstring": "Returns a list of a specific number of random ingredients.\n\nArgs:\nnumber_of_ingredients (int): The number of ingredients to include.\n\nReturns:\nlist: A list containing specific number of random ingredients.", "function_declaration": "def generate_random_ingredients(number_of_ingredients...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef generate_specific_ingredients(n=5):\n \"\"\"\n Returns a list of n specific random ingredients.\n If n is greater than the number of available ingredients, all in...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001472", "row_id": 1472, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_4496']" }
0.526794
Filter_1472
I
[ "generate_random_ingredients", "generate_recipe" ]
2
[ [ "generate_recipe", "generate_random_ingredients" ] ]
1
[]
false
[]
false
pytest
true
[]
true
c2767a52e7e1955e6dd259960fa467f1751cae13
ac0885bacf91d8ed83ab4a381683609dc09795bd
v1.0
instruct
Filter
Filter_1488_I
def greet(name): return f"Hello, {name}" def process_request(user): greeting = greet(user["name"]) return {"message": greeting, "user_id": user["id"]}
def greet(name): """ Returns a greeting string for the given name """ return f"Hello, {name}" def process_request(user): """ Processes the user request by greeting the user and returning the user id Parameters: user (dict): A dictionary containing 'name' and 'id' keys Retu...
from solution import greet, process_request def test_greet(): assert greet("Alice") == "Hello, Alice" assert greet("Bob") == "Hello, Bob" assert greet("") == "Hello, " def test_process_request(): user = {"name": "Alice", "id": 123} expected_result = {"message": "Hello, Alice", "user_id": 123} ...
[ { "docstring": "Returns a greeting string for the given name", "function_declaration": "def greet(name):", "function_name": "greet", "parameter_list": "(name)" }, { "docstring": "Processes the user request by greeting the user and returning the user id\n\nParameters:\nuser (dict): A dictiona...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def greet(name):\n return f\"Hello, {name}\"\n\ndef process_request(user):\n \"\"\"\n Generates a greeting message for the user and returns a dictionary \n containing this message ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001488", "row_id": 1488, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_4568']" }
0.481033
Filter_1488
I
[ "greet", "process_request" ]
2
[ [ "process_request", "greet" ] ]
1
[]
false
[]
false
pytest
true
[]
true
d92993e6c7c6c170327eb04fd9dfe195995935e0
8675624fa29b4572468c04fcbeb5fa3e8d649893
v1.0
instruct
Filter
Filter_1504_I
This is a basic implementation of the bogo-sort algorithm: ``` def bogo_sort(arr): import random while not is_sorted(arr): random.shuffle(arr) return arr ``` However, the `is_sorted` function is not defined anywhere in the code snippet. How do you propose we define the `is_sorted` function?
def is_sorted(arr): """ Check if the array is sorted in non-decreasing order. """ for i in range(len(arr) - 1): if arr[i] > arr[i + 1]: return False return True def bogo_sort(arr): import random while not is_sorted(arr): random.shuffle(arr) return arr
from solution import is_sorted, bogo_sort def test_is_sorted_empty(): assert is_sorted([]) == True def test_is_sorted_single_element(): assert is_sorted([1]) == True def test_is_sorted_sorted_array(): assert is_sorted([1, 2, 3, 4, 5]) == True def test_is_sorted_unsorted_array(): assert is_sorted([5,...
[ { "docstring": "Check if the array is sorted in non-decreasing order.", "function_declaration": "def is_sorted(arr):", "function_name": "is_sorted", "parameter_list": "(arr)" }, { "docstring": null, "function_declaration": "def bogo_sort(arr):", "function_name": "bogo_sort", "par...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_sorted(arr):\n \"\"\"\n Returns True if the array is sorted in non-decreasing order, False otherwise.\n \"\"\"\n for i in range(len(arr) - 1):\n if arr[i] > arr[i + 1...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001504", "row_id": 1504, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_4626']" }
0.41206
Filter_1504
I
[ "is_sorted", "bogo_sort" ]
2
[ [ "bogo_sort", "is_sorted" ] ]
1
[]
false
[]
false
pytest
true
[]
true
7818e7cfa28faec315569e6a57d93190402c79f0
9386b5a78fc48e9c80ca39b9cef4e5212e8a574c
v1.0
instruct
Filter
Filter_1533_I
import heapq def findKthLargest(nums, k): return heapq.nlargest(k, nums)[-1] def main(): nums = [3,2,1,5,6,4] k = 2 print(findKthLargest(nums, k)) # Output: 5 if __name__ == "__main__": main() In the above code, the nlargest() function in the heapq module returns the n largest elements from the...
def partition(nums, left, right): pivot = nums[right] i = left for j in range(left, right): if nums[j] <= pivot: nums[i], nums[j] = nums[j], nums[i] i += 1 nums[i], nums[right] = nums[right], nums[i] return i def quickselect(nums, left, right, k): if left == righ...
from solution import findKthLargest def test_findKthLargest_basic(): assert findKthLargest([3, 2, 1, 5, 6, 4], 2) == 5 assert findKthLargest([3, 2, 3, 1, 2, 4, 5, 5, 6], 4) == 4 def test_findKthLargest_single_element(): assert findKthLargest([1], 1) == 1 def test_findKthLargest_sorted_list(): assert ...
[ { "docstring": null, "function_declaration": "def partition(nums, left, right):", "function_name": "partition", "parameter_list": "(nums, left, right)" }, { "docstring": null, "function_declaration": "def quickselect(nums, left, right, k):", "function_name": "quickselect", "param...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def findKthLargest(nums, k):\n \"\"\"\n Returns the k-th largest element in the list nums.\n \"\"\"\n nums_sorted = sorted(nums, reverse=True)\n return nums_sorted[k-1]\n\ndef m...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001533", "row_id": 1533, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_4709']" }
0.677091
Filter_1533
I
[ "partition", "quickselect", "findKthLargest" ]
3
[ [ "findKthLargest", "quickselect" ], [ "quickselect", "partition" ] ]
2
[]
false
[]
false
pytest
true
[]
true
a56adfcc85e1296f5e0dd368a2b5fd2a6e99c5bb
4606b78041789a31632e787bad9a4a34be8f5fc2
v1.0
instruct
Filter
Filter_1536_I
def generate_prime_factors(n): factors = [] divisor = 2 while n > 1: if n % divisor == 0: factors.append(divisor) n = n // divisor else: divisor += 1 return factors def is_prime(n): if n < 2: return False for i in range(2, int(n**0.5) ...
def generate_prime_factors(n): """ Generate prime factors of a given number n. """ factors = [] divisor = 2 while n > 1: if n % divisor == 0: factors.append(divisor) n = n // divisor else: divisor += 1 return factors def is_prime(n): "...
def test_generate_prime_factors(): assert generate_prime_factors(10) == [2, 5] assert generate_prime_factors(20) == [2, 2, 5] assert generate_prime_factors(15) == [3, 5] assert generate_prime_factors(17) == [17] assert generate_prime_factors(1) == [] def test_is_prime(): assert is_prime(2) == T...
[ { "docstring": "Generate prime factors of a given number n.", "function_declaration": "def generate_prime_factors(n):", "function_name": "generate_prime_factors", "parameter_list": "(n)" }, { "docstring": "Check if a given number n is a prime number.", "function_declaration": "def is_pri...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def generate_prime_factors(n):\n \"\"\"\n Generates the prime factors of the given number n.\n \"\"\"\n factors = []\n divisor = 2\n while n > 1:\n if n % divisor == 0...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001536", "row_id": 1536, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_4727']" }
0.771995
Filter_1536
I
[ "generate_prime_factors", "is_prime", "distinct_prime_factors" ]
3
[ [ "distinct_prime_factors", "generate_prime_factors" ] ]
1
[]
false
[]
false
pytest
false
[]
true
481474593d2435da64d4565ae293215cfd675564
4f4bd9205f7326128cd25f3043aeec94ff42628d
v1.0
instruct
Filter
Filter_1567_I
### Options for Organizing the Call Stack #### Option 1: Linked Stack Implementation We can implement the call stack using a linked list where each node represents a function call. The stack operations like push and pop can be implemented using the head of the linked list. ```python import random class Node: def...
# A list-based implementation is generally more suitable for this scenario # due to its simplicity and built-in methods for stack operations. import random class Stack: def __init__(self): self.stack = [] def push(self, value): self.stack.append(value) def pop(self): if self.is_e...
from solution import Stack, add_one, multiply_by_two def test_stack_push_pop(): stack = Stack() stack.push(1) stack.push(2) stack.push(3) assert stack.pop() == 3 assert stack.pop() == 2 assert stack.pop() == 1 def test_stack_is_empty(): stack = Stack() assert stack.is_empty() s...
[]
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "# Solution:\n# For this particular scenario, both the linked list and list implementations are viable.\n# However, the list implementation is more suitable due to its simplicity and efficiency...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001567", "row_id": 1567, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_4837']" }
0.512419
Filter_1567
I
[ "get_random_number", "add_one", "multiply_by_two", "create_and_use_stack" ]
4
[ [ "create_and_use_stack", "add_one" ], [ "create_and_use_stack", "get_random_number" ], [ "create_and_use_stack", "multiply_by_two" ] ]
3
[]
false
[ "Stack" ]
true
pytest
true
[]
true
77c36a8f7292ce40373303ead1e132e3d500b0ac
f7243cdf39968d9ecf33d6c14ea763a798214497
v1.0
instruct
Filter
Filter_1586_I
import random def roll_dice(): return random.randint(1, 6) def determine_winner(player_roll, computer_roll): if player_roll > computer_roll: print(f"You rolled a {player_roll} and the computer rolled a {computer_roll}. You win!") return "player" elif player_roll < computer_roll: p...
import random def roll_dice(): return random.randint(1, 6) def determine_winner(player_roll, computer_roll): if player_roll > computer_roll: return "player" elif player_roll < computer_roll: return "computer" else: return "tie" def determine_score(player_rolls, computer_rolls...
import pytest from solution import roll_dice, determine_winner, determine_score def test_roll_dice(): for _ in range(100): # run enough times to check the whole range roll = roll_dice() assert 1 <= roll <= 6 def test_determine_winner(): assert determine_winner(5, 3) == "player" assert det...
[ { "docstring": null, "function_declaration": "def roll_dice():", "function_name": "roll_dice", "parameter_list": "()" }, { "docstring": null, "function_declaration": "def determine_winner(player_roll, computer_roll):", "function_name": "determine_winner", "parameter_list": "(play...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "import random\n\ndef roll_dice():\n return random.randint(1, 6) \n\ndef determine_winner(player_roll, computer_roll):\n if player_roll > computer_roll:\n return \"player\"\n el...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001586", "row_id": 1586, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_4899']" }
0.618335
Filter_1586
I
[ "roll_dice", "determine_winner", "determine_score" ]
3
[ [ "determine_score", "determine_winner" ] ]
1
[]
false
[]
false
pytest
true
[]
true
4b18145315125f2ea5c2bbc2a5259ac92f93f59d
4ed4667444d172d703d6e18742bcea7adade4ebc
v1.0
instruct
Filter
Filter_1592_I
import os import time def my_decorator(func): def wrapper(*args, **kwargs): start_time = time.time() result = func(*args, **kwargs) end_time = time.time() print(f"Time taken to execute the function is {end_time - start_time} seconds.") return result return wrapper @my...
import time def my_decorator_with_params(param): def decorator(func): def wrapper(*args, **kwargs): start_time = time.time() result = func(*args, **kwargs) end_time = time.time() print(f"Time taken to execute the function is {end_time - start_time} seconds. {...
import time import pytest from solution import my_decorator_with_params, say_hello, greet_in_language @pytest.fixture def disable_sleep(monkeypatch): def mock_sleep(seconds): pass monkeypatch.setattr(time, 'sleep', mock_sleep) def test_greet_in_spanish(disable_sleep): greeting = say_hello("John", ...
[ { "docstring": null, "function_declaration": "def my_decorator_with_params(param):", "function_name": "my_decorator_with_params", "parameter_list": "(param)" }, { "docstring": null, "function_declaration": "def greet_in_language(language, name):", "function_name": "greet_in_language"...
[ 0, 1, 1 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def greet_in_language(language, name):\n translations = {\n \"english\": f\"Hello, {name}!\",\n \"spanish\": f\"Hola, {name}!\",\n \"french\": f\"Bonjour, {name}!\",\n ...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001592", "row_id": 1592, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_4913']" }
0.481941
Filter_1592
I
[ "my_decorator_with_params", "greet_in_language", "say_hello" ]
3
[ [ "say_hello", "greet_in_language" ], [ "say_hello", "my_decorator_with_params" ] ]
2
[]
false
[]
false
pytest
true
[]
true
0f13c198b993ebebde930f8a43bb61e6d1942d7b
218328db5ac8f1126dfa329de8962f7a8e100833
v1.0
instruct
Filter
Filter_1607_I
import collections def check_subtree(t1, t2): if t2 is None: return True if t1 is None: return False if match_tree(t1, t2): return True return check_subtree(t1.left, t2) or check_subtree(t1.right, t2) def match_tree(t1, t2): if t1 is None and t2 is None: return True...
class Node: def __init__(self, x): self.val = x self.left = None self.right = None def is_subtree(tree, sub_tree): """ Checks if sub_tree is a subtree of tree. Parameters: tree (Node): The root node of the main tree. sub_tree (Node): The root node of the subtree. ...
from solution import Node, is_subtree def test_is_subtree_true_case(): root = Node(26) root.right = Node(3) root.right.right = Node(3) root.left = Node(10) root.left.left = Node(4) root.left.left.right = Node(30) root.left.right = Node(6) subRoot = Node(10) subRoot.right = Node(6)...
[]
[ 1, 1, 0 ]
2
easy
0.667
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "class Node:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef is_subtree(tree, sub_tree):\n \"\"\"\n Checks if sub_tree is a s...
trial_gpt4o_0
{ "original_instruction": "", "prompt_id": "00001607", "row_id": 1607, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_4977']" }
0.487652
Filter_1607
I
[ "is_subtree", "is_identical" ]
2
[ [ "is_subtree", "is_identical" ] ]
1
[]
false
[ "Node" ]
true
pytest
true
[]
true
65ea796b62f50fcb075dd002b857b70d24d1ae25
7985dd8e4a9a08fee521445eecf1de8cec5edbd4
v1.0
instruct
Filter
Filter_1620_I
def is_palindrome(n): """Check if a number is a palindrome.""" return str(n) == str(n)[::-1] def highest_palindrome(): """Find the highest numerical value which is the product of two 3-digit numbers.""" max_palindrome = 0 for i in range(999, 99, -1): for j in range(i, 99, -1): p...
def is_palindrome(n): """ Check if a number is a palindrome. """ return str(n) == str(n)[::-1] def highest_palindrome(): """ Find the highest numerical value which is the product of two 3-digit numbers. """ max_palindrome = 0 for i in range(999, 99, -1): for j in range(i, 99...
from solution import is_palindrome, highest_palindrome def test_is_palindrome(): assert is_palindrome(121) == True assert is_palindrome(123) == False assert is_palindrome(1221) == True assert is_palindrome(1223) == False assert is_palindrome(1) == True def test_highest_palindrome(): assert hig...
[ { "docstring": "Check if a number is a palindrome.", "function_declaration": "def is_palindrome(n):", "function_name": "is_palindrome", "parameter_list": "(n)" }, { "docstring": "Find the highest numerical value which is the product of two 3-digit numbers.", "function_declaration": "def ...
[ 1, 1, 1 ]
3
easy
1
{ "trial_gpt4o_0": { "file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl", "solution_code": "def is_palindrome(n):\n \"\"\"\n Check if a number is a palindrome.\n \"\"\"\n return str(n) == str(n)[::-1]\n\ndef highest_palindrome():\n \"\"\"\n Find the highest numerica...
trial_gpt4o_2
{ "original_instruction": "", "prompt_id": "00001620", "row_id": 1620, "seed_ids": "['Meta-Llama-3.1-70B-Instruct_5035']" }
0.715997
Filter_1620
I
[ "is_palindrome", "highest_palindrome" ]
2
[ [ "highest_palindrome", "is_palindrome" ] ]
1
[]
false
[]
false
pytest
true
[]
true
9bcf074ce83213d95c857c96fcec941ef8a256d1
defefd51d05009a4fc963b7bf31356e3a5dd4605