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_2985_I | I'm trying to create a recipe book. Can you give me a hint about how to implement a function that takes user input for ingredients and quantities, and then lets the user enter multiple standard units for the ingredients (like "cup", "tablespoon", "ounce", etc.) for each ingredient, and keeps track of the ingredient qua... | def convert_to_grams(quantity, unit):
conversion_factors = {
"cup": 240,
"tablespoon": 15,
"teaspoon": 5,
"ounce": 28.35,
"gram": 1,
}
return quantity * conversion_factors[unit]
def input_ingredient():
ingredient_data = {}
while True:
ingredient_name... | def test_convert_to_grams():
assert convert_to_grams(1, 'cup') == 240
assert convert_to_grams(3, 'tablespoon') == 45
assert convert_to_grams(2, 'teaspoon') == 10
assert convert_to_grams(4, 'ounce') == 113.4
assert convert_to_grams(100, 'gram') == 100
def test_input_ingredient(monkeypatch):
inpu... | [
{
"docstring": null,
"function_declaration": "def convert_to_grams(quantity, unit):",
"function_name": "convert_to_grams",
"parameter_list": "(quantity, unit)"
},
{
"docstring": null,
"function_declaration": "def input_ingredient():",
"function_name": "input_ingredient",
"paramet... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def create_recipe():\n \"\"\"\n Allows user to input ingredients with quantities and units, \n and keeps track of these in both user-entered units and standard units (grams).\n Ret... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00002985",
"row_id": 2985,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_9689']"
} | 0.467825 | Filter_2985 | I | [
"convert_to_grams",
"input_ingredient"
] | 2 | [
[
"input_ingredient",
"convert_to_grams"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 60e8db1363acab1c654e128d40625f3313114a30 | 85a4dfb48e802cd00054bb08a8dfde0cb60da9b3 | |||
v1.0 | instruct | Filter | Filter_2994_I | Can you make a short program that simulates a k-means clustering algorithm on a 2 Dimensional dataset? Here's an example of what the clusters could look like:
Blue dots represent the dataset, yellow dots represent the centroids, and dotted lines are the boundaries of the clusters.
The final output should print out t... | import numpy as np
def initialize_centroids(points, k):
"""
Randomly initialize centroids from the given points.
Args:
points (ndarray): The array of points.
k (int): The number of clusters.
Returns:
ndarray: The initialized centroids.
"""
return points[np.... | import numpy as np
from solution import initialize_centroids, assign_clusters, update_centroids, kmeans
def test_initialize_centroids():
np.random.seed(42)
points = np.random.rand(100, 2)
centroids = initialize_centroids(points, 3)
assert centroids.shape == (3, 2)
def test_assign_clusters():
point... | [
{
"docstring": "Randomly initialize centroids from the given points.\n\nArgs:\n points (ndarray): The array of points.\n k (int): The number of clusters.\n \nReturns:\n ndarray: The initialized centroids.",
"function_declaration": "def initialize_centroids(points, k):",
"function_name": "ini... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import numpy as np\n\ndef initialize_centroids(points, k):\n np.random.seed(42) # For reproducibility\n return points[np.random.choice(points.shape[0], size=k, replace=False)]\n\ndef as... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00002994",
"row_id": 2994,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_9707']"
} | 0.714103 | Filter_2994 | I | [
"initialize_centroids",
"assign_clusters",
"update_centroids",
"kmeans"
] | 4 | [
[
"kmeans",
"assign_clusters"
],
[
"kmeans",
"initialize_centroids"
],
[
"kmeans",
"update_centroids"
]
] | 3 | [] | false | [] | false | pytest | true | [
"numpy"
] | false | f405e2915df743237980b7e7b91fc0f94867a591 | 35a2ea8bd82934975c2341b84afbc8eda7be7c73 | |||
v1.0 | instruct | Filter | Filter_3018_I | In this problem, you are given the head of a linked list, and you need to reorder it such that the data values in the nodes appear in alternating ascending and descending order. Specifically, the first set of nodes should be in ascending order, the second set should be in descending order, and so on.
Here is a sample ... | class Node:
def __init__(self, data):
self.data = data
self.next = None
def find_middle(head):
slow, fast = head, head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
return slow
def reverse_list(head):
prev = None
while head:
next_node ... | from solution import Node, reorder_linked_list
def list_to_linked_list(items):
if not items:
return None
head = Node(items[0])
current = head
for item in items[1:]:
current.next = Node(item)
current = current.next
return head
def linked_list_to_list(head):
items = []
... | [] | [
0,
1,
0
] | 1 | medium | 0.333 | {
"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.next = None\n\ndef reorder_linked_list(head):\n if not head or not head.next:\n return head\n \n... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00003018",
"row_id": 3018,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_9771']"
} | 0.542585 | Filter_3018 | I | [
"find_middle",
"reverse_list",
"reorder_linked_list"
] | 3 | [
[
"reorder_linked_list",
"find_middle"
],
[
"reorder_linked_list",
"reverse_list"
]
] | 2 | [] | false | [
"Node"
] | true | pytest | true | [] | true | 51e9f4e84ecda22ec11b752bcb8053e8cabfc6e1 | 4a1596705eae0a9a40806afa48fda27cbea6b50e | |||
v1.0 | instruct | Filter | Filter_3029_I | In Python, if you have a list of integers, how do you find all prime numbers within that list? | def is_prime(num):
"""
Checks if a number is prime.
"""
if num <= 1:
return False
for i in range(2, int(num ** 0.5) + 1):
if num % i == 0:
return False
return True
def find_primes_in_list(lst):
"""
Finds all prime numbers in a given list of integers.
"""
... | from solution import is_prime, find_primes_in_list
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(-5) == False
def test_find_primes_in... | [
{
"docstring": "Checks if a number is prime.",
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": "Finds all prime numbers in a given list of integers.",
"function_declaration": "def find_primes_in_list(lst):",
"func... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Determines if an integer n is a prime number.\n \"\"\"\n if n <= 1:\n return False\n if n <= 3:\n return True\n if n % 2 == 0 or n %... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00003029",
"row_id": 3029,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_9806']"
} | 0.642068 | Filter_3029 | I | [
"is_prime",
"find_primes_in_list"
] | 2 | [
[
"find_primes_in_list",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | f0ab24e11feca6d98c43e8949a4c2f1f2f72f102 | 1cad74b899a37db47e937382669081b7c46cff62 | |||
v1.0 | instruct | Filter | Filter_3040_I | You can share code in which language you are most comfortable. I'm looking for a solution that will only work when the system clock is set to a certain time.
I.e. an application that will only do certain things when the system clock is set to Saturday at 2PM.
Here's an example of how you might structure this in Pyth... | import datetime
def perform_action():
"""
Dummy function to represent the action to be performed
"""
print("Action performed!")
def check_time_and_perform_action():
"""
Checks the current time and performs action if it is Saturday at 2 PM
"""
current_time = datetime.datetime.now()
... | from solution import check_time_and_perform_action
from unittest.mock import patch
import datetime
def test_perform_action_on_saturday_2pm(capfd):
test_time = datetime.datetime(2023, 10, 28, 14, 0)
with patch('datetime.datetime') as mock_datetime:
mock_datetime.now.return_value = test_time
mock... | [
{
"docstring": "Dummy function to represent the action to be performed",
"function_declaration": "def perform_action():",
"function_name": "perform_action",
"parameter_list": "()"
},
{
"docstring": "Checks the current time and performs action if it is Saturday at 2 PM",
"function_declara... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import datetime\n\ndef do_something_special():\n \"\"\"\n This function contains special actions to be executed\n only on Saturdays at 2 PM.\n \"\"\"\n # Dummy action for demons... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00003040",
"row_id": 3040,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_9828']"
} | 0.50698 | Filter_3040 | I | [
"perform_action",
"check_time_and_perform_action"
] | 2 | [
[
"check_time_and_perform_action",
"perform_action"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 8a6d2ec3bd8ca23a5e1a043266c717c4b5fdb21a | 1f13f8e30470ffb3956ee18304679ae9ac018f86 | |||
v1.0 | instruct | Filter | Filter_3043_I | I'm trying to develop a program that reads an input file and does conversion on the contents. The input file is in a fixed format, and each line contains 3 fields separated by commas: name, value, and unit. In the output I want to see the original fields, plus a calculated field that shows the value in a standardized u... | def convert_to_grams(value, unit):
"""
Convert the given value to grams based on the provided unit.
Supported units: kg, oz, mg, g
"""
conversion_factors = {
'kg': 1000,
'oz': 28.3495,
'mg': 0.001,
'g': 1
}
if unit not in conversion_factors:
raise... | import pytest
from solution import convert_to_grams, process_file
def test_convert_to_grams():
assert convert_to_grams(1, 'kg') == 1000
assert convert_to_grams(1, 'oz') == 28.3495
assert convert_to_grams(1, 'mg') == 0.001
assert convert_to_grams(1, 'g') == 1
with pytest.raises(ValueError):
... | [
{
"docstring": "Convert the given value to grams based on the provided unit.\nSupported units: kg, oz, mg, g",
"function_declaration": "def convert_to_grams(value, unit):",
"function_name": "convert_to_grams",
"parameter_list": "(value, unit)"
},
{
"docstring": "Read the input file, convert ... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def convert_to_grams(value, unit):\n \"\"\"\n Convert the given value to grams based on the provided unit.\n Supported units: kg, oz, mg, g\n \"\"\"\n conversion_factors = {\n ... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00003043",
"row_id": 3043,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_9836']"
} | 0.361666 | Filter_3043 | I | [
"convert_to_grams",
"process_file"
] | 2 | [
[
"process_file",
"convert_to_grams"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 8bd0cf9dbbac243c7ec592ba6d6281681519b025 | 88f162d0e8cc9408adf15c345f2a682b4082b33f | |||
v1.0 | instruct | Filter | Filter_3045_I | Here are the rules for a card game called "Double or Nothing":
* The game is played using a standard deck of 52 cards (without jokers).
* The objective of the game is to guess whether the value of the next card will be higher or lower than the value of the previous card.
* The game starts with two cards dealt fac... | import random
class Card:
def __init__(self, suit, value):
self.suit = suit
self.value = value
class Deck:
def __init__(self):
self.cards = [Card(s, v) for s in ['Hearts', 'Diamonds', 'Clubs', 'Spades']
for v in ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10'... | from solution import Card, Deck, card_value, game
def test_initial_money_invalid():
deck = Deck()
initial_cards = (deck.deal_card(), deck.deal_card())
result = game(deck, -5, initial_cards, [])
assert result == "Invalid initial money amount."
def test_invalid_bet_exceeds_money():
deck = Deck()
... | [] | [
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\nclass Card:\n def __init__(self, suit, value):\n self.suit = suit\n self.value = value\n\nclass Deck:\n def __init__(self):\n self.cards = [Card(s, ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003045",
"row_id": 3045,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_9838']"
} | 0.611686 | Filter_3045 | I | [
"card_value",
"game"
] | 2 | [
[
"game",
"card_value"
]
] | 1 | [] | false | [
"Card",
"Deck"
] | true | pytest | true | [] | true | 5dffd742150c4f472c7f770b76593ea1d6df6053 | a5ce3083ffc6a94519af90c314ac5b31b604ae76 | |||
v1.0 | instruct | Filter | Filter_3062_I | In this problem, you will write a program that simulates a game of 5-card Poker. You will write functions to deal a hand, determine the rank of the hand, and evaluate whether a hand beats another hand, with the following specifications:
(a) The function dealHand() draws 5 cards from a deck, without replacement, and ret... | import random
# Define card ranks and suits
ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades']
values = {rank: index for index, rank in enumerate(ranks, start=2)}
# Create a deck of 52 cards
deck = [(rank, suit) for rank in ranks for suit in su... | from solution import dealHand, rankHand, beats
def test_dealHand():
hand = dealHand()
assert len(hand) == 5
for card in hand:
assert card in deck
def test_rankHand():
assert rankHand([('A', 'Hearts'), ('K', 'Hearts'), ('Q', 'Hearts'), ('J', 'Hearts'), ('10', 'Hearts')]) == 1000 # Royal Flush
... | [
{
"docstring": "Draws 5 cards from a deck, without replacement, and returns them as a list of tuples.",
"function_declaration": "def dealHand():",
"function_name": "dealHand",
"parameter_list": "()"
},
{
"docstring": "Accepts a list of tuples representing a hand and returns an integer value ... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\nfrom collections import Counter\n\n# Rank to value mapping for easier computation of the hand value\nCARD_RANKS = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003062",
"row_id": 3062,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_9880']"
} | 0.628148 | Filter_3062 | I | [
"dealHand",
"rankHand",
"beats"
] | 3 | [
[
"beats",
"rankHand"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 6a8a58e7d3855f26cfbd2be76176a36a23abb457 | fa67bc293d06ba454a7f2835b8b8896e69645c67 | |||
v1.0 | instruct | Filter | Filter_3102_I | This problem is taken from the book "Programming Challenge" by Steven S. Skiena and Miguel A. Revilla. The problem statement is:
`Prime Spiral`
Print the first 10000 primes.
The problem seems simple but the trick is that the primes are arranged in a spiral pattern in a 2D plane.
Here is the picture of the spiral pat... | import math
def is_prime(n):
"""
Check if a number is prime.
"""
if n < 2:
return False
for i in range(2, int(math.sqrt(n)) + 1):
if n % i == 0:
return False
return True
def generate_primes(n):
"""
Generate the first n primes.
"""
primes = []
num... | from solution import is_prime, generate_primes
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(29) == True
assert is_prime(0) == False
assert is_prime(1) == False
assert is_prime(97) == True
def test_generate_primes():
... | [
{
"docstring": "Check if a number is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Generate the first n primes.",
"function_declaration": "def generate_primes(n):",
"function_name": "generate_primes",
... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import math\n\ndef is_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(math.sqrt(n)) + 1):\n if n % i =... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00003102",
"row_id": 3102,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_9975']"
} | 0.547318 | Filter_3102 | I | [
"is_prime",
"generate_primes"
] | 2 | [
[
"generate_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 3475573d24178760932ccf3c6249528feae742d9 | 24f1a3e1352d40bda8dc831fbdfedf25e100369c | |||
v1.0 | instruct | Filter | Filter_3128_I | I'd like to create a bot that takes a name of a person and gives out a random quote. I'd like to have the option to add new quotes and update existing ones in the future.
Here's my Python code that I've created so far:
```
import json
# Data file to store quotes
DATA_FILE = 'quotes.json'
def get_quote(name):
try... | import json
# Constants
DATA_FILE = 'quotes.json'
GET_QUOTE = '1'
ADD_QUOTE = '2'
UPDATE_QUOTE = '3'
QUIT = '4'
def load_data():
"""Loads quotes data from the JSON file."""
try:
with open(DATA_FILE, 'r') as f:
return json.load(f)
except FileNotFoundError:
return {}
def save_da... | import pytest
import json
import os
from solution import get_quote, add_quote, update_quote, DATA_FILE
@pytest.fixture(autouse=True)
def setup_and_teardown():
# Setup before each test
if os.path.exists(DATA_FILE):
os.remove(DATA_FILE)
yield
# Teardown after each test
if os.path.exists(DATA... | [
{
"docstring": "Loads quotes data from the JSON file.",
"function_declaration": "def load_data():",
"function_name": "load_data",
"parameter_list": "()"
},
{
"docstring": "Saves quotes data to the JSON file.",
"function_declaration": "def save_data(data):",
"function_name": "save_dat... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import json\n\n# Data file to store quotes\nDATA_FILE = 'quotes.json'\n\n\ndef get_quote(name):\n \"\"\"\n Fetches a quote for a given name from the file.\n \n Args:\n - name (s... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003128",
"row_id": 3128,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_10048']"
} | 0.540282 | Filter_3128 | I | [
"load_data",
"save_data",
"get_quote",
"add_quote",
"update_quote",
"main"
] | 6 | [
[
"add_quote",
"load_data"
],
[
"add_quote",
"save_data"
],
[
"get_quote",
"load_data"
],
[
"update_quote",
"load_data"
],
[
"update_quote",
"save_data"
]
] | 5 | [] | false | [] | false | pytest | true | [] | true | cd8454adcb96c6693a53a086f522cee8cba93041 | 9c4d4614fabc85d83353909080e31442ae5bc2c3 | |||
v1.0 | instruct | Filter | Filter_3136_I | We have a simple web scraper in Python that we want to modify in order to add two new features. One feature would allow the scraper to get information from a second website and add the results of the second website to the same output csv file. The second feature would add a progress bar to our web scraping operation.
... | import csv
import urllib.request
from bs4 import BeautifulSoup
from tqdm import tqdm
# Specify URLs
url1 = 'https://www.source1.com'
url2 = 'https://www.source2.com'
# Define CSV output file
csv_output = 'scraped_data.csv'
# Open and read the HTML content
def read_html(url):
return urllib.request.urlopen(url).re... | from solution import read_html, scrape_info, save_to_csv, fetch_and_save
import os
import csv
# Mocking the urllib.request.urlopen for unit testing
def mock_urlopen(url):
class MockResponse:
def read(self):
return b'''
<html>
<body>
<span class='t... | [
{
"docstring": null,
"function_declaration": "def read_html(url):",
"function_name": "read_html",
"parameter_list": "(url)"
},
{
"docstring": null,
"function_declaration": "def scrape_info(html):",
"function_name": "scrape_info",
"parameter_list": "(html)"
},
{
"docstring... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import csv\nimport urllib.request\nfrom bs4 import BeautifulSoup\nfrom tqdm import tqdm\n\n# Specify URLs\nurl1 = 'https://www.source1.com'\nurl2 = 'https://www.source2.com'\n\n# Define CSV ou... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00003136",
"row_id": 3136,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_10083']"
} | 0.72553 | Filter_3136 | I | [
"read_html",
"scrape_info",
"save_to_csv",
"fetch_and_save",
"main"
] | 5 | [
[
"fetch_and_save",
"read_html"
],
[
"fetch_and_save",
"save_to_csv"
],
[
"fetch_and_save",
"scrape_info"
]
] | 3 | [] | false | [] | false | pytest | true | [
"bs4",
"tqdm"
] | false | a56babba7be84bfbbce02879301d41d69cb5307b | e2867122d5da8bd7fb4402681d258a85fa7dabf3 | |||
v1.0 | instruct | Filter | Filter_3148_I | There are three files - A, B and C , the contents of these files are shown below -
File A contains the first 1000 prime numbers
File B contains the first 2000 prime numbers
File C contains the first 500 prime numbers along with some extra non-prime data
Assuming that file B is the source of truth for the first 2000 pr... | def read_primes_from_file(filepath):
"""
Reads prime numbers from a file. Assumes each line in the file contains one number.
Returns a set of integers.
"""
primes = set()
with open(filepath, 'r') as file:
for line in file:
num = int(line.strip())
if is_prime(num):... | from solution import read_primes_from_file, is_prime, merge_prime_files
import os
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(13) == True
assert is_prime(20) == False
def create_test_file(filepath, numbers):
with open(f... | [
{
"docstring": "Reads prime numbers from a file. Assumes each line in the file contains one number.\nReturns a set of integers.",
"function_declaration": "def read_primes_from_file(filepath):",
"function_name": "read_primes_from_file",
"parameter_list": "(filepath)"
},
{
"docstring": "Checks... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def read_file(filepath):\n \"\"\"\n Reads a file and returns a list of integers. Assumes one number per line.\n \"\"\"\n with open(filepath, 'r') as file:\n content = file.r... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003148",
"row_id": 3148,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_10115']"
} | 0.417798 | Filter_3148 | I | [
"read_primes_from_file",
"is_prime",
"merge_prime_files"
] | 3 | [
[
"merge_prime_files",
"read_primes_from_file"
],
[
"read_primes_from_file",
"is_prime"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 19a768d3a62a8d70fa1bb86ce42cc4bc6fcc7167 | 824323f4fdce8663d770e2e535226a9203142311 | |||
v1.0 | instruct | Filter | Filter_3152_I | Keep track of each player's score. Each move is a random draw from a pack of standard playing cards, without replacement. The card's suit determines which player gets points:
* Hearts: Player 1 gets 1 point
* Diamonds: Player 2 gets 1 point
* Clubs: Player 1 gets 2 points
* Spades: Player 0 (neither of the two players... | import random
def simulate_game():
"""
Simulates a game where cards are drawn randomly until either player's score reaches 10.
Returns the score of both players as a tuple (player1_score, player2_score).
"""
suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades']
deck = suits * 13 # A standard deck ... | from solution import simulate_game, simulate_multiple_games
def test_simulate_game_scores():
result = simulate_game()
assert isinstance(result, tuple)
assert len(result) == 2
assert all(isinstance(score, int) for score in result)
assert max(result) >= 10
def test_simulate_multiple_games_count():
... | [
{
"docstring": "Simulates a game where cards are drawn randomly until either player's score reaches 10.\nReturns the score of both players as a tuple (player1_score, player2_score).",
"function_declaration": "def simulate_game():",
"function_name": "simulate_game",
"parameter_list": "()"
},
{
... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\n\ndef simulate_game():\n \"\"\"\n Simulates a single game of drawing cards until either player's score reaches 10.\n Returns the final scores of both players.\n \"\"... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003152",
"row_id": 3152,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_10122']"
} | 0.596918 | Filter_3152 | I | [
"simulate_game",
"simulate_multiple_games"
] | 2 | [
[
"simulate_multiple_games",
"simulate_game"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 605082ee19f29d633bf10db025989f697bcda295 | 002fed9c4f7c8455de667fae941c340777be521f | |||
v1.0 | instruct | Filter | Filter_3163_I | Here is a function to check if a number is prime, using a probabilistic method:
```python
import random
def is_prime(n, k=5):
"""Tests if n is prime using the Miller-Rabin primality test."""
if n < 2:
return False
for p in [2, 3, 5, 7, 11, 13, 17, 19, 23]:
if n % p == 0:
return F... | import random
def is_prime(n, k=5):
"""Tests if n is prime using the Miller-Rabin primality test."""
if n < 2:
return False
for p in [2, 3, 5, 7, 11, 13, 17, 19, 23]:
if n % p == 0:
return n == p
r, s = 0, n - 1
while s % 2 == 0:
r += 1
s //= 2
for _ ... | from solution import is_prime, primes_in_range
def test_is_prime():
assert is_prime(2) == True
assert is_prime(3) == True
assert is_prime(4) == False
assert is_prime(17) == True
assert is_prime(18) == False
assert is_prime(19) == True
def test_primes_in_range():
assert primes_in_range(1, 1... | [
{
"docstring": "Tests if n is prime using the Miller-Rabin primality test.",
"function_declaration": "def is_prime(n, k=5):",
"function_name": "is_prime",
"parameter_list": "(n, k=5)"
},
{
"docstring": "Returns a list of prime numbers within the given range [start, end].",
"function_decl... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def primes_in_range(start, end):\n \"\"\"\n Returns a list of prime numbers in the given range [start, end).\n Uses the is_prime function to check primality.\n \"\"\"\n prime_nu... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003163",
"row_id": 3163,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_10144']"
} | 0.66698 | Filter_3163 | I | [
"is_prime",
"primes_in_range"
] | 2 | [
[
"primes_in_range",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | cf59ae0f5c8c405571c930c1f5e4479ae13ecbdb | 454345fef548320d036f8a367a6c2bc4332bc0fb | |||
v1.0 | instruct | Filter | Filter_3164_I | Assuming a keyboard of a standard QWERTY layout, write a code to create a Генератор случайных предложений (Generator of random sentences). Since the keyboard layout is QWERTY, the characters adjacent to each other are not like "bcdfgh" or "acdeg" but more like "qwertyuiopasdfghjklzxcvbnm". | import random
# QWERTY Keyboard Layout neighbor mapping
qwerty_neighbors = {
'q': 'was', 'w': 'qeasd', 'e': 'wrdsf', 'r': 'etdfg', 't': 'ryfgv', 'y': 'tuhgv', 'u': 'yihj',
'i': 'uojkl', 'o': 'ipkl', 'p': 'ol',
'a': 'qwsz', 's': 'awdzxc', 'd': 'serfcx', 'f': 'drtgvc', 'g': 'ftyhbv', 'h': 'gyujnbv', 'j': 'hu... | from solution import generator_random_sentence
def test_random_sentence_length():
template = "hello world"
generated = generator_random_sentence(template)
assert len(generated) == len(template), "The generated sentence should have the same length as the template."
def test_random_sentence_non_empty():
... | [
{
"docstring": "Returns a string containing characters adjacent to `char` on a QWERTY keyboard.",
"function_declaration": "def get_qwerty_neighbors(char):",
"function_name": "get_qwerty_neighbors",
"parameter_list": "(char)"
},
{
"docstring": "Returns a random adjacent character from QWERTY ... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\n\nqwerty_layout = {\n 'q': 'wsa', 'w': 'qase', 'e': 'wsdr', 'r': 'edft', 't': 'rfgy', 'y': 'tghu', 'u': 'yhjki', 'i': 'ujklo', 'o': 'iklp', 'p': 'ol',\n 'a': 'qwsz', 's': ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003164",
"row_id": 3164,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_10147']"
} | 0.573961 | Filter_3164 | I | [
"get_qwerty_neighbors",
"random_qwerty_char",
"generator_random_sentence"
] | 3 | [
[
"generator_random_sentence",
"random_qwerty_char"
],
[
"random_qwerty_char",
"get_qwerty_neighbors"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | a8b0ea811a4e875f20c9b8a812d5ff92ede5e365 | fce6283df1e250357fa9946d52a0cd6c789b67e0 | |||
v1.0 | instruct | Filter | Filter_3220_I | I've recently come across the concept of the "N-Queens Problem". It's an interesting problem in computer science, where the goal is to place N queens on an NxN chessboard such that no two queens attack each other.
I'm looking for a backtracking algorithm to solve this problem. Can you provide a Python implementation? | def is_safe(board, row, col, n):
"""
Check if it's safe to place a queen at board[row][col].
This means no queen can attack this position.
"""
# Check if there's a queen in the same column
for i in range(row):
if board[i][col] == 1:
return False
# Check upper-left di... | from solution import solve_n_queens
def test_solve_n_queens_4():
solution = solve_n_queens(4)
expected_solution = [
[0, 1, 0, 0],
[0, 0, 0, 1],
[1, 0, 0, 0],
[0, 0, 1, 0]
]
assert solution == expected_solution or solution == [
[0, 0, 1, 0],
[1, 0, 0, 0],... | [
{
"docstring": "Check if it's safe to place a queen at board[row][col].\nThis means no queen can attack this position.",
"function_declaration": "def is_safe(board, row, col, n):",
"function_name": "is_safe",
"parameter_list": "(board, row, col, n)"
},
{
"docstring": "Utilizes backtracking t... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def solve_n_queens(n):\n \"\"\"\n Solve the N-Queens problem using a backtracking algorithm.\n Return a list of all valid board configurations, \n where each configuration is repre... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00003220",
"row_id": 3220,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_10282']"
} | 0.442495 | Filter_3220 | I | [
"is_safe",
"solve_n_queens_util",
"solve_n_queens"
] | 3 | [
[
"solve_n_queens",
"solve_n_queens_util"
],
[
"solve_n_queens_util",
"is_safe"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | b0c1f45944ae428ed39fe8bae750e538aab450a4 | 32a93e352aeaaeb497ad823837bac6da5010579a | |||
v1.0 | instruct | Filter | Filter_3234_I | Getting index after split
I'm trying to write a function that splits a string into a list of characters, and then returns the index of the specified character in the list. Here is what I have so far:
```
def find_index(lst, value):
try:
return lst.index(value)
except ValueError:
return -1
def ... | def find_index(lst, value, start=0):
"""
Finds the first index of value in lst starting from the index 'start'.
If the value is not found, it returns -1.
"""
try:
return lst.index(value, start)
except ValueError:
return -1
def process_string(input_str, character, start=0):
"... | from solution import process_string
def test_process_string_first_occurrence():
assert process_string("hello world", "o") == 4
def test_process_string_second_occurrence():
assert process_string("hello world", "o", 5) == 7
def test_process_string_not_found():
assert process_string("hello world", "x") == -... | [
{
"docstring": "Finds the first index of value in lst starting from the index 'start'.\nIf the value is not found, it returns -1.",
"function_declaration": "def find_index(lst, value, start=0):",
"function_name": "find_index",
"parameter_list": "(lst, value, start=0)"
},
{
"docstring": "Proc... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def find_index(lst, value, start=0):\n \"\"\"\n Finds the first index of value in lst starting from the index 'start'.\n If the value is not found, it returns -1.\n \"\"\"\n try... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00003234",
"row_id": 3234,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_10311']"
} | 0.506554 | Filter_3234 | I | [
"find_index",
"process_string"
] | 2 | [
[
"process_string",
"find_index"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | f243341d98fe71db6e5b49e74336a0566024fc5e | a61e7fa3561b63f135f67f3f31069be9e3ac571d | |||
v1.0 | instruct | Filter | Filter_3239_I | This problem asks to find the shortest path between any two nodes in an unweighted graph. I am writing a simple BFS algorithm to solve this problem. However, after I pass the adjacency list to my BFS function, it does not return anything. Here is my code:
```
def bfs(graph, start, end):
queue = []
queue.appen... | def bfs(graph, start, end):
queue = []
queue.append([start])
while queue:
path = queue.pop(0)
node = path[-1]
if node == end:
return path
for next_node in graph[node]:
if next_node not in path:
new_path = list(path)
new_... | def test_shortest_path():
graph = {
'A': ['B', 'C'],
'B': ['A', 'D', 'E'],
'C': ['A', 'F'],
'D': ['B'],
'E': ['B', 'F'],
'F': ['C', 'E']
}
assert shortest_path(graph, 'A', 'F') == ['A', 'C', 'F']
assert shortest_path(graph, 'A', 'D') == ['A', 'B', 'D']
... | [
{
"docstring": null,
"function_declaration": "def bfs(graph, start, end):",
"function_name": "bfs",
"parameter_list": "(graph, start, end)"
},
{
"docstring": null,
"function_declaration": "def shortest_path(graph, start, end):",
"function_name": "shortest_path",
"parameter_list":... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def bfs(graph, start, end):\n queue = []\n queue.append([start])\n visited = set() # To keep track of visited nodes\n \n while queue:\n path = queue.pop(0)\n node... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00003239",
"row_id": 3239,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_10331']"
} | 0.477386 | Filter_3239 | I | [
"bfs",
"shortest_path"
] | 2 | [
[
"shortest_path",
"bfs"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | dd2c8982ebfc374621d7f70f229396b99eab2d55 | 0c62bc87a6e69a84f35b9329011db2f6b0878c7b | |||
v1.0 | instruct | Filter | Filter_3251_I | Two distinct binary trees are given. Find the similarity ratio between the two trees
Here is the approach:
Use a recursive function to traverse the two binary trees simultaneously. If the data of the nodes at the current positions is same, then increment the similarity counter.
After traversing the complete trees, di... | class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def count_nodes_and_similarities(root1, root2):
if root1 is None and root2 is None:
return 0, 0
if root1 is None or root2 is None:
return (count_nodes(root1) if root2 is None el... | from solution import Node, binary_tree_similarity
def test_same_tree():
root1 = Node(1)
root1.left = Node(2)
root1.right = Node(3)
root1.left.left = Node(4)
root1.left.right = Node(5)
root1.right.left = Node(6)
root1.right.right = Node(7)
root2 = Node(1)
root2.left = Node(2)
ro... | [] | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class Node:\n def __init__(self, data):\n self.data = data\n self.left = None\n self.right = None\n\ndef count_nodes(root):\n if root is None:\n return 0\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003251",
"row_id": 3251,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_10363']"
} | 0.493216 | Filter_3251 | I | [
"count_nodes_and_similarities",
"binary_tree_similarity",
"count_nodes"
] | 3 | [
[
"binary_tree_similarity",
"count_nodes_and_similarities"
],
[
"count_nodes_and_similarities",
"count_nodes"
]
] | 2 | [] | false | [
"Node"
] | true | pytest | true | [] | true | 6f6c212a536232b229f06c98a701362add7b724c | 438efea955211b99885356f0e4c649057758fc69 | |||
v1.0 | instruct | Filter | Filter_3261_I | Blackjack - Creating a Game in Python
=====================================
### Game Overview
In this game, the goal is to get a hand value closest to 21 without going over. The game is played with a standard 52-card deck.
### Card Values
* Numbered cards (2-10) are worth their face value.
* Jacks, Queens, and ... | import random
# Define a dictionary to store the card 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
}
# Function to create a deck of cards
def create_deck():
suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades']
ranks = ... | from solution import create_deck, calculate_hand_value
def test_create_deck():
deck = create_deck()
assert len(deck) == 52, "Deck should have 52 cards"
suits = {'Hearts', 'Diamonds', 'Clubs', 'Spades'}
ranks = {'2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'}
for card in deck:
... | [
{
"docstring": null,
"function_declaration": "def create_deck():",
"function_name": "create_deck",
"parameter_list": "()"
},
{
"docstring": null,
"function_declaration": "def calculate_hand_value(hand):",
"function_name": "calculate_hand_value",
"parameter_list": "(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\n# Define a dictionary to store the card values\ncard_values = {\n '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10,\n 'J': 10, 'Q': 10, 'K': 10, ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003261",
"row_id": 3261,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_10385']"
} | 0.582864 | Filter_3261 | I | [
"create_deck",
"calculate_hand_value",
"play_game"
] | 3 | [
[
"play_game",
"calculate_hand_value"
],
[
"play_game",
"create_deck"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | cbbb707fcb0819c081045fbe97f6d39e824051ab | 13ab6bf72c30c68969587ccc7ca001daa751197d | |||
v1.0 | instruct | Filter | Filter_3282_I | The Fibonacci sequence is defined by the recurrence relation:
$$F(n) = F(n-1) + F(n-2),$$
where $F(1) = 1$ and $F(2) = 1$. Write a program to find the nth Fibonacci number.
Here is a simple iterative solution:
```
def fibonacci(n):
a, b = 1, 1
for _ in range(n - 1):
a, b = b, a + b
return a
```
H... | def multiply(F, M):
x = F[0][0] * M[0][0] + F[0][1] * M[1][0]
y = F[0][0] * M[0][1] + F[0][1] * M[1][1]
z = F[1][0] * M[0][0] + F[1][1] * M[1][0]
w = F[1][0] * M[0][1] + F[1][1] * M[1][1]
F[0][0] = x
F[0][1] = y
F[1][0] = z
F[1][1] = w
def power(F, n):
if n == 0 or n == 1:
... | from solution import fibonacci
def test_fibonacci_base_cases():
assert fibonacci(0) == 0
assert fibonacci(1) == 1
assert fibonacci(2) == 1
def test_fibonacci_small_numbers():
assert fibonacci(3) == 2
assert fibonacci(4) == 3
assert fibonacci(5) == 5
assert fibonacci(6) == 8
def test_fibon... | [
{
"docstring": null,
"function_declaration": "def multiply(F, M):",
"function_name": "multiply",
"parameter_list": "(F, M)"
},
{
"docstring": null,
"function_declaration": "def power(F, n):",
"function_name": "power",
"parameter_list": "(F, n)"
},
{
"docstring": null,
... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def multiply(F, M):\n x = F[0][0]*M[0][0] + F[0][1]*M[1][0]\n y = F[0][0]*M[0][1] + F[0][1]*M[1][1]\n z = F[1][0]*M[0][0] + F[1][1]*M[1][0]\n w = F[1][0]*M[0][1] + F[1][1]*M[1][1]\... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003282",
"row_id": 3282,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_10431']"
} | 0.628936 | Filter_3282 | I | [
"multiply",
"power",
"fibonacci"
] | 3 | [
[
"fibonacci",
"power"
],
[
"power",
"multiply"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 16a640125c0b980724178e38653e0dd3099910f1 | 18b5dde0894f1b5df2aef868d0719a168fe74c7b | |||
v1.0 | instruct | Filter | Filter_3294_I | This script provides conversion functions for converting a string to different formats.
```python
def to_snake_case(input_string):
"""Converts input_string to snake_case."""
words = input_string.split(" ")
return "_".join([x.lower() for x in words])
def to_kebab_case(input_string):
"""Converts input_st... | def split_words(input_string):
return input_string.split(" ")
def to_snake_case(input_string):
"""Converts input_string to snake_case."""
words = split_words(input_string)
return "_".join([x.lower() for x in words])
def to_kebab_case(input_string):
"""Converts input_string to kebab-case."""
wo... | from solution import to_snake_case, to_kebab_case, to_camel_case, to_title_case, to_upper_case, to_lower_case
def test_to_snake_case():
assert to_snake_case("Hello World") == "hello_world"
assert to_snake_case("This Is A Test") == "this_is_a_test"
def test_to_kebab_case():
assert to_kebab_case("Hello Worl... | [
{
"docstring": null,
"function_declaration": "def split_words(input_string):",
"function_name": "split_words",
"parameter_list": "(input_string)"
},
{
"docstring": "Converts input_string to snake_case.",
"function_declaration": "def to_snake_case(input_string):",
"function_name": "to... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def split_words(input_string):\n return input_string.split(\" \")\n\ndef to_snake_case(input_string):\n \"\"\"Converts input_string to snake_case.\"\"\"\n words = split_words(input_st... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003294",
"row_id": 3294,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_10459']"
} | 0.495977 | Filter_3294 | I | [
"split_words",
"to_snake_case",
"to_kebab_case",
"to_camel_case",
"to_title_case",
"to_upper_case",
"to_lower_case"
] | 7 | [
[
"to_camel_case",
"split_words"
],
[
"to_kebab_case",
"split_words"
],
[
"to_snake_case",
"split_words"
],
[
"to_title_case",
"split_words"
]
] | 4 | [] | false | [] | false | pytest | true | [] | true | f468a71c3593480c05eec20a7ed85f0c75d5d77d | 508e0778d3179f5b9f65d7246ae425341d87ed98 | |||
v1.0 | instruct | Filter | Filter_3402_I | The recursive formula for the Fibonacci sequence is:
\[ F(n) = F(n - 1) + F(n - 2) \]
with initial conditions \( F(0) = 0 \) and \( F(1) = 1 \).
a) Write a recursive function in Python to compute the nth Fibonacci number.
b) Explain how Python implements recursion.
c) Compute the first 10 Fibonacci numbers using Pyt... | def fibonacci(n):
"""
Returns the nth Fibonacci number.
"""
if n == 0:
return 0
elif n == 1:
return 1
else:
return fibonacci(n - 1) + fibonacci(n - 2)
# Function to compute the first 10 Fibonacci numbers
def first_10_fibonacci_numbers():
return [fibonacci(i) for i in... | from solution import fibonacci, first_10_fibonacci_numbers
def test_fibonacci_base_cases():
assert fibonacci(0) == 0
assert fibonacci(1) == 1
def test_fibonacci_recursive_case():
assert fibonacci(2) == 1
assert fibonacci(3) == 2
assert fibonacci(4) == 3
assert fibonacci(5) == 5
assert fibo... | [
{
"docstring": "Returns the nth Fibonacci number.",
"function_declaration": "def fibonacci(n):",
"function_name": "fibonacci",
"parameter_list": "(n)"
},
{
"docstring": null,
"function_declaration": "def first_10_fibonacci_numbers():",
"function_name": "first_10_fibonacci_numbers",
... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def fibonacci(n):\n \"\"\"\n Returns the nth Fibonacci number using recursion.\n \"\"\"\n if n == 0:\n return 0\n elif n == 1:\n return 1\n else:\n retur... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00003402",
"row_id": 3402,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_10742']"
} | 0.737898 | Filter_3402 | I | [
"fibonacci",
"first_10_fibonacci_numbers"
] | 2 | [
[
"first_10_fibonacci_numbers",
"fibonacci"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 2f93fa957b048b9759163a2a33387565aa4104c0 | f21ce3b23d73143630022adaaf26a377713f6799 | |||
v1.0 | instruct | Filter | Filter_3453_I | I have been given a task to do which for security reasons I am not allowed to disclose the details. Let's just say it's a personal security project.
However I need help with an algorithm and I am hoping you can assist me with it.
I am trying to write an algorithm that can take a list of items and create unique permut... | from itertools import permutations
def is_valid_permutation(perm, categories):
"""
Checks if a given permutation is valid based on the categories,
ensuring no two consecutive items are from the same category.
"""
for i in range(len(perm) - 1):
if categories[perm[i]] == categories[perm[i + ... | def test_is_valid_permutation():
categories = {
'A1': 'A', 'A2': 'A',
'B1': 'B', 'B2': 'B',
'C1': 'C'
}
# Valid permutation
valid_perm = ('A1', 'B1', 'C1', 'A2', 'B2')
assert is_valid_permutation(valid_perm, categories)
# Invalid permutation
invalid_perm = ('A1', 'A... | [
{
"docstring": "Checks if a given permutation is valid based on the categories, \nensuring no two consecutive items are from the same category.",
"function_declaration": "def is_valid_permutation(perm, categories):",
"function_name": "is_valid_permutation",
"parameter_list": "(perm, categories)"
}... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from itertools import permutations\n\ndef is_valid_permutation(perm, categories):\n \"\"\"\n Checks if a given permutation is valid based on the categories, \n ensuring no two consecu... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00003453",
"row_id": 3453,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_10905']"
} | 0.543885 | Filter_3453 | I | [
"is_valid_permutation",
"unique_permutations"
] | 2 | [
[
"unique_permutations",
"is_valid_permutation"
]
] | 1 | [] | false | [] | false | pytest | false | [] | true | 5969c88e8e1f4ac49005bc744ce1780c486ab91d | e6a21c9ee0ecd4800c1a87a4d46f0e751125363c | |||
v1.0 | instruct | Filter | Filter_3456_I | I'm working on a Python project, and I need some help with a piece of code. It's supposed to take a text file with numbers separated by spaces as input, parse the numbers, and then find the sum, mean, median, and standard deviation of the numbers. I've got the sum and mean working, but I'm not sure how to implement the... | import math
def parse_numbers_from_file(file_path):
"""
Reads numbers from the file and returns them as a list.
"""
with open(file_path, 'r') as file:
contents = file.read()
return list(map(float, contents.split()))
def calculate_sum(numbers):
"""
Returns the sum of numbers.
""... | from solution import parse_numbers_from_file, calculate_sum, calculate_mean, calculate_median, calculate_std_deviation
def test_calculate_sum():
assert calculate_sum([1, 2, 3, 4, 5]) == 15
assert calculate_sum([0, -1, 1]) == 0
def test_calculate_mean():
assert calculate_mean([1, 2, 3, 4, 5]) == 3
asse... | [
{
"docstring": "Reads numbers from the file and returns them as a list.",
"function_declaration": "def parse_numbers_from_file(file_path):",
"function_name": "parse_numbers_from_file",
"parameter_list": "(file_path)"
},
{
"docstring": "Returns the sum of numbers.",
"function_declaration"... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import math\n\ndef read_numbers_from_file(filename):\n \"\"\"\n Reads numbers from a space-separated text file and returns them as a list of floats.\n \"\"\"\n with open(filename, ... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00003456",
"row_id": 3456,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_10911']"
} | 0.6224 | Filter_3456 | I | [
"parse_numbers_from_file",
"calculate_sum",
"calculate_mean",
"calculate_median",
"calculate_std_deviation"
] | 5 | [
[
"calculate_std_deviation",
"calculate_mean"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 4213c31f7f65d7b76935144d155ad21f84bbf49e | 329a453db0322bac4a53c429fe651d14ec228be1 | |||
v1.0 | instruct | Filter | Filter_3463_I | Here's a model to generate handwritten digits: an RNN that takes in 28x28 images and outputs the class labels. The output is the class label for the digit: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}.
The model generates an output for every pixel in the 28x28 image, but we only care about the final output. However, currently the l... | import torch
import torch.nn as nn
import torch.optim as optim
class DigitRNN(nn.Module):
def __init__(self, input_size, hidden_size, output_size, num_layers):
super(DigitRNN, self).__init__()
self.rnn = nn.RNN(input_size, hidden_size, num_layers, batch_first=True)
self.fc = nn.Linear(hidde... | import torch
from torch.utils.data import DataLoader, TensorDataset
from solution import DigitRNN, calculate_loss_at_last_output
def test_digit_rnn_loss_calculation():
input_size = 28 # Each row of the image
hidden_size = 128
output_size = 10 # Digits from 0 to 9
num_layers = 2
batch_size = 2
... | [] | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import torch\nimport torch.nn as nn\nimport torch.optim as optim\n\nclass DigitRNN(nn.Module):\n def __init__(self, input_size, hidden_size, output_size, num_layers):\n super(DigitRN... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00003463",
"row_id": 3463,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_10926']"
} | 0.517472 | Filter_3463 | I | [
"calculate_loss_at_last_output",
"train_rnn_model"
] | 2 | [
[
"train_rnn_model",
"calculate_loss_at_last_output"
]
] | 1 | [] | false | [
"DigitRNN"
] | true | pytest | true | [
"torch"
] | false | c03f8c5745d48b58c2a42fb95b070a11c90ae7ae | aa6b1280d80613fc653f18a44461f65d460f062d | |||
v1.0 | instruct | Filter | Filter_3473_I | I do not know how to make a function calling another function.
This function could have different names. I am just using the word "function" here.
I am a python user, you are welcome to change the name of this example as you are the expert.
Let's look at this example.
Function greet() is calling function hello() in... | def greet(name):
"""
Prints a greeting message by calling the hello function.
"""
print("How are you, " + hello(name))
def hello(name):
"""
Returns the name.
"""
return name
greet("yici") | from io import StringIO
import sys
from solution import greet, hello
def test_hello():
assert hello("yici") == "yici"
def test_greet():
captured_output = StringIO() # Create StringIO object
sys.stdout = captured_output # Redirect stdout
greet("yici")
sys.stdout = sys.__stdout__ ... | [
{
"docstring": "Prints a greeting message by calling the hello function.",
"function_declaration": "def greet(name):",
"function_name": "greet",
"parameter_list": "(name)"
},
{
"docstring": "Returns the name.",
"function_declaration": "def hello(name):",
"function_name": "hello",
... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def greet(name):\n \"\"\"\n This function greets the user by printing a greeting message.\n \"\"\"\n print(\"How are you, \")\n hello(name)\n\ndef hello(name):\n \"\"\"\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003473",
"row_id": 3473,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_10944']"
} | 0.411855 | Filter_3473 | I | [
"greet",
"hello"
] | 2 | [
[
"greet",
"hello"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 798b7801c893d140541842890e41019ded73c222 | 19a59d26db43ac160c69b00866b9cc95c9609586 | |||
v1.0 | instruct | Filter | Filter_3475_I | I'm coding a new product and it's a complex algorithm for route optimization for efficient delivery. Sounds like a fascinating project! This algorithm will be used with a logistics company to make their deliveries more efficient and reduce costs.
I'm trying to use a combination of techniques, a genetic algorithm and ... | import random
import math
def initialize_population(size, n_cities):
return [random.sample(range(n_cities), n_cities) for _ in range(size)]
def fitness(route, distance_matrix):
return sum(distance_matrix[route[i - 1]][route[i]] for i in range(len(route)))
def selection(population, distance_matrix, k=3):
... | import pytest
from solution import initialize_population, fitness, selection, crossover, mutate, genetic_algorithm, simulated_annealing, hybrid_algorithm
def test_initialize_population():
pop = initialize_population(5, 10)
assert len(pop) == 5
assert all(len(route) == 10 for route in pop)
assert all(le... | [
{
"docstring": null,
"function_declaration": "def initialize_population(size, n_cities):",
"function_name": "initialize_population",
"parameter_list": "(size, n_cities)"
},
{
"docstring": null,
"function_declaration": "def fitness(route, distance_matrix):",
"function_name": "fitness"... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\nimport numpy as np\n\ndef genetic_algorithm_route_optimization(\n initial_population,\n fitness_function,\n mutation_function,\n crossover_function,\n population_... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00003475",
"row_id": 3475,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_10948']"
} | 0.395774 | Filter_3475 | I | [
"initialize_population",
"fitness",
"selection",
"crossover",
"mutate",
"genetic_algorithm",
"simulated_annealing",
"hybrid_algorithm"
] | 8 | [
[
"genetic_algorithm",
"crossover"
],
[
"genetic_algorithm",
"fitness"
],
[
"genetic_algorithm",
"initialize_population"
],
[
"genetic_algorithm",
"mutate"
],
[
"genetic_algorithm",
"selection"
],
[
"hybrid_algorithm",
"genetic_algorithm"
],
[
... | 9 | [] | false | [] | false | pytest | true | [] | true | eaac82e17de0a76a375236119344cc9b328fa843 | 0cfc21b6e334b127e3d5fc432d8650c84233e10b | |||
v1.0 | instruct | Filter | Filter_3540_I | After writing the code for a Tic-Tac-Toe game, the programmer found that the game continues to allow moves after one player has won. The problem is that the code only checks for a win after all possible moves have been made on the board. However, this is inefficient and doesn't follow the rules of Tic-Tac-Toe.
The cor... | def check_win(board, player):
# check rows
for row in board:
if row.count(player) == 3:
return True
# check columns
for col in range(3):
if board[0][col] == player and board[1][col] == player and board[2][col] == player:
return True
# check diagonals
if (b... | from solution import check_win, print_board
def test_check_win_horizontal():
board = [['X', 'X', 'X'],
['O', ' ', ' '],
[' ', ' ', ' ']]
assert check_win(board, 'X') == True
assert check_win(board, 'O') == False
def test_check_win_vertical():
board = [['X', 'O', ' '],
... | [
{
"docstring": null,
"function_declaration": "def check_win(board, player):",
"function_name": "check_win",
"parameter_list": "(board, player)"
},
{
"docstring": null,
"function_declaration": "def play_game():",
"function_name": "play_game",
"parameter_list": "()"
},
{
"d... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def check_win(board, player):\n # check rows\n for row in board:\n if row.count(player) == 3:\n return True\n # check columns\n for col in range(3):\n if b... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003540",
"row_id": 3540,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11114']"
} | 0.540668 | Filter_3540 | I | [
"check_win",
"play_game",
"print_board",
"get_move"
] | 4 | [
[
"play_game",
"check_win"
],
[
"play_game",
"get_move"
],
[
"play_game",
"print_board"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | c88717d4e189239c3e53395c3777f324b9821792 | c47d582b7731cd2e734455db7b325249dc8c6e38 | |||
v1.0 | instruct | Filter | Filter_3548_I | Here is the code snippet:
`
while (true) {
if (close_enough(y, 0.0001)) {
break;
}
if (s < 0) {
s = increment_step(); // For example: s += 0.001;
} else {
s = decrement_step(); // For example: s -= 0.001;
}
y = update_value(s);
time_needed = calculate_time_needed(y);... | def close_enough(value, threshold):
"""
Determines if the value is within the threshold of zero.
"""
return abs(value) <= threshold
def increment_step(current_step):
"""
Increments the step size.
"""
return current_step + 0.001
def decrement_step(current_step):
"""
Decrements t... | import pytest
from solution import (close_enough, increment_step, decrement_step, update_value, calculate_time_needed, iterative_process)
def test_close_enough():
assert close_enough(0.0001, 0.0001) is True
assert close_enough(0.0002, 0.0001) is False
assert close_enough(-0.0001, 0.0001) is True
assert... | [
{
"docstring": "Determines if the value is within the threshold of zero.",
"function_declaration": "def close_enough(value, threshold):",
"function_name": "close_enough",
"parameter_list": "(value, threshold)"
},
{
"docstring": "Increments the step size.",
"function_declaration": "def in... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def close_enough(value, target, threshold=0.0001):\n \"\"\"\n Check if value is close enough to the target within the threshold.\n \"\"\"\n return abs(value - target) < threshold\n... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003548",
"row_id": 3548,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11131']"
} | 0.409039 | Filter_3548 | I | [
"close_enough",
"increment_step",
"decrement_step",
"update_value",
"calculate_time_needed",
"iterative_process"
] | 6 | [
[
"iterative_process",
"calculate_time_needed"
],
[
"iterative_process",
"close_enough"
],
[
"iterative_process",
"decrement_step"
],
[
"iterative_process",
"increment_step"
],
[
"iterative_process",
"update_value"
]
] | 5 | [] | false | [] | false | pytest | true | [] | true | 37110d9bbba3aedd15333f3d40862757dbf85f09 | 4788b8ea6fae3cceb38434c39ba68996316f3038 | |||
v1.0 | instruct | Filter | Filter_3562_I | You can use the following code as a starting point:
```
def calculate_checksum(row):
return sum([digits for digits in map(int, row)])
```
This is the code that we want to be applied on each row in a file.
Here's how we could read the file and apply the function to each row:
```
from collections import defaultd... | import pandas as pd
from collections import Counter
def calculate_checksum(row):
return sum(map(int, row))
def main_pandas(filename):
df = pd.read_csv(filename, header=None)
checksums = df[0].apply(lambda x: calculate_checksum(str(x)))
result = checksums.value_counts().to_dict()
for key, valu... | import pytest
from io import StringIO
import pandas as pd
from unittest.mock import mock_open, patch
from solution import calculate_checksum, main_one_liner, main_pandas
def test_calculate_checksum():
assert calculate_checksum("123") == 6
assert calculate_checksum("111") == 3
assert calculate_checksum("45... | [
{
"docstring": null,
"function_declaration": "def calculate_checksum(row):",
"function_name": "calculate_checksum",
"parameter_list": "(row)"
},
{
"docstring": null,
"function_declaration": "def main_pandas(filename):",
"function_name": "main_pandas",
"parameter_list": "(filename... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from pandas import DataFrame\nimport pandas as pd\n\ndef calculate_checksum(row):\n \"\"\"\n Calculate checksum for the given row.\n The row is a list of digits in string format.\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003562",
"row_id": 3562,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11173']"
} | 0.564402 | Filter_3562 | I | [
"calculate_checksum",
"main_pandas",
"main_one_liner"
] | 3 | [
[
"main_one_liner",
"calculate_checksum"
],
[
"main_pandas",
"calculate_checksum"
]
] | 2 | [] | false | [] | false | pytest | true | [
"pandas"
] | false | b13f578347448d790b36ae85f9c8891e16020765 | 36cb2191d85b9fac6c46fb5c5b22635d9cc2d99a | |||
v1.0 | instruct | Filter | Filter_3603_I | I want to implement an algorithm that finds an integer solution (x, y) for the equation ax + by = c. The algorithm should work for any integer coefficients a, b, and c.
One way to solve this problem is by using the Extended Euclidean Algorithm to find the GCD of a and b, and then using the coefficients of Bézout's ide... | def extended_euclidean(a, b):
"""
Uses the Extended Euclidean Algorithm to find the GCD of a and b,
as well as the coefficients x and y of Bézout's identity:
ax + by = gcd(a, b)
Returns a tuple (gcd, x, y).
"""
if a == 0:
return b, 0, 1
else:
gcd, x, y = extended_euclidea... | from solution import find_solution
def test_find_solution_basic():
assert find_solution(30, 12, 18) == (3, -6)
assert find_solution(7, 5, 1) == (-2, 3)
def test_find_solution_no_solution():
assert find_solution(2, 4, 5) is None
assert find_solution(10, 0, 3) is None
def test_find_solution_edge_cases(... | [
{
"docstring": "Uses the Extended Euclidean Algorithm to find the GCD of a and b,\nas well as the coefficients x and y of Bézout's identity:\nax + by = gcd(a, b)\nReturns a tuple (gcd, x, y).",
"function_declaration": "def extended_euclidean(a, b):",
"function_name": "extended_euclidean",
"parameter... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def extended_euclidean(a, b):\n if a == 0:\n return b, 0, 1\n else:\n gcd, x, y = extended_euclidean(b % a, a)\n return gcd, y - (b // a) * x, x\n\ndef find_solution... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00003603",
"row_id": 3603,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11274']"
} | 0.57253 | Filter_3603 | I | [
"extended_euclidean",
"find_solution"
] | 2 | [
[
"find_solution",
"extended_euclidean"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | c58e81df539b4f6d827c62586cce96ec6987beff | 503ebb74f1fe75c6a62d780260b5cd8a97711c1c | |||
v1.0 | instruct | Filter | Filter_3613_I | Here is a function that implements the `insert` method for a binary tree. It works by starting at the root, comparing the value of the node with the value we're trying to insert, and moving left or right accordingly.
```python
class Node:
def __init__(self, value):
self.value = value
self.left = No... | class Node:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
self.height = 1
def get_height(node):
if not node:
return 0
return node.height
def get_balance(node):
if not node:
return 0
return get_height(node.left) - ge... | from solution import Node, insert, inorder_traversal
def test_insert_to_empty_tree():
root = insert(None, 10)
assert root.value == 10
assert root.left is None
assert root.right is None
def test_single_rotation():
root = insert(None, 10)
root = insert(root, 20)
assert root.value == 10
a... | [] | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class Node:\n def __init__(self, value):\n self.value = value\n self.left = None\n self.right = None\n self.height = 1\n\ndef insert(root, value):\n \"\"\"\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003613",
"row_id": 3613,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11300']"
} | 0.540628 | Filter_3613 | I | [
"get_height",
"get_balance",
"right_rotate",
"left_rotate",
"insert",
"inorder_traversal"
] | 6 | [
[
"get_balance",
"get_height"
],
[
"insert",
"get_balance"
],
[
"insert",
"get_height"
],
[
"insert",
"left_rotate"
],
[
"insert",
"right_rotate"
],
[
"left_rotate",
"get_height"
],
[
"right_rotate",
"get_height"
]
] | 7 | [] | false | [
"Node"
] | true | pytest | true | [] | true | 1215d3e205fb080ce50394bcf066919b8e405e6f | a7e347fdbc32287b26606650dd8506caa6a31a53 | |||
v1.0 | instruct | Filter | Filter_3628_I | Here is a simple game idea: Given a random string of numbers, write a program that counts the number of distinct digits in that string.
For example, "12345" returns 5 distinct digits and "99999" returns 1 distinct digits.
Here is some example code in Python:
```
import random
def count_distinct_digits(s):
distinc... | def count_distinct_digits(s):
"""
Returns the number of distinct digits in the input string `s`.
"""
distinct = set(s)
return len(distinct)
def sorted_digits(s):
"""
Returns the digits in the input string `s` sorted in ascending order.
"""
return ''.join(sorted(s))
def find_digit(s... | from solution import count_distinct_digits, sorted_digits, find_digit
def test_count_distinct_digits():
assert count_distinct_digits('12345') == 5
assert count_distinct_digits('99999') == 1
assert count_distinct_digits('1122334455') == 5
assert count_distinct_digits('') == 0
assert count_distinct_d... | [
{
"docstring": "Returns the number of distinct digits in the input string `s`.",
"function_declaration": "def count_distinct_digits(s):",
"function_name": "count_distinct_digits",
"parameter_list": "(s)"
},
{
"docstring": "Returns the digits in the input string `s` sorted in ascending order.... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def count_distinct_digits_and_find_digit(s, digit):\n \"\"\"\n Counts the number of distinct digits in the string `s` and \n checks if the given `digit` is present in the sorted list ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003628",
"row_id": 3628,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11348']"
} | 0.594796 | Filter_3628 | I | [
"count_distinct_digits",
"sorted_digits",
"find_digit"
] | 3 | [
[
"find_digit",
"sorted_digits"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 07bb2058193c68958b919cba5f802854bc4ca33d | ce0005237a35e748244e91447d6168a2b16cde70 | |||
v1.0 | instruct | Filter | Filter_3632_I | In this problem, we're going to create a bowling game, and we want to calculate the bowling score for the player. We have the following rules:
- Each game of bowling includes ten frames. In each frame, the player has two chances to roll the ball, unless they score a strike.
- If the player rolls the ball three times, t... | def calculate_bowling_score(rolls):
"""
Calculate the total score for a game of bowling.
:param rolls: List of integers representing the number of pins knocked down in each roll.
:return: Integer representing the total score.
"""
score = 0
roll_index = 0
for frame in range(10):
... | from solution import calculate_bowling_score
def test_all_strikes():
assert calculate_bowling_score([10]*12) == 300
def test_all_spares_with_5():
assert calculate_bowling_score([5, 5]*10 + [5]) == 150
def test_no_strikes_no_spares():
assert calculate_bowling_score([3, 4]*10) == 70
def test_mixed_scores(... | [
{
"docstring": "Calculate the total score for a game of bowling.\n\n:param rolls: List of integers representing the number of pins knocked down in each roll.\n:return: Integer representing the total score.",
"function_declaration": "def calculate_bowling_score(rolls):",
"function_name": "calculate_bowli... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def calculate_bowling_score(rolls):\n \"\"\"\n Calculate the total score for a game of bowling.\n\n :param rolls: List of integers representing the number of pins knocked down in each... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00003632",
"row_id": 3632,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11369']"
} | 0.592059 | Filter_3632 | I | [
"calculate_bowling_score",
"is_strike",
"is_spare",
"sum_of_frame"
] | 4 | [
[
"calculate_bowling_score",
"is_spare"
],
[
"calculate_bowling_score",
"is_strike"
],
[
"calculate_bowling_score",
"sum_of_frame"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | 55c8720343d334c81a8ffb4a43b16a2bdc3d1001 | f0e70ca9d14cf5889dbcb2d0c9748c56fe63158e | |||
v1.0 | instruct | Filter | Filter_3638_I | Twin primes are prime numbers that differ by 2. For example, 3 and 5, 11 and 13, and 17 and 19 are all pairs of twin primes. Write a Python program that will determine whether two input integers are twin primes.
```python
def is_prime(n):
# ... (code here)
return True # or False
def are_twin_primes(a, b):
... | def is_prime(n):
"""
Determines if a given number n is prime.
"""
if n <= 1:
return False
for i in range(2, int(n**0.5) + 1): # Check divisors up to sqrt(n)
if n % i == 0:
return False
return True
def are_twin_primes(a, b):
"""
Determines if two numbers a an... | from solution import is_prime, are_twin_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(17) == True
assert is_prime(18) == False
assert is_prime(19) == True
assert is_prime(20) == Fa... | [
{
"docstring": "Determines if a given number n is prime.",
"function_declaration": "def is_prime(n):",
"function_name": "is_prime",
"parameter_list": "(n)"
},
{
"docstring": "Determines if two numbers a and b are twin primes.",
"function_declaration": "def are_twin_primes(a, b):",
"f... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(n):\n \"\"\"\n Check if a number is prime.\n \"\"\"\n if n <= 1:\n return False\n if n == 2:\n return True # 2 is the only even prime number\n if ... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00003638",
"row_id": 3638,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11383']"
} | 0.609011 | Filter_3638 | I | [
"is_prime",
"are_twin_primes"
] | 2 | [
[
"are_twin_primes",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 35648eb0c086fa17854e835506173f6cb8c02a57 | 0029e6a4ed9e54819097aa2afbd5fdd3327dd0e8 | |||
v1.0 | instruct | Filter | Filter_3652_I | I'm looking for a way to handle a specific problem with dates in Python. I have a list of dates, and I want to check if there are any duplicate dates. The problem is that the dates may be in slightly different formats, so I need a way to normalize them. Any suggestions? | from datetime import datetime
def normalize_date(date_str):
"""
Normalizes a date string to a consistent format.
This function assumes date strings can be in multiple formats.
"""
possible_formats = [
"%Y-%m-%d",
"%d-%m-%Y",
"%m/%d/%Y",
"%d/%m/%Y",
"%Y/%m/%d"... | import pytest
from solution import normalize_date, has_duplicate_dates
def test_normalize_date():
assert normalize_date("2023-01-15") == "2023-01-15"
assert normalize_date("15-01-2023") == "2023-01-15"
assert normalize_date("01/15/2023") == "2023-01-15"
assert normalize_date("15/01/2023") == "2023-01-1... | [
{
"docstring": "Normalizes a date string to a consistent format.\nThis function assumes date strings can be in multiple formats.",
"function_declaration": "def normalize_date(date_str):",
"function_name": "normalize_date",
"parameter_list": "(date_str)"
},
{
"docstring": "Checks if there are... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from datetime import datetime\n\ndef normalize_date(date_str):\n \"\"\"\n Normalizes a date string to a consistent format.\n This function assumes date strings can be in multiple form... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00003652",
"row_id": 3652,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11424']"
} | 0.545602 | Filter_3652 | I | [
"normalize_date",
"has_duplicate_dates"
] | 2 | [
[
"has_duplicate_dates",
"normalize_date"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | ad3db69d6c8c74f178637d313f24b29ce14b1b45 | 4e2fb7c5d5d71038a330d0e5effab3d741d5e9ea | |||
v1.0 | instruct | Filter | Filter_3685_I | We are tasked with finding the shortest palindrome in a given string. A palindrome is a string that reads the same forwards and backwards.
To solve this problem, we can create a new string that is the input string concatenated with its reverse. We then need to find the longest proper prefix of this new string that is ... | def compute_prefix_function(s):
m = len(s)
pi = [0] * m
k = 0
for q in range(1, m):
while k > 0 and s[k] != s[q]:
k = pi[k - 1]
if s[k] == s[q]:
k = k + 1
pi[q] = k
return pi
def shortest_palindrome(s):
if s == s[::-1]: # Check for palindrome
... | from solution import shortest_palindrome
def test_shortest_palindrome():
assert shortest_palindrome("abba") == "abba" # Already a palindrome
assert shortest_palindrome("aacecaaa") == "aaacecaaa"
assert shortest_palindrome("abcd") == "dcbabcd"
assert shortest_palindrome("") == "" # Empty string
as... | [
{
"docstring": null,
"function_declaration": "def compute_prefix_function(s):",
"function_name": "compute_prefix_function",
"parameter_list": "(s)"
},
{
"docstring": null,
"function_declaration": "def shortest_palindrome(s):",
"function_name": "shortest_palindrome",
"parameter_li... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def compute_prefix_function(s):\n m = len(s)\n pi = [0] * m\n k = 0\n for q in range(1, m):\n while k > 0 and s[k] != s[q]:\n k = pi[k - 1]\n if s[k] == s[... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003685",
"row_id": 3685,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11503']"
} | 0.748122 | Filter_3685 | I | [
"compute_prefix_function",
"shortest_palindrome"
] | 2 | [
[
"shortest_palindrome",
"compute_prefix_function"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 465ba0edd0dfca2e4bf9e3a44308e81c83d5f75c | 5120e3bbcedb528cd1d26408cdf7ebf0a8e92100 | |||
v1.0 | instruct | Filter | Filter_3686_I | I have a text file containing a list of numbers, one number per line. I also have a separate text file containing a list of ranges (e.g., `1-5` representing the range from 1 to 5 inclusive). I want to check whether each number in the first file falls within any of the ranges in the second file. I can do this with a sim... | def read_numbers(file_path):
"""
Reads numbers from a file, each number in one line.
Returns a list of all the numbers.
"""
with open(file_path, 'r') as file:
return [int(line.strip()) for line in file]
def read_ranges(file_path):
"""
Reads ranges from a file, each range in the form... | from solution import read_numbers, read_ranges, is_number_in_range, check_numbers_against_ranges
def test_read_numbers(tmp_path):
test_file = tmp_path / "numbers.txt"
test_file.write_text("1\n2\n3\n4\n5\n")
expected = [1, 2, 3, 4, 5]
result = read_numbers(test_file)
assert result == expected
def ... | [
{
"docstring": "Reads numbers from a file, each number in one line.\nReturns a list of all the numbers.",
"function_declaration": "def read_numbers(file_path):",
"function_name": "read_numbers",
"parameter_list": "(file_path)"
},
{
"docstring": "Reads ranges from a file, each range in the fo... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def number_in_ranges(number, ranges):\n \"\"\"\n Check if a number falls within any of the given ranges.\n \n Args:\n number (int): The number to check.\n ranges (list of tup... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003686",
"row_id": 3686,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11507']"
} | 0.475594 | Filter_3686 | I | [
"read_numbers",
"read_ranges",
"is_number_in_range",
"check_numbers_against_ranges"
] | 4 | [
[
"check_numbers_against_ranges",
"is_number_in_range"
],
[
"check_numbers_against_ranges",
"read_numbers"
],
[
"check_numbers_against_ranges",
"read_ranges"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | b4bd839547934c9f45b682e16344324b11bf40e6 | 6626a759b1d489549ba2454f1c5f02e02731216b | |||
v1.0 | instruct | Filter | Filter_3701_I | Create a simple spell-check in Python.
Here are the words that the spellcheck would be checking against:
• Oak
• Maple
• Pine
• Ash
• Teak
• Cedar
• Walnut
• Cherry
• Drupe
• Birch
• Beech
• Pineapple
• Walnut
I made a typo and I wrote Pnie. In this case if Pnie is found in the list then print Pnie was found otherwise ... | def levenshtein_distance(s1, s2):
"""
Computes the Levenshtein distance between two strings.
"""
if len(s1) < len(s2):
return levenshtein_distance(s2, s1)
if len(s2) == 0:
return len(s1)
previous_row = range(len(s2) + 1)
for i, c1 in enumerate(s1):
current_r... | from solution import levenshtein_distance, spell_check
def test_levenshtein_distance():
assert levenshtein_distance("kitten", "sitting") == 3
assert levenshtein_distance("flaw", "lawn") == 2
assert levenshtein_distance("", "test") == 4
assert levenshtein_distance("test", "") == 4
assert levenshtein... | [
{
"docstring": "Computes the Levenshtein distance between two strings.",
"function_declaration": "def levenshtein_distance(s1, s2):",
"function_name": "levenshtein_distance",
"parameter_list": "(s1, s2)"
},
{
"docstring": "Checks if a word is in the list of words using Levenshtein distance."... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def levenshtein_distance(s1, s2):\n \"\"\"\n Computes the Levenshtein distance between two strings.\n \"\"\"\n if len(s1) < len(s2):\n return levenshtein_distance(s2, s1)\n ... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00003701",
"row_id": 3701,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11541']"
} | 0.539542 | Filter_3701 | I | [
"levenshtein_distance",
"spell_check"
] | 2 | [
[
"spell_check",
"levenshtein_distance"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 49c13b0cafabf38aca7c03848d10d3ba0e4025e4 | d4038ec01731b26e964a1872692fe78408d525d9 | |||
v1.0 | instruct | Filter | Filter_3710_I | This algorithm sorts a list of integers using merge sort:
```
def merge_sort(lst):
if len(lst) <= 1:
return lst
mid = len(lst) // 2
left_half = lst[:mid]
right_half = lst[mid:]
left_half = merge_sort(left_half)
right_half = merge_sort(right_half)
return merge(left_half, right_hal... | def merge_sort(lst):
if len(lst) <= 1:
return lst
mid = len(lst) // 2
left_half = lst[:mid]
right_half = lst[mid:]
left_half = merge_sort(left_half)
right_half = merge_sort(right_half)
return merge(left_half, right_half)
def merge(left, right):
sorted_list = []
left_index... | from solution import merge_sort
def test_merge_sort_empty():
assert merge_sort([]) == []
def test_merge_sort_single_element():
assert merge_sort([1]) == [1]
def test_merge_sort_already_sorted():
assert merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]
def test_merge_sort_unsorted():
assert merge_sort([... | [
{
"docstring": null,
"function_declaration": "def merge_sort(lst):",
"function_name": "merge_sort",
"parameter_list": "(lst)"
},
{
"docstring": null,
"function_declaration": "def merge(left, right):",
"function_name": "merge",
"parameter_list": "(left, right)"
}
] | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def merge_sort(lst):\n if len(lst) <= 1:\n return lst\n\n mid = len(lst) // 2\n left_half = lst[:mid]\n right_half = lst[mid:]\n\n left_half = merge_sort(left_half)\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003710",
"row_id": 3710,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11560']"
} | 0.569084 | Filter_3710 | I | [
"merge_sort",
"merge"
] | 2 | [
[
"merge_sort",
"merge"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 1fa1dec3755ea922d31c23be0c5c3653934957bc | ece1e5b6438fe4ba7ca9ca6a912b85f18abe8037 | |||
v1.0 | instruct | Filter | Filter_3717_I | I have access to a piece of code that is a simulation of a Hogwarts house sorting ceremony. The code takes in a users name and a series of values for different traits (such as bravery, intelligence, etc.) and then outputs which Hogwarts house they are sorted into. I am looking to add the functionality of telling the us... | def determine_house(traits):
"""
Determines the primary and secondary Hogwarts house based on the given traits.
Args:
traits (dict): A dictionary with Hogwarts houses as keys and trait scores as values.
Returns:
(str, str): A tuple containing the primary and secondary Hogwarts houses.
... | from solution import sorting_ceremony
def test_sorting_ceremony_true_gryffindor():
result = sorting_ceremony("Harry", 90, 40, 50, 60)
assert result == "Harry, you are a true Gryffindor with a hidden Slytherin!"
def test_sorting_ceremony_true_ravenclaw():
result = sorting_ceremony("Luna", 40, 90, 50, 60)
... | [
{
"docstring": "Determines the primary and secondary Hogwarts house based on the given traits.\nArgs:\n traits (dict): A dictionary with Hogwarts houses as keys and trait scores as values.\n\nReturns:\n (str, str): A tuple containing the primary and secondary Hogwarts houses.",
"function_declaration":... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def sort_into_houses(name, bravery, intelligence, loyalty, ambition):\n \"\"\"\n Returns the primary house and a hidden house based on the user's traits.\n :param name: string, name o... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00003717",
"row_id": 3717,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11574']"
} | 0.345644 | Filter_3717 | I | [
"determine_house",
"sorting_ceremony"
] | 2 | [
[
"sorting_ceremony",
"determine_house"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | c5dca2c620de9e9c6e7d7eddcb885930563af477 | 495b6c4601d4e583c9b326ebbf2e549d3e5dc385 | |||
v1.0 | instruct | Filter | Filter_3718_I | Here is the output, which I will label below to make it easier to understand:
```
1 | MEASUREMENTS
2 |
3 | SYSTEM VALUE
4 | ========== =======
5 |
6 | LENGTH 1500.00
7 | WIDTH 3000.00
8 | HEIGHT 700.00
9 | WEIGHT 0.00
10 | CAPACITY 0.00
11 |
12 | TANK... | import re
def extract_values(report):
"""
Extracts CAPACITY and TANK_COUNT values from the report.
"""
capacity_match = re.search(r'CAPACITY\s+([\d\.]+)', report)
tank_count_match = re.search(r'TANK_COUNT\s+(\d+)', report)
if not capacity_match or not tank_count_match:
raise ValueError... | import pytest
from solution import calculate_total_capacity, extract_values
def test_extract_values_valid_report():
report = """
1 | MEASUREMENTS
2 |
3 | SYSTEM VALUE
4 | ========== =======
5 |
6 | LENGTH 1500.00
7 | WIDTH 3000.00
8 | HEIGHT ... | [
{
"docstring": "Extracts CAPACITY and TANK_COUNT values from the report.",
"function_declaration": "def extract_values(report):",
"function_name": "extract_values",
"parameter_list": "(report)"
},
{
"docstring": "Calculates the total capacity based on CAPACITY and TANK_COUNT values from the ... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import re\n\ndef extract_values(report):\n \"\"\"\n Extracts CAPACITY and TANK_COUNT values from the report.\n \"\"\"\n capacity_match = re.search(r'CAPACITY\\s+([\\d\\.]+)', repor... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003718",
"row_id": 3718,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11577']"
} | 0.548858 | Filter_3718 | I | [
"extract_values",
"calculate_total_capacity"
] | 2 | [
[
"calculate_total_capacity",
"extract_values"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 58f24588ef201bc814e1981d58c2ad1fffaada7f | 66b191c787d02c5295ee67bc919df8be44b3fe20 | |||
v1.0 | instruct | Filter | Filter_3727_I | This is a journal of a spaceship captain, with occasional entries about various alien species met during the journey, notes about maintenance, and internal conflicts. I want to be able to specify the number of days the journal spans across and the amount of entries. For instance, if I want a journal spanning 15 days wi... | import random
def journal_entry(days_covered, category, entry):
print(f"Day {days_covered}: {category}")
print(entry)
print()
def alien_species_encounter(days_covered, species_name, description):
entry = f"Encountered an alien species known as the '{species_name}'. They are {description}."
journal... | from solution import journal_entry, alien_species_encounter, maintenance_log, internal_conflict, captain_journal
def test_alien_species_encounter(capsys):
alien_species_encounter(2, "Zorgon", "hostile and aggressive")
captured = capsys.readouterr()
assert "Day 2: Alien Species Encounter" in captured.out
... | [
{
"docstring": null,
"function_declaration": "def journal_entry(days_covered, category, entry):",
"function_name": "journal_entry",
"parameter_list": "(days_covered, category, entry)"
},
{
"docstring": null,
"function_declaration": "def alien_species_encounter(days_covered, species_name,... | [
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 journal_entry(days_covered, category, entry):\n print(f\"Day {days_covered}: {category}\")\n print(entry)\n print()\n\ndef alien_species_encounter(days_covered, s... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00003727",
"row_id": 3727,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11594']"
} | 0.398748 | Filter_3727 | I | [
"journal_entry",
"alien_species_encounter",
"maintenance_log",
"internal_conflict",
"captain_journal"
] | 5 | [
[
"alien_species_encounter",
"journal_entry"
],
[
"captain_journal",
"alien_species_encounter"
],
[
"captain_journal",
"internal_conflict"
],
[
"captain_journal",
"maintenance_log"
],
[
"internal_conflict",
"journal_entry"
],
[
"maintenance_log",
"... | 6 | [] | false | [] | false | pytest | true | [] | true | da73556490bb08c633b696bd80bb8bce22455a1d | deae62488412c7e71e60eba775025e2580eef250 | |||
v1.0 | instruct | Filter | Filter_3740_I | I have a large static text file that I need to split into multiple smaller files based on a specific delimiter. I can specify the size of each file (in KB, MB, or GB) and I need to preserve the order of the records.
The input file is also compressed with gzip, so it needs to be decompressed on the fly while being proc... | import os
import gzip
def split_file(input_file, delimiter, output_dir, chunk_size):
chunk_size_bytes = convert_size_to_bytes(chunk_size)
if not os.path.exists(output_dir):
os.makedirs(output_dir)
with gzip.open(input_file, 'rb') as f_in:
file_count = 0
current_chunk_size ... | import os
import pytest
from solution import split_file, convert_size_to_bytes
def test_split_file_creates_files(tmp_path):
input_file = tmp_path / "test.gz"
output_dir = tmp_path / "output"
data = b"line1\nline2\nline3\nline4\n"
# Create a gzip file for testing
with gzip.open(input_file, 'wb'... | [
{
"docstring": null,
"function_declaration": "def split_file(input_file, delimiter, output_dir, chunk_size):",
"function_name": "split_file",
"parameter_list": "(input_file, delimiter, output_dir, chunk_size)"
},
{
"docstring": null,
"function_declaration": "def convert_size_to_bytes(siz... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import gzip\nimport os\n\ndef split_file(input_file, delimiter, output_dir, chunk_size):\n chunk_size_bytes = convert_size_to_bytes(chunk_size)\n \n if not os.path.exists(output_dir):... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00003740",
"row_id": 3740,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11629']"
} | 0.544739 | Filter_3740 | I | [
"split_file",
"convert_size_to_bytes"
] | 2 | [
[
"split_file",
"convert_size_to_bytes"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 818907990d366f0534f41a5938e9fb9d3b0edf90 | c0163e8ba617ad22c64f01cb45e880ada742d4ed | |||
v1.0 | instruct | Filter | Filter_3771_I | ### Overwriting A Worksheet (Regardless Of Existing Content)
```python
def overwrite_worksheet(workbook, worksheet_name, headers, data):
worksheet = workbook.add_worksheet(worksheet_name)
worksheet.write_row(0, 0, headers)
for num, row in enumerate(data, start=1):
worksheet.write_row(num, 0, row)
`... | def add_worksheet(workbook, worksheet_name):
"""
Adds a new worksheet to the workbook with the given name.
Overwrites any worksheet with the same name.
"""
return workbook.add_worksheet(worksheet_name)
def write_headers(worksheet, headers):
"""
Writes the headers to the first row of the wor... | import pytest
from unittest.mock import Mock
from solution import add_worksheet, write_headers, write_data, overwrite_worksheet
def test_add_worksheet():
workbook = Mock()
workbook.add_worksheet.return_value = "worksheet"
worksheet = add_worksheet(workbook, "Sheet1")
assert worksheet == "worksheet"
... | [
{
"docstring": "Adds a new worksheet to the workbook with the given name.\nOverwrites any worksheet with the same name.",
"function_declaration": "def add_worksheet(workbook, worksheet_name):",
"function_name": "add_worksheet",
"parameter_list": "(workbook, worksheet_name)"
},
{
"docstring":... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def add_worksheet(workbook, worksheet_name):\n \"\"\"\n Adds a new worksheet to the given workbook.\n \"\"\"\n return workbook.add_worksheet(worksheet_name)\n\ndef write_headers(wo... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00003771",
"row_id": 3771,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11727']"
} | 0.522633 | Filter_3771 | I | [
"add_worksheet",
"write_headers",
"write_data",
"overwrite_worksheet"
] | 4 | [
[
"overwrite_worksheet",
"add_worksheet"
],
[
"overwrite_worksheet",
"write_data"
],
[
"overwrite_worksheet",
"write_headers"
]
] | 3 | [] | false | [] | false | pytest | true | [] | true | 312f7a11d1654e1ba191bc887b9a7935037f12f3 | ad8111755246f1e018f5cc51f2d9e647cb850a63 | |||
v1.0 | instruct | Filter | Filter_3779_I | The temperature is measured in degrees Fahrenheit in the range from 32°F to 212°F. Write a Python program that will iterate through the range from 32°F to 212°F, convert the temperature from Fahrenheit to Celsius, and then print it. | def fahrenheit_to_celsius(fahrenheit):
"""
Converts temperature from Fahrenheit to Celsius.
"""
celsius = (fahrenheit - 32) * 5.0/9.0
return celsius
def print_fahrenheit_to_celsius():
"""
Iterates through the range of temperatures from 32°F to 212°F, converts each to Celsius, and prints the... | from solution import fahrenheit_to_celsius
def test_fahrenheit_to_celsius_freezing_point():
assert fahrenheit_to_celsius(32) == 0
def test_fahrenheit_to_celsius_boiling_point():
assert fahrenheit_to_celsius(212) == 100
def test_fahrenheit_to_celsius_body_temp():
# Normal body temperature in Fahrenheit is... | [
{
"docstring": "Converts temperature from Fahrenheit to Celsius.",
"function_declaration": "def fahrenheit_to_celsius(fahrenheit):",
"function_name": "fahrenheit_to_celsius",
"parameter_list": "(fahrenheit)"
},
{
"docstring": "Iterates through the range of temperatures from 32°F to 212°F, co... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def fahrenheit_to_celsius(fahrenheit):\n \"\"\"\n Converts temperature from Fahrenheit to Celsius.\n Args:\n fahrenheit (float): Temperature in Fahrenheit.\n\n Returns:\n flo... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003779",
"row_id": 3779,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11752']"
} | 0.432405 | Filter_3779 | I | [
"fahrenheit_to_celsius",
"print_fahrenheit_to_celsius"
] | 2 | [
[
"print_fahrenheit_to_celsius",
"fahrenheit_to_celsius"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | e365ed590a4b8cd8d40bbb060ad71886df926c24 | c240ebc14d7e8be3e35b05c32a9d7cbb0b778cf7 | |||
v1.0 | instruct | Filter | Filter_3789_I | A company sells a variety of products, and for each product, it calculates the price as the base price of the product plus the total cost of all features in the product. There are multiple features for each product. The total price of all products is 100,000. The company wants to sort the products by price in descendin... | def total_price(base_price, *features):
"""
Returns the total price of a product given its base price and feature prices.
"""
return base_price + sum(features)
def sort_products_by_price(products):
"""
Sorts a list of products by their total price in descending order.
Args:
product... | from solution import total_price, sort_products_by_price
def test_total_price():
assert total_price(2000, 1000, 2000) == 5000
assert total_price(3000, 2000, 3000) == 8000
assert total_price(1000, 1500, 1000) == 3500
def test_sort_products_by_price():
products = [
("Product A", 2000, 1000, 2000... | [
{
"docstring": "Returns the total price of a product given its base price and feature prices.",
"function_declaration": "def total_price(base_price, *features):",
"function_name": "total_price",
"parameter_list": "(base_price, *features)"
},
{
"docstring": "Sorts a list of products by their ... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def calculate_total_price(base_price, features):\n \"\"\"\n Calculate the total price of a product including its base price and the sum of all features.\n :param base_price: int, the ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003789",
"row_id": 3789,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11786']"
} | 0.540919 | Filter_3789 | I | [
"total_price",
"sort_products_by_price"
] | 2 | [
[
"sort_products_by_price",
"total_price"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 96d296004b2ebbfe9e11fce49c479865fa3ca795 | b54f8fd8d55aada2274d3655171a75c8dff3b43e | |||
v1.0 | instruct | Filter | Filter_3812_I | In this problem, we'll create a rock-paper-scissors game. Instead of asking the user to type in their move directly, let's allow the user to type in either "rock," "paper," or "scissors," or abbreviate their move as "r," "p," or "s." | import random
def convert_to_full_move(move):
if move == "r":
return "rock"
elif move == "p":
return "paper"
elif move == "s":
return "scissors"
return move
def determine_winner(user_move, comp_move):
if user_move == comp_move:
return "Tie"
elif (user_move == "r... | from solution import convert_to_full_move, determine_winner, play_rps
def test_convert_to_full_move():
assert convert_to_full_move("r") == "rock"
assert convert_to_full_move("p") == "paper"
assert convert_to_full_move("s") == "scissors"
assert convert_to_full_move("rock") == "rock"
assert convert_t... | [
{
"docstring": null,
"function_declaration": "def convert_to_full_move(move):",
"function_name": "convert_to_full_move",
"parameter_list": "(move)"
},
{
"docstring": null,
"function_declaration": "def determine_winner(user_move, comp_move):",
"function_name": "determine_winner",
... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\n\ndef get_computer_move():\n moves = [\"rock\", \"paper\", \"scissors\"]\n return random.choice(moves)\n\ndef determine_winner(player_move, computer_move):\n # Translat... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003812",
"row_id": 3812,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11835']"
} | 0.604268 | Filter_3812 | I | [
"convert_to_full_move",
"determine_winner",
"play_rps"
] | 3 | [
[
"play_rps",
"convert_to_full_move"
],
[
"play_rps",
"determine_winner"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 63df8816e0c453894f97279fb9e1b26aea2e6aa4 | ccc5d1eb3fa15af5c06a7c603d1776989f3f0bae | |||
v1.0 | instruct | Filter | Filter_3820_I | I'm trying to write a script to automate a particular workflow. The script will take in a list of files with their corresponding file types (either .jpg, or .pdf). The script should then process each file by downloading it, and running it through a series of processing steps. If the file type is .jpg, the script will r... | from PIL import Image
import requests
from io import BytesIO
def download_file(url):
"""
Downloads the file from the given URL.
"""
response = requests.get(url)
response.raise_for_status()
return BytesIO(response.content)
def process_jpg(file_stream):
"""
Processes a jpg image by resiz... | from solution import process_files
from PIL import Image
import requests
from io import BytesIO
def test_process_files_jpg():
# Create an in-memory jpg file for testing
original_image = Image.new('RGB', (100, 100), 'blue')
file_stream = BytesIO()
original_image.save(file_stream, format='JPEG')
file... | [
{
"docstring": "Downloads the file from the given URL.",
"function_declaration": "def download_file(url):",
"function_name": "download_file",
"parameter_list": "(url)"
},
{
"docstring": "Processes a jpg image by resizing and adding a watermark.",
"function_declaration": "def process_jpg(... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from PIL import Image\nimport requests\nfrom io import BytesIO\n\ndef download_file(url):\n \"\"\"\n Download the file from the given url and return the content.\n \"\"\"\n respons... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003820",
"row_id": 3820,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11857']"
} | 0.540093 | Filter_3820 | I | [
"download_file",
"process_jpg",
"process_files"
] | 3 | [
[
"process_files",
"download_file"
],
[
"process_files",
"process_jpg"
]
] | 2 | [] | false | [] | false | pytest | true | [
"PIL",
"requests"
] | false | c7067cad29ea62b53e11e45d13b7a7066090f7ff | ba2c63b3c39449869e3409ae719f6daff1f7a12d | |||
v1.0 | instruct | Filter | Filter_3855_I | Here is an example of helper functions, which we can use to create a simple preprocessor.
`preprocess` parses a source file and it will return a tuple containing the parsed source data and any errors.
```python
import re
class PreprocessorError(Exception):
pass
def parse_include_line(line):
"""Parses an ... | import re
class PreprocessorError(Exception):
pass
def parse_include_line(line):
"""Parses an include line to get the filename"""
match = re.match(r'^\s*#include\s+"([^"]+)"', line)
if match:
return match.group(1)
else:
raise PreprocessorError(f"Invalid include directive: {line}")
... | import pytest
from solution import parse_include_line, preprocess, PreprocessorError
def test_parse_include_line_valid():
assert parse_include_line('#include "file1.h"') == 'file1.h'
assert parse_include_line(' #include "file2.h"') == 'file2.h'
assert parse_include_line('\t#include "file3.h"') == 'file3.h... | [] | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import re\n\nclass PreprocessorError(Exception):\n pass\n\ndef parse_include_line(line):\n \"\"\"Parses an include line to get the filename\"\"\"\n match = re.match(r'^\\s*#include\\s... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00003855",
"row_id": 3855,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11942']"
} | 0.517517 | Filter_3855 | I | [
"parse_include_line",
"preprocess"
] | 2 | [
[
"preprocess",
"parse_include_line"
]
] | 1 | [] | false | [
"PreprocessorError"
] | true | pytest | true | [] | true | 6d87ab32ed313c11aa895639f916463cc9bfcbac | 636dbf3afbced94ac8898fb6254e036ec8900f97 | |||
v1.0 | instruct | Filter | Filter_3866_I | This challenge is to write a program that repeatedly prompts the user for input until a valid time in 12-hour format is entered.
### Definition of a valid time
A valid time in 12-hour format is in the form `(1-12):(0-59) AM/PM`, where:
- The hour is a number between 1 and 12 (inclusive).
- The minute is a number betw... | import re
def validate_time(time_str):
"""
Validates if the given time string is in the correct 12-hour format (1-12):(0-59) AM/PM.
"""
pattern = re.compile(r'^(1[0-2]|0?[1-9]):([0-5][0-9])\s*([AaPp][Mm])$')
match = pattern.match(time_str.strip())
return bool(match)
def get_time():
""... | from solution import validate_time, get_time
def test_validate_time_valid_cases():
assert validate_time('10:30 AM') == True
assert validate_time('12:59 PM') == True
assert validate_time('1:00 am') == True
assert validate_time('02:15 pm') == True
def test_validate_time_invalid_cases():
assert valid... | [
{
"docstring": "Validates if the given time string is in the correct 12-hour format (1-12):(0-59) AM/PM.",
"function_declaration": "def validate_time(time_str):",
"function_name": "validate_time",
"parameter_list": "(time_str)"
},
{
"docstring": "Continuously prompts the user for time input ... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import re\n\ndef validate_time(time_str):\n \"\"\"\n Validates if the given time string is in the correct 12-hour format (1-12):(0-59) AM/PM.\n \"\"\"\n pattern = re.compile(r'^(1[... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00003866",
"row_id": 3866,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_11969']"
} | 0.627424 | Filter_3866 | I | [
"validate_time",
"get_time",
"main"
] | 3 | [
[
"get_time",
"validate_time"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 9799fe424a59b6571f6bf66b892159c1898a0212 | c53be5d577c5ed79b604a932f45d56e993f49fd3 | |||
v1.0 | instruct | Filter | Filter_3892_I | Here is a simple recursive function that calculates the greatest common divisor of two numbers using the Euclidean algorithm:
```
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
```
The Euclidean algorithm works by repeatedly replacing `a` and `b` with `b` and `a` modulo `b` until ... | def extended_gcd(a, b):
"""
Returns a tuple (gcd, x, y) such that gcd is the greatest common divisor of a and b,
and x and y are the coefficients such that ax + by = gcd.
"""
if b == 0:
return (a, 1, 0)
else:
g, x1, y1 = extended_gcd(b, a % b)
x = y1
y = x1 - (a /... | from solution import gcd_with_inverse
def test_gcd_basic_cases():
assert gcd_with_inverse(48, 18) == (6, None)
assert gcd_with_inverse(101, 103) == (1, 51)
def test_multiplicative_inverse():
assert gcd_with_inverse(3, 7) == (1, 5)
assert gcd_with_inverse(10, 17) == (1, 12)
def test_no_inverse():
... | [
{
"docstring": "Returns a tuple (gcd, x, y) such that gcd is the greatest common divisor of a and b,\nand x and y are the coefficients such that ax + by = gcd.",
"function_declaration": "def extended_gcd(a, b):",
"function_name": "extended_gcd",
"parameter_list": "(a, b)"
},
{
"docstring": "... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def extended_gcd(a, b):\n \"\"\"\n Returns a tuple (gcd, x, y) such that gcd is the greatest common divisor of a and b,\n and x, y are the coefficients satisfying the equation: ax + b... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00003892",
"row_id": 3892,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12021']"
} | 0.583814 | Filter_3892 | I | [
"extended_gcd",
"gcd_with_inverse"
] | 2 | [
[
"gcd_with_inverse",
"extended_gcd"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 3b8fedf592c95ad99c1279d20b5ba21aa74b2d3b | 574ceba8c82e90805dd42d7a3ab1edfd3117060c | |||
v1.0 | instruct | Filter | Filter_3893_I | This is a python program to solve a maze defined by a matrix. It uses a depth-first search (DFS) algorithm.
# Maze Solving Program
```python
from collections import deque
def is_valid_move(maze, visited, row, col):
return (0 <= row < len(maze) and
0 <= col < len(maze[0]) and
maze[row][c... | from collections import deque
def is_valid_move(maze, visited, row, col):
"""
Checks if a move to (row, col) is within maze bounds, not visited, and not a wall (represented by 1).
"""
return (0 <= row < len(maze) and
0 <= col < len(maze[0]) and
maze[row][col] == 0 and
... | import pytest
from solution import solve_maze
def test_maze_with_no_obstacles():
maze = [
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]
]
start = (0, 0)
end = (3, 3)
assert solve_maze(maze, start, end) == True
def test_maze_with_obstacles():
maze = [
... | [
{
"docstring": "Checks if a move to (row, col) is within maze bounds, not visited, and not a wall (represented by 1).",
"function_declaration": "def is_valid_move(maze, visited, row, col):",
"function_name": "is_valid_move",
"parameter_list": "(maze, visited, row, col)"
},
{
"docstring": "Pe... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class Point:\n def __init__(self, x, y):\n self.x = x\n self.y = y\n \n def __eq__(self, other):\n return self.x == other.x and self.y == other.y\n \n def _... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003893",
"row_id": 3893,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12022']"
} | 0.552684 | Filter_3893 | I | [
"is_valid_move",
"dfs",
"solve_maze"
] | 3 | [
[
"dfs",
"is_valid_move"
],
[
"solve_maze",
"dfs"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | f2743ca4161daad7f8abd63c8a689a3858b334f4 | 6ea47591972e7940440357e014c3c129a6b01311 | |||
v1.0 | instruct | Filter | Filter_3903_I | I have two problems that only require a slight modification of the same algorithm, but I'm struggling to extract a generic, reusable function from the two algorithms.
Here's the original code:
```python
def calculate_battery_level(var_data):
# ... (some code that doesn't matter for the problem)
values = var_da... | def calculate_battery_metric(var_data, threshold):
"""
Calculate a battery metric based on a given threshold.
Args:
var_data (dict): A dictionary containing the values; key should be 'values'.
threshold (float): The threshold for comparison.
Returns:
float: The calculated battery m... | from solution import calculate_battery_level, calculate_battery_charging_status, calculate_battery_metric
def test_calculate_battery_level():
var_data = {'values': [0.2, 0.4, -0.1, 0.6, 0.8]}
assert calculate_battery_level(var_data) == 0.8 # 4 out of 5 values are > 0
def test_calculate_battery_charging_statu... | [
{
"docstring": "Calculate a battery metric based on a given threshold.\n\nArgs:\nvar_data (dict): A dictionary containing the values; key should be 'values'.\nthreshold (float): The threshold for comparison.\n\nReturns:\nfloat: The calculated battery metric.",
"function_declaration": "def calculate_battery_... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def calculate_metric(var_data, threshold):\n \"\"\"\n Calculates the percentage of values in var_data that exceed the given threshold.\n \n Args:\n var_data (dict): Dictionary c... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003903",
"row_id": 3903,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12052']"
} | 0.47659 | Filter_3903 | I | [
"calculate_battery_metric",
"calculate_battery_level",
"calculate_battery_charging_status"
] | 3 | [
[
"calculate_battery_charging_status",
"calculate_battery_metric"
],
[
"calculate_battery_level",
"calculate_battery_metric"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | d9fa0fc7815167b261e92817ba7d6a7a7f10cd18 | 79b3f591b7b2608f1ffcb3cc96ef4527ab1b9d07 | |||
v1.0 | instruct | Filter | Filter_3909_I | Here is a simple Datatable with one row and two columns. I would like to add an extra column with a hyperlink to edit the row. Here is a code snippet to generate the Datatable with the extra column.
```python
import pandas as pd
from IPython.display import display, HTML
# Create a sample dataframe
data = {'Name': ['J... | import pandas as pd
from IPython.display import display, HTML
import ipywidgets as widgets
# Create a sample dataframe
data = {'Name': ['John'], 'Age': [25]}
df = pd.DataFrame(data)
# Create a new column with the edit buttons
df_edit = df.assign(Edit=[f'<button onclick="IPython.notebook.kernel.execute(\'edit_row({idx... | def test_edit_row():
import pandas as pd
from IPython.display import display, HTML
import ipywidgets as widgets
# Create a sample dataframe
data = {'Name': ['John'], 'Age': [25]}
df = pd.DataFrame(data)
# Create a new column with the edit buttons
df_edit = df.assign(Edit=[f'<button onc... | [
{
"docstring": null,
"function_declaration": "def edit_row(index):",
"function_name": "edit_row",
"parameter_list": "(index)"
},
{
"docstring": null,
"function_declaration": "def update_display():",
"function_name": "update_display",
"parameter_list": "()"
},
{
"docstring... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import pandas as pd\nfrom IPython.display import display, HTML\nfrom ipywidgets import (\n Text,\n Button,\n HBox,\n VBox,\n Layout,\n Output,\n interactive_output\n)\n\n#... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003909",
"row_id": 3909,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12061']"
} | 0.419715 | Filter_3909 | I | [
"edit_row",
"update_display"
] | 2 | [
[
"edit_row",
"update_display"
]
] | 1 | [] | false | [] | false | pytest | false | [
"IPython",
"ipywidgets",
"pandas"
] | false | 50b0dd6bf2589139f579f2cdd1f0c7cd6c67677f | 966b1fc50ba8b9c3791a00cb791720078b3426da | |||
v1.0 | instruct | Filter | Filter_3914_I | You have the following Python script that prints the first 10 multiples of a given number:
```
def first_n_multiples(n, num):
multiples = []
for i in range(1, n+1):
multiples.append(num * i)
return multiples
number = int(input("Enter a number: "))
multiples = first_n_multiples(10, number)
for i in ... | def first_n_multiples(n, num):
"""
Returns a list of the first n multiples of num.
"""
multiples = []
for i in range(1, n + 1):
multiples.append(num * i)
return multiples
def first_n_multiples_of_first_m_numbers(n, m):
"""
Returns a list of lists, where each inner list contains ... | from solution import first_n_multiples, first_n_multiples_of_first_m_numbers
def test_first_n_multiples():
assert first_n_multiples(10, 3) == [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]
assert first_n_multiples(5, 2) == [2, 4, 6, 8, 10]
assert first_n_multiples(3, 5) == [5, 10, 15]
def test_first_n_multiples_of... | [
{
"docstring": "Returns a list of the first n multiples of num.",
"function_declaration": "def first_n_multiples(n, num):",
"function_name": "first_n_multiples",
"parameter_list": "(n, num)"
},
{
"docstring": "Returns a list of lists, where each inner list contains the first n multiples\nof ... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def first_n_multiples(n, num):\n \"\"\"\n Returns a list of the first n multiples of num.\n \"\"\"\n multiples = []\n for i in range(1, n+1):\n multiples.append(num * i)\... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003914",
"row_id": 3914,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12068']"
} | 0.496684 | Filter_3914 | I | [
"first_n_multiples",
"first_n_multiples_of_first_m_numbers"
] | 2 | [
[
"first_n_multiples_of_first_m_numbers",
"first_n_multiples"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 402599558e6cc6dea716269f90659e66856e4d0a | c5dec5a171fd96efb671a4c828ece7e20fd1763f | |||
v1.0 | instruct | Filter | Filter_3942_I | On a standard GPS system, you can manually enter coordinates to a high degree of accuracy for navigation. Assume that the coordinates for the White House, for example, is 38.8977° N latitude and 77.0365° W longitude. Write a program that will take an input file or a manual entry of a set of coordinates, convert them to... | def dms_to_decimal(degrees, minutes, seconds, direction):
"""
Converts coordinates from DMS (Degrees, Minutes, Seconds) to decimal format.
:param degrees: The degrees component of the coordinate.
:param minutes: The minutes component of the coordinate.
:param seconds: The seconds component of t... | from solution import dms_to_decimal, coordinates_to_decimal, convert_coordinates_to_decimal_and_output
def test_dms_to_decimal_north():
assert dms_to_decimal(38, 53, 51.72, 'N') == 38.8977
def test_dms_to_decimal_west():
assert dms_to_decimal(77, 2, 11.4, 'W') == -77.0365
def test_coordinates_to_decimal():
... | [
{
"docstring": "Converts coordinates from DMS (Degrees, Minutes, Seconds) to decimal format.\n\n:param degrees: The degrees component of the coordinate.\n:param minutes: The minutes component of the coordinate.\n:param seconds: The seconds component of the coordinate.\n:param direction: The direction (N, S, E, ... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def convert_to_decimal(degrees, minutes, seconds, direction):\n \"\"\"\n Converts coordinates from degrees, minutes, and seconds to decimal form.\n \n Args:\n - degrees (int): T... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003942",
"row_id": 3942,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12154']"
} | 0.450425 | Filter_3942 | I | [
"dms_to_decimal",
"coordinates_to_decimal",
"convert_coordinates_to_decimal_and_output"
] | 3 | [
[
"convert_coordinates_to_decimal_and_output",
"coordinates_to_decimal"
],
[
"coordinates_to_decimal",
"dms_to_decimal"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | c4db103f02f027ea7782f1fd36eb4373a0a082c6 | 57174560bb5a3f7d287308ac7e1213c82196d47a | |||
v1.0 | instruct | Filter | Filter_3954_I | Given a binary matrix (i.e., a matrix with only zeros and ones), write a function to determine the number of 'islands'. Here, an island is a group of connected non-zero values.
Example:
[[1, 1, 1, 1, 0],
[1, 1, 0, 1, 0],
[1, 1, 0, 0, 0],
[0, 0, 0, 0, 0]]
This matrix would have 1 island because all the connected r... | def numIslands(grid):
"""
Function to count the number of islands in a given binary matrix.
An island is a group of connected 1s (connected horizontally or vertically).
:param grid: List[List[int]], a binary matrix
:return: int, the number of islands
"""
if not grid:
return 0
... | from solution import numIslands
def test_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_multiple_islands():
grid = [
[1, 1, 0, 0, 0],
[1, 1, 0, 0, 0],
[0, 0, 1,... | [
{
"docstring": "Function to count the number of islands in a given binary matrix.\nAn island is a group of connected 1s (connected horizontally or vertically).\n\n:param grid: List[List[int]], a binary matrix\n:return: int, the number of islands",
"function_declaration": "def numIslands(grid):",
"functi... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def numIslands(grid):\n \"\"\"\n Returns the number of islands in a given binary matrix.\n \"\"\"\n if not grid:\n return 0\n\n count = 0\n for i in range(len(grid)):\... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00003954",
"row_id": 3954,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12187']"
} | 0.583289 | Filter_3954 | I | [
"numIslands",
"dfs"
] | 2 | [
[
"numIslands",
"dfs"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 4b942798ba7c17d78743398e597393f03cdbaeb8 | 142759eaad85a2b11d50b0bec2408f0ea5a1de4f | |||
v1.0 | instruct | Filter | Filter_3961_I | A student has created a function to generate a random number between 1 and 100. This function is supposed to be called within another function that generates a set of 50 unique random numbers within the same range and returns the set. Here's the student's code:
```python
import random
def generate_random_number():
... | import random
def generate_random_number():
"""
Generates a random number between 1 and 100.
"""
return random.randint(1, 100)
def generate_random_set():
"""
Generates a set of 50 unique random numbers between 1 and 100.
Returns:
Set[int]: A set containing 50 unique random numbers.... | from solution import generate_random_set
def test_generate_random_set_length():
result_set = generate_random_set()
assert len(result_set) == 50
def test_generate_random_set_range():
result_set = generate_random_set()
assert all(1 <= num <= 100 for num in result_set)
def test_generate_random_set_uniqu... | [
{
"docstring": "Generates a random number between 1 and 100.",
"function_declaration": "def generate_random_number():",
"function_name": "generate_random_number",
"parameter_list": "()"
},
{
"docstring": "Generates a set of 50 unique random numbers between 1 and 100.\nReturns:\n Set[int]:... | [
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():\n return random.randint(1, 100)\n\ndef generate_random_set():\n random_set = set()\n while len(random_set) < 50:\n random_set.add... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003961",
"row_id": 3961,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12199']"
} | 0.570332 | Filter_3961 | I | [
"generate_random_number",
"generate_random_set"
] | 2 | [
[
"generate_random_set",
"generate_random_number"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | b2bc8dda29d2ef8234344f4621b720d34fe93a85 | 7318efdcbb2f29a86d509871c9891f6c3d37a5b8 | |||
v1.0 | instruct | Filter | Filter_3983_I | I would like to generate random numbers within a specified age range and gender. For example, include the gender (Male/Female). I would like to generate the random values.
Can you write a simple Python script that does this? | import random
def generate_random_age(min_age, max_age):
"""
Generates a random age between min_age and max_age inclusive.
"""
return random.randint(min_age, max_age)
def generate_random_gender():
"""
Randomly returns either 'Male' or 'Female'.
"""
return random.choice(['Male', 'Female... | from solution import generate_random_age, generate_random_gender, generate_random_person
def test_generate_random_age():
min_age = 20
max_age = 30
for _ in range(100):
age = generate_random_age(min_age, max_age)
assert min_age <= age <= max_age
def test_generate_random_gender():
gender... | [
{
"docstring": "Generates a random age between min_age and max_age inclusive.",
"function_declaration": "def generate_random_age(min_age, max_age):",
"function_name": "generate_random_age",
"parameter_list": "(min_age, max_age)"
},
{
"docstring": "Randomly returns either 'Male' or 'Female'."... | [
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_person(min_age, max_age):\n \"\"\"\n Generates a dictionary with random age between min_age and max_age, and random gender.\n \n Parameters:\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003983",
"row_id": 3983,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12281']"
} | 0.534545 | Filter_3983 | I | [
"generate_random_age",
"generate_random_gender",
"generate_random_person"
] | 3 | [
[
"generate_random_person",
"generate_random_age"
],
[
"generate_random_person",
"generate_random_gender"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 7cd340d74f11de8c800f1e11664215082dc7c7d5 | f6598e610e2b88184a1f7f696ba93c082be983d5 | |||
v1.0 | instruct | Filter | Filter_3989_I | In the extension of the well-known in combinatorial graph theory of the “Eight Queens Puzzle” of placing 8 non-attacking queens on an 8x8 chessboard, you can imagine a matrix of (x) rows and (y) columns, where you place (n> 0) of queens on such grid. Write a Python program that can generate the queen positions for the ... | def is_safe(board, row, col):
"""
Check if a queen can be safely placed at board[row][col].
"""
for i in range(col):
if board[row][i] == 1:
return False
for i, j in zip(range(row, -1, -1), range(col, -1, -1)):
if board[i][j] == 1:
return False
for i, j i... | from solution import solve_n_queens
def test_solve_n_queens_8x8_8():
result = solve_n_queens(8, 8, 8)
assert result != "No solution exists"
assert all(sum(row) <= 1 for row in result)
assert all(sum(col) <= 1 for col in zip(*result))
def test_solve_n_queens_4x4_4():
result = solve_n_queens(4, 4, 4... | [
{
"docstring": "Check if a queen can be safely placed at board[row][col].",
"function_declaration": "def is_safe(board, row, col):",
"function_name": "is_safe",
"parameter_list": "(board, row, col)"
},
{
"docstring": "Utilizes backtracking to solve the N-queens problem.",
"function_decla... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def solve_n_queens(x, y, n):\n \"\"\"\n Solves the generalized N-Queens problem for a grid of size x rows and y columns and places n queens.\n Returns a list of tuples representing th... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00003989",
"row_id": 3989,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12303']"
} | 0.506431 | Filter_3989 | I | [
"is_safe",
"solve_n_queens_util",
"solve_n_queens"
] | 3 | [
[
"solve_n_queens",
"solve_n_queens_util"
],
[
"solve_n_queens_util",
"is_safe"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 4a5cde7d560df209554fc868f82a8ae1bb0c0481 | ffb4548a3b9cabee94d7178b40d861634c20f6c1 | |||
v1.0 | instruct | Filter | Filter_4019_I | K-means Clustering Analysis
# Problem
K-means is a type of unsupervised machine learning algorithm that is used to identify clusters or patterns in an unlabeled dataset. In the given problem, we are asked to implement a k-means clustering algorithm.
# Approach
Our approach to solving this problem will be to follow th... | import numpy as np
def initialize_centroids(data, k):
"""Initialize k centroids randomly."""
indices = np.random.choice(data.shape[0], k, replace=False)
centroids = data[indices, :]
return centroids
def assign_to_clusters(data, centroids):
"""Assign each data point to the closest centroid."""
... | import numpy as np
from solution import kmeans, assign_to_clusters
def test_initialize_centroids():
data = np.array([[1, 2], [1, 4], [1, 0], [4, 2], [4, 4], [4, 0]])
k = 2
centroids = initialize_centroids(data, k)
assert centroids.shape == (k, data.shape[1])
def test_assign_to_clusters():
data = n... | [
{
"docstring": "Initialize k centroids randomly.",
"function_declaration": "def initialize_centroids(data, k):",
"function_name": "initialize_centroids",
"parameter_list": "(data, k)"
},
{
"docstring": "Assign each data point to the closest centroid.",
"function_declaration": "def assign... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import numpy as np\n\ndef initialize_centroids(data, k):\n \"\"\"Initialize k centroids randomly.\"\"\"\n indices = np.random.choice(data.shape[0], k, replace=False)\n centroids = dat... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004019",
"row_id": 4019,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12379']"
} | 0.800037 | Filter_4019 | I | [
"initialize_centroids",
"assign_to_clusters",
"update_centroids",
"calculate_wcss",
"kmeans_single_run",
"kmeans"
] | 6 | [
[
"kmeans",
"kmeans_single_run"
],
[
"kmeans_single_run",
"assign_to_clusters"
],
[
"kmeans_single_run",
"calculate_wcss"
],
[
"kmeans_single_run",
"initialize_centroids"
],
[
"kmeans_single_run",
"update_centroids"
]
] | 5 | [] | false | [] | false | pytest | true | [
"numpy"
] | false | e56ad320e292ce1272d7913e975fd2f82f7495cd | 6446362219bf9c76fdee30dc69328f824988bc22 | |||
v1.0 | instruct | Filter | Filter_4021_I | I'm working on a project where I need to take an HTML file and automatically generate image URLs, so I can feed them into a catch-all settings file that will be used by an image optimization tool to automatically optimize the images.
Is there a method to automatically get all images from an HTML page without having to... | from bs4 import BeautifulSoup
import requests
def extract_image_urls(html_content):
"""
Extracts all image URLs from the given HTML content.
Parameters:
- html_content (str): The HTML content as a string.
Returns:
- list: A list of image URLs.
"""
soup = BeautifulSoup(html_con... | from solution import extract_image_urls, extract_image_urls_from_url
import requests
from unittest.mock import patch
def test_extract_image_urls():
html_content = '''
<html>
<body>
<img src="http://example.com/image1.jpg" />
<img src="http://example.com/image2.png" />
... | [
{
"docstring": "Extracts all image URLs from the given HTML content.\n\nParameters:\n- html_content (str): The HTML content as a string.\n\nReturns:\n- list: A list of image URLs.",
"function_declaration": "def extract_image_urls(html_content):",
"function_name": "extract_image_urls",
"parameter_lis... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import requests\nfrom bs4 import BeautifulSoup\n\ndef get_image_urls_from_html(url):\n \"\"\"\n Given a URL of an HTML page, this function fetches the page content and extracts all image... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004021",
"row_id": 4021,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12384']"
} | 0.409939 | Filter_4021 | I | [
"extract_image_urls",
"extract_image_urls_from_url"
] | 2 | [
[
"extract_image_urls_from_url",
"extract_image_urls"
]
] | 1 | [] | false | [] | false | pytest | true | [
"bs4",
"requests"
] | false | aa3a028a84db6218b754cd0fac2d2024d9ba8867 | 44d9541049266b824e46f42b21342fd1e20fc4e8 | |||
v1.0 | instruct | Filter | Filter_4037_I | You are tasked with writing a Python program that addresses the following scenario. A certain business wants their customers to be able to purchase items from their storefront at a discounted price, depending on the quantity of items purchased. The discount structure is as follows:
- When a customer purchases 1-9 items... | def get_discount_amount(discount_rate, price):
"""
Calculates the discounted price.
:param discount_rate: A float representing the discount rate (e.g., 0.1 for 10%)
:param price: A float representing the original price of an item
:return: A float representing the discounted price
"""
re... | from solution import calculate_total_price
def test_no_discount():
assert calculate_total_price(5, 100) == 500
assert calculate_total_price(1, 100) == 100
assert calculate_total_price(9, 50) == 450
def test_ten_percent_discount():
assert calculate_total_price(10, 100) == 900
assert calculate_total... | [
{
"docstring": "Calculates the discounted price.\n\n:param discount_rate: A float representing the discount rate (e.g., 0.1 for 10%)\n:param price: A float representing the original price of an item\n:return: A float representing the discounted price",
"function_declaration": "def get_discount_amount(discou... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def get_discount_amount(discount_rate, price):\n \"\"\"\n Calculate the total discounted price given a discount rate and original price.\n \n :param discount_rate: The discount rat... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004037",
"row_id": 4037,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12429']"
} | 0.589121 | Filter_4037 | I | [
"get_discount_amount",
"calculate_total_price"
] | 2 | [
[
"calculate_total_price",
"get_discount_amount"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 2e708bb1aa6d4dd41143bad93b7a52247852305a | 8d67c50b632a020753d91bab61a54373b31e8847 | |||
v1.0 | instruct | Filter | Filter_4055_I | Your task is to build an API that generates "Sales" data. The data should include an ID, a date, an employee's name, a customer's name, and a sales amount. Each sales record should have a unique ID, and the DATE should be randomly generated within a specified time range. The same applies to the employee and customer na... | import random
import datetime
def generate_random_date(start_date, end_date):
"""
Generate a random date between start_date and end_date.
"""
time_between_dates = end_date - start_date
days_between_dates = time_between_dates.days
random_number_of_days = random.randrange(days_between_dates)
... | from solution import generate_random_date, generate_sales_data
import datetime
def test_generate_random_date():
start_date = datetime.date(2022, 1, 1)
end_date = datetime.date(2022, 12, 31)
random_date = generate_random_date(start_date, end_date)
assert start_date <= random_date <= end_date
def t... | [
{
"docstring": "Generate a random date between start_date and end_date.",
"function_declaration": "def generate_random_date(start_date, end_date):",
"function_name": "generate_random_date",
"parameter_list": "(start_date, end_date)"
},
{
"docstring": "Generate random sales data.",
"funct... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\nimport string\nfrom datetime import datetime, timedelta\n\ndef generate_random_date(start_date, end_date):\n \"\"\" Generate a random date between start_date and end_date. \"... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004055",
"row_id": 4055,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12488']"
} | 0.486084 | Filter_4055 | I | [
"generate_random_date",
"generate_sales_data"
] | 2 | [
[
"generate_sales_data",
"generate_random_date"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 8eebaf489554120f6e32afec106576e120bc9d79 | 197229823593b28fdfe680663ab986d2b4612cf6 | |||
v1.0 | instruct | Filter | Filter_4072_I | Here is the reference solution for backtracking solution:
```python
def exist(board, word):
if not board:
return False
for i in range(len(board)):
for j in range(len(board[0])):
if dfs(board, i, j, word):
return True
return False
def dfs(board, i, j, word):
i... | def exist(board, word):
if not board:
return False
for i in range(len(board)):
for j in range(len(board[0])):
if dfs(board, i, j, word):
return True
return False
def dfs(board, i, j, word):
if len(word) == 0:
return True
if i<0 or i>=len(board) o... | from solution import exist
def test_exist_found():
board = [
['A','B','C','E'],
['S','F','C','S'],
['A','D','E','E']
]
word = "ABCCED"
assert exist(board, word) == True
def test_exist_not_found():
board = [
['A','B','C','E'],
['S','F','C','S'],
['A',... | [
{
"docstring": null,
"function_declaration": "def exist(board, word):",
"function_name": "exist",
"parameter_list": "(board, word)"
},
{
"docstring": null,
"function_declaration": "def dfs(board, i, j, word):",
"function_name": "dfs",
"parameter_list": "(board, i, j, word)"
}
] | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def exist(board, word):\n if not board:\n return False\n for i in range(len(board)):\n for j in range(len(board[0])):\n if dfs(board, i, j, word):\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004072",
"row_id": 4072,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12526']"
} | 0.611288 | Filter_4072 | I | [
"exist",
"dfs"
] | 2 | [
[
"exist",
"dfs"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | cf21c2d980c7cd283194e592792706310612bc83 | 1418375bd561fb3b074efd769a6937ba0c34c4a2 | |||
v1.0 | instruct | Filter | Filter_4086_I | This is a kicker algorithm for codons. It needs to be python 2.7 and takes a list of integers. The idea is that for every codon, you move a certain number of "tiles" based on one of the codon sequences. The order of the codon sequences matters as the first sequence moves you a smaller distance. The movement distanc... | sequence_mapping = {'ATA': 1, 'ATC': 1, 'ATT': 1, 'ATG': 1,'ACA': 1, 'ACC': 1, 'ACG': 1,
'ACT': 1, 'AAC': 1, 'AAT': 1, 'AAG': 1, 'AAA': 1, 'AGC': 1, 'AGT': 1,
'AGG': 1, 'AGA': 1, 'CTA': 3, 'CTC': 3, 'CTG': 3, 'CTT': 3, 'CCA': 3,
'CCC': 3, 'CCG': 3, 'CCT': 3, '... | from solution import move_tile, multiple_codons
def test_move_tile():
assert move_tile('ATA') == 1
assert move_tile('CTC') == 3
assert move_tile('GTA') == 9
assert move_tile('ZZZ') == 0 # invalid codon
def test_multiple_codons():
assert multiple_codons(['ATA', 'CTA', 'GTA']) == 13
assert mult... | [
{
"docstring": "Moves the tile based on the codon sequence",
"function_declaration": "def move_tile(codon):",
"function_name": "move_tile",
"parameter_list": "(codon)"
},
{
"docstring": "Moves the tiles based on the list of codon sequences",
"function_declaration": "def multiple_codons(c... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "sequence_mapping = {'ATA': 1, 'ATC': 1, 'ATT': 1, 'ATG': 1,'ACA': 1, 'ACC': 1, 'ACG': 1,\n 'ACT': 1, 'AAC': 1, 'AAT': 1, 'AAG': 1, 'AAA': 1, 'AGC': 1, 'AGT': 1,\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004086",
"row_id": 4086,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12552']"
} | 0.516736 | Filter_4086 | I | [
"move_tile",
"multiple_codons"
] | 2 | [
[
"multiple_codons",
"move_tile"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 45c2b31c2df4e88bc76e7ae59334a46e5ffa236e | d63821574302a52a12c01fd6bc4a7662f9bc0ad2 | |||
v1.0 | instruct | Filter | Filter_4094_I | ### Graph-Based Image Segmentation
This Python function implements the graph-based image segmentation algorithm, which segments an image into Foreground (FG) and Background (BG) based on the edges between neighboring pixel vertices in a graph.
```python
import numpy as np
def graph_based_segmentation(image):
"""... | import numpy as np
def perform_graph_cut(graph_vertices, graph_edges):
"""
Mock implementation of the perform_graph_cut function.
This function will simulate a graph cut operation by returning a random min cut.
Args:
graph_vertices (ndarray): The array of graph vertices.
graph_edges (ndarr... | import numpy as np
from solution import graph_based_segmentation, perform_graph_cut
def test_graph_based_segmentation_shape():
image = np.array([[100, 150, 200], [120, 180, 210], [100, 150, 200]])
foreground, background, min_cut = graph_based_segmentation(image)
assert foreground.shape == image.shape
a... | [
{
"docstring": "Mock implementation of the perform_graph_cut function.\nThis function will simulate a graph cut operation by returning a random min cut.\n\nArgs:\ngraph_vertices (ndarray): The array of graph vertices.\ngraph_edges (ndarray): The array of graph edges.\n\nReturns:\ntuple: \n - min_cut (ndarray... | [
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\n\ndef graph_based_segmentation(image):\n \"\"\"\n This function performs graph-based image segmentation.\n\n Args:\n image (ndarray): The input image.\n\n Re... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004094",
"row_id": 4094,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12565']"
} | 0.604077 | Filter_4094 | I | [
"perform_graph_cut",
"graph_based_segmentation"
] | 2 | [
[
"graph_based_segmentation",
"perform_graph_cut"
]
] | 1 | [] | false | [] | false | pytest | true | [
"numpy"
] | false | 504d48a71054e242beb2abdbddaeafd80ad801c0 | c74dc4345be92a6a99c3795e25df796c65e47366 | |||
v1.0 | instruct | Filter | Filter_4121_I | This is a homework question from Intro to algorithms.
The problem is asking me to implement a sorted list with the specified run time for each operation.
From the list of words inserted, determine if it is a palindrome.
Here is the implementation of the sorted list with hash set:
```python
class SortedList:
def... | def is_palindrome(word):
"""
Returns True if the word is a palindrome, else False.
"""
return word == word[::-1]
def palindromes_in_list(words):
"""
Returns a list of words that are palindromes.
"""
return [word for word in words if is_palindrome(word)] | from solution import is_palindrome, palindromes_in_list
def test_is_palindrome():
assert is_palindrome('madam') == True
assert is_palindrome('dad') == True
assert is_palindrome('aabcd') == False
assert is_palindrome('apple') == False
assert is_palindrome('racecar') == True
assert is_palindrome(... | [
{
"docstring": "Returns True if the word is a palindrome, else False.",
"function_declaration": "def is_palindrome(word):",
"function_name": "is_palindrome",
"parameter_list": "(word)"
},
{
"docstring": "Returns a list of words that are palindromes.",
"function_declaration": "def palindr... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_palindrome(word):\n \"\"\"\n Returns True if the word is a palindrome, else False.\n \"\"\"\n return word == word[::-1]\n\ndef palindromes_in_list(words):\n \"\"\"\n R... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00004121",
"row_id": 4121,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12645']"
} | 0.580992 | Filter_4121 | I | [
"is_palindrome",
"palindromes_in_list"
] | 2 | [
[
"palindromes_in_list",
"is_palindrome"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 32c7cd8cf7895c2c821254ef5653b4a7f646e60a | d8a7510d4581f76add7821ce797a6cbe8d62a5d5 | |||
v1.0 | instruct | Filter | Filter_4127_I | In the United Kingdom, when police stop a driver, the minimum penalty points that they can assign is a fixed number based on the vehicle's category. The assigned penalty points
are doubled during certain times of the year or on particular roads and also if the driver is a repeat offender. We want to calculate the penal... | # Dictionary holding the base penalty points for each vehicle category
vehicle_penalty_points = {
'A': 3,
'B': 2,
'C': 5,
'D': 6
}
def calculate_base_penalty(vehicle_category):
"""
Returns the base penalty points for the given vehicle category.
"""
return vehicle_penalty_points.get(vehi... | from solution import calculate_base_penalty, calculate_doubled_penalty
def test_calculate_base_penalty():
assert calculate_base_penalty('A') == 3
assert calculate_base_penalty('B') == 2
assert calculate_base_penalty('C') == 5
assert calculate_base_penalty('D') == 6
assert calculate_base_penalty('E'... | [
{
"docstring": "Returns the base penalty points for the given vehicle category.",
"function_declaration": "def calculate_base_penalty(vehicle_category):",
"function_name": "calculate_base_penalty",
"parameter_list": "(vehicle_category)"
},
{
"docstring": "Returns the penalty points for the g... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "vehicle_penalty_points = {\n 'A': 3,\n 'B': 2,\n 'C': 5,\n 'D': 6\n}\n\ndef calculate_base_penalty(vehicle_category):\n return vehicle_penalty_points.get(vehicle_category, 0)\n\... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004127",
"row_id": 4127,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12656']"
} | 0.592432 | Filter_4127 | I | [
"calculate_base_penalty",
"calculate_doubled_penalty"
] | 2 | [
[
"calculate_doubled_penalty",
"calculate_base_penalty"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 29f44ed02d7e6abac0dbe76077887faca2022889 | b619d740107b40e544d6d0a03b91da4f7f2c670a | |||
v1.0 | instruct | Filter | Filter_4159_I | A set of integers is presented to you with the guarantee that they have at least one common divisor (other than 1). Given that the numbers are not necessarily sorted and may contain duplicates, write a code snippet to find the least common multiple (LCM) of the set of integers. After finding the LCM, code a small drive... | from math import gcd
from functools import reduce
def lcm(a, b):
"""
Returns the least common multiple (LCM) of two integers a and b.
"""
return abs(a * b) // gcd(a, b)
def find_lcm(numbers):
"""
Returns the least common multiple (LCM) of a list of integers.
"""
return reduce(lcm, numb... | from solution import lcm, find_lcm
def test_lcm_two_numbers():
assert lcm(4, 5) == 20
assert lcm(6, 8) == 24
assert lcm(7, 14) == 14
def test_find_lcm_multiple_numbers():
assert find_lcm([4, 5, 6]) == 60
assert find_lcm([6, 8, 3]) == 24
assert find_lcm([7, 14, 21]) == 42
assert find_lcm([9... | [
{
"docstring": "Returns the least common multiple (LCM) of two integers a and b.",
"function_declaration": "def lcm(a, b):",
"function_name": "lcm",
"parameter_list": "(a, b)"
},
{
"docstring": "Returns the least common multiple (LCM) of a list of integers.",
"function_declaration": "def... | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import math\nfrom functools import reduce\n\ndef gcd(a, b):\n \"\"\"\n Compute the greatest common divisor of a and b.\n \"\"\"\n while b:\n a, b = b, a % b\n return a\n\... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004159",
"row_id": 4159,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12727']"
} | 0.581916 | Filter_4159 | I | [
"lcm",
"find_lcm"
] | 2 | [
[
"find_lcm",
"lcm"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 6d83ec1f2d333ac81324ea662586fbcdb04312a6 | e93278564af157e4ba6d2404a76e58b5a761dbb7 | |||
v1.0 | instruct | Filter | Filter_4160_I | I'd to make (space to dot) adjustments to multiple .txt files within a specific path. The problem being I need to 'cycle through' every line within each text file while ensuring that the .txt files in question are addressed correctly.
My requirement is: IF a line of text within a .txt file contains a specific "code", ... | import os
namespace_map = {
'catalog': 'catalog.dot',
'product': 'product.dot',
'cateyor': 'cateyor.dot',
'television': 'television.dot',
'id': 'id.dot',
'purchase-connection': 'purchase getConnection.id'
}
def replace_keywords(line, namespace_map):
for key, value in namespace_map.items():... | import os
import pytest
from solution import replace_keywords, process_files
namespace_map = {
'catalog': 'catalog.dot',
'product': 'product.dot',
'cateyor': 'cateyor.dot',
'television': 'television.dot',
'id': 'id.dot',
'purchase-connection': 'purchase getConnection.id'
}
def test_replace_key... | [
{
"docstring": null,
"function_declaration": "def replace_keywords(line, namespace_map):",
"function_name": "replace_keywords",
"parameter_list": "(line, namespace_map)"
},
{
"docstring": null,
"function_declaration": "def process_files(input_path, output_path, namespace_map):",
"fun... | [
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 space_to_dot(filepath, output_dir, ns_dict):\n with open(filepath, 'r') as file:\n lines = file.readlines()\n\n modified_lines = []\n for line in lines:\n ... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00004160",
"row_id": 4160,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12728']"
} | 0.490432 | Filter_4160 | I | [
"replace_keywords",
"process_files"
] | 2 | [
[
"process_files",
"replace_keywords"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 180b51ec5cd7bb01c87f90f1b07b12927a2ec9d4 | a5130a1ee4b8d1eaa8fe77e26110c4b8168f73df | |||
v1.0 | instruct | Filter | Filter_4237_I | Rock, paper, scissors is a hand game where:
- Rock breaks scissors, as rock can crush scissors.
- Paper covers rock, as paper can cover rock.
- Scissors cut paper.
Write a program that plays a game of rock, paper, scissors with a user.
The program:
- To do so, it should present a list of options with a number asocia... | import random
def get_computer_choice():
return random.choice(['Rock', 'Paper', 'Scissors'])
def get_result(user_choice, computer_choice):
outcomes = {
('Rock', 'Scissors'): 'Rock breaks Scissors. User wins!',
('Scissors', 'Paper'): 'Scissors cut Paper. User wins!',
('Paper', 'Rock'): ... | import pytest
from solution import get_computer_choice, get_result, play_game
def test_get_computer_choice():
choices = ['Rock', 'Paper', 'Scissors']
for _ in range(100): # Test multiple times to ensure randomness includes all options
assert get_computer_choice() in choices
def test_get_result_user_w... | [
{
"docstring": null,
"function_declaration": "def get_computer_choice():",
"function_name": "get_computer_choice",
"parameter_list": "()"
},
{
"docstring": null,
"function_declaration": "def get_result(user_choice, computer_choice):",
"function_name": "get_result",
"parameter_lis... | [
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 play_round(user_choice):\n choices = ['Rock', 'Paper', 'Scissors']\n computer_choice = random.choice(choices)\n result = ''\n \n if user_choice == computer_... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00004237",
"row_id": 4237,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12968']"
} | 0.580691 | Filter_4237 | I | [
"get_computer_choice",
"get_result",
"play_game"
] | 3 | [
[
"play_game",
"get_computer_choice"
],
[
"play_game",
"get_result"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 6d6fc7a9c926c9019eb54b1c07705f471f1f808d | 55a2f4da172b86fdcbb312c04eeae90a54350277 | |||
v1.0 | instruct | Filter | Filter_4250_I | This problem is definitely related to recursion. I have an array of elements where every element is an array of integers from 0-4, and I want to convert those integers into the letters A-B. I know how to do this part. However, when I have a two dimensional array that has nested arrays in it, I become lost. Here's an ex... | def numToLetters(n):
numbers = [0, 1, 2, 3, 4]
letters = ['A', 'B', 'C', 'D', 'E']
return letters[n]
def convertNestedArray(arr):
"""
Converts a nested array of integers (0-4) to letters (A-E) using recursion.
"""
if isinstance(arr, int):
return numToLetters(arr)
return [convert... | from solution import numToLetters, convertNestedArray
def test_numToLetters():
assert numToLetters(0) == 'A'
assert numToLetters(1) == 'B'
assert numToLetters(2) == 'C'
assert numToLetters(3) == 'D'
assert numToLetters(4) == 'E'
def test_convertNestedArray_single_layer():
assert convertNestedA... | [
{
"docstring": null,
"function_declaration": "def numToLetters(n):",
"function_name": "numToLetters",
"parameter_list": "(n)"
},
{
"docstring": "Converts a nested array of integers (0-4) to letters (A-E) using recursion.",
"function_declaration": "def convertNestedArray(arr):",
"func... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def num_to_letters(n):\n \"\"\"\n Converts a number between 0 and 4 to its corresponding letter A-E.\n \"\"\"\n return chr(n + ord('A'))\n\ndef convert_nested_array(arr):\n \"\"... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004250",
"row_id": 4250,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_12994']"
} | 0.481341 | Filter_4250 | I | [
"numToLetters",
"convertNestedArray"
] | 2 | [
[
"convertNestedArray",
"numToLetters"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 110a134300c5bd9e25a5f18936abd1bfb1e8f1a2 | 300046afa0c844297b2dbf23b3c68016471e2e00 | |||
v1.0 | instruct | Filter | Filter_4295_I | In Python, how can I change all the signum functions to be non zero with a dictionary or mapping layer? | def signum(x):
"""
Returns the signum of x, where:
-1 if x < 0
1 if x > 0
0 if x = 0
"""
if x < 0:
return -1
elif x > 0:
return 1
else:
return 0
def mapped_signum(x):
"""
Returns a mapped signum of x ensuring non-zero output:
-1 if x < 0
1 ... | from solution import signum, mapped_signum
def test_signum_negative():
assert signum(-5) == -1
def test_signum_zero():
assert signum(0) == 0
def test_signum_positive():
assert signum(5) == 1
def test_mapped_signum_negative():
assert mapped_signum(-5) == -1
assert mapped_signum(-100) == -1
d... | [
{
"docstring": "Returns the signum of x, where:\n-1 if x < 0\n 1 if x > 0\n 0 if x = 0",
"function_declaration": "def signum(x):",
"function_name": "signum",
"parameter_list": "(x)"
},
{
"docstring": "Returns a mapped signum of x ensuring non-zero output:\n-1 if x < 0\n 1 if x >= 0",
"fu... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def custom_signum(x):\n \"\"\"\n Custom signum function that maps 0 to 1 to ensure non-zero output.\n \"\"\"\n if x > 0:\n return 1\n elif x < 0:\n return -1\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004295",
"row_id": 4295,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13107']"
} | 0.465288 | Filter_4295 | I | [
"signum",
"mapped_signum"
] | 2 | [
[
"mapped_signum",
"signum"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 4d882722d6f7cf9e3fcea0cc9ee28715275df38a | 5cab79b0752d8edd27e543f66b31eead8715c71a | |||
v1.0 | instruct | Filter | Filter_4296_I | I'm studying machine learning and deep learning, and one of the recommended texts for me is: "Deep Learning" by Ian Goodfellow, Yoshua Bengio, and Aaron Courville. This book is often recommended even by top researchers.
Can you provide usage examples and code snippets in Python that illustrate the most important conc... | import numpy as np
# Example 1: Implementing a simple Neural Network with one hidden layer in NumPy
def sigmoid(x):
return 1 / (1 + np.exp(-x))
def sigmoid_derivative(x):
return x * (1 - x)
# Train a simple Neural Network
def train(X, y, epochs=10000, learning_rate=0.1):
np.random.seed(1)
input_laye... | from solution import train, predict
import numpy as np
def test_neural_network_training():
X = np.array([[0,0],[0,1],[1,0],[1,1]])
y = np.array([[0],[1],[1],[0]])
wh, bh, wout, bout = train(X, y, epochs=10000, learning_rate=0.1)
# Predict on training examples
predictions = predict(X, wh, ... | [
{
"docstring": null,
"function_declaration": "def sigmoid(x):",
"function_name": "sigmoid",
"parameter_list": "(x)"
},
{
"docstring": null,
"function_declaration": "def sigmoid_derivative(x):",
"function_name": "sigmoid_derivative",
"parameter_list": "(x)"
},
{
"docstring... | [
0,
1,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import numpy as np\nimport tensorflow as tf\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Dense\n\n# Example 1: Basic linear regression with NumPy\ndef l... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00004296",
"row_id": 4296,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13108']"
} | 0.304868 | Filter_4296 | I | [
"sigmoid",
"sigmoid_derivative",
"train",
"predict"
] | 4 | [
[
"predict",
"sigmoid"
],
[
"train",
"sigmoid"
],
[
"train",
"sigmoid_derivative"
]
] | 3 | [] | false | [] | false | pytest | true | [
"numpy"
] | false | 75604017e393a54825151b02ade9f4224e09c580 | 26b18bc5ff6a357a2d27ab7e7d06e3e55bdbdc06 | |||
v1.0 | instruct | Filter | Filter_4298_I | Computer Engineer Scott is working on a CPU project and received a sequence of hexadecimal characters:
'abcdefabc'
Now Rahmen wants to write a separate function that can compare this string with any other arbitrary string ideally of same length to check if they match character by character.
Here's an example of what... | def compare_strings(str1, str2, match=True):
"""
Compare two strings character by character.
Args:
str1 (str): The first string.
str2 (str): The second string.
match (bool): If True, check if all characters match.
If False, check if all characters mismatch.
Returns:
b... | from solution import compare_strings, mismatches_strings
def test_compare_strings_all_match():
assert compare_strings('abcdefabc', 'abcdefabc', match=True) == True
def test_compare_strings_partial_match():
assert compare_strings('abcdefabc', 'abcxefabc', match=True) == False
def test_compare_strings_no_match... | [
{
"docstring": "Compare two strings character by character.\nArgs:\nstr1 (str): The first string.\nstr2 (str): The second string.\nmatch (bool): If True, check if all characters match. \n If False, check if all characters mismatch.\n\nReturns:\nbool: True if strings match or mismatch as specified, ... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def compare_strings(str1, str2, match=True):\n \"\"\"Compare two strings character by character for matches or mismatches.\"\"\"\n if len(str1) != len(str2):\n raise ValueError(\"... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00004298",
"row_id": 4298,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13113']"
} | 0.70166 | Filter_4298 | I | [
"compare_strings",
"mismatches_strings"
] | 2 | [
[
"mismatches_strings",
"compare_strings"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | d40e5e4a255600210138c432c788d46237467496 | 2c6bffc28f3d20b7c285afd70366973d28290053 | |||
v1.0 | instruct | Filter | Filter_4302_I | You've been to proverbial "dark side" during your programming education and emerged the other side, wise. So here is the issue:
Given a directed acyclic graph (DAG) represented as an adjacency list and the minimum number of nodes to be removed from the graph to make it a topological sort (i.e., removing all cycles), I ... | from collections import defaultdict
def strongly_connected_components(graph):
"""
Kosaraju's algorithm to find all strongly connected components of a graph.
"""
def fill_order(v, visited, stack):
visited[v] = True
for neighbor in graph[v]:
if not visited[neighbor]:
... | from solution import minimum_nodes_to_remove
def test_single_scc():
graph = {
0: [1],
1: [2],
2: [0],
}
result = minimum_nodes_to_remove(graph)
assert len(result) == 1
assert result[0] in [0, 1, 2]
def test_disjoint_cycles():
graph = {
0: [1],
1: [2],
... | [
{
"docstring": "Kosaraju's algorithm to find all strongly connected components of a graph.",
"function_declaration": "def strongly_connected_components(graph):",
"function_name": "strongly_connected_components",
"parameter_list": "(graph)"
},
{
"docstring": "Given a directed graph, find the ... | [
0,
0,
1
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def minimum_nodes_to_remove_to_break_cycles(graph):\n \"\"\"\n Returns the minimum set of nodes to remove to break all cycles in the graph.\n \n Parameters:\n graph (dict): A di... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004302",
"row_id": 4302,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13122']"
} | 0.507134 | Filter_4302 | I | [
"strongly_connected_components",
"minimum_nodes_to_remove"
] | 2 | [
[
"minimum_nodes_to_remove",
"strongly_connected_components"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 58ee0519c1ce36533fdaa7dc728050d3a26ed421 | 7167d6a35827df68a997b1176b6d33d34b440166 | |||
v1.0 | instruct | Filter | Filter_4352_I | Here is the code for sorting an array of integers:
```python
def sort(arr: list[int], start: int, end: int) -> None:
if start < end:
pivot = partition(arr, start, end)
sort(arr, start, pivot - 1)
sort(arr, pivot + 1, end)
def partition(arr: list[int], start: int, end: int) -> int:
piv... | def sort(arr: list[str], start: int, end: int) -> None:
if start < end:
pivot = partition(arr, start, end)
sort(arr, start, pivot - 1)
sort(arr, pivot + 1, end)
def partition(arr: list[str], start: int, end: int) -> int:
pivot = arr[start]
i = start + 1
j = end
done = False... | import pytest
from solution import sort
def test_sort_strings():
arr = ["banana", "apple", "cherry"]
expected = ["apple", "banana", "cherry"]
sort(arr, 0, len(arr) - 1)
assert arr == expected
def test_sort_single_string():
arr = ["apple"]
expected = ["apple"]
sort(arr, 0, 0)
assert arr... | [
{
"docstring": null,
"function_declaration": "def sort(arr, start, end):",
"function_name": "sort",
"parameter_list": "(arr, start, end)"
},
{
"docstring": null,
"function_declaration": "def partition(arr, start, end):",
"function_name": "partition",
"parameter_list": "(arr, star... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def sort(arr: list[str], start: int, end: int) -> None:\n if start < end:\n pivot = partition(arr, start, end)\n sort(arr, start, pivot - 1)\n sort(arr, pivot + 1, end)... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00004352",
"row_id": 4352,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13278']"
} | 0.619374 | Filter_4352 | I | [
"sort",
"partition"
] | 2 | [
[
"sort",
"partition"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 6c5e24a72ad0e90dc6bae5ba39b01662771f5713 | e542ac1e21c1fee3e53f9b8fa84a9ccf0fca3fab | |||
v1.0 | instruct | Filter | Filter_4383_I | I have a neat little problem for you. Here it is.
I'm trying to find all spots where two adjacent rectangles have the same dimensions. I'll give you the points that define these rectangles in a 2D space, so essentially: I'm looking to write a code that can determine adjacent rectangles with equal area.
Here's some s... | class Rectangle:
def __init__(self, x, y, width, height):
self.x = x
self.y = y
self.width = width
self.height = height
def are_rectangles_adjacent(rect1, rect2):
"""
Check if two rectangles are adjacent.
"""
# Check if adjacent by x axis
if (rect1.x == rect2.x a... | import pytest
from solution import Rectangle, find_adjacent_equal_rectangles
def test_no_adjacent_equal_rectangles():
rectangles = [
Rectangle(0, 0, 100, 50),
Rectangle(200, 60, 50, 100),
Rectangle(300, 150, 50, 100),
Rectangle(400, 10, 100, 10)
]
assert find_adjacent_e... | [] | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class Rectangle:\n def __init__(self, x, y, width, height):\n self.x = x\n self.y = y\n self.width = width\n self.height = height\n\ndef are_rectangles_adjacent(... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00004383",
"row_id": 4383,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13363']"
} | 0.542373 | Filter_4383 | I | [
"are_rectangles_adjacent",
"find_adjacent_equal_rectangles",
"sample_test"
] | 3 | [
[
"find_adjacent_equal_rectangles",
"are_rectangles_adjacent"
],
[
"sample_test",
"find_adjacent_equal_rectangles"
]
] | 2 | [] | false | [
"Rectangle"
] | true | pytest | true | [] | true | 3c4b647e61cb08785872b3dd2eb3b003dcd569ad | 196609c763da33378f9d10035789169cc833bb35 | |||
v1.0 | instruct | Filter | Filter_4390_I | I'm attempting to solve the "Goldbach's Conjecture" problem, which is a well-known Non-deterministic Polynomial-time (NP) problem. I'd like to find the first occurrence of two prime numbers that add up to the given number `n`. Do you have a simple code solution that can find the first occurrence of two prime numbers th... | def is_prime(num):
"""
Checks if a number is a prime number.
"""
if num <= 1:
return False
if num == 2:
return True
if num % 2 == 0:
return False
for i in range(3, int(num**0.5) + 1, 2):
if num % i == 0:
return False
return True
def goldbach(n... | from solution import goldbach, is_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
def test_goldbach_basic():
assert goldbach(4) == (2, 2)
assert goldbach(6) == (3, 3)
as... | [
{
"docstring": "Checks if a number is a prime number.",
"function_declaration": "def is_prime(num):",
"function_name": "is_prime",
"parameter_list": "(num)"
},
{
"docstring": "Finds the first pair of prime numbers that add up to `n`.\nIf such a pair exists, returns it as a tuple (p1, p2).\nI... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_prime(num):\n \"\"\"\n Checks if a number is a prime number.\n \"\"\"\n if num <= 1:\n return False\n if num == 2:\n return True\n if num % 2 == 0:\n ... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00004390",
"row_id": 4390,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13379']"
} | 0.53863 | Filter_4390 | I | [
"is_prime",
"goldbach"
] | 2 | [
[
"goldbach",
"is_prime"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | b43f52f46ee6e8d5ec02f53a1f96958107c90bb8 | 4211e5530c8e181852ec257e5fc0bb735fe1982f | |||
v1.0 | instruct | Filter | Filter_4392_I | Balanced Binary Tree
======================
A balanced binary tree
------------------------
In this problem, we aim to write a program that can find whether a binary tree is balanced or not. We will define a balanced binary tree as one where the difference between the height of its left and right subtrees cannot be g... | class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
def checkHeightAndBalance(node):
if node is None:
return 0, True
left_height, is_left_balanced = checkHeightAndBalance(node.left)
right_height, is_right_balanced = checkHeightAndBalan... | import pytest
from solution import TreeNode, isBalanced
def test_empty_tree():
assert isBalanced(None) == True
def test_single_node_tree():
root = TreeNode(1)
assert isBalanced(root) == True
def test_balanced_tree():
root = TreeNode(3)
root.left = TreeNode(9)
root.right = TreeNode(20)
roo... | [] | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class TreeNode:\n def __init__(self, x):\n self.val = x\n self.left = None\n self.right = None\n\ndef isBalanced(root):\n def check_balance_and_height(node):\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004392",
"row_id": 4392,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13384']"
} | 0.756534 | Filter_4392 | I | [
"checkHeightAndBalance",
"isBalanced"
] | 2 | [
[
"isBalanced",
"checkHeightAndBalance"
]
] | 1 | [] | false | [
"TreeNode"
] | true | pytest | true | [] | true | ed421ebf1cc3f73259b33dea3f132fb97c2b3bd5 | 99dea88cf9fa014b2bf781a2f6caaa3e1fa58bf0 | |||
v1.0 | instruct | Filter | Filter_4400_I | An algorithm is designed to find daily returns from historical stock prices. The algorithm has the following steps:
1. Export the historical stock price data into a vector
2. Calculate the percentage change for each day as (P(n+1) - P(n)) / P(n)
3. Save the changes in a separate output vector
4. Loop through the outpu... | def calculate_daily_returns(prices):
"""
Calculate the daily returns from a list of historical stock prices.
:param prices: List of stock prices.
:return: List of daily returns with duplicates removed.
"""
output = []
for i in range(1, len(prices)):
daily_return = (prices[i] - price... | import pytest
from solution import calculate_daily_returns, remove_duplicates
def test_calculate_daily_returns():
prices = [100, 105, 102, 108]
expected = [0.05, -0.02857142857142857, 0.058823529411764705]
assert calculate_daily_returns(prices) == expected
def test_calculate_daily_returns_with_same_prices... | [
{
"docstring": "Calculate the daily returns from a list of historical stock prices.\n\n:param prices: List of stock prices.\n:return: List of daily returns with duplicates removed.",
"function_declaration": "def calculate_daily_returns(prices):",
"function_name": "calculate_daily_returns",
"paramete... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def calculate_daily_returns(prices):\n \"\"\"\n This function calculates the daily returns of stock prices.\n \"\"\"\n output = []\n for i in range(1, len(prices)):\n dai... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004400",
"row_id": 4400,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13402']"
} | 0.518034 | Filter_4400 | I | [
"calculate_daily_returns",
"remove_duplicates"
] | 2 | [
[
"calculate_daily_returns",
"remove_duplicates"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | c45267db4ce7502ff89262521a8ec481a225dbd4 | f524765a3271d1c122676896419d65dc08d55d56 | |||
v1.0 | instruct | Filter | Filter_4401_I | In a lab, a body is considered dead when its temperature drops by one half of the normal body temperature (which is around 37 Celsius). Write a Python program to determine whether a body is dead or not by its current body temperature. This should be a loop where the user can keep inputting temperatures and find out whe... | def is_body_dead(current_temp):
"""
Returns whether a body is dead based on its current temperature.
A body is considered dead if its temperature drops to or below half of the normal body temperature.
Normal body temperature is 37 Celsius.
"""
normal_temp = 37
if current_temp <= normal_temp ... | from solution import is_body_dead
def test_temperature_above_half_normal():
assert is_body_dead(20) == False
def test_temperature_exactly_half_normal():
assert is_body_dead(18.5) == True
def test_temperature_below_half_normal():
assert is_body_dead(18) == True
def test_temperature_normal():
assert i... | [
{
"docstring": "Returns whether a body is dead based on its current temperature.\nA body is considered dead if its temperature drops to or below half of the normal body temperature.\nNormal body temperature is 37 Celsius.",
"function_declaration": "def is_body_dead(current_temp):",
"function_name": "is_... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def is_body_dead(temp):\n \"\"\"\n Determines if the body is dead based on the given temperature.\n \"\"\"\n normal_temp = 37.0\n half_normal_temp = normal_temp / 2\n return ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004401",
"row_id": 4401,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13405']"
} | 0.388104 | Filter_4401 | I | [
"is_body_dead",
"check_body_temperature"
] | 2 | [
[
"check_body_temperature",
"is_body_dead"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 4334defa352dcd447fd8b92d3adb3264d9129d6f | 293ea61f96ffb84f3f5d9b17fbb239cdf3d18533 | |||
v1.0 | instruct | Filter | Filter_4403_I | I will describe a bingo program, and I would like you to create it using Python. The program should work in the terminal.
Here are the general specifications:
The bingo card has 5 rows and 5 columns. Each cell can contain a unique 5-character string. The program must verify that the input string is at least 5 charact... | import random
import string
def generateRandomString(length=5):
lettersAndDigits = string.ascii_uppercase + string.digits
return ''.join(random.choice(lettersAndDigits) for _ in range(length))
def create_bingo_card():
card = [[generateRandomString() for _ in range(5)] for _ in range(5)]
return card
d... | import pytest
from solution import create_bingo_card, print_card, mark_card
def test_generateRandomString():
s = generateRandomString()
assert isinstance(s, str)
assert len(s) == 5
def test_create_bingo_card():
card = create_bingo_card()
assert len(card) == 5
for row in card:
assert le... | [
{
"docstring": null,
"function_declaration": "def generateRandomString(length=5):",
"function_name": "generateRandomString",
"parameter_list": "(length=5)"
},
{
"docstring": null,
"function_declaration": "def create_bingo_card():",
"function_name": "create_bingo_card",
"parameter... | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\nimport string\n\ndef generate_random_string(length=5):\n \"\"\"\n Generate a random string of uppercase letters and digits of the specified length.\n \"\"\"\n letter... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00004403",
"row_id": 4403,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13409']"
} | 0.572468 | Filter_4403 | I | [
"generateRandomString",
"create_bingo_card",
"print_card",
"mark_card",
"play_game"
] | 5 | [
[
"create_bingo_card",
"generateRandomString"
],
[
"play_game",
"create_bingo_card"
],
[
"play_game",
"mark_card"
],
[
"play_game",
"print_card"
]
] | 4 | [] | false | [] | false | pytest | true | [] | true | e2395887173068e3825d2e5495e5de7b1f67a531 | 42d88a0980d3242f4e3522a8f8a0ffb36e9c74ee | |||
v1.0 | instruct | Filter | Filter_4436_I | We have as many as 10 paylines in a slot machine. Writing a program to test more than a thousand of games will need too much time. So we want to simulate this by **Monte Carlo** simulation. Create a program (written in Python) of the Monte Carlo simulation of the slot machine.
How does it work? | import random
# Define the slot machine's symbols and associated payouts
symbols = ["Cherry", "Lemon", "Orange", "Plum", "Bell", "Bar", "Seven"]
payouts = {
"Cherry": 2,
"Lemon": 3,
"Orange": 5,
"Plum": 10,
"Bell": 20,
"Bar": 50,
"Seven": 100
}
def spin_slot_machine():
"""
Simulate... | from solution import spin_slot_machine, calculate_payout, monte_carlo_simulation
def test_spin_slot_machine():
spin_result = spin_slot_machine()
assert len(spin_result) == 3
assert all(symbol in symbols for symbol in spin_result)
def test_calculate_payout():
assert calculate_payout(["Cherry", "Cherry"... | [
{
"docstring": "Simulates a single spin of the slot machine.\nReturns a list of three randomly chosen symbols.",
"function_declaration": "def spin_slot_machine():",
"function_name": "spin_slot_machine",
"parameter_list": "()"
},
{
"docstring": "Calculates the payout for a given spin result."... | [
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 monte_carlo_slot_machine(num_simulations=10000):\n \"\"\"\n Simulates a slot machine using the Monte Carlo method.\n \n Params:\n - num_simulations: Number ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004436",
"row_id": 4436,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13485']"
} | 0.380232 | Filter_4436 | I | [
"spin_slot_machine",
"calculate_payout",
"monte_carlo_simulation"
] | 3 | [
[
"monte_carlo_simulation",
"calculate_payout"
],
[
"monte_carlo_simulation",
"spin_slot_machine"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 33d8d7d5dff1670bad80db719c2fb7f68e93c857 | c3ba2cabbbe9822fc08b7c32c8108956bbf03184 | |||
v1.0 | instruct | Filter | Filter_4457_I | WPA2, WPA3 and WPA3-PSK and WPA2-PSK implementation,
- KCK (ECDHE - ECDH triggered)
Modeling in python of client, APs and key management
Hi, let's get some basic implementation on python. This can help me to visualize better the key management process.
As per your request, I will provide a detailed description and i... | import os
import hashlib
import hmac
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.kdf.hkdf import HKDF
class AP:
def __init__(self, mac_address):... | import pytest
from solution import AP, Client, simulate_handshake, verify_kck
def test_key_generation_and_exchange():
ap = AP(mac_address="00:11:22:33:44:55")
client = Client(mac_address="66:77:88:99:AA:BB")
kck_ap, kck_client = simulate_handshake(ap, client)
assert kck_ap is not None
assert ... | [] | [
1,
1,
0
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import hashlib\nimport secrets\nfrom cryptography.hazmat.primitives.asymmetric import ec\nfrom cryptography.hazmat.primitives.serialization import Encoding, PublicFormat\n\nclass AP:\n def ... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00004457",
"row_id": 4457,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13551']"
} | 0.407026 | Filter_4457 | I | [
"generate_shared_key",
"derive_kck",
"simulate_handshake",
"verify_kck"
] | 4 | [
[
"simulate_handshake",
"derive_kck"
],
[
"simulate_handshake",
"generate_shared_key"
]
] | 2 | [] | false | [
"AP",
"Client"
] | true | pytest | true | [
"cryptography"
] | false | 4014cef2931c2b671c326f3cdff8ccf274efcff1 | 90e76a69aa37d104a8ac19c392ec432e82142722 | |||
v1.0 | instruct | Filter | Filter_4470_I | This is a question regarding Python:
The defaultdict type of dictionary is the default dictionary of the collections module. With the defaultdict a key not yet encountered by the dictionary is treated differently depending on a user-supplied argument, default_factory, rather than raising a default KeyError.
I... | from collections import defaultdict
def create_defaultdict_with_factory(factory):
"""
Creates a defaultdict with the provided factory function.
"""
return defaultdict(factory)
def defaultdict_example():
"""
Demonstrates the behavior of defaultdict with different factories.
"""
# Exampl... | from solution import create_defaultdict_with_factory, defaultdict_example
from collections import defaultdict
def test_create_defaultdict_with_list_factory():
d = create_defaultdict_with_factory(list)
assert isinstance(d, defaultdict)
assert d.default_factory == list
assert d['new_key'] == []
def ... | [
{
"docstring": "Creates a defaultdict with the provided factory function.",
"function_declaration": "def create_defaultdict_with_factory(factory):",
"function_name": "create_defaultdict_with_factory",
"parameter_list": "(factory)"
},
{
"docstring": "Demonstrates the behavior of defaultdict w... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "from collections import defaultdict\n\n# Create a defaultdict with int as the default_factory\ndef create_defaultdict_int():\n return defaultdict(int)\n\n# Create a defaultdict with a custo... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004470",
"row_id": 4470,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13573']"
} | 0.452902 | Filter_4470 | I | [
"create_defaultdict_with_factory",
"defaultdict_example"
] | 2 | [
[
"defaultdict_example",
"create_defaultdict_with_factory"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 017700bc5ffa5aec80195f63636c72aa9c5f8851 | 8726fe5bfd87fd8b8353b8b6591d53a12a7eae03 | |||
v1.0 | instruct | Filter | Filter_4479_I | This function gets all [game ID, karma] pairs of a user's games from APIs; currently it returns the list of game ids.
I'd like to implement both the following options:
- get all game ids
- get firewall logs
To define the new function, I strongly believe that using a single responsibility principle and the DRY princ... | def get_game_ids(api_data):
"""
Returns a list of all game IDs from the provided API data.
"""
return [game['id'] for game in api_data['games']]
def get_firewall_logs(api_data):
"""
Returns firewall logs from the provided API data.
"""
return api_data['firewall_logs']
def get_user_data... | import pytest
from solution import get_user_data
api_data_example = {
"games": [{"id": 1}, {"id": 2}, {"id": 3}],
"firewall_logs": [{"log": "log1"}, {"log": "log2"}]
}
def test_get_game_ids():
result = get_user_data(api_data_example, 'game_ids')
assert result == [1, 2, 3]
def test_get_firewall_logs()... | [
{
"docstring": "Returns a list of all game IDs from the provided API data.",
"function_declaration": "def get_game_ids(api_data):",
"function_name": "get_game_ids",
"parameter_list": "(api_data)"
},
{
"docstring": "Returns firewall logs from the provided API data.",
"function_declaration... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def get_info(api_type, user_id):\n \"\"\"\n Fetches game ids or firewall logs from the API based on the api_type.\n \n Parameters:\n api_type (str): Type of API to fetch data fr... | trial_gpt4o_1 | {
"original_instruction": "",
"prompt_id": "00004479",
"row_id": 4479,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13594']"
} | 0.314654 | Filter_4479 | I | [
"get_game_ids",
"get_firewall_logs",
"get_user_data"
] | 3 | [
[
"get_user_data",
"get_firewall_logs"
],
[
"get_user_data",
"get_game_ids"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 125ed03e7312992225d6cd82b740a124582313cc | 351d630a840733834679ea58d202a5fa8c00dcde | |||
v1.0 | instruct | Filter | Filter_4487_I | ### Basic Programming Concepts
#### Exercise 1.1: Understanding Basic Programming Constructs
Python Basics: Practice Assignments
1. Variables, Basic Operators, Control Structures
2. Functions
3. Lists and Tuples
4. Dictionaries
5. Object Oriented Programming
Problem 1: Variables, Basic Operators, Control Struct... | def calculate(num1, operator, num2):
"""
Perform calculation based on the operator.
"""
if operator == '+':
return num1 + num2
elif operator == '-':
return num1 - num2
elif operator == '*':
return num1 * num2
elif operator == '/':
if num2 != 0:
ret... | from solution import calculate
def test_addition():
assert calculate(3, '+', 2) == 5
def test_subtraction():
assert calculate(5, '-', 2) == 3
def test_multiplication():
assert calculate(3, '*', 2) == 6
def test_division():
assert calculate(6, '/', 2) == 3.0
def test_division_by_zero():
assert c... | [
{
"docstring": "Perform calculation based on the operator.",
"function_declaration": "def calculate(num1, operator, num2):",
"function_name": "calculate",
"parameter_list": "(num1, operator, num2)"
},
{
"docstring": null,
"function_declaration": "def basic_calculator():",
"function_n... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def calculate(num1, operator, num2):\n \"\"\"\n Perform the calculation based on the operator.\n \n Parameters:\n - num1: The first number (float).\n - operator: A st... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004487",
"row_id": 4487,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13616']"
} | 0.708758 | Filter_4487 | I | [
"calculate",
"basic_calculator"
] | 2 | [
[
"basic_calculator",
"calculate"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | a2bb004e08f82f181df9956fb7a6bdfc61ddc1c1 | 4c6098b00b58077becfcd7c2c7a7cc9ea84cb212 | |||
v1.0 | instruct | Filter | Filter_4488_I | A standard deck of 52 cards contains the cards 2 through Ace, each with one of the four suits: hearts, diamonds, clubs, and spades. Write a simple Python program to simulate drawing five random cards from the deck.
Here's a basic version of the program you could use as a starting point:
```
import random
suits = ['He... | import random
def create_deck():
suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades']
ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King', 'Ace']
return [(rank, suit) for suit in suits for rank in ranks]
def draw_cards(n):
if n > 52:
raise ValueError("Cannot draw more t... | from solution import draw_cards, create_deck
def test_draw_five_cards():
cards = draw_cards(5)
assert len(cards) == 5
assert all(isinstance(card, tuple) for card in cards)
assert all(len(card) == 2 for card in cards)
assert set(card[1] for card in cards).issubset({'Hearts', 'Diamonds', 'Clubs', 'Sp... | [
{
"docstring": null,
"function_declaration": "def create_deck():",
"function_name": "create_deck",
"parameter_list": "()"
},
{
"docstring": null,
"function_declaration": "def draw_cards(n):",
"function_name": "draw_cards",
"parameter_list": "(n)"
}
] | [
1,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\n\ndef create_deck():\n suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades']\n ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King', 'Ace']\n retu... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00004488",
"row_id": 4488,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13617']"
} | 0.720263 | Filter_4488 | I | [
"create_deck",
"draw_cards"
] | 2 | [
[
"draw_cards",
"create_deck"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | fce62583c3f7466baa276994e56b518923cff038 | b149d532c99f24ddddc1908569b9ebfd598ac15a | |||
v1.0 | instruct | Filter | Filter_4505_I | In a game of chess, the queen is the most powerful piece. You can move your queen to any square on the board that is horizontally, vertically, or diagonally in line with your queen. Given the following chess board:
`A B C D E F G H`
`1 | | | | | | | |`
`2 | | | | | | | |`
`3 | | | | | | | |`
`4 | | | | | | | |`
`5 | |... | import heapq
def pos_to_index(pos):
"""
Convert the chess board position (like 'E5') to indexes (x, y) in the range 0-7.
"""
column, row = pos[0], int(pos[1])
x = ord(column) - ord('A')
y = row - 1
return x, y
def index_to_pos(x, y):
"""
Convert indexes (x, y) to the chess board po... | from solution import get_queen_moves
def test_queen_moves_center():
moves = get_queen_moves("E5")
expected_moves = sorted([
"F5", "G5", "H5", "D5", "C5", "B5", "A5",
"E6", "E7", "E8", "E4", "E3", "E2", "E1",
"F6", "G7", "H8", "F4", "G3", "H2",
"D6", "C7", "B8", "D4", "C3", "B2"... | [
{
"docstring": "Convert the chess board position (like 'E5') to indexes (x, y) in the range 0-7.",
"function_declaration": "def pos_to_index(pos):",
"function_name": "pos_to_index",
"parameter_list": "(pos)"
},
{
"docstring": "Convert indexes (x, y) to the chess board position (like 'E5').",... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import heapq\n\ndef pos_to_index(pos):\n \"\"\"\n Convert the chess board position (like 'E5') to indexes (x, y) in the range 0-7.\n \"\"\"\n column, row = pos[0], int(pos[1])\n ... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00004505",
"row_id": 4505,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13664']"
} | 0.613797 | Filter_4505 | I | [
"pos_to_index",
"index_to_pos",
"get_queen_moves"
] | 3 | [
[
"get_queen_moves",
"index_to_pos"
],
[
"get_queen_moves",
"pos_to_index"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 31a471d6a6b3ce72ed736c5b155987cea7fe7a1f | f33c383ecc89f995cb3d8e8748d7de073d9a11a1 | |||
v1.0 | instruct | Filter | Filter_4520_I | I'm trying to implement a pattern for when a method is called. Let me explain: when a method is called, that method checks if a certain condition is met, and if the condition is met, then it calls another method. Then, when that second method is done, instead of returning to the calling method, it directly returns to t... | def first_method(caller_return_fn=None):
"""
First method checks a condition and calls second_method if the condition is met.
"""
condition_met = check_condition()
if condition_met:
return second_method(caller_return_fn=caller_return_fn)
else:
return "Condition not met, continui... | from solution import first_method, second_method
def test_condition_met():
def caller_return_fn(result):
return "Caller received: " + result
assert first_method(caller_return_fn=caller_return_fn) == "Caller received: Result from second_method"
def test_condition_not_met(monkeypatch):
# Patchi... | [
{
"docstring": "First method checks a condition and calls second_method if the condition is met.",
"function_declaration": "def first_method(caller_return_fn=None):",
"function_name": "first_method",
"parameter_list": "(caller_return_fn=None)"
},
{
"docstring": "Second method performs its op... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "class Pattern:\n def __init__(self):\n self.condition_met = False\n\n def method_caller(self):\n if self.check_condition():\n return self.method_to_call()\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004520",
"row_id": 4520,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13705']"
} | 0.353779 | Filter_4520 | I | [
"first_method",
"second_method",
"check_condition"
] | 3 | [
[
"first_method",
"check_condition"
],
[
"first_method",
"second_method"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 338e63d2b71c4774ce3195768db56465b582fc8b | b6d803b180154ca0a9b783017acf9aadeb94e97f | |||
v1.0 | instruct | Filter | Filter_4527_I | This project is meant to educate developers on image processing techniques and uses OpenCV (Open Source Computer Vision) Library to implement some.
To start with, I am trying to integrate some image processing techniques basic techniques such as applying a threshold to an image, converting a color image to grayscale,... | import cv2
def pixel_threshold(image, threshold):
(T, thresh) = cv2.threshold(image, threshold, 255, cv2.THRESH_BINARY_INV)
return thresh
def convert_color_to_grayscale(image):
return cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
def edge_detection(image):
return cv2.Canny(image,100,200)
def apply_blur(im... | import cv2
import numpy as np
from solution import process_image, convert_color_to_grayscale, pixel_threshold, edge_detection, apply_blur, invert_color
def test_convert_color_to_grayscale():
image = np.zeros((100, 100, 3), dtype=np.uint8)
gray_image = convert_color_to_grayscale(image)
assert len(gray_image... | [
{
"docstring": null,
"function_declaration": "def pixel_threshold(image, threshold):",
"function_name": "pixel_threshold",
"parameter_list": "(image, threshold)"
},
{
"docstring": null,
"function_declaration": "def convert_color_to_grayscale(image):",
"function_name": "convert_color_... | [
1,
0,
0
] | 1 | medium | 0.333 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import cv2\n\ndef pixel_threshold(image, threshold):\n (T, thresh) = cv2.threshold(image, threshold, 255, cv2.THRESH_BINARY_INV)\n return thresh\n\ndef convert_color_to_grayscale(image):... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00004527",
"row_id": 4527,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13731']"
} | 0.577482 | Filter_4527 | I | [
"pixel_threshold",
"convert_color_to_grayscale",
"edge_detection",
"apply_blur",
"invert_color",
"process_image"
] | 6 | [
[
"process_image",
"apply_blur"
],
[
"process_image",
"convert_color_to_grayscale"
],
[
"process_image",
"edge_detection"
],
[
"process_image",
"invert_color"
],
[
"process_image",
"pixel_threshold"
]
] | 5 | [] | false | [] | false | pytest | true | [
"cv2",
"numpy"
] | false | 9cd9fb9f0902c2eda5cf47dc757e7b0b7ec1cf2f | c8573938f2d8504d84563f3469f776b915598bbe | |||
v1.0 | instruct | Filter | Filter_4528_I | Rock, Paper and Scissors
=========================
Write the code for the Rock, Paper and Scissors game.
### Rules
- Rock beats Scissors
- Scissors beats Paper
- Paper beats Rock
- If the choice is the same, it's a draw
### Requirements
* The game will be played in the command line
* The player can choose Rock... | import random
def get_computer_choice():
choices = ['rock', 'paper', 'scissors']
return random.choice(choices)
def determine_winner(user_choice, computer_choice):
if user_choice == computer_choice:
return 0
if (user_choice == 'rock' and computer_choice == 'scissors') or \
(user_choice =... | from solution import get_computer_choice, determine_winner
def test_determine_winner_draw():
for choice in ['rock', 'paper', 'scissors']:
assert determine_winner(choice, choice) == 0
def test_determine_winner_user_wins():
assert determine_winner('rock', 'scissors') == 1
assert determine_winner('sc... | [
{
"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,
0,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\n\ndef get_computer_choice():\n choices = ['rock', 'paper', 'scissors']\n return random.choice(choices)\n\ndef determine_winner(user_choice, computer_choice):\n if user_... | trial_gpt4o_0 | {
"original_instruction": "",
"prompt_id": "00004528",
"row_id": 4528,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13738']"
} | 0.595022 | Filter_4528 | I | [
"get_computer_choice",
"determine_winner",
"game"
] | 3 | [
[
"game",
"determine_winner"
],
[
"game",
"get_computer_choice"
]
] | 2 | [] | false | [] | false | pytest | true | [] | true | 569b3d6330c6b0f0ac75f9bcd1f53ea6a76275e7 | 880e61f68ec65c4c28288a601cce30f8a825418d | |||
v1.0 | instruct | Filter | Filter_4548_I | This action moves the turtle by a random number of steps based on the user's
input value.
```python
import random
def turtle_move(turtle, user_value):
"""
Move the turtle by a random number of steps based on the user's input value.
Parameters:
turtle (str): The name of the turtle.
user_value ... | import random
def move_turtle(turtle, steps):
"""
Function to move the turtle the given number of steps.
Parameters:
turtle (str): The name of the turtle.
steps (int): The number of steps to move the turtle.
"""
# For simplicity, we are just printing it out. In practice, this could int... | from solution import turtle_move, move_turtle
def test_turtle_move():
turtle = "Leo"
user_value = 10
move_turtle_steps = turtle_move(turtle, user_value)
assert 0 <= move_turtle_steps <= 10
def test_move_turtle(capfd):
move_turtle("Leonardo", 5)
captured = capfd.readouterr()
assert cap... | [
{
"docstring": "Function to move the turtle the given number of steps.\n\nParameters:\nturtle (str): The name of the turtle.\nsteps (int): The number of steps to move the turtle.",
"function_declaration": "def move_turtle(turtle, steps):",
"function_name": "move_turtle",
"parameter_list": "(turtle, ... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "import random\n\ndef move_turtle(turtle, steps):\n \"\"\"\n Mock function to simulate turtle movement.\n \"\"\"\n print(f\"The turtle '{turtle}' moved {steps} steps.\")\n\ndef turt... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004548",
"row_id": 4548,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13792']"
} | 0.682228 | Filter_4548 | I | [
"move_turtle",
"turtle_move",
"main"
] | 3 | [
[
"turtle_move",
"move_turtle"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | a1af933e2b4153fdc8de53e392fbd137ee311b9f | 19e94eb20e48ea7ec4e3bfcabd63d71951dcf2e6 | |||
v1.0 | instruct | Filter | Filter_4563_I | It seems like the edges of the lid are not aligned with the edges of the lid when I try to put it back on to the container. Is there a way to teach a robot to learn an object's symmetry so that I could write code for it to properly realign the edges? | import cv2
import numpy as np
def find_symmetry_axis(image):
"""
This function detects the symmetry axis of a given binary image.
"""
contours, _ = cv2.findContours(image, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
if len(contours) == 0:
raise ValueError("No contours found in the image.")
... | import pytest
import cv2
import numpy as np
from solution import find_symmetry_axis, align_lid
def test_find_symmetry_axis():
# Create a simple binary image with a rectangle in the center
image = np.zeros((100, 100), dtype=np.uint8)
cv2.rectangle(image, (30, 30), (70, 70), 255, -1) # draw a white rectangl... | [
{
"docstring": "This function detects the symmetry axis of a given binary image.",
"function_declaration": "def find_symmetry_axis(image):",
"function_name": "find_symmetry_axis",
"parameter_list": "(image)"
},
{
"docstring": "This function aligns the symmetry axis of the lid with the contai... | [
0,
1,
1
] | 2 | easy | 0.667 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def analyze_symmetry(image):\n \"\"\"\n Analyzes the symmetry of an item from an image.\n This is a placeholder function.\n \"\"\"\n # Placeholder code for symmetry analysis\n ... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004563",
"row_id": 4563,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13833']"
} | 0.237466 | Filter_4563 | I | [
"find_symmetry_axis",
"align_lid"
] | 2 | [
[
"align_lid",
"find_symmetry_axis"
]
] | 1 | [] | false | [] | false | pytest | true | [
"cv2",
"numpy"
] | false | 32ca016157d7ad9f28bda10f0e2dabdc3024700a | 3d032bc626209a3c8c8c750b74cf1266325342fe | |||
v1.0 | instruct | Filter | Filter_4568_I | In this problem, we will build a code snippet that will add several vectors and the result will be a list of values. We will do this by first creating a function that will add two vectors at a time, and then extending that function to sum an arbitrary number of vectors. | def add_two_vectors(vec1, vec2):
"""
Adds two vectors element-wise.
Args:
vec1 (list): The first vector.
vec2 (list): The second vector.
Returns:
list: The element-wise sum of vec1 and vec2.
"""
return [a + b for a, b in zip(vec1, vec2)]
def add_vectors(*vector... | from solution import add_two_vectors, add_vectors
def test_add_two_vectors():
assert add_two_vectors([1, 2], [3, 4]) == [4, 6]
assert add_two_vectors([1, 1], [1, 1]) == [2, 2]
assert add_two_vectors([0, 0], [1, 2]) == [1, 2]
assert add_two_vectors([-1, -2], [1, 2]) == [0, 0]
def test_add_vectors():
... | [
{
"docstring": "Adds two vectors element-wise.\n\nArgs:\n vec1 (list): The first vector.\n vec2 (list): The second vector.\n\nReturns:\n list: The element-wise sum of vec1 and vec2.",
"function_declaration": "def add_two_vectors(vec1, vec2):",
"function_name": "add_two_vectors",
"parameter_... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def add_vectors(v1, v2):\n \"\"\"\n Adds two vectors v1 and v2 and returns the resulting vector.\n\n Parameters:\n v1 (list of int/float): The first vector.\n v2 (list of int/fl... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004568",
"row_id": 4568,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13846']"
} | 0.550251 | Filter_4568 | I | [
"add_two_vectors",
"add_vectors"
] | 2 | [
[
"add_vectors",
"add_two_vectors"
]
] | 1 | [] | false | [] | false | pytest | true | [] | true | 87e216e712a9db06af3f36f3ca81798e8853d93c | 0b0167c143b17c2921dd3b527fa6ca8893e2aa25 | |||
v1.0 | instruct | Filter | Filter_4571_I | using Python, how do you do trim start and trim end
I know in Python there is no native str.trim() function. However there is strip(), lstrip(), and rstrip(). But I want to do the trimming myself without using strip() or the likes
Here is my code. :
```
def trim_start(input_str):
# this is going to be a simple... | def trim_start(input_str):
"""
This function trims the leading whitespace characters (spaces, tabs, newlines, carriage returns)
from the start of the string.
"""
start_idx = 0
while start_idx < len(input_str):
if input_str[start_idx] not in [" ", "\t", "\n", "\r"]:
break
... | def test_trim_start():
assert trim_start(" Hello") == "Hello"
assert trim_start("\tHello") == "Hello"
assert trim_start("\nHello") == "Hello"
assert trim_start("\rHello") == "Hello"
assert trim_start("Hello") == "Hello"
assert trim_start(" \t\n\r Hello") == "Hello"
assert trim_start(" ... | [
{
"docstring": "This function trims the leading whitespace characters (spaces, tabs, newlines, carriage returns) \nfrom the start of the string.",
"function_declaration": "def trim_start(input_str):",
"function_name": "trim_start",
"parameter_list": "(input_str)"
},
{
"docstring": "This func... | [
1,
1,
1
] | 3 | easy | 1 | {
"trial_gpt4o_0": {
"file_source": "Magpie-Filter-89K_sanitized_prepared0_results_combined.jsonl",
"solution_code": "def trim_start(input_str):\n \"\"\"\n Trim the start of the string from all types of whitespace.\n \"\"\"\n start_idx = 0\n while start_idx < len(input_str):\n if not inp... | trial_gpt4o_2 | {
"original_instruction": "",
"prompt_id": "00004571",
"row_id": 4571,
"seed_ids": "['Meta-Llama-3.1-70B-Instruct_13852']"
} | 0.552666 | Filter_4571 | I | [
"trim_start",
"trim_end",
"trim"
] | 3 | [
[
"trim",
"trim_end"
],
[
"trim",
"trim_start"
]
] | 2 | [] | false | [] | false | pytest | false | [] | true | b2e9b6547acb73838f700a7b6cd2d9b7800ff0a7 | 441bcc8debaac1affc99beb93f2ca6864cc1d0b5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.