id stringlengths 32 32 | input stringlengths 181 3.45k | output stringlengths 70 36.6k | domain stringclasses 2
values | generation_algorithm stringclasses 2
values | llm_judgement stringlengths 446 1.62k | unit_tests stringlengths 277 6.65k | tests_execution_status stringclasses 708
values | average_test_score stringclasses 11
values |
|---|---|---|---|---|---|---|---|---|
45ec4865601377389e9590693d52df71 | You are tasked with implementing a custom sorting algorithm in Python to sort a list of integers in ascending order. Your function should be named `custom_sort`. The algorithm you choose to implement must be either bubble sort or selection sort. Your function should return the sorted list.
**Input:**
- A list of integ... | Here's a Python implementation of a **custom sorting algorithm** using **Selection Sort**, as requested. The function is named `custom_sort` and returns the sorted list in ascending order.
```python
def custom_sort(arr):
# Traverse through all array elements
for i in range(len(arr)):
# Find the minimum... | generic | self-instruct | {"requirement_conformance": {"score": 5, "justification": "The solution fully meets the requirement by implementing a custom sorting algorithm (selection sort) that sorts a list of integers in ascending order and is named `custom_sort`."}, "logical_correctness": {"score": 5, "justification": "The logic of the selection... | ["\nassert custom_sort([64, 25, 12, 22, 11]) == [11, 12, 22, 25, 64]\n", "\nassert custom_sort([5, 2, 9, 1, 5, 6]) == [1, 2, 5, 5, 6, 9]\n", "\nassert custom_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n", "\nassert custom_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5]\n", "\nassert custom_sort([]) == []\n", "\nassert custom_so... | ["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"] | 1 |
677939876b07542e01433f5406ed0a25 | You are given a directed graph with `n` nodes and `m` edges. Each node `i` has an associated profit `p_i`, and each edge `j` connecting node `u_j` to node `v_j` has an associated cost `c_j`. Your task is to find a path starting from node 1 that maximizes the total profit minus the total cost. If multiple paths yield th... | To solve this problem, we need to find a **path starting from node 1** that **maximizes the total profit minus the total cost**.
### Key Observations:
- **Profit of a node** is added when you visit the node.
- **Cost of an edge** is subtracted when you use the edge.
- We want to **maximize (sum of profits) - (sum of ... | algorithmic | self-instruct | {"requirement_conformance": {"score": 4, "justification": "The solution addresses the main requirement of finding a path starting from node 1 that maximizes the total profit minus the total cost. However, it does not handle the case where no path exists from node 1 to any other node, which could result in an incorrect ... | ["\nassert max_profit_minus_cost(1, 0, [10], []) == 10\n", "\nassert max_profit_minus_cost(2, 1, [10, 20], [(1, 2, 5)]) == 25\n", "\nassert max_profit_minus_cost(3, 2, [10, 20, 30], [(1, 2, 5), (2, 3, 10)]) == 45\n", "\nassert max_profit_minus_cost(3, 2, [10, 20, 30], [(1, 2, 25), (2, 3, 10)]) == 10\n", "\nassert max_p... | ["pass", "pass", "pass", "fail", "fail", "fail", "fail", "fail", "fail", "fail"] | 0.3 |
59922d1e09a12101a8018344e6f34b44 | You are tasked with implementing a function to display a tree structure in the console. The tree is represented as a dictionary where each key is a node name and each value is a list of its child node names. Your function should print the tree starting from the root node, with each level of the tree indented by two spa... | Here's a Python function that prints the tree structure as described. It uses a **Depth-First Search (DFS)** approach to traverse the tree and prints each node with the appropriate indentation:
```python
def print_tree(tree, root, indent=0):
# Print the current node
print(' ' * indent + root)
# If th... | generic | self-instruct | {"requirement_conformance": {"score": 5, "justification": "The solution fully meets the requirements by correctly printing the tree structure with each level indented by two spaces."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optimally structured. The function uses recur... | ["\nassert print_tree({\"root\": [\"child1\", \"child2\"]}, \"root\") == \"root\\n child1\\n child2\"\n", "\nassert print_tree({\"root\": [\"child1\"]}, \"root\") == \"root\\n child1\"\n", "\nassert print_tree({\"root\": []}, \"root\") == \"root\"\n", "\nassert print_tree({\"root\": [\"child1\", \"child2\"], \"child... | ["fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail"] | 0 |
fd546ced41c1bc61f2e0254a837b2484 | You are given the task of simulating the placement of `n` stars in a spiral constellation centered at the origin (0,0) on a 2D plane. The first star should be positioned at the topmost point (0, radius). The stars must be distributed along a logarithmic spiral defined by the equation `r = a * e^(b * θ)`, where `a` and ... | To simulate the placement of `n` stars on a **logarithmic spiral**, we need to:
---
### 🌌 **Logarithmic Spiral Overview**
The spiral is defined by the polar equation:
$$
r = a \cdot e^{b \cdot \theta}
$$
Where:
- `r` is the distance from the origin.
- `θ` is the angle in radians.
- `a` and `b` are constants to be... | generic | evol-instruct | {"requirement_conformance": {"score": 4, "justification": "The function generates a spiral pattern of stars and returns a list of tuples representing the coordinates. It meets the basic requirements but could benefit from more detailed specifications for constants a and b, and the angle increment calculation could be m... | ["\nassert len(generate_constellation(1)) == 1\n", "\nassert generate_constellation(1) == [(0.0, 1.0)]\n", "\nassert len(generate_constellation(5)) == 5\n", "\nassert generate_constellation(0) == []\n", "\nassert generate_constellation(2)[0][1] > generate_constellation(2)[1][1]\n", "\nassert generate_constellation(3)[0... | ["pass", "fail", "pass", "fail", "fail", "fail", "pass", "fail", "fail", "pass"] | 0.4 |
09904b654c87c0697844fcf03431e7d4 | You are given a string `s`. Your task is to write a function `count_vowels_consonants` that processes the string and returns a dictionary with two keys: `'vowels'` and `'consonants'`. The values associated with these keys should represent the number of vowels and consonants in the string, respectively. The function sho... | Here's a Python function that fulfills the requirements:
### ✅ **Function Description:**
- **Input:** A string `s` (can contain any characters).
- **Output:** A dictionary with the counts of vowels and consonants.
- **Vowels:** `'a', 'e', 'i', 'o', 'u'` (case-insensitive).
- **Consonants:** All other alphabetic charac... | generic | self-instruct | {"requirement_conformance": {"score": 5, "justification": "The function fully meets all the specified requirements. It takes a string as input, returns a dictionary with counts of vowels and consonants, ignores non-alphabetic characters, and is case-insensitive."}, "logical_correctness": {"score": 5, "justification": "... | ["\nassert count_vowels_consonants(\"Hello, World!\") == {'vowels': 3, 'consonants': 7}\n", "\nassert count_vowels_consonants(\"Python Programming\") == {'vowels': 4, 'consonants': 11}\n", "\nassert count_vowels_consonants(\"AEIOU\") == {'vowels': 5, 'consonants': 0}\n", "\nassert count_vowels_consonants(\"bcdfg\") == ... | ["pass", "fail", "pass", "pass", "pass", "pass", "fail", "pass", "pass", "pass"] | 0.8 |
c9023f53e0045f9faf7d58cfc1a6a3a8 | You are given a hypergraph `H` represented as a list of edges, where each edge is a set of nodes. Your task is to compute the s-centrality of nodes or edges in the hypergraph using a provided centrality measure function `func`. The s-centrality should be calculated without modifying or removing any edges from the hyper... | To compute the **s-centrality** in a **hypergraph** using a given centrality function `func`, we need to **project the hypergraph** into a **standard graph** (where each edge is a pair of nodes), and then apply the centrality function to the resulting graph.
---
### ✅ **Steps to Solve the Problem:**
1. **Read Input:... | generic | evol-instruct | {"requirement_conformance": {"score": 3, "justification": "The solution converts the hypergraph to a simple graph and computes centrality using the provided function. However, it does not explicitly handle the s-centrality measure, which is a specific type of centrality measure for hypergraphs. The solution also does n... | ["\nassert compute_s_centrality([{'a', 'b'}, {'b', 'c'}], nx.degree_centrality) == {'a': 0.5, 'b': 1.0, 'c': 0.5}\n", "\nassert compute_s_centrality([{'x', 'y', 'z'}, {'x', 'w'}], nx.degree_centrality) == {'x': 1.0, 'y': 0.5, 'z': 0.5, 'w': 0.5}\n", "\nassert compute_s_centrality([{'a', 'b', 'c'}, {'b', 'c', 'd'}, {'d'... | ["fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail"] | 0 |
fbbb0c0887a9a0c73bd3a8120ee916e6 | You are given a sequence of integers. Your task is to implement a function `sum_of_even_elements` that computes the sum of all even numbers in the sequence. The sequence can be a list, tuple, or range of integers. If the sequence is a list or tuple and contains more than 5 even numbers, return the sum of these even num... | Here's a Python function `sum_of_even_elements` that fulfills the described behavior:
### **Function Explanation:**
1. **Input**: A sequence of integers (list, tuple, or range).
2. **Process**:
- Extract even numbers from the sequence.
- If the sequence is a **list or tuple** and contains **more than 5 even numb... | generic | evol-instruct | {"requirement_conformance": {"score": 5, "justification": "The solution fully meets all specified requirements, including handling different types of input sequences and the additional requirement of sorting and summing even numbers when the sequence is a list or tuple with more than 5 even numbers."}, "logical_correct... | ["\nassert sum_of_even_elements([1, 2, 3, 4, 5]) == 6\n", "\nassert sum_of_even_elements(range(1, 11)) == 30\n", "\nassert sum_of_even_elements((1, 3, 5, 7, 9)) == 0\n", "\nassert sum_of_even_elements([10, 2, 8, 4, 6, 12, 14, 16]) == 60\n", "\nassert sum_of_even_elements([2, 4, 6, 8, 10]) == 30\n", "\nassert sum_of_eve... | ["pass", "pass", "pass", "fail", "pass", "pass", "pass", "pass", "pass", "pass"] | 0.9 |
a60116ba63b3ef08f472bde38f8f9633 | You are given a list of distinct integers `elements` and an integer `n`. Your task is to write a function `generate_combinations` that returns all possible combinations of `n` elements from the `elements` list. The function should utilize Python's `itertools` module to generate these combinations. The original list sho... | You can achieve this by using Python's built-in `itertools.combinations` function, which efficiently generates all possible combinations of a given length from an iterable. Here's how you can implement the `generate_combinations` function:
```python
import itertools
def generate_combinations(elements, n):
"""
... | generic | self-instruct | {"requirement_conformance": {"score": 5, "justification": "The function fully meets the requirements by using the itertools module to generate combinations and handling cases where n is greater than the length of the elements list."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct... | ["\nassert generate_combinations([1, 2, 3, 4], 2) == [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]\n", "\nassert generate_combinations([1, 2, 3], 4) == []\n", "\nassert generate_combinations(['a', 'b', 'c'], 2) == [('a', 'b'), ('a', 'c'), ('b', 'c')]\n", "\nassert generate_combinations([], 1) == []\n", "\nassert gen... | ["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"] | 1 |
3a0e0f6ee90a20df30951c09c29ada0d | You are tasked with implementing a `Matrix` class in Python that supports basic matrix operations. The class should be able to handle the following operations:
1. **Initialization**: Create a matrix from a given list of lists (rows).
2. **Addition**: Add two matrices of the same dimensions.
3. **Subtraction**: Subtrac... | Here's a complete implementation of the `Matrix` class in Python that supports all the required operations:
```python
class Matrix:
def __init__(self, data):
"""
Initialize a matrix from a list of lists.
"""
if not all(len(row) == len(data[0]) for row in data):
raise Val... | generic | self-instruct | {"requirement_conformance": {"score": 4, "justification": "The class meets most of the specified requirements, including initialization, addition, subtraction, multiplication, transposition, determinant calculation, and string representation. However, it does not include a check for the size attribute in the constructo... | ["\nassert str(Matrix([[1, 2], [3, 4]])) == \"1\\t2\\n3\\t4\"\n", "\nassert (Matrix([[1, 2], [3, 4]]) + Matrix([[5, 6], [7, 8]])).data == [[6, 8], [10, 12]]\n", "\nassert (Matrix([[1, 2], [3, 4]]) - Matrix([[1, 1], [1, 1]])).data == [[0, 1], [2, 3]]\n", "\nassert (Matrix([[1, 2], [3, 4]]) * Matrix([[2, 0], [1, 2]])).da... | ["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"] | 1 |
07ef99918679cecd9602bbdee0ee65ee | You are given three integers `a`, `b`, and `c`. Your task is to implement a function `rotate_numbers(a, b, c)` that returns a tuple with the integers rotated in the following manner: the first integer should move to the second position, the second integer should move to the third position, and the third integer should ... | You can implement the `rotate_numbers` function as follows, using **tuple unpacking** in Python to rotate the values **without using any additional variables** for swapping:
```python
def rotate_numbers(a, b, c):
return (c, a, b)
```
### Explanation:
- The function takes three integers `a`, `b`, and `c`.
- It ret... | generic | evol-instruct | {"requirement_conformance": {"score": 5, "justification": "The function fully meets the requirement by correctly rotating the input integers and returning them in the specified order."}, "logical_correctness": {"score": 5, "justification": "The logic of the function is completely correct and directly implements the req... | ["\nassert rotate_numbers(1, 2, 3) == (3, 1, 2)\n", "\nassert rotate_numbers(4, 5, 6) == (6, 4, 5)\n", "\nassert rotate_numbers(0, 0, 0) == (0, 0, 0)\n", "\nassert rotate_numbers(-1, -2, -3) == (-3, -1, -2)\n", "\nassert rotate_numbers(10, 20, 30) == (30, 10, 20)\n", "\nassert rotate_numbers(100, 200, 300) == (300, 100... | ["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"] | 1 |
b6dbfa73932fba72ffdad2685940342e | You are tasked with implementing a function `is_palindrome` that checks if a given string is a palindrome. A string is considered a palindrome if, after removing all non-alphanumeric characters and converting all uppercase letters to lowercase, it reads the same forwards and backwards. Your function should return `True... | Here's how you can implement the `is_palindrome` function in Python **without using regular expressions or built-in string methods** that directly remove non-alphanumeric characters:
### ✅ **Approach:**
1. **Filter valid characters** manually: iterate through the string and only keep alphanumeric characters (i.e., `'a... | generic | self-instruct | {"requirement_conformance": {"score": 5, "justification": "The function fully meets the requirements by considering only alphanumeric characters, ignoring case, and returning the correct boolean value for palindrome checking."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct. The ... | ["\nassert is_palindrome(\"A man, a plan, a canal: Panama\") == True\n", "\nassert is_palindrome(\"race a car\") == False\n", "\nassert is_palindrome(\"No 'x' in Nixon\") == True\n", "\nassert is_palindrome(\"Was it a car or a cat I saw?\") == True\n", "\nassert is_palindrome(\"12321\") == True\n", "\nassert is_palindr... | ["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"] | 1 |
2946f9b1e5009eb04a124cdfd9b7548b | You are given a text file named "data.txt". Your task is to write a program that reads this file and counts the frequency of each word, excluding common stop words. The stop words are: "the", "and", "is", "in", "at", "which", "on", "a", "an". The comparison for stop words should be case-insensitive. The output should l... | Here's a Python program that reads the `data.txt` file, counts the frequency of each word while excluding the specified stop words (case-insensitively), and prints the result in descending order of frequency.
### ✅ Python Code:
```python
import re
from collections import Counter
# Define the stop words
stop_words = ... | algorithmic | self-instruct | {"requirement_conformance": {"score": 5, "justification": "The solution fully meets all specified requirements. It reads a text file, counts the number of times each word appears, ignores common stop words in a case-insensitive manner, and outputs the count of each word in descending order of frequency."}, "logical_cor... | ["\nassert word_count('empty.txt') == None\n", "\nassert word_count('single_word.txt') == None\n", "\nassert word_count('stop_words_only.txt') == None\n", "\nassert word_count('mixed_case.txt') == None\n", "\nassert word_count('punctuation.txt') == None\n", "\nassert word_count('multiple_lines.txt') == None\n", "\nasse... | ["fail", "pass", "pass", "fail", "pass", "pass", "fail", "fail", "fail", "fail"] | 0.4 |
ada5f48d6e408a6af5cb7bec05351a3d | You are tasked with implementing a Python class `Employee` to manage employee details in a company's database. The class should support the following functionalities:
- Initialize an employee with a name, ID, department, and salary.
- Provide a method to give a raise to the employee, which increases the salary by a sp... | Here's the implementation of the `Employee` class in Python, based on your requirements:
```python
class Employee:
def __init__(self, name, id, department, salary):
self.name = name
self.id = id
self.department = department
self.salary = salary
def give_raise(self, amount):
... | generic | self-instruct | {"requirement_conformance": {"score": 3, "justification": "The class meets basic requirements by including the specified attributes and methods, but it does not include any additional methods or properties that might be expected in a more comprehensive Employee class."}, "logical_correctness": {"score": 4, "justificati... | ["\nassert Employee(\"John Doe\", 1, \"HR\", 50000).name == \"John Doe\"\n", "\nassert Employee(\"Jane Smith\", 2, \"Engineering\", 75000).id == 2\n", "\nassert Employee(\"Alice Johnson\", 3, \"Marketing\", 60000).department == \"Marketing\"\n", "\nassert Employee(\"Bob Brown\", 4, \"Finance\", 80000).salary == 80000\n... | ["pass", "pass", "pass", "pass", "fail", "pass", "pass", "pass", "pass", "pass"] | 0.9 |
897396a94bdeb10a842a66c3cabf216f | You are given a list of `n` intervals, where each interval is represented by a pair of integers `(start, end)`. Your task is to calculate the total overlap between all pairs of intervals. The overlap between two intervals is defined as the length of their intersection. If two intervals do not intersect, their overlap i... | To solve the problem of computing the **total overlap between all pairs of intervals**, we need to:
1. **Sort the intervals** by their `start` points.
2. **Iterate through all pairs** of intervals and calculate the overlap for each pair.
3. **Sum up all the overlaps**.
---
### Step-by-step Explanation:
#### 1. Sort... | generic | evol-instruct | {"requirement_conformance": {"score": 5, "justification": "The solution fully meets all specified requirements. It sorts the intervals by their start points and calculates the total overlap between all pairs of intervals."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optim... | ["\nassert total_overlap([(1, 5), (3, 7), (2, 4), (6, 8)]) == 6\n", "\nassert total_overlap([(1, 3), (4, 6), (7, 9)]) == 0\n", "\nassert total_overlap([(1, 10), (2, 5), (3, 7)]) == 8\n", "\nassert total_overlap([(5, 10), (10, 15), (15, 20)]) == 0\n", "\nassert total_overlap([(1, 2), (2, 3), (3, 4)]) == 0\n", "\nassert ... | ["pass", "pass", "fail", "pass", "pass", "pass", "pass", "fail", "pass", "pass"] | 0.8 |
f1e5ef7044585a580153c15d6d06e0d7 | Chef and Chefu are eagerly looking to purchase cakes of equal price from a cake shop. Chef has coins of denomination $N$ and Chefu has coins of denomination $M$. They wish to determine the minimum amount they must spend to buy cakes such that each of them pays an equal amount using only their respective coins. Implemen... | To solve this problem, we need to compute the **Least Common Multiple (LCM)** of two integers `N` and `M`, which represents the smallest amount that both Chef and Chefu can pay using only their respective coins.
The LCM of two numbers is related to their **Greatest Common Divisor (GCD)** by the formula:
$$
\text{LCM}... | algorithmic | evol-instruct | {"requirement_conformance": {"score": 3, "justification": "The solution attempts to find the minimum amount to be spent by calculating the LCM of the two denominations. However, it does not fully meet the requirement of not using multiplication or division operations, as it uses division in the calculation of the LCM."... | ["\nassert minimum_amount(12, 18) == 36\n", "\nassert minimum_amount(5, 10) == 10\n", "\nassert minimum_amount(7, 3) == 21\n", "\nassert minimum_amount(21, 6) == 42\n", "\nassert minimum_amount(8, 12) == 24\n", "\nassert minimum_amount(1, 1) == 1\n", "\nassert minimum_amount(13, 17) == 221\n", "\nassert minimum_amount(... | ["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"] | 1 |
6066118a6c1e9af805f3b37e8b7ed55d | You are tasked with writing a program that reads a JSON file and retrieves the value associated with a specified key. Your program should prompt the user to input the filename and the key. The program must handle the following scenarios:
- If the file does not exist, output an error message: "Error: The file '{filename... | Here's a Python program that meets your requirements. It reads a JSON file, retrieves the value associated with a specified key, and handles the specified error conditions.
```python
import json
import os
def main():
# Prompt user for filename and key
filename = input("Enter the filename: ")
key = input("... | generic | self-instruct | {"requirement_conformance": {"score": 5, "justification": "The program fully meets all specified requirements. It prompts the user for the file name and key, handles cases where the file does not exist, and handles cases where the key is not found in the JSON file."}, "logical_correctness": {"score": 5, "justification"... | ["\nassert read_json_key(\"data.json\", \"name\") == \"John\"\n", "\nassert read_json_key(\"data.json\", \"age\") == 30\n", "\nassert read_json_key(\"data.json\", \"address\") == \"Key 'address' not found in the JSON data.\"\n", "\nassert read_json_key(\"non_existent_file.json\", \"name\") == \"Error: The file 'non_exi... | ["fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail"] | 0 |
d55496138ee703c02f2732b0ed19c799 | You are tasked with developing a keyword extraction system for a document analysis project. Implement a function `extract_keywords(text: str, num_keywords: int) -> List[str]` that processes a given text and identifies the top `num_keywords` most frequently occurring words. The function should handle punctuation and be ... | To implement the `extract_keywords` function, we need to:
1. **Normalize the text**: Convert all characters to lowercase to ensure case-insensitive comparison.
2. **Remove punctuation**: Filter out non-alphanumeric characters to extract only words.
3. **Tokenize the text**: Split the text into individual words.
4. **C... | generic | self-instruct | {"requirement_conformance": {"score": 5, "justification": "The function fully meets the requirements by taking a string `text` and an integer `num_keywords` as input and returning a list of the top `num_keywords` most frequent words in the text. It also considers punctuation and case sensitivity."}, "logical_correctnes... | ["\nassert extract_keywords(\"hello world hello\", 1) == [\"hello\"]\n", "\nassert extract_keywords(\"test test test test\", 2) == [\"test\"]\n", "\nassert extract_keywords(\"a b c d e f g\", 3) == [\"a\", \"b\", \"c\"]\n", "\nassert extract_keywords(\"Python is great, and python is fun.\", 2) == [\"python\", \"is\"]\n... | ["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"] | 1 |
0fb19322cc1987058b2f94ebe9b56c82 | You are given a function `f(x1, x2, ..., xn) = x1^2 + x2^2 + ... + xn^2` where each variable `xi` must be an integer between 1 and 10 inclusive. Your task is to find the set of integers `(x1, x2, ..., xn)` that minimizes the function `f`. Implement a genetic algorithm to solve this optimization problem. Your program sh... | Here's a Python implementation of a **Genetic Algorithm** to minimize the function `f(x1, x2, ..., xn) = x1^2 + x2^2 + ... + xn^2` where each `xi` is an integer between 1 and 10 inclusive.
We use:
- Random initialization of the population.
- Selection via tournament selection.
- Crossover via single-point crossover.
-... | algorithmic | self-instruct | {"requirement_conformance": {"score": 4, "justification": "The solution addresses the main requirements of implementing a genetic algorithm to optimize the sum of squares function with constraints on variable values. However, it does not specify the exact number of variables or generations, which are part of the proble... | ["\nassert genetic_algorithm(10, 1, 10)[1] >= 1 and genetic_algorithm(10, 1, 10)[1] <= 100\n", "\nassert genetic_algorithm(20, 2, 20)[1] >= 2 and genetic_algorithm(20, 2, 20)[1] <= 200\n", "\nassert genetic_algorithm(30, 3, 30)[1] >= 3 and genetic_algorithm(30, 3, 30)[1] <= 300\n", "\nassert all(1 <= x <= 10 for x in g... | ["fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail"] | 0 |
31803e17ff08a171b7c1bceb2ae258b2 | You are given a list of distinct words `W` and a list of tuples `T`. Each tuple in `T` contains a sequence of words. Your task is to construct a new list of tuples `T'` where each tuple is formed by removing the first word from the corresponding tuple in `T` and appending a new word from `W`. The new word must not alre... | To solve this problem, we need to:
1. **Iterate over each tuple** in the list `T`.
2. **Remove the first word** from each tuple.
3. **Find the next word in `W`** in a circular manner (i.e., wrap around to the start if needed) that is **not already in the tuple**.
4. **Append that new word** to the tuple.
5. **Store th... | generic | evol-instruct | {"requirement_conformance": {"score": 5, "justification": "The solution fully meets all specified requirements. It removes the first word from each tuple, appends a new word from the list of words, and ensures no word is repeated within a single tuple."}, "logical_correctness": {"score": 5, "justification": "The logic ... | ["\nassert transform_tuples([\"apple\", \"banana\", \"cherry\"], [(\"orange\", \"banana\"), (\"cherry\", \"date\")]) == [(\"banana\", \"apple\"), (\"date\", \"banana\")]\n", "\nassert transform_tuples([\"apple\", \"banana\", \"cherry\"], [(\"apple\", \"banana\"), (\"banana\", \"cherry\")]) == [(\"banana\", \"cherry\"),... | ["pass", "fail", "pass", "pass", "pass", "pass", "fail", "fail", "pass", "fail"] | 0.6 |
4968e29cd2aaded9b8613650a17f50c0 | You are given two dictionaries, `dict1` and `dict2`. Your task is to update `dict1` in-place with values from `dict2` under the following conditions:
- Only update the values of keys that are present in both `dict1` and `dict2`.
- A value in `dict1` should only be updated if the corresponding value in `dict2` is strict... | Here's a Python function that performs the described operation:
```python
def merge_dicts(dict1: dict, dict2: dict) -> dict:
for key in dict1:
if key in dict2 and dict2[key] > dict1[key]:
dict1[key] = dict2[key]
return dict1
```
### Explanation:
- The function iterates over each key in `di... | generic | evol-instruct | {"requirement_conformance": {"score": 5, "justification": "The solution fully meets all specified requirements. It updates the values of `dict1` in-place only if the corresponding value in `dict2` is strictly greater, and it does not modify the keys of `dict1`."}, "logical_correctness": {"score": 5, "justification": "T... | ["\nassert merge_dicts({'a': 1, 'b': 2}, {'b': 3, 'c': 4}) == {'a': 1, 'b': 3}\n", "\nassert merge_dicts({'x': 10, 'y': 20}, {'x': 5, 'y': 25}) == {'x': 10, 'y': 25}\n", "\nassert merge_dicts({'m': 100, 'n': 200}, {'m': 100, 'n': 200}) == {'m': 100, 'n': 200}\n", "\nassert merge_dicts({'p': 1, 'q': 2}, {'r': 3, 's': 4}... | ["fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail"] | 0 |
388dd359dc4decd2fc8b601ea4f6d9d9 | You are given a list of convex polygons, each defined by the number of its sides. For each polygon, determine the number of ways to draw non-intersecting diagonals inside it. Output a list of these counts.
**Input:**
- The first line contains an integer `T` (1 ≤ T ≤ 100), the number of test cases.
- Each of the next `... | To solve this problem, we need to count the number of **non-intersecting diagonal triangulations** of a convex polygon with `N` sides.
### Key Concept:
The number of ways to triangulate a convex polygon with `N` sides (i.e., drawing non-intersecting diagonals to divide it into `N-2` triangles) is given by the **(N-2)t... | algorithmic | evol-instruct | {"requirement_conformance": {"score": 5, "justification": "The solution fully meets the requirements by calculating the number of non-intersecting diagonals for each polygon in the list using the Catalan number formula."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct. The soluti... | ["\nassert non_intersecting_diagonals([3]) == [1]\n", "\nassert non_intersecting_diagonals([4]) == [1]\n", "\nassert non_intersecting_diagonals([5]) == [2]\n", "\nassert non_intersecting_diagonals([6]) == [5]\n", "\nassert non_intersecting_diagonals([7]) == [14]\n", "\nassert non_intersecting_diagonals([8]) == [42]\n",... | ["fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail"] | 0 |
a35b9faff916765db87cf32ed1fe1dbc | You are tasked with implementing a function `extract_emails` that identifies and extracts all valid email addresses from a provided text string. The function should utilize regular expressions to accurately match email addresses, accommodating various formats, including those with subdomains and special characters. You... | Here's a Python implementation of the `extract_emails` function using **regular expressions** to identify and extract all valid email addresses from a given text. The regex is designed to handle:
- Local parts with letters, digits, dots, underscores, and hyphens.
- Domains with subdomains and multiple levels (e.g., `m... | generic | self-instruct | {"requirement_conformance": {"score": 5, "justification": "The function fully meets the requirement by extracting email addresses from a given text using regular expressions and handling different email formats, including those with subdomains and special characters."}, "logical_correctness": {"score": 4, "justificatio... | ["\nassert extract_emails(\"contact@example.com\") == [\"contact@example.com\"]\n", "\nassert extract_emails(\"support@my-subdomain.example.co.uk\") == [\"support@my-subdomain.example.co.uk\"]\n", "\nassert extract_emails(\"admin@company.org\") == [\"admin@company.org\"]\n", "\nassert extract_emails(\"user.name+tag+sor... | ["pass", "pass", "pass", "pass", "pass", "fail", "pass", "pass", "pass", "pass"] | 0.9 |
3befca9a6d9ae69d1f6c548bf6cac1f7 | You are given a message encrypted using a modified Vigenere cipher. In this variant, the ASCII value of each character in the key is offset by a random integer between -5 and 5 before being used to shift the characters in the ciphertext. Your task is to decrypt the message. The key is repeated as necessary to match the... | To decrypt the message, we need to reverse the encryption process. Here's a step-by-step breakdown of the process:
---
### **Encryption Summary (Modified Vigenère Cipher):**
1. For each character in the key:
- Calculate the ASCII value of the character.
- Apply a random offset (between -5 and 5).
- Use the o... | generic | evol-instruct | {"requirement_conformance": {"score": 4, "justification": "The solution addresses the core requirement of decrypting a message encrypted with a modified Vigenere cipher, considering an offset for each key character. However, it assumes the alphabet is based on ASCII values (0-255) rather than strictly alphabetic charac... | ["\nassert decrypt_modified_vigenere(\"b\", \"a\", [1]) == \"a\"\n", "\nassert decrypt_modified_vigenere(\"a\", \"b\", [-1]) == \"a\"\n", "\nassert decrypt_modified_vigenere(\"f\", \"a\", [5]) == \"a\"\n", "\nassert decrypt_modified_vigenere(\"a\", \"f\", [-5]) == \"a\"\n", "\nassert decrypt_modified_vigenere(\"m\", \"... | ["fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail"] | 0 |
2ec799cdcce1ff1d9ceef1b7748fdce0 | You are tasked with designing a RESTful API using Flask to manage a simple to-do list application. The API must support the following operations:
1. **GET /tasks**: Retrieve all tasks.
2. **POST /tasks**: Create a new task. The request body must be a JSON object with at least a 'title' field.
3. **GET /tasks/<task_id>... | Here's a complete implementation of a **RESTful API for a To-Do List** using **Flask** in Python. This API supports all the required operations:
---
### ✅ **Features Implemented**
- GET `/tasks`: Retrieve all tasks.
- POST `/tasks`: Create a new task.
- GET `/tasks/<task_id>`: Retrieve a specific task.
- PUT `/tasks/... | generic | self-instruct | {"requirement_conformance": {"score": 5, "justification": "The solution fully meets all the specified requirements by implementing all the required RESTful API endpoints for managing a to-do list."}, "logical_correctness": {"score": 4, "justification": "The logic is largely correct and consistent, handling tasks approp... | ["\nassert get_tasks().json == {'tasks': [{'id': 1, 'title': 'Buy groceries', 'description': 'Milk, Cheese, Pizza, Fruit', 'done': False}, {'id': 2, 'title': 'Learn Python', 'description': 'Need to find a good Python tutorial on the web', 'done': False}]}\n", "\nassert get_task(1).json == {'task': {'id': 1, 'title': 'B... | ["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"] | 1 |
5eb796d9734418c88a24c07bc1ac0a73 | You are given a list of integers. Your task is to implement a function that computes the median of the list. The function should handle edge cases where the list is empty or contains only one element.
**Input:**
- A list of integers `lst` (0 ≤ len(lst) ≤ 10^5), where each integer `x` satisfies -10^9 ≤ x ≤ 10^9.
**Ou... | Here's a Python function that computes the **median** of a list of integers as described in your problem:
### ✅ Features:
- Handles empty list (raises `ValueError`)
- Handles single-element list
- Handles both **odd** and **even** length lists correctly
- Efficient for large lists (up to 100,000 elements)
---
### ✅ ... | generic | self-instruct | {"requirement_conformance": {"score": 5, "justification": "The function fully meets the requirements by calculating the median and handling edge cases where the list is empty or contains only one element."}, "logical_correctness": {"score": 5, "justification": "The logic for finding the median is completely correct and... | ["\nassert find_median([1, 3, 5]) == 3\n", "\nassert find_median([1, 3, 5, 7]) == 4.0\n", "\nassert find_median([1]) == 1\n", "\nassert find_median([7, 3, 1, 5]) == 4.0\n", "\nassert find_median([10, 20, 30, 40, 50]) == 30\n", "\nassert find_median([1, 2, 3, 4, 5, 6]) == 3.5\n", "\nassert find_median([5, 5, 5, 5, 5]) =... | ["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"] | 1 |
827041a2e7bc57c884acc86d5e271e4f | You are given a list of distinct items. Your task is to write a function `generate_combinations` that generates all possible combinations of these items. The function should return a list of lists, where each inner list represents a unique combination of the items. The order of the combinations in the output does not m... | You can solve this problem using **recursion** or **itertools**, but since you're asking for a function that generates all combinations, I'll provide a clean and efficient implementation using **itertools**.
### ✅ Solution using `itertools`
```python
import itertools
def generate_combinations(items):
combination... | generic | self-instruct | {"requirement_conformance": {"score": 5, "justification": "The function fully meets the requirement by generating all possible combinations of the input list and returning them as a list of lists."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optimally structured. It uses ... | ["\nassert generate_combinations([]) == [[]]\n", "\nassert generate_combinations(['a']) == [[], ['a']]\n", "\nassert generate_combinations(['a', 'b']) == [[], ['a'], ['b'], ['a', 'b']]\n", "\nassert generate_combinations(['a', 'b', 'c']) == [[], ['a'], ['b'], ['c'], ['a', 'b'], ['a', 'c'], ['b', 'c'], ['a', 'b', 'c']]\... | ["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"] | 1 |
99dbb44e76ad466dc936f7976fff75ff | You are given a task to develop a program that verifies the integrity of a file by comparing its SHA-1 hash with a provided hash value. The program should handle case sensitivity and special characters in filenames across different operating systems. Your program will receive two inputs: a filename and a SHA-1 hash val... | Here's a Python program that verifies the integrity of a file by computing its SHA-1 hash and comparing it to a provided hash. The program handles case sensitivity and special characters in filenames and works across different operating systems (Windows, macOS, Linux).
### ✅ Features:
- Accepts a filename and expected... | generic | evol-instruct | {"requirement_conformance": {"score": 4, "justification": "The solution addresses the main requirements of verifying file integrity using SHA-1 hash and handling filenames with case sensitivity and special characters. However, it does not explicitly handle cross-operating system differences in filename handling."}, "lo... | ["\nassert verify_file_integrity(\"testfile.txt\", \"da39a3ee5e6b4b0d3255bfef95601890afd80709\") == False\n", "\nassert verify_file_integrity(\"testfile.txt\", \"2ef7bde608ce5404e97d5f042f95f89f1c232871\") == True\n", "\nassert verify_file_integrity(\"TestFile.txt\", \"2ef7bde608ce5404e97d5f042f95f89f1c232871\") == Fal... | ["fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail"] | 0 |
34f8c8f01f1f5968c940ea7f26b7e7df | You are tasked with developing a Python function `extract_keywords` that processes a given text and returns a list of the most frequent keywords. The function should utilize the Natural Language Toolkit (NLTK) for text processing and keyword extraction. The keywords should be limited to nouns, adjectives, verbs, and ad... | Here's a Python function `extract_keywords` that meets your requirements. It uses **NLTK** for tokenization, part-of-speech tagging, and filtering out stopwords and punctuation. The function then returns the top `n` most frequent keywords based on the specified parts of speech: **nouns**, **adjectives**, **verbs**, and... | generic | self-instruct | {"requirement_conformance": {"score": 5, "justification": "The function fully meets the requirements by extracting the most frequent keywords from the input text using NLTK. It also allows specifying the number of top keywords to return."}, "logical_correctness": {"score": 5, "justification": "The logic is completely c... | ["\nassert extract_keywords(\"The quick brown fox jumps over the lazy dog.\") == ['quick', 'brown', 'fox', 'jumps', 'lazy']\n", "\nassert extract_keywords(\"Python is great and Python is fun.\", top_n=2) == ['python', 'great']\n", "\nassert extract_keywords(\"NLTK is a leading platform for building Python programs to w... | ["fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail"] | 0 |
9be1cf77ab32f990d408e770baaa4d7c | You are tasked with implementing a function `filter_even_numbers` that processes a list of integers. Your goal is to return a new list consisting solely of the even numbers from the provided list. The current implementation utilizes a `for` loop, but you must refactor it to use a list comprehension.
**Input:**
- A li... | Certainly! You can refactor the function `filter_even_numbers` to use a **list comprehension** for a more concise and Pythonic implementation.
### ✅ **List Comprehension Version**
```python
def filter_even_numbers(numbers):
return [num for num in numbers if num % 2 == 0]
```
### 🔍 **Explanation:**
- The list co... | generic | self-instruct | {"requirement_conformance": {"score": 5, "justification": "The solution fully meets the requirement by rewriting the function using a list comprehension to filter even numbers."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optimally structured, using a list comprehension t... | ["\nassert filter_even_numbers([1, 2, 3, 4, 5, 6]) == [2, 4, 6]\n", "\nassert filter_even_numbers([10, 15, 20, 25, 30]) == [10, 20, 30]\n", "\nassert filter_even_numbers([11, 13, 17, 19]) == []\n", "\nassert filter_even_numbers([]) == []\n", "\nassert filter_even_numbers([0, -2, -4, -5]) == [0, -2, -4]\n", "\nassert fi... | ["fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail"] | 0 |
04e293f6f763e88e5c21786341ec7c2b | You are given a positive integer \( n \). Your task is to implement a function that computes the \( n \)-th Fibonacci number using memoization. The Fibonacci sequence is defined as follows: \( F(1) = 1 \), \( F(2) = 1 \), and \( F(n) = F(n-1) + F(n-2) \) for \( n > 2 \).
**Input:**
- A single integer \( n \) (1 ≤ \( n... | Here's a Python function that computes the $ n $-th Fibonacci number using **memoization**. Memoization is used to store previously computed Fibonacci numbers to avoid redundant calculations and improve performance.
### ✅ Python Code:
```python
def fibonacci(n, memo={}):
if n in memo:
return memo[n]
if... | algorithmic | self-instruct | {"requirement_conformance": {"score": 4, "justification": "The solution meets the basic requirement of calculating the nth Fibonacci number using memoization. However, it does not handle the case when n is less than 1, which is not specified in the question but is an important edge case."}, "logical_correctness": {"sco... | ["\nassert fibonacci(1) == 1\n", "\nassert fibonacci(2) == 1\n", "\nassert fibonacci(3) == 2\n", "\nassert fibonacci(4) == 3\n", "\nassert fibonacci(5) == 5\n", "\nassert fibonacci(6) == 8\n", "\nassert fibonacci(7) == 13\n", "\nassert fibonacci(8) == 21\n", "\nassert fibonacci(9) == 34\n", "\nassert fibonacci(10) == 5... | ["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"] | 1 |
f4480f0cf22a893ec64202a8ea7443f2 | You are tasked with implementing a function `parse_log_entry(entry)` that processes a log entry string and extracts specific components. The log entry is formatted as `"[timestamp] [log_level] message"`. Your function should return a dictionary with keys `timestamp`, `log_level`, and `message` corresponding to the extr... | Here's the implementation of the `parse_log_entry(entry)` function in Python. It uses string splitting and validation to extract the `timestamp`, `log_level`, and `message` from a log entry string in the format `"[timestamp] [log_level] message"`:
```python
def parse_log_entry(entry):
parts = entry.strip().split('... | generic | self-instruct | {"requirement_conformance": {"score": 4, "justification": "The function meets the basic requirements by parsing the log entry into a dictionary with the correct keys. However, it does not handle the case where the timestamp and log level are not enclosed in square brackets as specified in the question."}, "logical_corr... | ["\nassert parse_log_entry(\"2023-04-01 12:34:56 [INFO] Server started successfully\") == {\"timestamp\": \"2023-04-01 12:34:56\", \"log_level\": \"INFO\", \"message\": \"Server started successfully\"}\n", "\nassert parse_log_entry(\"[2023-04-01 12:34:56] [INFO] Server started successfully\") == {}\n", "\nassert parse_... | ["fail", "fail", "pass", "pass", "fail", "fail", "fail", "fail", "pass", "pass"] | 0.4 |
a97cf0c3abad742b13e37f737696cb61 | You are tasked with implementing a `Car` class in Python to simulate a car's attributes and behaviors. The class should encapsulate the following properties: `make`, `model`, `year`, and `mileage`. Your implementation should include the following methods:
- `drive(distance: int)`: This method should increase the car's... | Here's the implementation of the `Car` class in Python according to your specifications:
```python
class Car:
def __init__(self, make: str, model: str, year: int, mileage: int):
self.make = make
self.model = model
self.year = year
self.mileage = mileage
def drive(self, distance... | generic | self-instruct | {"requirement_conformance": {"score": 5, "justification": "The class Car fully meets all the specified requirements by including the attributes make, model, year, and mileage, and the methods drive, update_year, and display_info."}, "logical_correctness": {"score": 5, "justification": "The logic of the class is complet... | ["\nassert Car(\"Toyota\", \"Corolla\", 2020, 15000).make == \"Toyota\"\n", "\nassert Car(\"Toyota\", \"Corolla\", 2020, 15000).model == \"Corolla\"\n", "\nassert Car(\"Toyota\", \"Corolla\", 2020, 15000).year == 2020\n", "\nassert Car(\"Toyota\", \"Corolla\", 2020, 15000).mileage == 15000\n", "\ncar = Car(\"Honda\", \... | ["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"] | 1 |
08fe2029a1043378709beee20b45f7b3 | You are given a list of integers. Your task is to determine the length of the longest increasing subsequence within this list. An increasing subsequence is defined as a sequence where each element is strictly greater than the preceding one. For example, in the list `[10, 9, 2, 5, 3, 7, 101, 18]`, the longest increasing... | We can solve the problem of finding the **length of the longest increasing subsequence (LIS)** using **dynamic programming** with a time complexity of **O(n log n)**, which is efficient for the given input size (up to 2500 elements).
### Approach:
We maintain a list `sub` where each element represents the smallest pos... | generic | self-instruct | {"requirement_conformance": {"score": 5, "justification": "The function correctly implements the logic to find the length of the longest increasing subsequence as specified in the question."}, "logical_correctness": {"score": 5, "justification": "The logic used in the function is completely correct and consistently str... | ["\nassert longest_increasing_subsequence([10, 9, 2, 5, 3, 7, 101, 18]) == 4\n", "\nassert longest_increasing_subsequence([0, 1, 0, 3, 2, 3]) == 4\n", "\nassert longest_increasing_subsequence([7, 7, 7, 7, 7, 7, 7]) == 1\n", "\nassert longest_increasing_subsequence([1, 2, 3, 4, 5]) == 5\n", "\nassert longest_increasing_... | ["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"] | 1 |
f9fcb503e66d124039403bcd09fadff1 | You are given a text file named `input.txt` containing a body of text. Your task is to write a Python script that reads this file, counts the occurrences of each word (ignoring case and punctuation), and writes the results to another file named `output.txt`. Each line in the output file should contain a word followed b... | Here's a Python script that performs the task as described:
### ✅ Features:
- Reads from `input.txt`
- Ignores **case** (e.g., "Hello" and "hello" are treated as the same word)
- Strips **punctuation** (e.g., "Hello," becomes "hello")
- Counts word occurrences
- Writes results to `output.txt`, sorted **alphabetically*... | algorithmic | self-instruct | {"requirement_conformance": {"score": 5, "justification": "The script fully meets all specified requirements by reading from an input file, counting word occurrences while ignoring case and punctuation, and writing the results to an output file."}, "logical_correctness": {"score": 5, "justification": "The logic is comp... | ["\nassert open('output.txt').read() == \"a 2\\nhello 1\\nworld 1\\n\" after count_words('input1.txt', 'output.txt') with 'input1.txt' containing \"Hello, world! a\\na\"\n", "\nassert open('output.txt').read() == \"test 2\\nthis 1\\n\" after count_words('input2.txt', 'output.txt') with 'input2.txt' containing \"Test th... | ["fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail"] | 0 |
da38a635d02525b50785630fbb94d678 | You are tasked with writing a Python program to generate the first `N` prime numbers. Implement a function to check if a number is prime and use it to generate the required list of prime numbers. Your program should output the first `N` prime numbers in ascending order.
**Input:**
- An integer `N` (1 ≤ N ≤ 100), repre... | Here's a Python program that generates the first `N` prime numbers. It includes a function to check if a number is prime and uses it to build a list of the first `N` primes.
```python
def is_prime(num):
"""Check if a number is prime."""
if num < 2:
return False
for i in range(2, int(num ** 0.5) + 1... | generic | self-instruct | {"requirement_conformance": {"score": 5, "justification": "The solution fully meets the requirement by generating a list of the first 20 prime numbers using a function to check if a number is prime."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optimally structured. The fu... | ["\nassert generate_primes(0) == []\n", "\nassert generate_primes(1) == [2]\n", "\nassert generate_primes(2) == [2, 3]\n", "\nassert generate_primes(5) == [2, 3, 5, 7, 11]\n", "\nassert generate_primes(10) == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]\n", "\nassert generate_primes(15) == [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, ... | ["fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail"] | 0 |
9db0281651185ed79c41a6c5a2d82538 | You are given a binary tree. Your task is to find the node whose children have the maximum greatest common divisor (GCD) among all pairs of siblings in the tree, with the additional condition that the sum of the values of the siblings must be a prime number. Return the value of such a node. If no such siblings exist, r... | To solve this problem, we need to:
1. Traverse the binary tree.
2. For each node, check if it has **two children** (left and right).
3. For each such node, compute the **GCD** of its children's values.
4. Check if the **sum of the children's values is a prime number**.
5. Track the **maximum GCD** among all nodes that... | algorithmic | evol-instruct | {"requirement_conformance": {"score": 4, "justification": "The solution addresses the main requirements of finding the node with the maximum GCD of its siblings where the sum of the siblings is a prime number. However, it does not explicitly ensure a single pass through the binary tree, as it uses a depth-first search ... | ["\nassert find_max_gcd_with_prime_siblings(TreeNode(10, TreeNode(2, TreeNode(3), TreeNode(7)), TreeNode(14, TreeNode(8), TreeNode(9)))) == 2\n", "\nassert find_max_gcd_with_prime_siblings(TreeNode(5, TreeNode(3, TreeNode(1), TreeNode(2)), TreeNode(7, TreeNode(4), TreeNode(6)))) == 1\n", "\nassert find_max_gcd_with_pri... | ["fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail", "fail"] | 0 |
173227f52279d285bba17a592c052fc5 | You are given a CSV file named `data.csv` with the first row containing column headers and subsequent rows containing numerical data. Your task is to write a Python program that reads this file, calculates the average of each numerical column, and prints the results in a formatted table. If a column contains non-numeri... | Here's a Python program that reads a CSV file (`data.csv`), calculates the average of each numerical column, and prints the results in a formatted table. It handles non-numeric values by skipping them and outputs `"N/A"` for columns with no valid numeric data.
### ✅ Python Code:
```python
import csv
import os
def ca... | generic | self-instruct | {"requirement_conformance": {"score": 5, "justification": "The solution fully meets all specified requirements. It reads a CSV file, calculates the average of each column, and displays the results in a formatted table."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optimall... | ["\nassert read_csv('data.csv')['Column1'] == [1.0, 2.0, 3.0]\n", "\nassert read_csv('data.csv')['Column2'] == [4.0, 5.0, 6.0]\n", "\nassert calculate_averages({'Column1': [1.0, 2.0, 3.0]}) == {'Column1': 2.0}\n", "\nassert calculate_averages({'Column2': [4.0, 5.0, 6.0]}) == {'Column2': 5.0}\n", "\nassert calculate_ave... | ["fail", "fail", "pass", "pass", "pass", "pass", "pass", "pass", "fail", "pass"] | 0.7 |
End of preview. Expand in Data Studio
Generated dataset
This dataset was pushed from existing parquet chunks with the following command:
python push_only.py --work_dir ./regen_melhoushi__OpenCodeInstruct-Qwen3-32B-nothink --output_repo melhoushi/OpenCodeInstruct-Qwen3-32B-nothink
Parameters
- work_dir:
./regen_melhoushi__OpenCodeInstruct-Qwen3-32B-nothink - output_repo:
melhoushi/OpenCodeInstruct-Qwen3-32B-nothink - dataset_config:
None - split:
train - private:
False
Notes
This README was generated automatically by the standalone push-only script.
- Downloads last month
- 41