id stringlengths 32 32 | input stringlengths 181 3.45k | output stringlengths 284 35.2k | 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 an implementation of the **selection sort** algorithm in Python, as requested. The function `custom_sort` will sort the input list in ascending order.
### ✅ Selection Sort Implementation:
```python
def custom_sort(arr):
# Selection Sort implementation
n = len(arr)
for i in range(n):
# Find ... | 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** in a **directed graph** that **maximizes the total profit minus the total cost**. Each node has a **profit**, and each edge has a **cost**. So, for any path, the total value is:
$$
\text{Total Value} = \sum (\text{profit of nodes}) - \sum (\text{co... | 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 a tree structure in the console, with each level indented by two spaces:
```python
def print_tree(tree, root, indent=0):
print(" " * indent + root)
for child in tree[root]:
print_tree(tree, child, indent + 1)
# Example usage:
tree = {
"root": ["child1", "child... | 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 in a **logarithmic spiral** constellation, we need to:
1. **Understand the logarithmic spiral**:
The equation of a logarithmic spiral is:
$$
r = a \cdot e^{b \cdot \theta}
$$
where:
- `r` is the radial distance from the origin.
- `θ` is the angle in radians.
... | 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 meets your requirements:
```python
def count_vowels_consonants(s):
vowels = set("aeiouAEIOU")
vowels_count = 0
consonants_count = 0
for char in s:
if char.isalpha():
if char in vowels:
vowels_count += 1
else:
... | 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** of nodes in a hypergraph using a provided centrality measure function `func`, we need to:
1. **Convert the hypergraph into a NetworkX Graph**.
2. **Apply the given centrality function** to the graph.
3. **Return the result as a dictionary**.
However, there's a key point to clarify: **s... | 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... | To solve this problem, we need to:
1. **Identify even numbers** in the given sequence.
2. **Check if the sequence is a list or tuple** and contains **more than 5 even numbers**.
3. If so, **sort the even numbers in ascending order** and compute their **sum**.
4. Otherwise, just **sum the even numbers** as usual.
Here... | 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... | Here's the implementation of the `generate_combinations` function that meets your requirements:
```python
import itertools
def generate_combinations(elements, n):
# Check if n is greater than the length of elements
if n > len(elements):
return []
# Generate all combinations of size n using it... | 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, including error handling and a clean string representation:
```python
class Matrix:
def __init__(self, data):
# Validate input
if not all(isinstance(row, list) for row in data):
r... | 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 ... | To rotate the numbers such that:
- `a` → second position
- `b` → third position
- `c` → first position
We can achieve this by returning a tuple in the order `(c, a, b)`.
Here's the implementation of the function:
```python
def rotate_numbers(a, b, c):
return (c, a, b)
```
### Example:
```python
print(rotate_n... | 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 a Python function `is_palindrome` that meets your requirements:
### ✅ Key Points:
- **No regex or built-in string methods** for removing non-alphanumeric characters.
- **Case-insensitive** comparison.
- **In-place processing** to avoid extra memory usage.
- Efficient for large strings (up to 100,000 characters)... | 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 (excluding the specified stop words), and prints the results in descending order of frequency.
### ✅ Python Code:
```python
from collections import Counter
import re
# List of stop words (case-insensitive)
stop_words = {"the", ... | 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 that meets all the specified 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... | 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 calculating the **total overlap between all pairs of intervals**, we can follow these steps:
---
### ✅ **Approach:**
1. **Sort the intervals** by their **start points**.
2. For **each pair of intervals**, compute the **overlap** between them.
3. Sum up the overlaps for all **unordered pairs**... | 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 find the **Least Common Multiple (LCM)** of two integers $ N $ and $ M $, which represents the **minimum amount** both Chef and Chefu must spend such that they each pay the same amount using their respective coin denominations.
### Key Insight:
The **LCM** of two numbers $ N $ and $ M... | 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 fulfills your requirements. It reads a JSON file, prompts the user for the filename and key, and handles the specified error scenarios.
```python
import json
import os
def read_json_value(filename, key):
try:
# Check if the file exists
if not os.path.exists(filename):
... | 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 ... | Here's a Python function that implements the `extract_keywords` function as described. It processes the input text to extract the top `num_keywords` most frequent words, handling punctuation and being case-insensitive.
```python
import re
from collections import Counter
from typing import List
def extract_keywords(te... | 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... | To solve this optimization problem using a **Genetic Algorithm (GA)**, we need to follow these steps:
### **Key Concepts:**
- **Fitness Function:** `f(x1, x2, ..., xn) = x1² + x2² + ... + xn²`
- **Goal:** Minimize the function, so **lower fitness is better**.
- **Constraints:** Each `xi` must be an integer between 1 a... | 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 process each tuple in the list `T` as follows:
1. **Remove the first word** from the tuple.
2. **Append a new word** from the list `W`:
- The new word must **not already be in the tuple**.
- It should be the **next word in `W` in a circular manner** (i.e., wrap around to the beg... | 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 the 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:
- We iterate through the keys of `dict1`.
... | 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 compute the number of ways to draw **non-intersecting diagonals** inside a convex polygon with `N` sides. This is a well-known combinatorial problem related to **Catalan numbers**.
---
### 🧠 Key Insight:
The number of ways to draw **non-intersecting diagonals** in a convex polygon ... | 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... | To solve the problem of extracting valid email addresses from a text string, we can use **regular expressions (regex)**. The goal is to match valid email formats while being flexible enough to handle common variations, such as subdomains, special characters in the local part, and multiple dots in the domain.
### ✅ **R... | 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 of the modified Vigenère cipher. Here's how it works:
### **Encryption Process Recap (Modified Vigenère Cipher):**
1. Each character in the **key** is first offset by a value from the `offsets` list.
2. The ASCII value of the key character is adjusted b... | 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 using **Flask** to manage a simple to-do list application, based on your requirements.
---
## ✅ Requirements
- **Python 3.7+**
- **Flask** (Install via `pip install flask`)
- **Flask-RESTful** (Optional, but can be used for better structure)
---
## 📁 Project Struc... | 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, with proper handling of edge cases such as an empty list.
### ✅ Function Implementation:
```python
def compute_median(lst):
if not lst:
raise ValueError("The list is empty")
# Sort the list
lst_sorted = sorted(lst)
... | 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 use Python's `itertools` module to generate all possible combinations of different lengths (from 0 to the length of the list). Here's the implementation of the `generate_combinations` function:
```python
import itertools
def generate_combinations(items):
combinations = []
for r in range(len(items) + 1... | 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 comparing its SHA-1 hash with a provided hash value. It handles case sensitivity and special characters in filenames, and works across different operating systems.
### ✅ Python Code:
```python
import hashlib
def compute_sha1_hash(filename):
"""Comp... | 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 processes the given text using **NLTK** to extract the top `n` most frequent keywords, limited to **nouns, adjectives, verbs, and adverbs**, while ignoring **stopwords** and **punctuation**.
### ✅ Requirements:
- Install NLTK if not already installed:
```bash
pip in... | 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... | To refactor the function `filter_even_numbers` from using a `for` loop to using a **list comprehension**, we can take advantage of the concise syntax that list comprehensions provide in Python.
Here's the implementation:
```python
def filter_even_numbers(numbers):
return [num for num in numbers if num % 2 == 0]
`... | 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... | To compute the $ n $-th Fibonacci number efficiently using **memoization**, we can use a recursive approach with a dictionary to store already computed values. This avoids redundant calculations and significantly improves performance, especially for larger values of $ n $.
Here's the Python implementation:
```python
... | 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 a Python function `parse_log_entry(entry)` that processes a log entry string according to the specified format and returns the appropriate dictionary:
```python
def parse_log_entry(entry):
# Split the entry into parts
parts = entry.split(" [", 1) # Split only once to separate timestamp from the rest
... | 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 that meets all the requirements:
```python
class Car:
def __init__(self, make, model, year, mileage):
self.make = make
self.model = model
self.year = year
self.mileage = mileage
def drive(self, distance):
"""Increas... | 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... | To solve the problem of finding the **length of the longest increasing subsequence (LIS)** in a list of integers, we can use an efficient algorithm with **O(n log n)** time complexity.
### ✅ **Approach:**
We maintain a list `tails`, where `tails[i]` represents the smallest possible tail value of an increasing subseque... | 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 reads the `input.txt` file, processes the text to count word occurrences (ignoring case and punctuation), and writes the sorted results to `output.txt`.
### ✅ Python Script:
```python
import string
from collections import Counter
def process_text(file_path):
with open(file_path, 'r') ... | 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 helper function to check if a number is prime and uses it to generate the list of primes.
### ✅ Python Code:
```python
def is_prime(n):
"""Check if a number is prime."""
if n <= 1:
return False
if n <= 3:
ret... | 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** and identify **sibling pairs** (i.e., two children of the same parent).
2. For each such pair, check:
- Their **sum is a prime number**.
- Their **GCD**.
3. Track the **node whose children have the maximum GCD** under the above condition.
4. If n... | 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 the `data.csv` file, calculates the average for each numerical column, and prints the results in a formatted table. It also handles non-numeric and empty data appropriately.
```python
import csv
def calculate_column_averages(file_path):
with open(file_path, 'r') as file:
... | 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-8B-nothink --output_repo melhoushi/OpenCodeInstruct-Qwen3-8B-nothink --split train --delete_existing_repo
Parameters
- work_dir:
./regen_melhoushi__OpenCodeInstruct-Qwen3-8B-nothink - output_repo:
melhoushi/OpenCodeInstruct-Qwen3-8B-nothink - dataset_config:
None - split:
train - private:
False
Notes
This README was generated automatically by the standalone push-only script.
- Downloads last month
- 99