Dataset Preview
Duplicate
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The dataset generation failed
Error code:   DatasetGenerationError
Exception:    TypeError
Message:      Couldn't cast array of type
struct<original_dataset: string, original_url: string, original_id: int64, original_raw_index: int64, original_split: string, seed_concepts: list<item: string>, code_modified: bool, tests_added: bool, reasoning_generated_or_rewritten: string, original_instruction: string, transformations: list<item: string>>
to
{'original_dataset': Value('string'), 'original_url': Value('string'), 'original_id': Value('int64'), 'original_split': Value('string'), 'seed_concepts': List(Value('string')), 'code_modified': Value('bool'), 'tests_added': Value('bool'), 'reasoning_generated_or_rewritten': Value('string'), 'original_instruction': Value('string'), 'transformations': List(Value('string'))}
Traceback:    Traceback (most recent call last):
                File "/usr/local/lib/python3.14/site-packages/datasets/builder.py", line 1827, in _prepare_split_single
                  for key, table in generator:
                                    ^^^^^^^^^
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 613, in wrapped
                  for item in generator(*args, **kwargs):
                              ~~~~~~~~~^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/packaged_modules/json/json.py", line 343, in _generate_tables
                  self._cast_table(pa_table, json_field_paths=json_field_paths),
                  ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/packaged_modules/json/json.py", line 132, in _cast_table
                  pa_table = table_cast(pa_table, self.info.features.arrow_schema)
                File "/usr/local/lib/python3.14/site-packages/datasets/table.py", line 2378, in table_cast
                  return cast_table_to_schema(table, schema)
                File "/usr/local/lib/python3.14/site-packages/datasets/table.py", line 2312, in cast_table_to_schema
                  cast_array_to_feature(
                  ~~~~~~~~~~~~~~~~~~~~~^
                      table[name] if name in table_column_names else pa.array([None] * len(table), type=schema.field(name).type),
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                      feature,
                      ^^^^^^^^
                  )
                  ^
                File "/usr/local/lib/python3.14/site-packages/datasets/table.py", line 1861, in wrapper
                  return pa.chunked_array([func(chunk, *args, **kwargs) for chunk in array.chunks])
                                           ~~~~^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/table.py", line 2158, in cast_array_to_feature
                  raise TypeError(f"Couldn't cast array of type\n{_short_str(array.type)}\nto\n{_short_str(feature)}")
              TypeError: Couldn't cast array of type
              struct<original_dataset: string, original_url: string, original_id: int64, original_raw_index: int64, original_split: string, seed_concepts: list<item: string>, code_modified: bool, tests_added: bool, reasoning_generated_or_rewritten: string, original_instruction: string, transformations: list<item: string>>
              to
              {'original_dataset': Value('string'), 'original_url': Value('string'), 'original_id': Value('int64'), 'original_split': Value('string'), 'seed_concepts': List(Value('string')), 'code_modified': Value('bool'), 'tests_added': Value('bool'), 'reasoning_generated_or_rewritten': Value('string'), 'original_instruction': Value('string'), 'transformations': List(Value('string'))}
              
              The above exception was the direct cause of the following exception:
              
              Traceback (most recent call last):
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1369, in compute_config_parquet_and_info_response
                  parquet_operations, partial, estimated_dataset_info = stream_convert_to_parquet(
                                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~^
                      builder, max_dataset_size_bytes=max_dataset_size_bytes
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                  )
                  ^
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 948, in stream_convert_to_parquet
                  builder._prepare_split(split_generator=splits_generators[split], file_format="parquet")
                  ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.14/site-packages/datasets/builder.py", line 1694, in _prepare_split
                  for job_id, done, content in self._prepare_split_single(
                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~^
                      gen_kwargs=gen_kwargs, job_id=job_id, **_prepare_split_args
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                  ):
                  ^
                File "/usr/local/lib/python3.14/site-packages/datasets/builder.py", line 1879, in _prepare_split_single
                  raise DatasetGenerationError("An error occurred while generating the dataset") from e
              datasets.exceptions.DatasetGenerationError: An error occurred while generating the dataset

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

