Dataset Viewer
Auto-converted to Parquet Duplicate
input
stringlengths
137
5.36k
output
stringlengths
79
6.43k
llm_judgement
stringlengths
400
2.38k
unit_tests
stringlengths
244
10.9k
tests_execution_status
stringclasses
11 values
average_test_score
stringclasses
2 values
You are given a singly linked list. Your task is to reverse the linked list in place and return the new head of the reversed list. The linked list is defined by the `ListNode` class, where each node contains an integer value and a pointer to the next node. **Input:** - The head of a singly linked list. **Output:** - ...
```python class ListNode: def __init__(self, value=0, next=None): self.value = value self.next = next def reverse_linked_list(head): """ Reverses a singly linked list in place. :param head: ListNode, the head of the linked list to be reversed. :return: ListNode, the head of the rev...
{"requirement_conformance": {"score": 5, "justification": "The solution fully meets the requirement of reversing a linked list in place. It correctly implements the logic to reverse the pointers of the linked list nodes."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optima...
["\nassert reverse_linked_list(None) is None\n", "\nassert reverse_linked_list(ListNode(1)).value == 1 and reverse_linked_list(ListNode(1)).next is None\n", "\nassert reverse_linked_list(ListNode(1, ListNode(2))).value == 2 and reverse_linked_list(ListNode(1, ListNode(2))).next.value == 1 and reverse_linked_list(ListNo...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are tasked with implementing a Python class `FileProcessor` designed to handle text file operations. The class should support the following functionalities: - **Initialization**: Accept a file path as input. - **File Reading**: Read the contents of the file and store it internally. - **Word Count**: Return the tot...
```python class FileProcessor: def __init__(self, file_path): """ Initialize the FileProcessor with a file path. :param file_path: Path to the text file. """ self.file_path = file_path self.file_contents = None def read_file(self): """ Re...
{"requirement_conformance": {"score": 5, "justification": "The class `FileProcessor` meets all the specified requirements: it has an `__init__` method to initialize with a file path, a `read_file` method to read the file contents, a `count_words` method to count the words, and a `find_longest_word` method to find the l...
["\nassert FileProcessor(\"test.txt\").count_words() == 0\n", "\nassert FileProcessor(\"test.txt\").find_longest_word() == \"\"\n", "\nfp = FileProcessor(\"test.txt\")\nfp.file_contents = \"hello world\"\nassert fp.count_words() == 2\n", "\nfp = FileProcessor(\"test.txt\")\nfp.file_contents = \"hello world\"\nassert fp...
["pass", "pass", "pass", "pass", "pass", "fail", "pass", "pass", "pass", "pass"]
0.9
Given a list of integers `nums` and an integer `target`, your task is to find the first pair of numbers in the list that add up to the `target`. The function should return this pair as a tuple. If no such pair exists, return `None`. Note that the list may contain duplicate numbers and is guaranteed to be non-empty. **...
```python from typing import List, Optional, Tuple def find_pair(nums: List[int], target: int) -> Optional[Tuple[int, int]]: """ Finds the first pair of numbers in the list that add up to the target. :param nums: List of integers. :param target: The target sum to find in the list. :return: A t...
{"requirement_conformance": {"score": 5, "justification": "The solution fully meets the requirements by returning a tuple of the first pair of numbers that add up to the target or None if no such pair exists."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optimally structur...
["\nassert find_pair([2, 7, 11, 15], 9) == (2, 7)\n", "\nassert find_pair([3, 2, 4], 6) == (2, 4)\n", "\nassert find_pair([3, 3], 6) == (3, 3)\n", "\nassert find_pair([1, 2, 3, 4, 5], 10) == None\n", "\nassert find_pair([1, 2, 3, 4, 5], 8) == (3, 5)\n", "\nassert find_pair([10, 15, 3, 7], 17) == (10, 7)\n", "\nassert f...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "fail"]
0.9
You are participating in a bioinformatics competition where you need to process FASTQ files. FASTQ is a standard file format for storing high-throughput sequencing data. Each FASTQ file contains sequences with two reads: a forward read (R1) and a reverse read (R2). Your task is to write a function `validate_and_order_...
```python def validate_and_order_fastq_files( lib1_r1, lib1_r2, lib2_r1, lib2_r2, lib3_r1, lib3_r2, lib4_r1, lib4_r2 ): """ Validates and orders the FASTQ files according to the specified library and read order. Args: lib1_r1 (str): Path to Library 1, Read 1 (R1). lib1_r...
{"requirement_conformance": {"score": 5, "justification": "The function fully meets all specified requirements by accepting eight arguments representing the FASTQ files for four libraries and two reads each, and returns them in the correct order. It also validates the file names according to the specified naming conven...
["\nassert validate_and_order_fastq_files(\"lib1_r1.fastq\", \"lib1_r2.fastq\", \"lib2_r1.fastq\", \"lib2_r2.fastq\", \"lib3_r1.fastq\", \"lib3_r2.fastq\", \"lib4_r1.fastq\", \"lib4_r2.fastq\") == [\"lib1_r1.fastq\", \"lib1_r2.fastq\", \"lib2_r1.fastq\", \"lib2_r2.fastq\", \"lib3_r1.fastq\", \"lib3_r2.fastq\", \"lib4_r...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are given a list `lst` of integers and three integers `start_idx`, `end_idx`, and `new_val`. Your task is to modify the list in-place by replacing all elements from index `start_idx` (inclusive) to `end_idx` (exclusive) with the value `new_val`. The function should not use any additional space other than a constant...
```python def replace_elements_in_list(lst, start_idx, end_idx, new_val): """ Replaces elements in the list `lst` from index `start_idx` (inclusive) to `end_idx` (exclusive) with `new_val`. :param lst: List of integers to be modified. :param start_idx: Starting index for replacement (inclusive). ...
{"requirement_conformance": {"score": 4, "justification": "The function correctly replaces elements from start_idx to end_idx with new_val and returns the modified list. However, it does not explicitly state that the operation is done in-place, which is an additional requirement."}, "logical_correctness": {"score": 5, ...
["\nassert replace_elements_in_list([1, 2, 3, 4, 5], 1, 3, 0) == [1, 0, 0, 4, 5]\n", "\nassert replace_elements_in_list([10, 20, 30, 40, 50], 0, 2, 99) == [99, 99, 30, 40, 50]\n", "\nassert replace_elements_in_list([7, 8, 9], 1, 2, 100) == [7, 100, 9]\n", "\nassert replace_elements_in_list([1, 1, 1, 1, 1], 2, 5, 2) == ...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are tasked with developing a Python function `generate_report` that processes a log file named `app.log`. The function should analyze the log entries and produce a report in a new file named `report.txt`. The report must include: - The total number of log entries. - The number of unique log messages. - The most fre...
```python def generate_report(): """ Reads a log file named 'app.log', analyzes the log entries, and generates a report in 'report.txt'. The report includes the total number of log entries, the number of unique log messages, and the most frequently occurring log message. """ from collections imp...
{"requirement_conformance": {"score": 5, "justification": "The function fully meets all specified requirements by reading the log file, analyzing the log entries, and generating a report with the total number of log entries, the number of unique log messages, and the most frequently occurring log message."}, "logical_c...
["\nassert open('report.txt').read().strip() == \"Total number of log entries: 0\\nNumber of unique log messages: 0\\nMost frequently occurring log message: 'None' (occurred 0 times)\"\n", "\nwith open('app.log', 'w') as file:\n file.write(\"Error: Something went wrong\\n\")\ngenerate_report()\nassert open('report.t...
["fail", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
0.9
You are given a URL string representing a link to an academic paper on a hypothetical repository. The URL format is strictly defined as follows: - The URL begins with `https://hypothetical-academic-repository.com/`. - Immediately following the domain, there is a 4-digit number representing the publication year. Your ...
```python def extract_year_from_url(url: str) -> int: """ Extracts the publication year from a given URL string. Args: url (str): The URL string from which to extract the year. Returns: int: The extracted publication year if the URL format is correct, otherwise 0. """ prefix = ...
{"requirement_conformance": {"score": 5, "justification": "The function fully meets the specified requirements by checking the URL format and extracting the year correctly."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and consistently handles the extraction of the year from t...
["\nassert extract_year_from_url(\"https://hypothetical-academic-repository.com/2022/paper123\") == 2022\n", "\nassert extract_year_from_url(\"https://hypothetical-academic-repository.com/1999/paper456\") == 1999\n", "\nassert extract_year_from_url(\"https://hypothetical-academic-repository.com/2000/\") == 2000\n", "\n...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are given a list of integers. Your task is to implement a function `get_unique_items_with_frequency(lst)` that processes this list by first removing any integers divisible by 3. Then, construct a dictionary where each key is a unique integer from the modified list, and the corresponding value is the frequency of th...
```python def get_unique_items_with_frequency(lst): """ Processes a list of integers by removing those divisible by 3, then returns a dictionary with unique integers as keys and their frequencies as values. :param lst: List of integers :return: Dictionary with unique integers and their frequencies ...
{"requirement_conformance": {"score": 4, "justification": "The function meets the basic requirements by filtering out integers divisible by 3 and counting the frequency of each unique item. However, it does not explicitly state that it is removing integers divisible by 3 in the comments, which could be considered a min...
["\nassert get_unique_items_with_frequency([1, 2, 3, 4, 5, 6]) == {1: 1, 2: 1, 4: 1, 5: 1}\n", "\nassert get_unique_items_with_frequency([3, 6, 9, 12]) == {}\n", "\nassert get_unique_items_with_frequency([10, 20, 30, 40, 50]) == {10: 1, 20: 1, 40: 1, 50: 1}\n", "\nassert get_unique_items_with_frequency([1, 1, 2, 2, 3, ...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are given two nested lists: `user_skills` and `required_skills`. Each list can contain strings representing skills or other nested lists of skills. Your task is to determine if there is at least one skill in `user_skills` that matches any skill in `required_skills` at any depth. Implement the function `can_perform_...
```python def flatten_list(nested_list): """ Flattens a nested list into a single list of elements. :param nested_list: A list that may contain nested lists of strings. :return: A flat list of strings. """ flat_list = [] for item in nested_list: if isinstance(item, list): ...
{"requirement_conformance": {"score": 5, "justification": "The solution fully meets the requirements by implementing the function `can_perform_task` that handles nested lists and checks for at least one matching skill between `user_skills` and `required_skills`."}, "logical_correctness": {"score": 5, "justification": "...
["\nassert can_perform_task(['Python'], ['Java', 'Python']) == True\n", "\nassert can_perform_task(['Python'], ['Java', ['Python']]) == True\n", "\nassert can_perform_task(['Python'], ['Java', ['C++']]) == False\n", "\nassert can_perform_task(['Python', ['Data Science']], ['Java', ['Data Science']]) == True\n", "\nasse...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "fail"]
0.9
You are given a string `text`. Your task is to implement a function `compress_spaces` that processes the string according to the following rules: 1. Replace any sequence of one or more whitespace characters with a single space. 2. Remove any leading or trailing spaces. 3. Ensure that no two consecutive punctuation mark...
```python import re def compress_spaces(text): """ Processes the input string by replacing sequences of whitespace with a single space, removing leading and trailing spaces, and ensuring no two consecutive punctuation marks are adjacent. :param text: The input string to be processed. :return: ...
{"requirement_conformance": {"score": 5, "justification": "The function fully meets all specified requirements: replacing sequences of whitespace with a single space, removing leading/trailing spaces, and ensuring no two consecutive punctuation marks are adjacent."}, "logical_correctness": {"score": 5, "justification":...
["\nassert compress_spaces(\"Hello, world! This is... a test.\") == \"Hello, world! This is. a test.\"\n", "\nassert compress_spaces(\" Leading and trailing spaces \") == \"Leading and trailing spaces\"\n", "\nassert compress_spaces(\"Multiple... punctuation!!!\") == \"Multiple. punctuation!\"\n", "\nassert co...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are given a dictionary `d` and a default value `default`. Implement a function `dict_func_map` that returns a function `mapper`. The `mapper` function should map each integer `x` in a list `lst` to the value in `d` if `x` is a key. If `x` is not a key, it should return `default`. The dictionary `d` can contain nest...
```python def dict_func_map(d, default): """ Returns a function that maps each integer x in a list to the value in d if x is a key. If x is not a key, it returns the default value. Supports nested dictionaries up to one level of depth. :param d: Dictionary with integer keys and integer or nested di...
{"requirement_conformance": {"score": 3, "justification": "The solution meets the basic requirements of mapping values from a dictionary and handling nested dictionaries up to one level of depth. However, it does not fully support the requirement of handling exceptions when accessing dictionary values."}, "logical_corr...
["\nassert dict_func_map({1: 2, 2: {2: 4, 3: 5}, 3: 6}, 0)(1) == 2\n", "\nassert dict_func_map({1: 2, 2: {2: 4, 3: 5}, 3: 6}, 0)(2) == 4\n", "\nassert dict_func_map({1: 2, 2: {2: 4, 3: 5}, 3: 6}, 0)(3) == 6\n", "\nassert dict_func_map({1: 2, 2: {2: 4, 3: 5}, 3: 6}, 0)(4) == 0\n", "\nassert dict_func_map({1: {1: 10, 2: ...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "fail", "pass", "pass"]
0.9
You are developing a simulation for a slot machine with three reels. Each reel displays one of six symbols: 'A', 'B', 'C', 'D', 'E', 'F'. The probability of each symbol appearing on a reel is given by the weights: [0.10, 0.20, 0.15, 0.20, 0.20, 0.15]. The slot machine pays out as follows: - 'A', 'A', 'A': 7.5x - 'B', '...
```python import random # Define Reel Symbols and their Weights (probabilities) symbols = ['A', 'B', 'C', 'D', 'E', 'F'] weights = [0.10, 0.20, 0.15, 0.20, 0.20, 0.15] # total = 1.00, weights must sum to 1 # Payouts for different combinations payouts = { ('A', 'A', 'A'): 7.5, ('B', 'B', 'B'): 5.0, ('C', ...
{"requirement_conformance": {"score": 5, "justification": "The solution fully meets all specified requirements. It simulates a slot machine with three reels, uses the given symbol probabilities, calculates payouts for specific combinations, and computes the average payout over 10,000 games."}, "logical_correctness": {"...
["\nassert isinstance(calculate_average_payout(), float)\n", "\nassert 0 <= calculate_average_payout() <= 7.5\n", "\nassert calculate_average_payout(1) >= 0\n", "\nassert calculate_average_payout(10000) != 0\n", "\nassert calculate_average_payout(1000) < calculate_average_payout(10000)\n", "\nassert calculate_average_p...
["pass", "pass", "pass", "pass", "pass", "fail", "pass", "pass", "pass", "pass"]
0.9
You are tasked with implementing a `Bookstore` class that manages a bookstore's inventory. The class should support the following operations: - `add_book(title, author, quantity)`: Adds a book to the inventory. If the book already exists, update its quantity. - `remove_book(title)`: Removes a book from the inventory. ...
```python class Bookstore: def __init__(self): """Initialize the inventory dictionary.""" self.inventory = {} def add_book(self, title, author, quantity): """Add a book to the inventory or update its quantity if it already exists.""" if title in self.inventory: self....
{"requirement_conformance": {"score": 4, "justification": "The class meets the basic requirements by implementing the methods add_book, remove_book, search_book, and display_inventory. However, it does not specify any additional requirements such as handling invalid inputs or updating book details."}, "logical_correctn...
["\nassert Bookstore().search_book(\"1984\") == 0\n", "\nbookstore = Bookstore()\nbookstore.add_book(\"1984\", \"George Orwell\", 12)\nassert bookstore.search_book(\"1984\") == 12\n", "\nbookstore = Bookstore()\nbookstore.add_book(\"1984\", \"George Orwell\", 12)\nbookstore.add_book(\"1984\", \"George Orwell\", 8)\nass...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are tasked with implementing a function to compute the n-th term of the Fibonacci sequence using recursion. Your function should handle large input values efficiently by utilizing memoization. The Fibonacci sequence is defined as follows: - F(0) = 0 - F(1) = 1 - F(n) = F(n-1) + F(n-2) for n > 1 **Input:** - A sin...
```python from functools import lru_cache @lru_cache(maxsize=None) def fibonacci(n): """ Calculate the n-th term of the Fibonacci sequence using recursion with memoization. Parameters: n (int): The term of the Fibonacci sequence to compute (0 ≤ n ≤ 100). Returns: int: The n-th term of...
{"requirement_conformance": {"score": 4, "justification": "The function meets the basic requirements by calculating the Fibonacci sequence up to the n-th term using recursion and includes base cases. However, it does not explicitly state that it handles large input values efficiently in the comments, although it does u...
["\nassert fibonacci(0) == 0\n", "\nassert fibonacci(1) == 1\n", "\nassert fibonacci(2) == 1\n", "\nassert fibonacci(3) == 2\n", "\nassert fibonacci(10) == 55\n", "\nassert fibonacci(20) == 6765\n", "\nassert fibonacci(30) == 832040\n", "\nassert fibonacci(40) == 102334155\n", "\nassert fibonacci(50) == 12586269025\n",...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are tasked with implementing a function to generate the Fibonacci sequence. The Fibonacci sequence is defined as follows: the first two terms are 0 and 1, and each subsequent term is the sum of the two preceding terms. Your function should return a list containing the first `n` terms of the Fibonacci sequence. **I...
```python def generate_sequence(n): """ Generate a list containing the first n terms of the Fibonacci sequence. Parameters: n (int): The number of terms to generate in the Fibonacci sequence. Returns: list: A list of integers containing the first n terms of the Fibonacci sequence. ...
{"requirement_conformance": {"score": 5, "justification": "The function fully meets the requirements by generating the first n terms of the Fibonacci sequence as specified."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and consistently generates the Fibonacci sequence for any ...
["\nassert generate_sequence(0) == []\n", "\nassert generate_sequence(1) == [0]\n", "\nassert generate_sequence(2) == [0, 1]\n", "\nassert generate_sequence(3) == [0, 1, 1]\n", "\nassert generate_sequence(5) == [0, 1, 1, 2, 3]\n", "\nassert generate_sequence(10) == [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]\n", "\nassert genera...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are given a list of coordinates representing the positions of various space stations in a 2D plane. Your task is to write a function that takes in the list of space station coordinates and a target coordinate, and returns the coordinates of the space station that is closest to the target. To minimize computational ...
```python def closest_space_station(space_stations, target): """ Returns the coordinates of the space station closest to the target. :param space_stations: List of tuples, each representing the coordinates of a space station. :param target: Tuple representing the coordinates of the target. :ret...
{"requirement_conformance": {"score": 5, "justification": "The solution fully meets the requirements by taking a list of space station coordinates and a target coordinate, and returning the closest space station coordinate."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct. The so...
["\nassert closest_space_station([(1, 2), (3, 4), (-1, -1)], (0, 0)) in [(1, 2), (-1, -1)]\n", "\nassert closest_space_station([(0, 0), (1, 1), (2, 2)], (0, 0)) == (0, 0)\n", "\nassert closest_space_station([(5, 5), (10, 10), (15, 15)], (10, 10)) == (10, 10)\n", "\nassert closest_space_station([(1, 1), (2, 2), (3, 3)],...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are tasked with implementing a function `convert_to_hex` that converts an integer to its hexadecimal representation. The function should handle both positive and negative integers. The hexadecimal string for positive numbers should be prefixed with '0x', and for negative numbers, it should be prefixed with '-0x'. F...
```python def convert_to_hex(number): """ Convert an integer to its hexadecimal representation with appropriate prefix. Args: number (int): The integer to convert. Returns: str: The hexadecimal representation of the integer with '0x' or '-0x' prefix. """ if number < 0: ...
{"requirement_conformance": {"score": 5, "justification": "The function fully meets all specified requirements, handling both positive and negative integers and returning the correct hexadecimal representation with the appropriate prefix."}, "logical_correctness": {"score": 5, "justification": "The logic is completely ...
["\nassert convert_to_hex(255) == '0xff'\n", "\nassert convert_to_hex(-255) == '-0xff'\n", "\nassert convert_to_hex(0) == '0x0'\n", "\nassert convert_to_hex(16) == '0x10'\n", "\nassert convert_to_hex(-16) == '-0x10'\n", "\nassert convert_to_hex(1) == '0x1'\n", "\nassert convert_to_hex(-1) == '-0x1'\n", "\nassert conver...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
Implement a Python class named `Car` with the following specifications: - **Attributes:** - `make`: A string representing the manufacturer of the car. - `model`: A string representing the model of the car. - `year`: An integer representing the year the car was manufactured. - `mileage`: An integer representing...
```python class Car: def __init__(self, make, model, year, mileage): """ Initializes a new Car instance with the given make, model, year, and mileage. :param make: str - The manufacturer of the car. :param model: str - The model of the car. :param year: int - The yea...
{"requirement_conformance": {"score": 3, "justification": "The solution meets basic requirements by defining a Car class with the specified attributes and methods. However, it does not include additional methods or attributes that might be expected, such as setting or getting individual attributes, or methods for reset...
["\nassert Car(\"Toyota\", \"Corolla\", 2020, 15000).make == \"Toyota\"\n", "\nassert Car(\"Honda\", \"Civic\", 2018, 20000).model == \"Civic\"\n", "\nassert Car(\"Ford\", \"Mustang\", 2021, 5000).year == 2021\n", "\nassert Car(\"Chevrolet\", \"Camaro\", 2019, 10000).mileage == 10000\n", "\ncar = Car(\"Tesla\", \"Model...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are given a list of integers `prices` where `prices[i]` is the price of a given stock on the `i-th` day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you c...
```python def max_profit(prices): """ Calculate the maximum profit from a single buy and sell operation on a list of stock prices. :param prices: List[int] - A list of integers representing daily stock prices. :return: int - The maximum profit that can be achieved. """ if not prices: ...
{"requirement_conformance": {"score": 5, "justification": "The function fully meets the requirements by calculating the maximum profit from a single buy and sell operation on a list of stock prices."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optimally structured. It eff...
["\nassert max_profit([7, 1, 5, 3, 6, 4]) == 5\n", "\nassert max_profit([7, 6, 4, 3, 1]) == 0\n", "\nassert max_profit([1, 2, 3, 4, 5]) == 4\n", "\nassert max_profit([3, 3, 5, 0, 0, 3, 1, 4]) == 4\n", "\nassert max_profit([1, 2]) == 1\n", "\nassert max_profit([1]) == 0\n", "\nassert max_profit([]) == 0\n", "\nassert ma...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are given a positive integer `n`. Your task is to determine if `n` is a perfect number. A perfect number is a positive integer that is equal to the sum of its proper divisors, excluding itself. For example, 6 is a perfect number because its divisors are 1, 2, and 3, and 1 + 2 + 3 = 6. **Input:** - A single integer...
```python def is_perfect_number(n): """ Determine if a given number is a perfect number. A perfect number is a positive integer that is equal to the sum of its proper divisors. Parameters: n (int): The number to check. Returns: bool: True if n is a perfect number, False otherw...
{"requirement_conformance": {"score": 5, "justification": "The function correctly implements the logic to determine if a number is a perfect number by summing its proper divisors and comparing the sum to the original number."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct. The f...
["\nassert is_perfect_number(6) == True\n", "\nassert is_perfect_number(28) == True\n", "\nassert is_perfect_number(496) == True\n", "\nassert is_perfect_number(8128) == True\n", "\nassert is_perfect_number(33550336) == True\n", "\nassert is_perfect_number(12) == False\n", "\nassert is_perfect_number(1) == False\n", "\...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are given a list of number pairs. For each pair, determine the relational operator that holds between the two numbers (i.e., `>`, `<`, or `==`). Print the relational result for each pair on a new line, ensuring that no duplicate relational statements are printed consecutively. **Input:** - A list of tuples, where ...
```python def relationalOperators(pairs): """ Prints the relational operator for each pair of numbers in the list, avoiding consecutive duplicates. :param pairs: List of tuples, where each tuple contains two integers. """ last_relation = None # Keep track of the last printed relation to avoid ...
{"requirement_conformance": {"score": 5, "justification": "The function fully meets the requirements by iterating through the list of number pairs, determining the relational operator for each pair, and printing the result without consecutive duplicates."}, "logical_correctness": {"score": 5, "justification": "The logi...
["\nassert relationalOperators([(1, 2), (2, 1)]) == None\n", "\nassert relationalOperators([(3, 3), (3, 3)]) == None\n", "\nassert relationalOperators([(1, 2), (2, 3), (3, 4)]) == None\n", "\nassert relationalOperators([(5, 5), (5, 5), (5, 5)]) == None\n", "\nassert relationalOperators([(1, 2), (2, 1), (1, 2)]) == None...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are tasked with creating a Python decorator named `log_execution_time` that measures and prints the execution time of any function it decorates. Your decorator should be able to handle functions with any number of positional and keyword arguments. **Input:** - A function `func` to be decorated. **Output:** - The...
```python import time import functools def log_execution_time(func): """Decorator to log the execution time of a function.""" @functools.wraps(func) def wrapper(*args, **kwargs): """Wrapper function to measure execution time.""" start_time = time.time() # Log the start time result ...
{"requirement_conformance": {"score": 5, "justification": "The solution fully meets the requirement of implementing a Python decorator that logs the execution time of any function it decorates. It includes the necessary import statements, defines the decorator function, and provides an example usage."}, "logical_correc...
["\nassert log_execution_time(lambda: 1)(1) == 1\n", "\nassert log_execution_time(lambda x: x + 1)(2) == 3\n", "\nassert log_execution_time(lambda x, y: x * y)(3, 4) == 12\n", "\nassert log_execution_time(lambda: None)() is None\n", "\nassert log_execution_time(lambda x: x)(\"test\") == \"test\"\n", "\nassert log_execu...
["fail", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
0.9
You are given a list of system logs, each represented as a dictionary with the following keys: `timestamp`, `level`, `message`, and `source`. Your task is to implement a function `validate_system_logs` that verifies the integrity of these logs based on the following criteria: 1. Each log must contain all four keys: `t...
```python import re from datetime import datetime def is_valid_identifier(s): """ Check if a string is a valid Python identifier. :param s: String to check. :return: True if the string is a valid identifier, False otherwise. """ return bool(re.match(r"^[a-zA-Z_]\w*$", s)) def validate_sys...
{"requirement_conformance": {"score": 5, "justification": "The solution fully meets all the specified requirements. It checks for all required keys, validates the timestamp format and validity, verifies the log level, ensures the message contains alphabetic characters, and checks if the source is a valid Python identif...
["\nassert validate_system_logs([{\"timestamp\": \"2023-10-01 12:34:56\", \"level\": \"INFO\", \"message\": \"System started\", \"source\": \"main\"}]) == True\n", "\nassert validate_system_logs([{\"timestamp\": \"2023-10-01 12:34:56\", \"level\": \"DEBUG\", \"message\": \"System started\", \"source\": \"main\"}]) == F...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are given a positive integer `number`. Your task is to write a function `get_prime_factors(number)` that returns a list of its prime factors in ascending order. A prime factor is a factor that is also a prime number. You must implement the function using only iterative methods and without using any built-in functio...
```python def get_prime_factors(number): """ Returns a list of prime factors of the given number in ascending order. :param number: An integer for which to find the prime factors. :return: A list of integers representing the prime factors. """ prime_factors = [] divisor = 2 while n...
{"requirement_conformance": {"score": 5, "justification": "The solution fully meets the requirement by implementing the function `get_prime_factors(number)` using only iterative methods and without using any built-in functions that directly deal with prime numbers. It returns a list of prime factors in ascending order....
["\nassert get_prime_factors(2) == [2]\n", "\nassert get_prime_factors(3) == [3]\n", "\nassert get_prime_factors(4) == [2, 2]\n", "\nassert get_prime_factors(5) == [5]\n", "\nassert get_prime_factors(6) == [2, 3]\n", "\nassert get_prime_factors(8) == [2, 2, 2]\n", "\nassert get_prime_factors(10) == [2, 5]\n", "\nassert...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are given a deeply nested dictionary that may contain nested lists with dictionaries or lists. Your task is to write a function `flatten_nested_dict` that flattens this dictionary. Each key in the resulting dictionary should be a unique identifier formed by concatenating the keys from the original dictionary and li...
```python def flatten_nested_dict(d, parent_key='', sep='_'): """ Flattens a nested dictionary with possibly nested lists and dictionaries. Keys are concatenated with sep separator to create unique identifiers. :param d: Dictionary to flatten :param parent_key: Used internally during recursion to k...
{"requirement_conformance": {"score": 5, "justification": "The function fully meets the requirements by handling nested dictionaries and lists, and ensuring keys maintain unique identifiers for each value."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optimally structured....
["\nassert flatten_nested_dict({'a': 1, 'b': 2}) == {'a': 1, 'b': 2}\n", "\nassert flatten_nested_dict({'a': {'b': 2}}) == {'a_b': 2}\n", "\nassert flatten_nested_dict({'a': {'b': {'c': 3}}}) == {'a_b_c': 3}\n", "\nassert flatten_nested_dict({'a': [1, 2, 3]}) == {'a_0': 1, 'a_1': 2, 'a_2': 3}\n", "\nassert flatten_nest...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
Implement a stack data structure with the following operations: `push`, `pop`, `peek`, and `size`. The stack should be designed to handle operations efficiently. Your implementation should pass the following test cases: - **Sample Input 1:** ``` push 10 push 20 peek pop size ``` - **Sample Output 1:** ...
```python class Stack: def __init__(self): """Initialize an empty stack.""" self.items = [] def push(self, item): """Add an item to the top of the stack.""" self.items.append(item) def pop(self): """Remove and return the top item of the stack. Raise an IndexError if...
{"requirement_conformance": {"score": 5, "justification": "The solution fully meets all specified requirements by implementing the push, pop, peek, and size methods for the stack data structure."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optimally structured. The method...
["\nassert Stack().size() == 0\n", "\nassert Stack().is_empty() == True\n", "\ns = Stack(); s.push(1); assert s.size() == 1\n", "\ns = Stack(); s.push(1); s.push(2); assert s.peek() == 2\n", "\ns = Stack(); s.push(1); s.push(2); s.pop(); assert s.peek() == 1\n", "\ns = Stack(); s.push(1); s.push(2); s.pop(); assert s.s...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "fail"]
0.9
You are given a dictionary `input_dict` where each key is associated with an integer value. Your task is to create a function that returns a new dictionary with the same keys, but with each value increased by a constant integer `k`. **Input:** - A dictionary `input_dict` with string keys and integer values. - An inte...
```python def add_constant_to_values(input_dict, k): """ Returns a new dictionary with the same keys as input_dict and values increased by k. :param input_dict: Dictionary with string keys and integer values. :param k: Integer constant to be added to each value in the dictionary. :return: New dicti...
{"requirement_conformance": {"score": 5, "justification": "The solution fully meets the requirements by taking a dictionary and a constant k as input and returning a new dictionary with values incremented by k."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optimally struct...
["\nassert add_constant_to_values({\"a\": 1, \"b\": 2, \"c\": 3}, 2) == {\"a\": 3, \"b\": 4, \"c\": 5}\n", "\nassert add_constant_to_values({\"x\": 10, \"y\": 20, \"z\": 30}, 5) == {\"x\": 15, \"y\": 25, \"z\": 35}\n", "\nassert add_constant_to_values({\"m\": -1, \"n\": -2, \"o\": -3}, 1) == {\"m\": 0, \"n\": -1, \"o\"...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are given a string `text` containing a mix of text and email addresses. Your task is to write a function `extract_emails(text)` that extracts all valid email addresses from the string and returns them as a list. An email address is defined as a sequence of characters that match the pattern `[a-zA-Z0-9._%+-]+@[a-zA-...
```python import re def extract_emails(text): """ Extracts all valid email addresses from the given text. Parameters: text (str): The input string containing text and email addresses. Returns: list: A list of strings, each representing a valid email address found in the input string. """ ...
{"requirement_conformance": {"score": 5, "justification": "The function fully meets the requirement by using regular expressions to extract email addresses from the input string and returning them as a list."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optimally structure...
["\nassert extract_emails(\"Please contact us at support@example.com\") == [\"support@example.com\"]\n", "\nassert extract_emails(\"No emails here!\") == []\n", "\nassert extract_emails(\"Multiple emails: test1@test.com, test2@test.org\") == [\"test1@test.com\", \"test2@test.org\"]\n", "\nassert extract_emails(\"Email ...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are tasked with implementing a function to compute the factorial of a non-negative integer `n`. The factorial of a number `n`, denoted as `n!`, is the product of all positive integers less than or equal to `n`. By definition, `0!` is `1`. Your function should correctly handle the base case and recursive case for co...
```python def factorial(n): """ Calculate the factorial of a non-negative integer n. Parameters: n (int): A non-negative integer whose factorial is to be computed. Returns: int: The factorial of the integer n. """ if n == 0: return 1 else: return n * factori...
{"requirement_conformance": {"score": 5, "justification": "The solution fully meets the requirement of calculating the factorial of a number and corrects the original code snippet."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optimally structured. It correctly handles the...
["\nassert factorial(0) == 1\n", "\nassert factorial(1) == 1\n", "\nassert factorial(2) == 2\n", "\nassert factorial(3) == 6\n", "\nassert factorial(4) == 24\n", "\nassert factorial(5) == 120\n", "\nassert factorial(6) == 720\n", "\nassert factorial(7) == 5040\n", "\nassert factorial(10) == 3628800\n", "\nassert factor...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are tasked with designing a REST API using Flask that supports CRUD operations on a list of books. The API should include the following endpoints: - `GET /books`: Returns a JSON object containing a list of all books. - `GET /books/<id>`: Returns a JSON object containing the book with the specified ID. If the book ...
```python from flask import Flask, jsonify, request, abort app = Flask(__name__) # Sample data structure to store books. books = [ {'id': 1, 'title': '1984', 'author': 'George Orwell'}, {'id': 2, 'title': 'The Great Gatsby', 'author': 'F. Scott Fitzgerald'}, {'id': 3, 'title': 'To Kill a Mockingbird', 'au...
{"requirement_conformance": {"score": 5, "justification": "The solution fully meets all the specified requirements by providing endpoints for getting all books, getting a book by ID, creating a new book, updating a book by ID, and deleting a book by ID."}, "logical_correctness": {"score": 4, "justification": "The logic...
["\nassert get_books().json == {'books': [{'id': 1, 'title': '1984', 'author': 'George Orwell'}, {'id': 2, 'title': 'The Great Gatsby', 'author': 'F. Scott Fitzgerald'}, {'id': 3, 'title': 'To Kill a Mockingbird', 'author': 'Harper Lee'}]}\n", "\nassert get_book(1).json == {'id': 1, 'title': '1984', 'author': 'George O...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
In a hypothetical programming language, data types are case-sensitive and can be represented in various formats. Your task is to implement a function `is_valid_type(text: str) -> bool` that determines whether a given string `text` is a valid data type in this language. The valid data types are `"int"`, `"FLOAT"`, `"Boo...
```python def is_valid_type(text: str) -> bool: """ Determines if the given string is a valid data type in a hypothetical programming language. Parameters: text (str): The string to check. Returns: bool: True if the string is a valid data type, False otherwise. """ valid_types ...
{"requirement_conformance": {"score": 5, "justification": "The function fully meets the requirement by checking if the input string is one of the specified valid data types."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optimally structured. It uses a set to store valid ty...
["\nassert is_valid_type(\"int\") == True\n", "\nassert is_valid_type(\"FLOAT\") == True\n", "\nassert is_valid_type(\"Boolean\") == True\n", "\nassert is_valid_type(\"str\") == True\n", "\nassert is_valid_type(\"INTEGER\") == True\n", "\nassert is_valid_type(\"STRING\") == True\n", "\nassert is_valid_type(\"boolean\")...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are given a doubly linked list and an integer `n`. Your task is to remove the n-th node from the end of the list and return the head of the modified list. The operation must be performed in O(1) space complexity and O(N) time complexity, without using any auxiliary data structures. **Input:** - The first line cont...
```python class Node: def __init__(self, data): self.data = data self.next = None self.prev = None def remove_nth_from_end(head, n): """ Removes the n-th node from the end of a doubly linked list. :param head: Node, the head of the doubly linked list. :param n: int, the...
{"requirement_conformance": {"score": 5, "justification": "The solution fully meets the requirements by removing the n-th node from the end of the doubly linked list in O(N) time complexity and O(1) space complexity without using any auxiliary data structures."}, "logical_correctness": {"score": 5, "justification": "Th...
["\nassert remove_nth_from_end(None, 1) == None\n", "\nassert remove_nth_from_end(Node(1), 1) == None\n", "\nassert remove_nth_from_end(Node(1), 2) == Node(1)\n", "\nnode1 = Node(1)\nnode2 = Node(2)\nnode1.next = node2\nnode2.prev = node1\nassert remove_nth_from_end(node1, 1) == node1 and node1.next == None\n", "\nnode...
["pass", "pass", "fail", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
0.9
You are tasked with implementing a recursive function to compute the factorial of a given integer. The factorial of a non-negative integer \( n \) is the product of all positive integers less than or equal to \( n \). By definition, the factorial of 0 is 1 (i.e., \( 0! = 1 \)). Your function should handle negative inpu...
```python def factorial(n): """ Calculate the factorial of a non-negative integer using recursion. Parameters: n (int): The integer for which the factorial is to be calculated. Returns: int: The factorial of the integer n. Raises: ValueError: If n is a negative integer. ...
{"requirement_conformance": {"score": 5, "justification": "The function fully meets all specified requirements: it calculates the factorial using recursion, returns 1 for 0, and raises a ValueError for negative inputs."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optimall...
["\nassert factorial(0) == 1\n", "\nassert factorial(1) == 1\n", "\nassert factorial(5) == 120\n", "\nassert factorial(7) == 5040\n", "\nassert factorial(10) == 3628800\n", "\nassert factorial(3) == 6\n", "\nassert factorial(15) == 1307674368000\n", "\ntry:\n factorial(-1)\nexcept ValueError as e:\n assert str(e)...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
In a shopping cart system, you need to implement a function `validate_discount_code` that checks if a user-entered discount code is valid based on lexicographical rotations. The function should accept two parameters: `input_code` and `valid_code`. The function should return `True` if `input_code` is a lexicographical r...
```python def validate_discount_code(input_code, valid_code): """ Validates if the input_code is a lexicographical rotation of the valid_code. Returns True if they are rotations of each other or if either is missing/empty. Otherwise, returns False. """ if not input_code or not valid_code: ...
{"requirement_conformance": {"score": 5, "justification": "The function fully meets all specified requirements. It checks if either code is missing or empty and returns True in that case. It also correctly checks if the input_code is a rotation of the valid_code."}, "logical_correctness": {"score": 5, "justification": ...
["\nassert validate_discount_code(\"abcde\", \"cdeab\") == True\n", "\nassert validate_discount_code(\"rotation\", \"tationro\") == True\n", "\nassert validate_discount_code(\"discount\", \"countdis\") == True\n", "\nassert validate_discount_code(\"valid\", \"valid\") == True\n", "\nassert validate_discount_code(\"code...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are tasked with implementing a function `findClosestRoot(n, k)` that computes the closest integer root of `n` to the power of `k`. Specifically, find the largest integer `r` such that `r^k` is less than or equal to `n`. Your solution must utilize a binary search algorithm for efficiency. **Constraints:** - `1 <= n...
```python def findClosestRoot(n, k): """ Finds the largest integer r such that r^k <= n using binary search. Parameters: n (int): The target number. k (int): The power to which the root is raised. Returns: int: The largest integer r such that r^k <= n. """ if n == 0: ...
{"requirement_conformance": {"score": 5, "justification": "The solution fully meets the requirements by implementing the function `findClosestRoot(n, k)` using a binary search approach to find the closest integer root of `n` to the power of `k`."}, "logical_correctness": {"score": 5, "justification": "The logic is comp...
["\nassert findClosestRoot(27, 3) == 3\n", "\nassert findClosestRoot(26, 3) == 3\n", "\nassert findClosestRoot(16, 2) == 4\n", "\nassert findClosestRoot(20, 2) == 4\n", "\nassert findClosestRoot(1, 1) == 1\n", "\nassert findClosestRoot(0, 5) == 0\n", "\nassert findClosestRoot(81, 4) == 3\n", "\nassert findClosestRoot(1...
["pass", "fail", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
0.9
You are given a list of dictionaries `employees`, where each dictionary contains the keys "name", "position", and "salary". Your task is to implement a function `highest_paid_employee(employees)` that returns the name of the employee with the highest salary. If the list is empty, the function should return `None`. **S...
```python def highest_paid_employee(employees): """ Returns the name of the employee with the highest salary from a list of employee dictionaries. If the list is empty, returns None. :param employees: List of dictionaries, each containing 'name', 'position', and 'salary' keys. :return: Name of ...
{"requirement_conformance": {"score": 5, "justification": "The function fully meets the requirement by returning the name of the employee with the highest salary."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optimally structured. It uses the max function with a key argume...
["\nassert highest_paid_employee([{\"name\": \"Alice\", \"position\": \"Engineer\", \"salary\": 100000}]) == \"Alice\"\n", "\nassert highest_paid_employee([{\"name\": \"Bob\", \"position\": \"Manager\", \"salary\": 120000}, {\"name\": \"Alice\", \"position\": \"Engineer\", \"salary\": 100000}]) == \"Bob\"\n", "\nassert...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "fail", "pass"]
0.9
You are given a dictionary `country_population_dict` where keys are country names (strings) and values are their respective populations (integers). Implement a function `sort_countries_by_population` that returns a list of tuples. Each tuple should contain a country name and its population, sorted by population in desc...
```python def sort_countries_by_population(country_population_dict): """ Sorts a dictionary of countries by their population in descending order. Parameters: country_population_dict (dict): A dictionary with country names as keys and populations as values. Returns: list: A list of tuples, each...
{"requirement_conformance": {"score": 5, "justification": "The solution fully meets the requirements by converting the dictionary to a list of tuples and sorting it by population in descending order."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optimally structured. The u...
["\nassert sort_countries_by_population({\"United States\": 331002651, \"India\": 1380004385, \"China\": 1439323776, \"Brazil\": 212559417, \"Nigeria\": 206139589, \"Bangladesh\": 166303461, \"Russia\": 145912025, \"Mexico\": 130268305, \"Japan\": 125836021, \"Ethiopia\": 114963583}) == [(\"China\", 1439323776), (\"Ind...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are tasked with implementing a function `get_config_value(config, key)` that navigates through a nested dictionary structure to retrieve a configuration value. The function should adhere to the following rules: - If the `key` is found in the dictionary and its value is a boolean, return the boolean value. - If the...
```python def get_config_value(config, key, depth=0): """ Retrieves a configuration value from a nested dictionary based on the given key. Parameters: config (dict): The configuration dictionary. key (str): The key to search for in the dictionary. depth (int): The current depth of recursion...
{"requirement_conformance": {"score": 4, "justification": "The function meets most of the requirements, including handling boolean and string values, converting strings to booleans based on the given rules, and recursively searching nested dictionaries up to a depth of 5 levels. However, it does not explicitly handle t...
["\nassert get_config_value({\"key\": \"true\"}, \"key\") == True\n", "\nassert get_config_value({\"key\": \"false\"}, \"key\") == False\n", "\nassert get_config_value({\"key\": \"anything\"}, \"key\") == True\n", "\nassert get_config_value({\"key\": True}, \"key\") == True\n", "\nassert get_config_value({\"key\": Fals...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are given a list of integers. Your task is to reverse the list in place without using recursion or any built-in reverse functions. You are not allowed to use additional data structures for this task. **Input:** - A list of integers `lst` where `1 <= len(lst) <= 10^5` and `-10^9 <= lst[i] <= 10^9`. **Output:** - ...
```python def reverse(lst): """ Reverses the given list in place without using recursion or built-in reverse functions. :param lst: List of integers to be reversed. """ left = 0 right = len(lst) - 1 while left < right: lst[left], lst[right] = lst[right], lst[left] l...
{"requirement_conformance": {"score": 5, "justification": "The solution fully meets the requirements by reversing the list in place without using recursion or built-in reverse functionalities."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optimally structured. The function...
["\nassert reverse([1, 2, 3, 4, 5]) == None\n", "\nassert reverse([1, 2, 3, 4, 5]) is None\n", "\nmy_list = [1, 2, 3, 4, 5]; reverse(my_list); assert my_list == [5, 4, 3, 2, 1]\n", "\nmy_list = [10, 20, 30]; reverse(my_list); assert my_list == [30, 20, 10]\n", "\nmy_list = ['a', 'b', 'c']; reverse(my_list); assert my_l...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are given a list of integers. Your task is to write a Python function that returns a new list containing only the odd numbers from the original list. Ensure your code is efficient and adheres to PEP8 guidelines. **Sample Input:** ``` [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ``` **Sample Output:** ``` [1, 3, 5, 7, 9] ```
```python def odd_numbers(numbers): """ Returns a list of odd numbers from the given list of integers. :param numbers: List of integers :return: List of odd integers """ return [number for number in numbers if number % 2 != 0] def main(): """ Main function to demonstrate the usage of o...
{"requirement_conformance": {"score": 5, "justification": "The solution fully meets the requirement of refactoring the code to be more efficient and PEP8 compliant. The code is already efficient and follows PEP8 guidelines."}, "logical_correctness": {"score": 5, "justification": "The logic of the code is completely cor...
["\nassert odd_numbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 3, 5, 7, 9]\n", "\nassert odd_numbers([2, 4, 6, 8, 10]) == []\n", "\nassert odd_numbers([1, 3, 5, 7, 9]) == [1, 3, 5, 7, 9]\n", "\nassert odd_numbers([]) == []\n", "\nassert odd_numbers([-1, -2, -3, -4, -5]) == [-1, -3, -5]\n", "\nassert odd_numbers([0, 1, ...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are given a list of integers representing the heights of a series of buildings. Your task is to write a function `count_visible_buildings` that determines the number of buildings visible from the left side. A building is considered visible if it is taller than all buildings to its left. **Input:** - A list of int...
```python def count_visible_buildings(heights): """ Counts the number of buildings visible from the left side. A building is visible if it is taller than all buildings to its left. :param heights: List of integers representing the heights of buildings. :return: Integer representing the num...
{"requirement_conformance": {"score": 5, "justification": "The solution fully meets the requirements by correctly implementing the logic to count the number of buildings visible from the left side based on their heights."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optima...
["\nassert count_visible_buildings([3, 7, 8, 3, 6, 1]) == 3\n", "\nassert count_visible_buildings([1, 2, 3, 4, 5]) == 5\n", "\nassert count_visible_buildings([5, 4, 3, 2, 1]) == 1\n", "\nassert count_visible_buildings([10, 10, 10, 10]) == 1\n", "\nassert count_visible_buildings([1]) == 1\n", "\nassert count_visible_bui...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are given two nested arrays `original` and `other`. Your task is to implement a function `same_structure_as` that returns `True` if and only if both arrays have the same nesting structure, the same length of nested arrays, and all non-array elements are of the same type and are non-negative numbers. **Constraints...
```python def same_structure_as(original, other): """ Returns True if both arrays have the same nesting structure, the same length of nested arrays, and all non-array elements are of the same type and are non-negative numbers. """ def same_type_and_non_negative(a, b): if isinstance(a, (int, ...
{"requirement_conformance": {"score": 5, "justification": "The solution fully meets all specified requirements, including checking for the same nesting structure, corresponding length of nested arrays, and ensuring non-array elements are of the same type and are non-negative numbers."}, "logical_correctness": {"score":...
["\nassert same_structure_as([1, 2, 3], [4, 5, 6]) == True\n", "\nassert same_structure_as([1, [2, 3]], [4, [5, 6]]) == True\n", "\nassert same_structure_as([1, [2, 3]], [4, [5, '6']]) == False\n", "\nassert same_structure_as([1, [2, 3]], [4, [5, 6, 7]]) == False\n", "\nassert same_structure_as([1, [2, 3]], [4, 5]) == ...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "fail", "pass", "pass"]
0.9
You are developing an e-commerce campaign management system. Your task is to implement a function `create_campaign` that creates a new campaign for a given client with a specified budget and merchant account. The campaign must be a standard shopping campaign targeting the US market, initially set to paused status, and ...
```python import datetime import uuid def campaign_exists(client: str, year: int, month: int) -> bool: """ Checks if a campaign already exists for the given client and month. Args: client (str): The client for whom the campaign is being created. year (int): The year of the campaign. ...
{"requirement_conformance": {"score": 4, "justification": "The solution meets most of the specified requirements, including creating a campaign with a unique name, setting it to paused status, enabling local inventory ads, and using a manual CPC bidding strategy with eCPC enabled. However, it does not explicitly handle...
["\nassert create_campaign(\"ClientA\", \"1234567890\", \"customers/1234567890/budgets/0\", \"987654321\").startswith(\"customers/1234567890/campaigns/clienta_shopping_\")\n", "\nassert create_campaign(\"ClientB\", \"0987654321\", \"customers/0987654321/budgets/1\", \"123456789\").startswith(\"customers/0987654321/camp...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
In a simulated space mission, a spacecraft's position in a 3D Cartesian coordinate system is given by a vector \((x, y, z)\). The spacecraft follows a trajectory defined by the function `trajectory(t)`, which returns the spacecraft's position at time \(t\). Your task is to implement a function `plane_crossing(t, posit...
```python def plane_crossing(t, position, last_position): """ Determines if the spacecraft has crossed the z=0 plane since the last time step. Parameters: t (float): The current time. position (tuple): A tuple of three floats (x, y, z) representing the current position. last_position (tuple): A...
{"requirement_conformance": {"score": 4, "justification": "The function addresses the core requirement of determining if the spacecraft has crossed the z=0 plane. However, it does not consider the possibility of crossing the plane multiple times, which is mentioned in the question."}, "logical_correctness": {"score": 4...
["\nassert plane_crossing(1, (0, 0, 1), (0, 0, -1)) == True\n", "\nassert plane_crossing(2, (0, 0, -1), (0, 0, 1)) == True\n", "\nassert plane_crossing(3, (0, 0, 0), (0, 0, 1)) == True\n", "\nassert plane_crossing(4, (0, 0, 0), (0, 0, -1)) == True\n", "\nassert plane_crossing(5, (0, 0, 1), (0, 0, 0.5)) == False\n", "\n...
["pass", "pass", "fail", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
0.9
You are given the task of implementing an efficient function to compute the nth Lucas number. The Lucas sequence is defined as follows: L(0) = 2, L(1) = 1, and for n > 1, L(n) = L(n-1) + L(n-2). Due to the recursive nature of the sequence, a naive recursive approach would result in exponential time complexity. Your goa...
```python def lucas(n, memo=None): """ Computes the nth Lucas number using memoization. Parameters: n (int): The position in the Lucas sequence. memo (dict): A dictionary used for memoization to store previously computed values. Returns: int: The nth Lucas number. """ if me...
{"requirement_conformance": {"score": 5, "justification": "The function `lucas(n)` meets all the specified requirements. It calculates the nth Lucas number using memoization and keeps track of the total and real calls to the function."}, "logical_correctness": {"score": 5, "justification": "The logic of the function is...
["\nassert lucas(0) == 2\n", "\nassert lucas(1) == 1\n", "\nassert lucas(2) == 3\n", "\nassert lucas(3) == 4\n", "\nassert lucas(4) == 7\n", "\nassert lucas(5) == 11\n", "\nassert lucas(10) == 123\n", "\nassert lucas(15) == 1364\n", "\nassert lucas(20) == 15127\n", "\nassert lucas(10, {'calls': {'total': 0, 'real': 0}}...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "fail"]
0.9
You are given a Python dictionary. Your task is to write a function that converts this dictionary into a JSON string. The function should utilize the `json` module. Your function should handle dictionaries with string, integer, and boolean values. **Input:** - A Python dictionary with keys and values of types string, ...
```python import json def dict_to_json(input_dict): """ Convert a Python dictionary to a JSON string. Parameters: input_dict (dict): A dictionary with string, integer, and boolean values. Returns: str: A JSON string representation of the input dictionary. """ return json.dumps(input_d...
{"requirement_conformance": {"score": 5, "justification": "The function fully meets the requirement by taking a dictionary as input and returning a string representation of the JSON object using the `json` module."}, "logical_correctness": {"score": 5, "justification": "The logic is completely correct and optimally str...
["\nassert dict_to_json({\"name\": \"Alice\", \"age\": 30, \"is_employee\": True}) == '{\"name\": \"Alice\", \"age\": 30, \"is_employee\": true}'\n", "\nassert dict_to_json({\"key\": \"value\", \"number\": 42}) == '{\"key\": \"value\", \"number\": 42}'\n", "\nassert dict_to_json({\"nested\": {\"key\": \"value\"}, \"lis...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "fail", "pass", "pass"]
0.9
You are given a string `hex_string` which may contain alphanumeric characters and possibly some non-alphanumeric characters at the beginning. Your task is to write a function `hex_to_binary` that processes this string to extract a valid hexadecimal number, converts it to a binary string, and returns the binary represen...
```python def hex_to_binary(hex_string): """ Converts a hexadecimal string to a binary string. Parameters: hex_string (str): The input string containing a hexadecimal number. Returns: str: The binary representation of the hexadecimal number, or an empty string if invalid. """ #...
{"requirement_conformance": {"score": 3, "justification": "The function meets basic requirements by converting a hexadecimal string to a binary string and handling invalid inputs. However, it does not specifically remove non-alphanumeric prefixes, only strips non-alphanumeric characters from the beginning and end."}, "...
["\nassert hex_to_binary(\"1A3F\") == \"1101000111111\"\n", "\nassert hex_to_binary(\"0x1A3F\") == \"1101000111111\"\n", "\nassert hex_to_binary(\"GHIJK\") == \"\"\n", "\nassert hex_to_binary(\"123abc\") == \"10010001110101100\"\n", "\nassert hex_to_binary(\"XYZ\") == \"\"\n", "\nassert hex_to_binary(\"0x\") == \"\"\n"...
["pass", "pass", "pass", "fail", "pass", "pass", "pass", "pass", "pass", "pass"]
0.9
You are developing a simulation for a simple computer processor with 8 general-purpose registers, each capable of storing a 32-bit integer. Implement a class `SimpleProcessor` with the following specifications: - The constructor should initialize all 8 registers to 0. - Implement a method `get_register_values()` that ...
```python class SimpleProcessor: def __init__(self): """ Initializes the SimpleProcessor with 8 registers set to 0 and a security counter set to 0. """ self._registers = {f"R{i}": 0 for i in range(8)} self._security_counter = 0 def get_register_values(self): """ ...
{"requirement_conformance": {"score": 3, "justification": "The solution initializes the 8 registers with values 0 and provides a method to get the register values. However, it does not correctly implement the security protocol incrementing the security counter by 5 for each individual register access; instead, it incre...
["\nassert SimpleProcessor().get_register_values() == {'R0': 0, 'R1': 0, 'R2': 0, 'R3': 0, 'R4': 0, 'R5': 0, 'R6': 0, 'R7': 0}\n", "\nassert SimpleProcessor().get_security_counter() == 0\n", "\nprocessor = SimpleProcessor()\nprocessor.get_register_values()\nassert processor.get_security_counter() == 40\n", "\nprocessor...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
You are playing a variant of Mahjong where a "Pung" is defined as a set of three identical tiles. Given a list of tiles and a target tile, determine if the target tile can form a Pung with the tiles in the list. Your solution must have a time complexity of O(n log n), where n is the length of the `tiles_list`. **Input...
```python def can_form_pung(target_tile, tiles_list): """ Determines if the target_tile can form a Pung with the tiles in the tiles_list. :param target_tile: A string representing the target tile. :param tiles_list: A list of strings representing the tiles in the player's hand. :return: True if...
{"requirement_conformance": {"score": 4, "justification": "The function correctly implements the logic to check if the target tile forms a Pung with the tiles in the list. However, it does not explicitly state the time complexity of O(n log n) in the comments or documentation, which is a minor requirement."}, "logical_...
["\nassert can_form_pung(\"A\", [\"A\", \"A\", \"A\"]) == True\n", "\nassert can_form_pung(\"B\", [\"B\", \"B\", \"C\"]) == False\n", "\nassert can_form_pung(\"C\", [\"A\", \"B\", \"C\", \"C\", \"C\"]) == True\n", "\nassert can_form_pung(\"D\", [\"D\", \"D\", \"D\", \"D\"]) == True\n", "\nassert can_form_pung(\"E\", [\...
["pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass", "pass"]
1
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
13