instruction
string
reasoning
string
code
string
tests
string
documentation
string
verification
dict
quality
dict
provenance
dict
Write a Python function to generate [Pascal's Triangle](https://en.wikipedia.org/wiki/Pascal%27s_triangle) up to an arbitrary height. The function should take in an integer `n` as input and return a list of `n` lists, where each list represents a row of the triangle. The output should be in the form of integer lists, w...
To generate Pascal's Triangle up to an arbitrary height, we can use dynamic programming to calculate each row by adding elements from the previous row. We'll start with the base case of a single row with a single `1`. Then, for each subsequent row, we'll calculate the elements by adding the corresponding elements from ...
def generate_pascal_triangle(n): triangle = [[1]] for i in range(1, n): row = [1] for j in range(1, i): row.append(triangle[i - 1][j - 1] + triangle[i - 1][j]) row.append(1) triangle.append(row) return triangle print(generate_pascal_triangle(5))
# [derived:explicit_asserts_in_instruction] assert generate_pascal_triangle(2) == [[1], [1, 1]] assert generate_pascal_triangle(5) == [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1]] assert generate_pascal_triangle(1) == [[1]] assert generate_pascal_triangle(3) == [[1], [1, 1], [1, 2, 1]]
The function starts by initializing the base case of a single row with a single `1`. Then, for each subsequent row, it calculates the elements by adding the corresponding elements from the previous row. The nested list comprehension generates a list of elements for each row, where each element is the sum of the corresp...
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 4 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(4 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 663783, "original_split": "train", "seed_concepts": [ "list slicing", "floor division", "mathematical formula imple...
Write a Python function that takes a string as the first argument and any number of keyword arguments as the second argument. The function should return a URL string that is constructed from the given string and the keyword arguments. Each key-value pair of the keyword arguments should be appended to the URL string as ...
To implement this function, you can use the `urllib.parse.urlencode` function from the Python standard library. This function takes a dictionary of keyword arguments and returns a string that is formatted as a query string. You can also use the `urllib.parse.urljoin` function to combine the base URL with the query stri...
from urllib.parse import urlencode, urljoin def build_url(base_url: str, **kwargs) -> str: query_string = urlencode(kwargs) return urljoin(base_url, '?' + query_string)
# [derived:explicit_asserts_in_instruction] assert build_url('https://example.com/search', q='keyword', num=10, hl='en') == 'https://example.com/search?q=keyword&num=10&hl=en' assert build_url('https://example.com/search', q='keyword') == 'https://example.com/search?q=keyword' assert build_url('https://example.com/sear...
This function uses the `urlencode` function to convert the keyword arguments into a query string, and then uses the `urljoin` function to combine the query string with the base URL.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 3 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(3 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 168341, "original_split": "train", "seed_concepts": [ "string concatenation", "string interpolation", "URL building...
Write a Python function to calculate the sum of the first `n` natural numbers. Implement the function using a list comprehension and arithmetic operations. Your code should pass the following assertions: ```python assert sum_of_natural_numbers(1) == 1 assert sum_of_natural_numbers(5) == 15 ```
The `sum()` function calculates the sum of the elements in the range generated by the `range()` function, which is a list comprehension.
def sum_of_natural_numbers(n): return sum(x for x in range(1, n + 1))
# [derived:explicit_asserts_in_instruction] assert sum_of_natural_numbers(1) == 1 assert sum_of_natural_numbers(5) == 15
Solution verified by execution. Tests assert 2 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 2 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(2 asserts)", ...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 685252, "original_split": "train", "seed_concepts": [ "list comprehension and arithmetic operations", "list traversal" ...
Create a Python function that takes two strings, `s1` and `s2`, and return their numerical difference. If either string cannot be converted to a valid number, return 0. Your code should pass the following assertions: ```python assert numerical_difference("123", "100") == 23 assert numerical_difference("abc", "100") ==...
You can use the `int()` function to convert strings to integers and the `try-except` block to catch the `ValueError` exception when a string cannot be converted to an integer. A simple way to find the numerical difference is to subtract `s2` from `s1`.
def numerical_difference(s1, s2): try: num1 = int(s1) num2 = int(s2) return num1 - num2 except ValueError: return 0
# [derived:explicit_asserts_in_instruction] assert numerical_difference('123', '100') == 23 assert numerical_difference('abc', '100') == 0
Solution verified by execution. Tests assert 2 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 2 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(2 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 308607, "original_split": "train", "seed_concepts": [ "string to number conversion", "string comparison" ], "code_m...
Given a list that contains some empty elements, write a Python function to filter out these empty elements and return a new list with only non-empty elements. Your code should pass the following test case: ```python lst = [1, 2, 3, None, 4, None, 5] expected_result = [1, 2, 3, 4, 5] assert remove_empty(lst) == expecte...
To filter out empty elements from a list in Python, we can leverage the `filter` function and provide a predicate function that checks if the element is not empty. The `filter` function will return a generator object, which we can convert into a list using the `list` function.
def remove_empty(lst: list) -> list: return list(filter(None, lst))
# [derived:explicit_asserts_in_instruction] expected_result = [1, 2, 3, 4, 5] lst = [1, 2, 3, None, 4, None, 5] assert remove_empty(lst) == expected_result
The `filter` function takes two arguments: a predicate function and an iterable object. In this case, we pass `None` as the predicate function, which is a shorthand for a function that returns `True` if the argument is not `None`, and `False` otherwise. This means that the `filter` function will remove elements from th...
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 1 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(1 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 499120, "original_split": "train", "seed_concepts": [ "list traversal", "empty element filtering" ], "code_modified...
Develop a Python function `is_prime` that determines whether a given integer `n` is prime. The function should return a Boolean value indicating whether `n` is prime or not. Your code should pass the following assertions: ```python assert is_prime(8) == False assert is_prime(2) == True assert is_prime(3) == True ```
To check if a given number `n` is prime, we can follow a well-known algorithm that checks for divisibility by all numbers between 2 and `n**0.5`. This is because any number greater than `n**0.5` will have a corresponding divisor less than or equal to `n**0.5`.
def is_prime(n): if n < 2: return False for i in range(2, int(n**0.5) + 1): if n % i == 0: return False return True
# [derived:explicit_asserts_in_instruction] assert is_prime(8) == False assert is_prime(2) == True assert is_prime(3) == True
Solution verified by execution. Tests assert 3 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 3 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(3 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 564393, "original_split": "train", "seed_concepts": [ "prime number analysis", "prime factorization", "function com...
Write a Python function that calculates the interest rate on a loan. Your function should take as input the loan amount, interest rate, and number of years and return the interest. Your code should pass the following test case: ```python loan_amount = 10000 interest_rate = 5 number_of_years = 3 assert calculate_intere...
In this implementation, the `calculate_interest` function takes three arguments: `loan_amount`, `interest_rate`, and `number_of_years`. It calculates the interest by multiplying the loan amount, interest rate, and number of years and returns the result.
def calculate_interest(loan_amount, interest_rate, number_of_years): interest = loan_amount * (interest_rate / 100) * number_of_years return interest
# [derived:explicit_asserts_in_instruction] interest_rate = 5 loan_amount = 10000 number_of_years = 3 assert calculate_interest(loan_amount, interest_rate, number_of_years) == 1500
Solution verified by execution. Tests assert 1 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 1 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(1 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 46719, "original_split": "train", "seed_concepts": [ "interest rate calculation", "interest rate formula implementation...
Create a Python function that returns a list of all the keys in a dictionary that start with a given prefix. For instance, given prefix "a", the function should return ["apple", "aardvark", "avocado"] for the following dictionary: ```python {"apple": 1, "aardvark": 3, "avocado": 2, "banana": 5} ``` Your code should p...
To create a function that returns a list of all keys in a dictionary that start with a given prefix, you can iterate over the dictionary keys and check if each key starts with the prefix.
def get_keys_with_prefix(dictionary, prefix): keys_with_prefix = [] for key in dictionary: if key.startswith(prefix): keys_with_prefix.append(key) return keys_with_prefix
# [derived:explicit_asserts_in_instruction] expected_keys = ['apple', 'aardvark', 'avocado'] test_dict = {'apple': 1, 'aardvark': 3, 'avocado': 2, 'banana': 5} assert get_keys_with_prefix(test_dict, 'a') == expected_keys
Solution verified by execution. Tests assert 1 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 1 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(1 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 352426, "original_split": "train", "seed_concepts": [ "dictionary traversal", "list creation", "string manipulation...
We have a function `f` that takes a list and returns a tuple of two elements: the first element is the first element in the list, and the second element is the number of elements in the list. We would like to test the function using mocking techniques to avoid the side effect of actually calling the function. We want t...
To test the function `f` using mocking techniques while ensuring that the first element of the tuple is the first element in the list, we can use the `unittest.mock` module to create a mock object of the function `f` and pass it to the function `mock_f`. This allows us to test the function `mock_f` without actually cal...
import unittest.mock def f(lst): return lst[0], len(lst) def mock_f(lst): mock_f = unittest.mock.Mock(return_value=(lst[0], len(lst))) return mock_f(lst)
lst = [1, 2, 3] result = mock_f(lst) expected_output = (lst[0], len(lst)) assert result == expected_output
This code creates a mock object of the function `f` using the `unittest.mock.Mock` class and passes it to the function `mock_f`. The mock object is configured to return a tuple where the first element is the first element in the list and the second element is the number of elements in the list. To test the function `m...
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s); solution run together with the response's own test code; PASSED. Up...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:released(1 asserts)" ...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 342096, "original_split": "train", "seed_concepts": [ "mocking of function behaviour for testing purposes", "modular co...
Write a Python function `image_mirror` that takes in an image as a list of lists of pixel values, and returns the mirrored image as a new list of lists. The function should mirror the image along the vertical axis and return the mirrored image as a new list. Your code should pass the following test case: ```python # T...
To write an `image_mirror` function that mirrors an image along the vertical axis, you need to: 1. Define a function that takes in an image as a list of lists of pixel values. 2. Within the function, you can reverse the order of the pixels in each row of the image to mirror them along the vertical axis. 3. Finally, re...
def image_mirror(image): mirrored_image = [] for row in image: mirrored_row = list(reversed(row)) mirrored_image.append(mirrored_row) return mirrored_image
# [derived:explicit_asserts_in_instruction] mirrored_image = [[3, 2, 1], [6, 5, 4], [9, 8, 7]] original_image = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] assert image_mirror(original_image) == mirrored_image
Solution verified by execution. Tests assert 1 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 1 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(1 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 152977, "original_split": "train", "seed_concepts": [ "pixel value extraction", "conditional list reversal", "pixel...
Write a Python function that takes an array and returns `True` if all its elements are unique, or `False` if there is at least one duplicate. Your code should pass the following test case: ```python arr1 = [1, 2, 3, 4, 5] arr2 = [1, 1, 2, 2, 3] assert has_duplicates(arr1) == False assert has_duplicates(arr2) == True `...
Factual summary of the verified solution — defines function(s): has_duplicates.
def has_duplicates(arr): unique_elements = set(arr) return len(arr) != len(unique_elements)
# [derived:explicit_asserts_in_instruction] arr1 = [1, 2, 3, 4, 5] arr2 = [1, 1, 2, 2, 3] assert has_duplicates(arr1) == False assert has_duplicates(arr2) == True
Solution verified by execution. Tests assert 2 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 2 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(2 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 205886, "original_split": "train", "seed_concepts": [ "unique element detection", "set membership check", "data ded...
I am writing a bittorrent client, and I need a function to encode an integer into a byte string in bencode format. Here are the rules: - if the value is an integer, it is represented as `i{value}e`. - if the value is a string, it is represented as `{length}:{value}`, where `{length}` is the length of the string in byt...
For the bittorrent client, you need to encode an integer into a byte string in bencode format. Bencode is a binary-based encoding format used in the BitTorrent protocol to represent different data types, including integers, strings, lists, and dictionaries. Here's how to encode an integer in bencode format: 1. Determi...
def encode_integer(value: int) -> bytes: if not isinstance(value, int): raise TypeError("Value must be an integer") return f"i{value}e".encode()
# [derived:explicit_asserts_in_instruction] assert encode_integer(1) == b'i1e'
Solution verified by execution. Tests assert 1 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 1 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(1 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 517200, "original_split": "train", "seed_concepts": [ "string encoding", "bencode protocol", "integer to bytes conv...
Write a Python function `all_true` that accepts a list or tuple of boolean values and returns True if and only if all values are True. You should solve this problem using only one line of code and without using any conditional statements (if, else, and/or for-loops). Your solution should use Python's `all` function as ...
Factual summary of the verified solution — defines function(s): all_true; constructs: comprehension.
def all_true(values): return all(value is True for value in values)
# [derived:explicit_asserts_in_instruction] assert all_true([True, False, True]) == False assert all_true((True, False, True)) == False assert all_true((True, True, True)) == True assert all_true([True, True, True]) == True
Solution verified by execution. Tests assert 4 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 4 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(4 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 157454, "original_split": "train", "seed_concepts": [ "boolean logic", "one-line looping with generators", "predica...
Implement a recursive quick sort algorithm in Python. If the input is already sorted, it should return the input without modification. If the input is not sorted, it should sort the input using a recursive algorithm. If the input is empty, it should return an empty list. If the input is invalid, it should raise a `Valu...
Factual summary of the verified solution — defines function(s): quick_sort; constructs: comprehension, recursion.
def quick_sort(arr): if len(arr) <= 1: # Base case: the array is already sorted return arr pivot = arr[0] # Choose the first element as the pivot left = [x for x in arr[1:] if x < pivot] # Elements less than the pivot right = [x for x in arr[1:] if x >= pivot] # Elements greater than or equ...
# [derived:explicit_asserts_in_instruction] assert quick_sort([1, 2, 3]) == [1, 2, 3] assert quick_sort([]) == [] assert quick_sort([5, 1, 3, 2, 4]) == [1, 2, 3, 4, 5] assert quick_sort([3, 2, 1]) == [1, 2, 3] assert quick_sort([1]) == [1]
Solution verified by execution. Tests assert 5 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 5 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(5 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 455476, "original_split": "train", "seed_concepts": [ "iterative quick sort implementation", "recursive function invoca...
Write a Python function that takes a string as input and returns a new string where all ANSI color sequences (i.e., sequences of escape codes starting with the escape character, `\x1b`, and ending with the letter `m`) are removed. Use regular expression to match the ANSI color sequence. Your code should pass the follo...
This function uses the `re` module to compile a regular expression pattern that matches the ANSI color sequence (`\x1b\[[0-9;]*m`). The `re.sub` method is then used to remove all matches of the pattern from the input string.
import re def remove_ansi_color(text: str) -> str: ansi_color_pattern = re.compile(r'\x1b\[[0-9;]*m') return ansi_color_pattern.sub('', text)
# [derived:explicit_asserts_in_instruction] assert remove_ansi_color('\x1b[0mHello, World!\x1b[0m') == 'Hello, World!'
Solution verified by execution. Tests assert 1 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 1 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(1 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 388622, "original_split": "train", "seed_concepts": [ "ANSI color code handling with regular expressions" ], "code_modi...
Define a Python function that takes a string and an optional parameter `sep` with a default value of `' '`. If `sep` is provided, the function should return the string split by the separator, otherwise the function should return a list of individual characters in the string. Your code should pass the following asserti...
Factual summary of the verified solution — defines function(s): split_string.
def split_string(s, sep=' '): return s.split(sep) if sep else list(s)
# [derived:explicit_asserts_in_instruction] assert split_string('Hello', sep='') == ['H', 'e', 'l', 'l', 'o']
Solution verified by execution. Tests assert 1 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 1 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(1 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 61100, "original_split": "train", "seed_concepts": [ "function overloading", "dynamic function definition", "dynami...
Create a Python function that takes two integers as input and returns their sum, difference, product, and quotient as a tuple. The function's signature should use type hints to indicate the expected types and return type. Your code should pass the following assertions: ```python assert arithmetic_operations(1, 2) == (...
To create a function that returns the sum, difference, product, and quotient of two integers, you can use a tuple to store the result. Additionally, you can use type hints to indicate the expected types and return type.
from typing import Tuple def arithmetic_operations(x: int, y: int) -> Tuple[int, int, int, int]: """ Performs arithmetic operations on two integers and returns the result as a tuple: (sum, difference, product, quotient) """ return x + y, x - y, x * y, x // y
# [derived:explicit_asserts_in_instruction] assert arithmetic_operations(1, 2) == (3, -1, 2, 0) assert arithmetic_operations(5, 5) == (10, 0, 25, 1)
Solution verified by execution. Tests assert 2 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 2 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(2 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 230696, "original_split": "train", "seed_concepts": [ "function definition", "function signature with type hints", ...
Write a Python function to generate a random string of given length and with characters from a given set. If no set is provided, use the standard alphabet (uppercase and lowercase letters, digits, and punctuation). Your code should pass the following assertion: ```python assert len(random_string(100)) == 100 ```
Factual summary of the verified solution — imports: random, string; defines function(s): random_string; constructs: loop.
import random import string def random_string(length, charset=string.ascii_letters + string.digits + string.punctuation): result = [] for _ in range(length): result.append(random.choice(charset)) return "".join(result)
# [derived:explicit_asserts_in_instruction] assert len(random_string(100)) == 100
Solution verified by execution. Tests assert 1 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 1 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(1 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 267391, "original_split": "train", "seed_concepts": [ "random number generation", "string manipulation", "default p...
Write a Python function named `logistic` to compute the logistic function, given a value `x` and a parameter `a`. This function should return the result of the logistic function, which is defined as follows: $$ f(x) = \frac{1}{1 + e^{-x/a}} $$ The function should also include type hints and type annotations for the p...
The `logistic` function takes two parameters, `x` and `a`, and returns the result of the logistic function. The `x` parameter represents the value to be evaluated, and the `a` parameter controls the function's steepness. The function calculates $e^{-x/a}$ using the `exp` function from the `math` module, and then uses t...
import math def logistic(x: float, a: float) -> float: """ Compute the logistic function for a given value and parameter. Parameters: x (float): The value to be evaluated. a (float): The parameter controlling the function's steepness. Returns: float: The result of the logistic...
# [derived:explicit_asserts_in_instruction] import math assert logistic(1, 1) == 1 / (1 + math.exp(-1)) assert logistic(0, 1) == 0.5 assert logistic(3, 1) == 1 / (1 + math.exp(-3)) assert logistic(2, 1) == 1 / (1 + math.exp(-2))
Solution verified by execution. Tests assert 4 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 4 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(4 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 672012, "original_split": "train", "seed_concepts": [ "mathematical function description", "parameter documentation", ...
Write a Python function that concatenates two strings. If one of the strings is `None` or empty, return the other string. Your code should pass the following assertions: ```python assert concatenate_strings(None, "World") == "World" assert concatenate_strings("Hello", None) == "Hello" assert concatenate_strings("Hello...
This implementation checks whether `s1` or `s2` is `None` or empty. If both are valid strings, they are concatenated using the `+` operator. Otherwise, the other string is returned.
def concatenate_strings(s1: str, s2: str) -> str: if s1 is None or not s1: return s2 elif s2 is None or not s2: return s1 else: return s1 + s2
# [derived:explicit_asserts_in_instruction] assert concatenate_strings(None, 'World') == 'World' assert concatenate_strings('Hello', None) == 'Hello' assert concatenate_strings('Hello', 'World') == 'HelloWorld'
Solution verified by execution. Tests assert 3 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 3 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(3 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 646808, "original_split": "train", "seed_concepts": [ "string concatenation", "check for None and empty string" ], ...
Write a Python function `is_int(s)` that takes a string `s` and returns `True` if `s` can be parsed as an integer, and `False` otherwise. Utilize exception handling to handle any potential errors and return `False` if an exception occurs. Your code should pass the following assertions: ```python assert is_int('123') i...
In this implementation: - We use `int(s)` to try to convert the string to an integer. - If the conversion is successful, the string can be parsed as an integer, so we return `True`. - If an exception occurs during the conversion, it's likely that the string cannot be parsed as an integer, so we catch the `ValueError` e...
def is_int(s): try: int(s) return True except ValueError: return False
# [derived:explicit_asserts_in_instruction] assert is_int('123') is True assert is_int('abc') is False assert is_int('12a3') is False
Solution verified by execution. Tests assert 3 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 3 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(3 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 119170, "original_split": "train", "seed_concepts": [ "function to check if an object can be parsed as an integer", "ex...
Write a Python function `flatten_dictionary` that takes a dictionary (possibly nested) as input and flattens it into a single-level dictionary, where the keys are dot-separated (e.g., 'a.b.c' for the key 'c' in sub-dictionary 'b' in dictionary 'a'). You can assume that the input dictionary will have string keys and val...
This implementation utilizes dictionary comprehension to construct a new dictionary, in which the keys are dot-separated. If a value is a nested dictionary, it is recursively flattened and the nested keys are updated in the new dictionary. Otherwise, the key-value pair is added directly to the new dictionary.
def flatten_dictionary(d): """ Flattens a nested dictionary into a single-level dictionary. The nested keys are separated by dots. For example, a dictionary {'a': {'b': 1, 'c': 2}, 'd': 3} will be flattened to {'a.b': 1, 'a.c': 2, 'd': 3}. """ flattened = {} for key, value in d.items(): ...
# [derived:explicit_asserts_in_instruction] d = {'a': {'b': 1, 'c': 2}, 'd': 3} expected = {'a.b': 1, 'a.c': 2, 'd': 3} assert flatten_dictionary(d) == expected
Solution verified by execution. Tests assert 1 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 1 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(1 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 546674, "original_split": "train", "seed_concepts": [ "nested dictionary lookup", "dictionary key modification" ], ...
Develop a Python function `convert_to_hours_and_minutes` that takes a string representing a duration in seconds and returns a string in the format `HH:MM`. For example, if the input string is `"3600"`, the function should return `"01:00"`.
To convert a duration in seconds to the `HH:MM` format, we can divide the input seconds by 3600 to get the hours and then by 60 to get the minutes. These values can be formatted as a string using the `strftime` function.
from datetime import datetime def convert_to_hours_and_minutes(duration): duration_in_seconds = int(duration) hours = duration_in_seconds // 3600 minutes = (duration_in_seconds % 3600) // 60 time = datetime.strptime(f"{hours}:{minutes}", "%H:%M") return time.strftime("%H:%M")
# [derived:input_return_pair] assert convert_to_hours_and_minutes('3600',) == '01:00'
Solution verified by execution. Tests assert 1 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 1 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(1 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 452496, "original_split": "train", "seed_concepts": [ "time unit conversions", "string interpolation", "formatting ...
Write a Python function `error_measure(a, b)` that returns the absolute difference between two numbers without using any built-in math functions. The function should also be annotated for type hints. The function's docstring should make the reader understand the function's purpose. Your code should pass the following ...
In this implementation: - The type hints on the function definition indicate that `a` and `b` are both `float` numbers. - The docstring explains that the function returns the absolute difference between `a` and `b`. - The function uses an if-else statement to check which of the two numbers is larger, and then subtracts...
def error_measure(a: float, b: float) -> float: """Return the absolute difference between two numbers without using any built-in math functions.""" if a > b: return a - b else: return b - a
# [derived:explicit_asserts_in_instruction] assert error_measure(5, 10) == 5 assert error_measure(10, 5) == 5
Solution verified by execution. Tests assert 2 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 2 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(2 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 191582, "original_split": "train", "seed_concepts": [ "error measurement", "function documentation" ], "code_modifi...
Write a Python function that takes in a positive integer as an argument and returns a string that represents the integer in its binary form. The string should be padded with zeros to the left so that it always has 32 characters. Your code should pass the following assertions: ```python assert int_to_bin(10) == "000000...
Factual summary of the verified solution — defines function(s): int_to_bin; constructs: loop.
def int_to_bin(num): if not isinstance(num, int) or num < 0: raise ValueError("Input must be a positive integer.") bin_str = "" while num > 0: bin_str = str(num % 2) + bin_str num //= 2 bin_str = (32 - len(bin_str)) * "0" + bin_str return bin_str
# [derived:explicit_asserts_in_instruction] assert int_to_bin(10) == '00000000000000000000000000001010' assert int_to_bin(4) == '00000000000000000000000000000100'
Solution verified by execution. Tests assert 2 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 2 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(2 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 486933, "original_split": "train", "seed_concepts": [ "bit string representation", "string formatting" ], "code_mod...
A code is a string of five characters. It is valid if it starts with "X" and contains only letters and numbers. Write a Python function to check if a code is valid. Your code should pass the following assertions: ```python assert is_valid_code("XABC5") assert not is_valid_code("XABC5!") assert not is_valid_code("Y1234...
To check if a code is valid, we need to check if it starts with "X" and contains only letters and numbers. We can use the `startswith()` method of the `str` class to check if the code starts with "X" and the `isalnum()` method of the `str` class to check if the code contains only letters and numbers
def is_valid_code(code): return code.startswith("X") and code[1:].isalnum()
# [derived:explicit_asserts_in_instruction] assert is_valid_code('XABC5') assert not is_valid_code('XABC5!') assert not is_valid_code('Y1234') assert is_valid_code('XabC5')
Solution verified by execution. Tests assert 4 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 4 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(4 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 6877, "original_split": "train", "seed_concepts": [ "string comparison", "limited branching with single-purpose functio...
Create a Python function `find_substrings(string, n)` that returns all substrings of length `n` from a given input `string`. For example, `find_substrings('abcde', 2)` should return `['ab', 'bc', 'cd', 'de']`.
The `range` function generates the starting indices for the substrings, and the list comprehension slices the string at each index to extract the substring of the desired length.
def find_substrings(string, n): return [string[i:i+n] for i in range(len(string)-n+1)]
# [derived:example_call_in_instruction] assert find_substrings('abcde', 2) == ['ab', 'bc', 'cd', 'de']
Solution verified by execution. Tests assert 1 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 1 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(1 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 579931, "original_split": "train", "seed_concepts": [ "string formatting", "dynamic string concatenation", "string ...
Define a Python function `create_regex(pattern)` that takes a string pattern as input and returns a regular expression object that matches it. If the pattern is invalid, the function should raise a `ValueError`. The pattern may contain characters, groups, and repetitions in any order. Here are some examples of valid pa...
You need to use recursion to solve this problem. The function should use the `re.compile()` method to create a regular expression object and `re.escape()` to escape special characters in the pattern. The function should also raise a `ValueError` if the pattern is invalid.
import re def create_regex(pattern): if not pattern: return elif "{" in pattern: group, repetition = pattern.split("{") return re.compile(re.escape(group) + "{" + create_regex(re.escape(repetition)) + "}") else: for symbol in ["*", "+", "?"]: if symbol in pattern...
# [derived:explicit_asserts_in_instruction] assert create_regex('a*').match('a') assert create_regex('a').match('a') assert create_regex('a*b?c+').match('ac')
Solution verified by execution. Tests assert 3 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 3 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(3 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 231886, "original_split": "train", "seed_concepts": [ "regular expression construction", "string formatting" ], "co...
Write a Python function to traverse a nested data structure of lists and tuples containing lists and tuples. The function should take a list/tuple of objects, recursively traverse them, and return a list of the **leaf-node** values (the values that are not themselves lists or tuples). You should use mutually recursive ...
1. **Identify the recursive nature of the data structure:** The data structure is a nested collection of lists and tuples containing lists and tuples. It's natural to consider recursive traversal and processing of these structures. 2. **Identify the base case:** The base case is when you encounter a non-list/non-tuple...
def process_list(collection): for item in collection: if isinstance(item, (list, tuple)): yield from process_list(item) if isinstance(item, list) else process_tuple(item) else: yield item def process_tuple(collection): for item in collection: if isinstance(item, ...
# [derived:explicit_asserts_in_instruction] assert list(process_list(((1, 2), (3, 4), 5))) == [1, 2, 3, 4, 5] assert list(process_list([1, 2, 3])) == [1, 2, 3] assert list(process_list([(1, 2), (3, 4), 5])) == [1, 2, 3, 4, 5] assert list(process_list([[[1, 2], [3, 4]], 5])) == [1, 2, 3, 4, 5] assert list(process_list([...
These functions define mutually recursive functions to traverse and process the nested data structure. The `process_list` function takes a list as input, iterates over each item in the list, and counts the number of times the word "cat" appears in the item. If the item is a list or tuple, it recursively calls either `p...
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 5 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(5 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 497495, "original_split": "train", "seed_concepts": [ "recursive tree traversal", "mutual recursion", "deferred eva...
Implement a Python function `indices` that takes a list of booleans and returns the indices of the list elements that are `True`. Do this using list comprehension and `enumerate`. For example, `indices([True, False, True])` should return `[0, 2]`.
The `enumerate` function is used to get both the index and the value of each element in the list. The `if` statement checks if the current element is `True`. If it is, the index of that element is appended to the list of indices. Finally, the list of indices is returned.
def indices(bool_list): indices = [] for i, bool_value in enumerate(bool_list): if bool_value: indices.append(i) return indices
# [derived:example_call_in_instruction] assert indices([True, False, True],) == [0, 2]
Solution verified by execution. Tests assert 1 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 1 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(1 asserts)", ...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 408562, "original_split": "train", "seed_concepts": [ "list comprehension", "index extraction from a boolean list" ],...
Write a Python function to calculate the average of a list of numbers. If the length of the list is 0, return `None`. Your code should pass the following assertions: ```python assert average([]) is None assert average([1, 2, 3]) == 2 ```
Factual summary of the verified solution — defines function(s): average.
def average(lst): if len(lst) == 0: return None return sum(lst) / len(lst)
# [derived:explicit_asserts_in_instruction] assert average([]) is None assert average([1, 2, 3]) == 2
Solution verified by execution. Tests assert 2 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 2 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(2 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 303574, "original_split": "train", "seed_concepts": [ "list processing", "average calculation" ], "code_modified": ...
Write a Python function to create a list of integers of length `n` that starts with `1` and increments by `1` each time until it reaches `n`. The function should also ensure that `n` is a positive integer. If `n` is a negative integer, the function should return an empty list. If `n` is `0`, the function should return...
Factual summary of the verified solution — defines function(s): create_list; constructs: loop.
def create_list(n): if n < 0: return [] elif n == 0: return [1] result = [] for i in range(1, n + 1): result.append(i) return result
# [derived:explicit_asserts_in_instruction] assert create_list(-1) == [] assert create_list(10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Solution verified by execution. Tests assert 2 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 2 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(2 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 405006, "original_split": "train", "seed_concepts": [ "branching", "variable assignment", "integer list generation"...
Write a Python function, `custom_max`, that takes a list of numbers as an argument and returns the maximum value using a recursive algorithm. The function should support multiple input types, such as lists, tuples, and arrays, and should handle empty input gracefully. The function should not use built-in Python functio...
To write a recursive function to find the maximum value in a list of numbers, we can use the following steps: 1. Define the `custom_max` function with a single argument, which is a list of numbers. 2. Check if the list is empty. If it is, return `None`. 3. Otherwise, if the list has only one element, return that eleme...
def custom_max(lst): """Find the maximum value in a list of numbers using a recursive algorithm. Args: lst (list): A list of numbers. Returns: float: The maximum value in the list. Examples: >>> custom_max([1, 2, 3]) 3.0 >>> custom_max([3.0, 2.0, 1.0]) ...
# [derived:explicit_asserts_in_instruction] assert custom_max([1, 2, 3]) == 3.0 assert custom_max([3.0, 2.0, 1.0]) == 3.0 assert custom_max([-1, -2, -3]) == -1.0 assert custom_max([1, 2, 3, 4, 5]) == 5.0 assert custom_max([]) is None
Solution verified by execution. Tests assert 5 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 5 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(5 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 407531, "original_split": "train", "seed_concepts": [ "function argument unpacking", "list/array processing", "min/...
Design a Python function that takes a string containing parentheses and returns `True` if the parentheses are balanced. The function should handle all types of parentheses, including curly braces (`{}`), brackets (`[]`), and parentheses (`()`) by counting the number of opening and closing parentheses for each type. Fo...
The function iterates over all characters in the string, `parens`. If the character is an opening parenthesis, it is pushed onto the stack. If the character is a closing parenthesis, we check if the stack is empty. If it is, the parentheses are not balanced, so we return `False`. If the stack is not empty, we pop the t...
def is_balanced(parens): stack = [] for char in parens: if char in ['(', '[', '{']: stack.append(char) else: if not stack: return False if char == ')' and stack[-1] != '(': return False if char == ']' and stack[-1] !...
# [derived:input_return_pair] assert is_balanced('{[()]}',) == True
Solution verified by execution. Tests assert 1 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 1 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(1 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 509427, "original_split": "train", "seed_concepts": [ "string manipulation", "parentheses balancing" ], "code_modif...
Write a Python function `validate_string_input` that takes a `string` and a `min_length` as input parameters, and returns True if the string's length is greater than or equal to the min_length, or False otherwise. If `min_length` is not provided, it should default to zero. You should validate the user input with a prec...
To validate a string input to meet a certain length requirement, you can write a function that takes the string and the minimum length as input parameters and returns a Boolean value. The function should validate the input parameters to ensure that they are valid and meet the necessary criteria. You can then use the `...
def validate_string_input(string, min_length=0): if not isinstance(string, str): raise TypeError("The 'string' parameter must be a string.") if not isinstance(min_length, int): raise TypeError("The 'min_length' parameter must be an integer.") if min_length < 0: raise ValueError("The ...
# [derived:example_call_in_instruction] assert validate_string_input('abc', 2) == True assert validate_string_input('s', 5) == False
This function takes two parameters: `string` and `min_length`. It has a default value of `0` for `min_length` so that it can be omitted when calling the function. The function first checks that the `string` parameter is a string and the `min_length` parameter is an integer. If not, it raises an appropriate error. It ...
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 2 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(2 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 7501, "original_split": "train", "seed_concepts": [ "input validation", "literal comparison", "conditional return" ...
Define a Python function `get_first_non_repeating_char(s)` that takes a string `s` and returns the first non-repeating character in it. If there is no such character, the function should return `None`. The function should be able to handle invalid inputs and gracefully fail without crashing when there is an error. You...
The goal is to develop a Python function `get_first_non_repeating_char(s)` that takes a string `s` and returns the first non-repeating character in it. If there is no such character, the function should return `None`. We will handle invalid inputs and gracefully fail without crashing. To achieve this, we will utilize ...
import collections def get_first_non_repeating_char(s): try: if isinstance(s, str) and len(s) > 0: counts = collections.Counter(s) for char in s: if counts[char] == 1: return char return None else: raise ValueError(...
# [derived:explicit_asserts_in_instruction] assert get_first_non_repeating_char('abcabc') is None assert get_first_non_repeating_char('aabbcc') is None assert get_first_non_repeating_char('') is None
Solution verified by execution. Tests assert 3 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 3 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(3 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 612908, "original_split": "train", "seed_concepts": [ "error handling", "graceful failure", "logging", "functio...
Implement a Python function `add_one` that takes a single integer argument `x` and returns the value of x + 1. Your code should pass the following assertions: ```python assert add_one(1) == 2 assert add_one(0) == 1 ```
In this implementation, we increment the input `x` by one and then return the result.
def add_one(x): return x + 1
# [derived:explicit_asserts_in_instruction] assert add_one(1) == 2 assert add_one(0) == 1
Solution verified by execution. Tests assert 2 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 2 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(2 asserts)", ...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 8335, "original_split": "train", "seed_concepts": [ "scalar to scalar function" ], "code_modified": false, "tests_add...
Write a Python function to convert an integer to its string representation in hexadecimal form. The function should follow the following rules: - Use lowercase letters for the hexadecimal digits, `'0'` through `'9'` and `'a'` through `'f'`. - For non-negative integers, the function should return the string representat...
Factual summary of the verified solution — defines function(s): int_to_hex.
def int_to_hex(num): return f"{'-' if num < 0 else ''}0x{'0' * ((abs(num) % 4) ^ (abs(num) % 4) - 4)}{abs(num):x}"
# [derived:explicit_asserts_in_instruction] assert int_to_hex(-17) == '-0x11' assert int_to_hex(0) == '0x0'
Solution verified by execution. Tests assert 2 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 2 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(2 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 65340, "original_split": "train", "seed_concepts": [ "modulo", "number rounding", "conditional expression" ], "...
Write a Python function `check_palindrome_permutation` that determines if a given string is a permutation of a palindrome. A palindrome is a word or phrase that is spelled the same forwards and backwards. The function should return `True` if the input string is a permutation of a palindrome, and `False` otherwise. You...
The implementation first counts the frequency of each character in the input string. Next, it checks if the string is a permutation of a palindrome by checking if there is at most one character with an odd frequency. If the condition is satisfied, it returns `True`, indicating that the string is a permutation of a pali...
def check_palindrome_permutation(string): frequency = {} for char in string: frequency[char] = frequency.get(char, 0) + 1 odd_frequency_count = 0 for char in frequency: if frequency[char] % 2 == 1: odd_frequency_count += 1 return odd_frequency_count <= 1
# [derived:explicit_asserts_in_instruction] assert check_palindrome_permutation('aabbbc') == False assert check_palindrome_permutation('aabbc') == True assert check_palindrome_permutation('abcd') == False
Solution verified by execution. Tests assert 3 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 3 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(3 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 407356, "original_split": "train", "seed_concepts": [ "string manipulation", "string comparison" ], "code_modified"...
Design a Python function that takes a tuple or an integer, and returns a tuple of the same length with the maximum value for each element. For example, given `input_data = (12, 3, 4)`, the function should return `(12, 12, 12)`.
To design a Python function that takes a tuple or an integer and returns a tuple of the same length with the maximum value for each element, we can follow these steps: 1. Check the input data type: Determine whether the input is a tuple or an integer. 2. Find the maximum value: Use `max()` to obtain the maximum value ...
def return_max_tuple(input_data): if isinstance(input_data, tuple): max_value = max(input_data) return tuple([max_value] * len(input_data)) elif isinstance(input_data, int): return (input_data,) else: raise TypeError('Input must be a tuple or an integer.')
# [derived:given_assignments] assert return_max_tuple((12, 3, 4),) == (12, 12, 12)
Solution verified by execution. Tests assert 1 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 1 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(1 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 154809, "original_split": "train", "seed_concepts": [ "polymorphism", "tuple and integer manipulation" ], "code_mod...
Write a Python function that takes an ordered list of (x, y) data points and returns the slope at a given x value. The function should handle the following cases: 1. If there are multiple points with the same x value, the slope should be calculated at the average y value of all matches. 2. If there are multiple points...
To write a Python function that takes an ordered list of (x, y) data points and returns the slope at a given x value, you can follow these steps: 1. Iterate over the data points and find any that match the given x value. 2. If there are multiple matches, calculate the average y value and use it to calculate the slope....
def slope_at_x(data, x): matching_data_points = [] for point in data: if point[0] == x: matching_data_points.append(point) if not matching_data_points: return None if len(matching_data_points) == 1: return matching_data_points[0][1] average_y = sum(point[1] for...
# [derived:explicit_asserts_in_instruction] data = [(1, 2), (1, 3), (1, 4), (2, 5), (3, 6)] assert slope_at_x(data, 1) == 3 assert slope_at_x(data, 2) == 5 assert slope_at_x(data, 3) == 6 assert slope_at_x(data, 4) is None
This implementation iterates over the data points and finds any that match the given x value. If there are multiple matches, it calculates the average y value and uses it to calculate the slope. If there is only one match, it calculates the slope using the matched data point. If there are no matches, it returns None.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 4 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(4 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 386537, "original_split": "train", "seed_concepts": [ "ordered list handling", "numerical differentiation" ], "code...
Write a Python function that takes an input string and escapes all special characters using Python's `re.escape` method. Your code should pass the following assertions: ```python assert escape_special_characters("?") == "\?" assert escape_special_characters("cat") == "cat" assert escape_special_characters("[") == "\["...
escape`:
import re def escape_special_characters(input_string): return re.escape(input_string)
# [derived:explicit_asserts_in_instruction] assert escape_special_characters('?') == '\\?' assert escape_special_characters('cat') == 'cat' assert escape_special_characters('[') == '\\['
The `re.escape` function converts all special characters in a given string into their escaped versions. For example, it converts `?` into `\?`, and `[` into `\[`, etc.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 3 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(3 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 336715, "original_split": "train", "seed_concepts": [ "regex-based escaping of special characters in a string" ], "code...
Implement a Python function `format_seq_string(seq, sep, width)` that takes a sequence and formats it into a string by concatenating all the elements of the input sequence, separated by the given separator. The function should pad each element with leading zeros to the given width. If the width is not a positive intege...
To implement a Python function that formats a sequence of elements into a string with leading zeros, we need to iterate through the sequence, padding each element with leading zeros to the given `width`, and join the elements with the given `sep` separator. Additionally, we need to handle the case where `width` is not ...
def format_seq_string(seq, sep, width): if not isinstance(width, int) or width <= 0: raise ValueError("width must be a positive integer") result = [] for element in seq: element_str = str(element) if len(element_str) < width: element_str = element_str.zfill(width) ...
# [derived:explicit_asserts_in_instruction] assert format_seq_string([5, 15, 25], ' ', 2) == '05 15 25' assert format_seq_string([1, 2, 3], ',', 2) == '01,02,03' assert format_seq_string([10, 20, 30], '-', 3) == '010-020-030' assert format_seq_string([1, 10, 100], '/', 3) == '001/010/100'
Solution verified by execution. Tests assert 4 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 4 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(4 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 644285, "original_split": "train", "seed_concepts": [ "sequence handling", "string formatting", "precondition check...
Design a Python function that takes a string and returns true if the string is a valid IP address. An IP address contains four segments, where each segment is a string of digits between 0 and 255. The function should return false if any segment is not valid. Your code should pass the following assertions: ```python as...
To validate an IP address, we need to check that it contains four segments, where each segment is a string of numbers between 0 and 255. To check each segment, we can use regular expressions to match the segment pattern, and parse the number to check if it is within the valid range. We can use the `ipaddress` module to...
import re import ipaddress def is_valid_ip_address(ip_address: str) -> bool: segment_pattern = r"^([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$" segments = ip_address.split(".") return len(segments) == 4 and all(re.match(segment_pattern, segment) for segment in segments)
# [derived:explicit_asserts_in_instruction] assert is_valid_ip_address('192.168.1.1') == True assert is_valid_ip_address('1.2.3.4.5.6') == False assert is_valid_ip_address('1.2.3.a') == False assert is_valid_ip_address('256.256.256.256') == False assert is_valid_ip_address('1000.1000.1000.1000') == False
The function uses regular expressions to validate the segments of the IP address. It checks that each segment is a string of numbers between 0 and 255. It also checks that the IP address contains exactly four segments.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 5 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(5 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 523252, "original_split": "train", "seed_concepts": [ "string manipulation", "IP address validation", "integer rang...
Write a Python function `format_time(time)` that takes a `time` string in the format "hh:mm:ss" and returns a new string in the format "h hours, m minutes, and s seconds". The given `time`string is guaranteed to be in the correct format. For example, given `time = "01:30:45"`, the function should return `"1 hour, 30 mi...
You can create a Python function that splits the `time` into its components (hours, minutes, and seconds), converts them to integers, and then formats them into the desired output string.
def format_time(time): hours, minutes, seconds = time.split(':') hours = int(hours) minutes = int(minutes) seconds = int(seconds) return f'{hours} hour, {minutes} minutes, and {seconds} seconds'
# [derived:given_assignments] assert format_time('01:30:45',) == '1 hour, 30 minutes, and 45 seconds'
Solution verified by execution. Tests assert 1 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 1 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(1 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 482745, "original_split": "train", "seed_concepts": [ "string formatting", "list slice", "string interpolation" ]...
Write a Python function that takes a string as input and returns the reversed string. Do not use any built-in methods or functions to solve this problem. ```python def reverse_string(str): # Write code here ``` Your code should pass the following assertions: ```python assert reverse_string("12345") == "54321" ass...
The `reverse_string` function iterates through the string `str` from the end to the beginning using a `for` loop. Each character is appended to the beginning of the `reversed_str` string, resulting in a reversed string.
def reverse_string(str): reversed_str = "" for char in str: reversed_str = char + reversed_str return reversed_str
# [derived:explicit_asserts_in_instruction] assert reverse_string('12345') == '54321' assert reverse_string('a') == 'a'
Solution verified by execution. Tests assert 2 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 2 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(2 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 4591, "original_split": "train", "seed_concepts": [ "function declaration", "argument assignment" ], "code_modified...
Write a Python function named `is_positive` that takes a float number as the argument and returns True if the number is positive. If the number is zero or negative, return False. Your code should pass the following assertion: ```python assert is_positive(2.5) is True # positive float ```
In this implementation, we check if the `number` is greater than or equal to zero. If it is, we return True. If it is not, we return False.
def is_positive(number): return number >= 0
# [derived:explicit_asserts_in_instruction] assert is_positive(2.5) is True
Solution verified by execution. Tests assert 1 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 1 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(1 asserts)", ...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 580101, "original_split": "train", "seed_concepts": [ "function definition", "conditional return", "handling of neg...
Write a Python function `validate_ip` that accepts a string as input and returns `True` if the input represents a valid IP address, and `False` otherwise. An IP address is valid if it consists of four integers separated by periods ("."), and each integer is in the range [0, 255]. If the input is invalid, your function...
Factual summary of the verified solution — defines function(s): validate_ip; constructs: loop, try/except error handling.
def validate_ip(ip_str): try: parts = ip_str.split('.') if len(parts) != 4: return False for part in parts: if not part.isdecimal(): # Check if part is an integer return False if not 0 <= int(part) <= 255: return False ...
# [derived:explicit_asserts_in_instruction] assert validate_ip('1.2.3.456') == False assert validate_ip('1.2.3') == False assert validate_ip('a.b.c.d') == False assert validate_ip('1.2.3.4.5') == False assert validate_ip('256.256.256.256') == False
Solution verified by execution. Tests assert 5 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 5 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(5 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 520045, "original_split": "train", "seed_concepts": [ "IP address validation", "string splitting", "exception handl...
Write a Python function that takes a string and returns a formatted string based on a predefined template. The function should replace certain placeholders with specific values, such as the user's name, user's score, and user's date of birth. If the user's name is "", and the user's score is 100, and the user's date of...
To solve this problem, you can use a string formatting method that supports named placeholders. This allows you to easily replace placeholders with specific values, such as user's name, user's score, and user's date of birth.
def format_template(name: str, score: int, dob: str) -> str: """ Returns a formatted string based on a predefined template. The function replaces certain placeholders with specific values, such as the user's name, user's score, and user's date of birth. """ template = "{name}'s score is {score} ...
# [derived:explicit_asserts_in_instruction] assert format_template('', 100, '1980-01-01') == "'s score is 100 and he was born on 1980-01-01." assert format_template('', 95, '1995-11-23') == "'s score is 95 and he was born on 1995-11-23." assert format_template('', 80, '1981-02-14') == "'s score is 80 and he was born on...
Solution verified by execution. Tests assert 3 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 3 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(3 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 6258, "original_split": "train", "seed_concepts": [ "data formatting using a template string", "conditional string conc...
Write a Python function that takes a list of integer numbers as an argument and returns a list with two values: the number of even numbers in the original list and the number of odd numbers in the original list. Use conditional variable assignment to set the value of the variables based on the evenness or oddness of th...
In this solution, we iterate through the numbers in the original list. For each number `num`, we check if it is even or odd using the modulus operator (`%`). If the remainder is 0, it is even, and we increment `even_count`. Otherwise, it is odd, and we increment `odd_count`. Finally, we return a list containing the cou...
def even_odd_count(numbers): even_count = 0 odd_count = 0 for num in numbers: if num % 2 == 0: even_count += 1 else: odd_count += 1 return [even_count, odd_count]
# [derived:explicit_asserts_in_instruction] assert even_odd_count([2, 4, 6, 8, 10]) == [5, 0] assert even_odd_count([1, 3, 5, 7, 9]) == [0, 5] assert even_odd_count([1, 2, 3, 4, 5]) == [2, 3]
Solution verified by execution. Tests assert 3 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 3 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(3 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 64386, "original_split": "train", "seed_concepts": [ "conditional variable assignment", "branching based on a value in ...
Implement the quicksort algorithm in Python. The Hoare partition is preferred but the Hoare partition with no temporary variable is also acceptable. Your implementation should be a recursive algorithm and also an in-place algorithm. Your code should pass the following assertions: ```python assert quicksort([3, 2, 1]) ...
To implement the quicksort algorithm in Python, you can follow these steps: 1. Choose a pivot that divides the original list into two sublists: larger than the pivot and smaller than the pivot. You can select any element of the list as the pivot, such as the first element, the last element, or a random element. 2. Div...
def quicksort(lst): if len(lst) <= 1: return lst pivot = lst[0] lower = [x for x in lst[1:] if x < pivot] upper = [x for x in lst[1:] if x >= pivot] return quicksort(lower) + [pivot] + quicksort(upper)
# [derived:explicit_asserts_in_instruction] assert quicksort([3, 2, 1]) == [1, 2, 3] assert quicksort([1]) == [1] assert quicksort([1, 3, 2]) == [1, 2, 3] assert quicksort([]) == []
This implementation uses list comprehensions to divide the list into two sublists based on the pivot. It recursively calls the quicksort function on the two sublists, and concatenates the sorted sublists along with the pivot to produce the final sorted list.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 4 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(4 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 580472, "original_split": "train", "seed_concepts": [ "quicksort implementation", "Hoare partition", "Hoare partiti...
Write a Python function to detect frequency labels (e.g., "50 Hz", "100 Hz", "200 Hz", etc.) in a string and return their corresponding frequencies in Hz. The function should return a list of tuples `(frequency, label)`, where `frequency` is an integer and `label` is a string. Use regular expressions to extract the fre...
This implementation uses regular expressions to find all occurrences of frequency labels in the input string. It extracts the frequency from the label and converts it to an integer, while preserving the original label string. The function returns a list of tuples, where each tuple represents a detected frequency label ...
import re def detect_frequency_labels(text): """ Detects frequency labels in a string and returns their corresponding frequencies. """ frequencies = [] pattern = re.compile(r'\d+ Hz') # Match a number followed by "Hz" for match in re.findall(pattern, text): frequency = int(match.split(...
# [derived:explicit_asserts_in_instruction] assert detect_frequency_labels('The frequency is 50 Hz and the amplitude is 10 V.') == [(50, '50 Hz')] assert detect_frequency_labels('The signal has a frequency of 100 Hz and an amplitude of 5 V.') == [(100, '100 Hz')] assert detect_frequency_labels('The signal has a frequen...
Solution verified by execution. Tests assert 3 example behavior(s) from the instruction.
{ "executed": true, "tests_passed": true, "verification_method": "Re-executed by us in sandbox (isolated subprocess: temp cwd, env stripped to PATH, python -I, RLIMIT_CPU=10s, RLIMIT_AS=2GB, RLIMIT_NPROC=64, RLIMIT_FSIZE=8MB, wall timeout 8-12s) against 3 assertion(s) automatically extracted from concrete literal...
{ "source_quality": "Tier 1 (documented): every released response was execution-filtered in a Docker sandbox during SelfCodeAlign data generation (NeurIPS'24, arXiv:2410.24198); seeds are real Python functions from The Stack via MultiPL-T; license ODC-BY-1.0", "example_quality": [ "tests:derived(3 asserts)" ]...
{ "original_dataset": "bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_url": "https://huggingface.co/datasets/bigcode/self-oss-instruct-sc2-exec-filter-50k", "original_id": 611006, "original_split": "train", "seed_concepts": [ "frequency label detection", "string manipulation" ], "code_m...
End of preview.
README.md exists but content is empty.
Downloads last month
697