Dataset Preview
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: CastError
Message: Couldn't cast
</tool_call>: int64
<tool_call>: int64
<|box_end|>: int64
<|box_start|>: int64
<|endoftext|>: int64
<|file_sep|>: int64
<|fim_middle|>: int64
<|fim_pad|>: int64
<|fim_prefix|>: int64
<|fim_suffix|>: int64
<|im_end|>: int64
<|im_start|>: int64
<|image_pad|>: int64
<|object_ref_end|>: int64
<|object_ref_start|>: int64
<|quad_end|>: int64
<|quad_start|>: int64
<|repo_name|>: int64
<|video_pad|>: int64
<|vision_end|>: int64
<|vision_pad|>: int64
<|vision_start|>: int64
chosen_code: string
pair_id: string
schema_version: string
task_id: string
specification: string
rejected_code: string
label_source: string
signature: string
to
{'schema_version': Value('string'), 'pair_id': Value('string'), 'task_id': Value('string'), 'specification': Value('string'), 'signature': Value('string'), 'chosen_code': Value('string'), 'rejected_code': Value('string'), 'label_source': Value('string')}
because column names don't match
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 2306, in cast_table_to_schema
raise CastError(
...<3 lines>...
)
datasets.table.CastError: Couldn't cast
</tool_call>: int64
<tool_call>: int64
<|box_end|>: int64
<|box_start|>: int64
<|endoftext|>: int64
<|file_sep|>: int64
<|fim_middle|>: int64
<|fim_pad|>: int64
<|fim_prefix|>: int64
<|fim_suffix|>: int64
<|im_end|>: int64
<|im_start|>: int64
<|image_pad|>: int64
<|object_ref_end|>: int64
<|object_ref_start|>: int64
<|quad_end|>: int64
<|quad_start|>: int64
<|repo_name|>: int64
<|video_pad|>: int64
<|vision_end|>: int64
<|vision_pad|>: int64
<|vision_start|>: int64
chosen_code: string
pair_id: string
schema_version: string
task_id: string
specification: string
rejected_code: string
label_source: string
signature: string
to
{'schema_version': Value('string'), 'pair_id': Value('string'), 'task_id': Value('string'), 'specification': Value('string'), 'signature': Value('string'), 'chosen_code': Value('string'), 'rejected_code': Value('string'), 'label_source': Value('string')}
because column names don't match
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 1880, in _prepare_split_single
raise DatasetGenerationError("An error occurred while generating the dataset") from e
datasets.exceptions.DatasetGenerationError: An error occurred while generating the datasetNeed help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
schema_version string | pair_id string | task_id string | specification string | signature string | chosen_code string | rejected_code string | label_source string |
|---|---|---|---|---|---|---|---|
1.0 | pair-000000 | train-longest_alternating_gap_subsequence-0000 | Given a list of integers nums and two positive integers a and b, find the maximum length of a subsequence (elements taken in original order, not necessarily contiguous) whose consecutive differences strictly alternate in direction and satisfy size thresholds: an up-step from x to y requires y - x >= a, a down-step from... | longest_alternating_gap_subsequence(nums, a, b) | def longest_alternating_gap_subsequence(nums, a, b):
# Input validation checks
if a < 1 or b < 1:
return -1
if not nums:
return 0
n = len(nums)
# Helper function to calculate the length of the alternating gap subsequence ending with nums[j]
def calculate_length(i, direc... | def longest_alternating_gap_subsequence(nums, a, b):
if a < 1 or b < 1:
return -1
if not nums:
return 0
n = len(nums)
up = [1] * n
down = [1] * n
for i in range(1, n):
if abs(nums[i] - nums[i-1]) == a:
up[i] = max(up[i], down[i-1] + 1)
... | preference-annotator |
1.0 | pair-000001 | train-longest_alternating_gap_subsequence-0000 | Given a list of integers nums and two positive integers a and b, find the maximum length of a subsequence (elements taken in original order, not necessarily contiguous) whose consecutive differences strictly alternate in direction and satisfy size thresholds: an up-step from x to y requires y - x >= a, a down-step from... | longest_alternating_gap_subsequence(nums, a, b) | def longest_alternating_gap_subsequence(nums, a, b):
if a <= 0 or b <= 0:
return -1
n = len(nums)
if n == 0:
return 0
directions = []
i = 1
while i < n:
difference = nums[i] - nums[i-1]
if difference > 0:
if directions and directions[-1] == 'down':
... | def longest_alternating_gap_subsequence(nums, a, b):
# Input validation checks
if a < 1 or b < 1:
return -1
if not nums:
return 0
n = len(nums)
# Helper function to calculate the length of the alternating gap subsequence ending with nums[j]
def calculate_length(i, direc... | preference-annotator |
1.0 | pair-000002 | train-longest_alternating_gap_subsequence-0000 | Given a list of integers nums and two positive integers a and b, find the maximum length of a subsequence (elements taken in original order, not necessarily contiguous) whose consecutive differences strictly alternate in direction and satisfy size thresholds: an up-step from x to y requires y - x >= a, a down-step from... | longest_alternating_gap_subsequence(nums, a, b) | def longest_alternating_gap_subsequence(nums, a, b):
# Input validation checks
if a < 1 or b < 1:
return -1
if not nums:
return 0
n = len(nums)
# Helper function to calculate the length of the alternating gap subsequence ending with nums[j]
def calculate_length(i, direc... | def longest_alternating_gap_subsequence(nums, a, b):
if a < 1 or b < 1:
return -1
if not nums:
return 0
def dfs(index, prev_diff):
if index == len(nums):
return 0
# Move down and check
i = index
while i < len(nums) and nums[i] - nums[inde... | preference-annotator |
1.0 | pair-000003 | train-longest_alternating_gap_subsequence-0000 | Given a list of integers nums and two positive integers a and b, find the maximum length of a subsequence (elements taken in original order, not necessarily contiguous) whose consecutive differences strictly alternate in direction and satisfy size thresholds: an up-step from x to y requires y - x >= a, a down-step from... | longest_alternating_gap_subsequence(nums, a, b) | def longest_alternating_gap_subsequence(nums, a, b):
# Input validation checks
if a < 1 or b < 1:
return -1
if not nums:
return 0
n = len(nums)
# Helper function to calculate the length of the alternating gap subsequence ending with nums[j]
def calculate_length(i, direc... | def longest_alternating_gap_subsequence(nums, a, b):
if not nums:
return 0
if a < 1 or b < 1:
return -1
n = len(nums)
up_dp = [1] * n
down_dp = [1] * n
for i in range(1, n):
if nums[i] > nums[i-1]:
up_dp[i] = max(up_dp[i], down_dp[i-1] + 1)
... | preference-annotator |
1.0 | pair-000004 | train-longest_alternating_gap_subsequence-0000 | Given a list of integers nums and two positive integers a and b, find the maximum length of a subsequence (elements taken in original order, not necessarily contiguous) whose consecutive differences strictly alternate in direction and satisfy size thresholds: an up-step from x to y requires y - x >= a, a down-step from... | longest_alternating_gap_subsequence(nums, a, b) | def longest_alternating_gap_subsequence(nums, a, b):
# Input validation checks
if a < 1 or b < 1:
return -1
if not nums:
return 0
n = len(nums)
# Helper function to calculate the length of the alternating gap subsequence ending with nums[j]
def calculate_length(i, direc... | def longest_alternating_gap_subsequence(nums, a, b):
if a < 1 or b < 1:
return -1
def max_length(start, off):
count = 0
while count and (a * (nums[count] - nums[count - 1]) < 0 or b * (nums[count + 1] - nums[count]) < 0):
count += 2 if off > 0 else -2
return count//2... | preference-annotator |
1.0 | pair-000005 | train-longest_alternating_gap_subsequence-0000 | Given a list of integers nums and two positive integers a and b, find the maximum length of a subsequence (elements taken in original order, not necessarily contiguous) whose consecutive differences strictly alternate in direction and satisfy size thresholds: an up-step from x to y requires y - x >= a, a down-step from... | longest_alternating_gap_subsequence(nums, a, b) | def longest_alternating_gap_subsequence(nums, a, b):
if a <= 0 or b <= 0:
return -1
n = len(nums)
if n == 0:
return 0
directions = []
i = 1
while i < n:
difference = nums[i] - nums[i-1]
if difference > 0:
if directions and directions[-1] == 'down':
... | def longest_alternating_gap_subsequence(nums, a, b):
if a < 1 or b < 1:
return -1
if not nums:
return 0
n = len(nums)
up = [1] * n
down = [1] * n
for i in range(1, n):
if abs(nums[i] - nums[i-1]) == a:
up[i] = max(up[i], down[i-1] + 1)
... | preference-annotator |
1.0 | pair-000006 | train-cap_consecutive_runs-0001 | Given a list `items` (ints and/or strings) and an integer `limit`, return a new list in which every maximal run of consecutive equal elements is truncated to at most `limit` elements, keeping the first `limit` of that run. Non-consecutive repeats (separated by different values) are independent runs and are not merged. ... | cap_consecutive_runs(items, limit) | def cap_consecutive_runs(items, limit):
if not items:
return []
output = [items[0]]
current_count = 1
for item in items[1:]:
if item == output[-1]:
current_count += 1
else:
if current_count > limit:
output.append(item)
... | def cap_consecutive_runs(items, limit):
if len(items) < 2 or limit <= 0:
return []
result = []
current_length = 0
for i in range(1, len(items)):
if items[i] != items[i - 1]:
if current_length > limit:
result.extend(items[-limit:])
else:
... | preference-annotator |
1.0 | pair-000007 | train-cap_consecutive_runs-0001 | Given a list `items` (ints and/or strings) and an integer `limit`, return a new list in which every maximal run of consecutive equal elements is truncated to at most `limit` elements, keeping the first `limit` of that run. Non-consecutive repeats (separated by different values) are independent runs and are not merged. ... | cap_consecutive_runs(items, limit) | def cap_consecutive_runs(items, limit):
if not items:
return []
output = [items[0]]
current_count = 1
for item in items[1:]:
if item == output[-1]:
current_count += 1
else:
if current_count > limit:
output.append(item)
... | def cap_consecutive_runs(items, limit):
if not items:
return []
result = []
prev_value = None
current_run_count = 0
for value in items:
if prev_value is None or value == prev_value:
current_run_count += 1
else:
if current_run_count > limit:
... | preference-annotator |
1.0 | pair-000008 | train-cap_consecutive_runs-0001 | Given a list `items` (ints and/or strings) and an integer `limit`, return a new list in which every maximal run of consecutive equal elements is truncated to at most `limit` elements, keeping the first `limit` of that run. Non-consecutive repeats (separated by different values) are independent runs and are not merged. ... | cap_consecutive_runs(items, limit) | def cap_consecutive_runs(items, limit):
if not items:
return []
output = [items[0]]
current_count = 1
for item in items[1:]:
if item == output[-1]:
current_count += 1
else:
if current_count > limit:
output.append(item)
... | def cap_consecutive_runs(items: list[int | str], limit: int) -> list[int | str]:
if limit <= 0:
return []
res = []
start = 0
for i, item in enumerate(items):
if i + 1 < len(items) and items[i] == items[i + 1]:
continue
if start > 0 or (start == 0 a... | preference-annotator |
1.0 | pair-000009 | train-cap_consecutive_runs-0001 | Given a list `items` (ints and/or strings) and an integer `limit`, return a new list in which every maximal run of consecutive equal elements is truncated to at most `limit` elements, keeping the first `limit` of that run. Non-consecutive repeats (separated by different values) are independent runs and are not merged. ... | cap_consecutive_runs(items, limit) | def cap_consecutive_runs(items, limit):
if not items:
return []
output = [items[0]]
current_count = 1
for item in items[1:]:
if item == output[-1]:
current_count += 1
else:
if current_count > limit:
output.append(item)
... | def cap_consecutive_runs(items, limit):
if not items:
return []
if limit <= 0:
return []
result = [items[0]]
for i in range(1, len(items)):
current_item = items[i]
last_item = result[-1]
if current_item == last_item:
result[-2] ... | preference-annotator |
1.0 | pair-000010 | train-cap_consecutive_runs-0001 | Given a list `items` (ints and/or strings) and an integer `limit`, return a new list in which every maximal run of consecutive equal elements is truncated to at most `limit` elements, keeping the first `limit` of that run. Non-consecutive repeats (separated by different values) are independent runs and are not merged. ... | cap_consecutive_runs(items, limit) | def cap_consecutive_runs(items, limit):
if not items:
return []
output = [items[0]]
current_count = 1
for item in items[1:]:
if item == output[-1]:
current_count += 1
else:
if current_count > limit:
output.append(item)
... | def cap_consecutive_runs(items, limit):
if items:
if limit <= 0:
return []
result = []
current_value = None
current_count = 0
for item in items:
if item == current_value:
current_count += 1
else:
... | preference-annotator |
1.0 | pair-000011 | train-to_camel_identifier-0003 | Convert a loosely formatted identifier into lowerCamelCase. Treat spaces, underscores and hyphens as separators: split `s` on any run of these separator characters and discard empty tokens (so leading/trailing/repeated separators are ignored). If there are no tokens, return "". The first token is converted entirely to ... | to_camel_identifier(s) | def to_camel_identifier(s):
tokens = filter(None, re.split(r'[ _\-\d]+', s))
camel_case = ''.join(token.strip('_').title() for token in tokens)
return '_' + camel_case[1:] if isinstance(camel_case[0], str.isdigit()) else camel_case | import re
def to_camel_identifier(s):
# Split the string on any run of spaces, underscores and hyphens, discard empty tokens
separator_pattern = r'[ _-]+'
tokens = [token.lower() for token in re.split(separator_pattern, s) if token]
# Convert the first token to lowercase, every subsequent token has it... | preference-annotator |
1.0 | pair-000012 | train-to_camel_identifier-0003 | Convert a loosely formatted identifier into lowerCamelCase. Treat spaces, underscores and hyphens as separators: split `s` on any run of these separator characters and discard empty tokens (so leading/trailing/repeated separators are ignored). If there are no tokens, return "". The first token is converted entirely to ... | to_camel_identifier(s) | import re
def to_camel_identifier(s):
s = re.sub(r'\W+', '_', s) # Replace non-word characters with _
parts = [part.lower() for part in s.split('_') if part] # Split and convert to lowercase excluding empty tokens
return '_' + parts[0] + ''.join(part.capitalize() for part in parts[1:]) if parts else '' ... | import re
def to_camel_identifier(s):
# Split the string on any run of spaces, underscores and hyphens, discard empty tokens
separator_pattern = r'[ _-]+'
tokens = [token.lower() for token in re.split(separator_pattern, s) if token]
# Convert the first token to lowercase, every subsequent token has it... | preference-annotator |
1.0 | pair-000013 | train-to_camel_identifier-0003 | Convert a loosely formatted identifier into lowerCamelCase. Treat spaces, underscores and hyphens as separators: split `s` on any run of these separator characters and discard empty tokens (so leading/trailing/repeated separators are ignored). If there are no tokens, return "". The first token is converted entirely to ... | to_camel_identifier(s) | import re
def to_camel_identifier(s):
s = re.sub(r'\W+', '_', s) # Replace non-word characters with _
parts = [part.lower() for part in s.split('_') if part] # Split and convert to lowercase excluding empty tokens
return '_' + parts[0] + ''.join(part.capitalize() for part in parts[1:]) if parts else '' ... | def to_camel_identifier(s):
tokens = filter(None, re.split(r'[ _\-\d]+', s))
camel_case = ''.join(token.strip('_').title() for token in tokens)
return '_' + camel_case[1:] if isinstance(camel_case[0], str.isdigit()) else camel_case | preference-annotator |
1.0 | pair-000014 | train-to_camel_identifier-0003 | Convert a loosely formatted identifier into lowerCamelCase. Treat spaces, underscores and hyphens as separators: split `s` on any run of these separator characters and discard empty tokens (so leading/trailing/repeated separators are ignored). If there are no tokens, return "". The first token is converted entirely to ... | to_camel_identifier(s) | import re
def to_camel_identifier(s):
s = re.sub(r'\W+', '_', s) # Replace non-word characters with _
parts = [part.lower() for part in s.split('_') if part] # Split and convert to lowercase excluding empty tokens
return '_' + parts[0] + ''.join(part.capitalize() for part in parts[1:]) if parts else '' ... | import re
def to_camel_identifier(s):
# Sanitize by removing non-alphanumeric characters except spaces and underscores.
sanitized = re.sub(r'[^a-zA-Z0-9_\-]+', '', s)
# Split based on spaces, underscores, or hyphen.
parts = sanitized.split(' ')
# Convert tokens: capitalize the first lette... | preference-annotator |
1.0 | pair-000015 | train-to_camel_identifier-0003 | Convert a loosely formatted identifier into lowerCamelCase. Treat spaces, underscores and hyphens as separators: split `s` on any run of these separator characters and discard empty tokens (so leading/trailing/repeated separators are ignored). If there are no tokens, return "". The first token is converted entirely to ... | to_camel_identifier(s) | import re
def to_camel_identifier(s):
# Sanitize by removing non-alphanumeric characters except spaces and underscores.
sanitized = re.sub(r'[^a-zA-Z0-9_\-]+', '', s)
# Split based on spaces, underscores, or hyphen.
parts = sanitized.split(' ')
# Convert tokens: capitalize the first lette... | import re
def to_camel_identifier(s):
# Split the string on any run of spaces, underscores and hyphens, discard empty tokens
separator_pattern = r'[ _-]+'
tokens = [token.lower() for token in re.split(separator_pattern, s) if token]
# Convert the first token to lowercase, every subsequent token has it... | preference-annotator |
1.0 | pair-000016 | train-to_camel_identifier-0003 | Convert a loosely formatted identifier into lowerCamelCase. Treat spaces, underscores and hyphens as separators: split `s` on any run of these separator characters and discard empty tokens (so leading/trailing/repeated separators are ignored). If there are no tokens, return "". The first token is converted entirely to ... | to_camel_identifier(s) | import re
def to_camel_identifier(s):
# Sanitize by removing non-alphanumeric characters except spaces and underscores.
sanitized = re.sub(r'[^a-zA-Z0-9_\-]+', '', s)
# Split based on spaces, underscores, or hyphen.
parts = sanitized.split(' ')
# Convert tokens: capitalize the first lette... | def to_camel_identifier(s):
tokens = filter(None, re.split(r'[ _\-\d]+', s))
camel_case = ''.join(token.strip('_').title() for token in tokens)
return '_' + camel_case[1:] if isinstance(camel_case[0], str.isdigit()) else camel_case | preference-annotator |
1.0 | pair-000017 | train-reverse_tail-0004 | Given a list of integers nums and an integer n, return a NEW list in which the last n elements of nums are reversed in place and all earlier elements keep their original order. If n <= 0, return an unchanged copy of nums. If n >= len(nums), return the whole list reversed. If nums is empty, return []. The input list mus... | reverse_tail(nums, n) | def reverse_tail(nums, n):
if n <= 0:
return nums[:]
end = min(len(nums), n)
# Reverse the last 'n' elements in-place
for i in range(end // 2):
nums[i], nums[end - 1 - i] = nums[end - 1 - i], nums[i]
return nums | def reverse_tail(nums, n):
if not nums:
return []
if n <= 0:
return nums
if n > len(nums):
return list(reversed(nums))
return nums[:-n] + list(reversed(nums[-n:])) | preference-annotator |
1.0 | pair-000018 | train-reverse_tail-0004 | Given a list of integers nums and an integer n, return a NEW list in which the last n elements of nums are reversed in place and all earlier elements keep their original order. If n <= 0, return an unchanged copy of nums. If n >= len(nums), return the whole list reversed. If nums is empty, return []. The input list mus... | reverse_tail(nums, n) | def reverse_tail(nums, n):
if n <= 0:
return nums[:]
end = min(len(nums), n)
# Reverse the last 'n' elements in-place
for i in range(end // 2):
nums[i], nums[end - 1 - i] = nums[end - 1 - i], nums[i]
return nums | def reverse_tail(nums, n):
if n <= 0:
return nums.copy()
elif n >= len(nums):
return nums[::-1]
else:
return nums[:-n][::-1] + nums[-n:] | preference-annotator |
1.0 | pair-000019 | train-reverse_tail-0004 | Given a list of integers nums and an integer n, return a NEW list in which the last n elements of nums are reversed in place and all earlier elements keep their original order. If n <= 0, return an unchanged copy of nums. If n >= len(nums), return the whole list reversed. If nums is empty, return []. The input list mus... | reverse_tail(nums, n) | def reverse_tail(nums, n):
if n == 0:
return nums[:]
elif n >= len(nums):
return nums[::-1]
else:
middle = nums[:len(nums) - n]
tail = nums[len(nums) - n:]
tail.reverse()
result = middle + tail
return result | def reverse_tail(nums, n):
if n <= 0:
return nums[:]
end = min(len(nums), n)
# Reverse the last 'n' elements in-place
for i in range(end // 2):
nums[i], nums[end - 1 - i] = nums[end - 1 - i], nums[i]
return nums | preference-annotator |
1.0 | pair-000020 | train-histogram_buckets-0005 | records is a list of dicts, field is a string key, width is an int. If width <= 0, return []. For each record that contains field (its value is an int, possibly negative), compute its bucket start as (value // width) * width using Python floor division (so negative values fall into the bucket at or below them, e.g. -1 ... | histogram_buckets(records, field, width) | def histogram_buckets(records, field, width):
if width <= 0:
return []
buckets = {i: 0 for i in range(-width, width + 1)}
for record in records:
if record.get(field) is not None and isinstance(record[field], int):
bucket_start = ((record[field] // width) + 1) * width
... | def histogram_buckets(records, field, width):
buckets = {}
for record in records:
if field not in record:
continue
value = record[field]
if width > 0:
bucket_start = (value // width) * width
if bucket_start not in buckets:
buckets[bucke... | preference-annotator |
1.0 | pair-000021 | train-histogram_buckets-0005 | records is a list of dicts, field is a string key, width is an int. If width <= 0, return []. For each record that contains field (its value is an int, possibly negative), compute its bucket start as (value // width) * width using Python floor division (so negative values fall into the bucket at or below them, e.g. -1 ... | histogram_buckets(records, field, width) | def histogram_buckets(records, field, width):
buckets = {}
for record in records:
if field not in record:
continue
value = record[field]
if width > 0:
bucket_start = (value // width) * width
if bucket_start not in buckets:
buckets[bucke... | def histogram_buckets(records, field, width):
if width <= 0:
return []
bucket_indices = set()
counts = {}
for record in records:
try:
value = record[field]
if value != None:
bucket_start = value // width * width
bucket_ind... | preference-annotator |
1.0 | pair-000022 | train-histogram_buckets-0005 | records is a list of dicts, field is a string key, width is an int. If width <= 0, return []. For each record that contains field (its value is an int, possibly negative), compute its bucket start as (value // width) * width using Python floor division (so negative values fall into the bucket at or below them, e.g. -1 ... | histogram_buckets(records, field, width) | def histogram_buckets(records, field, width):
buckets = {}
for record in records:
if field not in record:
continue
value = record[field]
if width > 0:
bucket_start = (value // width) * width
if bucket_start not in buckets:
buckets[bucke... | def histogram_buckets(records, field, width):
if width <= 0:
return []
buckets = {}
for record in records:
value = record.get(field)
if value is not None:
bucket_start = (value // width) * width
if bucket_start not in buckets:
buckets[bucket_s... | preference-annotator |
1.0 | pair-000023 | train-histogram_buckets-0005 | records is a list of dicts, field is a string key, width is an int. If width <= 0, return []. For each record that contains field (its value is an int, possibly negative), compute its bucket start as (value // width) * width using Python floor division (so negative values fall into the bucket at or below them, e.g. -1 ... | histogram_buckets(records, field, width) | def histogram_buckets(records, field, width):
buckets = {}
for record in records:
if field not in record:
continue
value = record[field]
if width > 0:
bucket_start = (value // width) * width
if bucket_start not in buckets:
buckets[bucke... | def histogram_buckets(records, field, width):
if width <= 0:
return []
result = []
for record in records:
if field not in record:
continue
value = record[field]
bucket_start = (value // width) * width
result.append([bucket_start... | preference-annotator |
1.0 | pair-000024 | train-histogram_buckets-0005 | records is a list of dicts, field is a string key, width is an int. If width <= 0, return []. For each record that contains field (its value is an int, possibly negative), compute its bucket start as (value // width) * width using Python floor division (so negative values fall into the bucket at or below them, e.g. -1 ... | histogram_buckets(records, field, width) | def histogram_buckets(records, field, width):
buckets = {}
for record in records:
if field not in record:
continue
value = record[field]
if width > 0:
bucket_start = (value // width) * width
if bucket_start not in buckets:
buckets[bucke... | def histogram_buckets(records, field, width):
if width <= 0:
return []
buckets = [[] for _ in range((max(record[field]//width for record in records) + width) // width)]
for record in records:
if field in record and isinstance(record[field], int):
bucket_index = (record[field... | preference-annotator |
1.0 | pair-000025 | train-min_palindrome_deletion_cost-0006 | Given a string s and a list of non-negative integers w where w[i] is the cost of deleting character s[i], delete a set of characters (possibly none, possibly all) so that the remaining characters, read in their original order, form a palindrome (the empty string and any single character count as palindromes). The total... | min_palindrome_deletion_cost(s, w) | def min_palindrome_deletion_cost(s, w):
if not s or not w or len(s) != len(w):
return -1
n = len(s)
# Create a prefix sum array for costs
prefix_costs = [0] * n
prefix_costs[0] = w[0]
for i in range(1, n):
prefix_costs[i] = prefix_costs[i-1] + w[i]
# Initialize... | def min_palindrome_deletion_cost(s: str, w: List[int]) -> Optional[int]:
if len(s) != len(w):
return -1
if not s:
return 0
n = len(s)
# Initialize DP table with infinity and set base cases
dp = [[float('inf')] * (n + 1) for _ in range(n)]
dp[0][0] = 0
# Fi... | preference-annotator |
1.0 | pair-000026 | train-min_palindrome_deletion_cost-0006 | Given a string s and a list of non-negative integers w where w[i] is the cost of deleting character s[i], delete a set of characters (possibly none, possibly all) so that the remaining characters, read in their original order, form a palindrome (the empty string and any single character count as palindromes). The total... | min_palindrome_deletion_cost(s, w) | def min_palindrome_deletion_cost(s, w):
if not s or not w or len(s) != len(w):
return -1
n = len(s)
# Create a prefix sum array for costs
prefix_costs = [0] * n
prefix_costs[0] = w[0]
for i in range(1, n):
prefix_costs[i] = prefix_costs[i-1] + w[i]
# Initialize... | def min_palindrome_deletion_cost(s, w):
if len(s) != len(w):
return -1
dp = [[float('inf')] * len(w) for _ in range(len(s))]
# Initialize base cases
for i in range(len(s)):
dp[i][i] = 0
for length in range(2, len(w)+1):
for i in range(len(s)-length+1):
... | preference-annotator |
1.0 | pair-000027 | train-min_palindrome_deletion_cost-0006 | Given a string s and a list of non-negative integers w where w[i] is the cost of deleting character s[i], delete a set of characters (possibly none, possibly all) so that the remaining characters, read in their original order, form a palindrome (the empty string and any single character count as palindromes). The total... | min_palindrome_deletion_cost(s, w) | def min_palindrome_deletion_cost(s, w):
if not s or not w or len(s) != len(w):
return -1
n = len(s)
# Create a prefix sum array for costs
prefix_costs = [0] * n
prefix_costs[0] = w[0]
for i in range(1, n):
prefix_costs[i] = prefix_costs[i-1] + w[i]
# Initialize... | def min_palindrome_deletion_cost(s, w):
if len(s) > len(w):
return -1
dp = [[float('inf')] * (len(s) + 1) for _ in range(len(s) + 1)]
for i in range(len(s) + 1):
for j in range(i + 1):
if i == j:
dp[i][j] = 0
else:
cost = w[j]... | preference-annotator |
1.0 | pair-000028 | train-min_palindrome_deletion_cost-0006 | Given a string s and a list of non-negative integers w where w[i] is the cost of deleting character s[i], delete a set of characters (possibly none, possibly all) so that the remaining characters, read in their original order, form a palindrome (the empty string and any single character count as palindromes). The total... | min_palindrome_deletion_cost(s, w) | def min_palindrome_deletion_cost(s, w):
if len(s) != len(w):
return -1
n = len(s)
dp = [[float('inf')] * (n + 1) for _ in range(n + 1)]
# Base case: an empty string forms a palindrome
dp[0][0] = 0
# Fill the DP table
for i in range(1, n + 1):
dp[i][i] = 0 # Single ... | def min_palindrome_deletion_cost(s, w):
if not s or not w or len(s) != len(w):
return -1
n = len(s)
# Create a prefix sum array for costs
prefix_costs = [0] * n
prefix_costs[0] = w[0]
for i in range(1, n):
prefix_costs[i] = prefix_costs[i-1] + w[i]
# Initialize... | preference-annotator |
1.0 | pair-000029 | train-best_entry_per_team-0008 | records is a list of dicts in a meaningful order. Only dicts containing ALL three keys 'team' (string), 'player' (string) and 'score' (int) are considered; others are ignored. For each distinct team, select the single considered record with the highest 'score'; if several records of that team share the highest score, s... | best_entry_per_team(records) | def best_entry_per_team(records):
teams = {}
for record in records:
if all(key in record for key in ('team', 'player', 'score')):
team = record['team']
player = record['player']
score = record['score']
if team not in teams or score > team... | def best_entry_per_team(records):
# Filter out invalid records
valid_records = [rec for rec in records if all(key in rec for key in ['team', 'player', 'score'])]
# Group the valid records by team
grouped_records = {}
for rec in valid_records:
team = rec['team']
if team not in gr... | preference-annotator |
1.0 | pair-000030 | train-best_entry_per_team-0008 | records is a list of dicts in a meaningful order. Only dicts containing ALL three keys 'team' (string), 'player' (string) and 'score' (int) are considered; others are ignored. For each distinct team, select the single considered record with the highest 'score'; if several records of that team share the highest score, s... | best_entry_per_team(records) | def best_entry_per_team(records):
teams = {}
for record in records:
if all(key in record for key in ('team', 'player', 'score')):
team = record['team']
player = record['player']
score = record['score']
if team not in teams or score > team... | def best_entry_per_team(records):
from collections import defaultdict, Counter
# Filter out invalid records
valid_records = [record for record in records if all(key in record for key in ['team', 'player', 'score'])]
# Collect scores per team
team_scores = defaultdict(int)
for record i... | preference-annotator |
1.0 | pair-000031 | train-best_entry_per_team-0008 | records is a list of dicts in a meaningful order. Only dicts containing ALL three keys 'team' (string), 'player' (string) and 'score' (int) are considered; others are ignored. For each distinct team, select the single considered record with the highest 'score'; if several records of that team share the highest score, s... | best_entry_per_team(records) | def best_entry_per_team(records):
teams = {}
for record in records:
if all(key in record for key in ('team', 'player', 'score')):
team = record['team']
player = record['player']
score = record['score']
if team not in teams or score > team... | def best_entry_per_team(records):
teams_scores = {}
for r in records:
if all(k in r for k in ['team', 'player', 'score']):
team = r['team']
score = r['score']
if team not in teams_scores or score > teams_scores[team][0]['score'] or (score == teams_scores[team][0]['sco... | preference-annotator |
1.0 | pair-000032 | train-best_entry_per_team-0008 | records is a list of dicts in a meaningful order. Only dicts containing ALL three keys 'team' (string), 'player' (string) and 'score' (int) are considered; others are ignored. For each distinct team, select the single considered record with the highest 'score'; if several records of that team share the highest score, s... | best_entry_per_team(records) | def best_entry_per_team(records):
# Filter out invalid records
valid_records = [rec for rec in records if all(key in rec for key in ['team', 'player', 'score'])]
# Group the valid records by team
grouped_records = {}
for rec in valid_records:
team = rec['team']
if team not in gr... | def best_entry_per_team(records):
from collections import defaultdict, Counter
# Filter out invalid records
valid_records = [record for record in records if all(key in record for key in ['team', 'player', 'score'])]
# Collect scores per team
team_scores = defaultdict(int)
for record i... | preference-annotator |
1.0 | pair-000033 | train-best_entry_per_team-0008 | records is a list of dicts in a meaningful order. Only dicts containing ALL three keys 'team' (string), 'player' (string) and 'score' (int) are considered; others are ignored. For each distinct team, select the single considered record with the highest 'score'; if several records of that team share the highest score, s... | best_entry_per_team(records) | def best_entry_per_team(records):
from collections import defaultdict, Counter
# Filter out invalid records
valid_records = [record for record in records if all(key in record for key in ['team', 'player', 'score'])]
# Collect scores per team
team_scores = defaultdict(int)
for record i... | def best_entry_per_team(records):
teams_scores = {}
for r in records:
if all(k in r for k in ['team', 'player', 'score']):
team = r['team']
score = r['score']
if team not in teams_scores or score > teams_scores[team][0]['score'] or (score == teams_scores[team][0]['sco... | preference-annotator |
1.0 | pair-000034 | train-best_entry_per_team-0008 | records is a list of dicts in a meaningful order. Only dicts containing ALL three keys 'team' (string), 'player' (string) and 'score' (int) are considered; others are ignored. For each distinct team, select the single considered record with the highest 'score'; if several records of that team share the highest score, s... | best_entry_per_team(records) | def best_entry_per_team(records):
teams_scores = {}
for r in records:
if all(k in r for k in ['team', 'player', 'score']):
team = r['team']
score = r['score']
if team not in teams_scores or score > teams_scores[team][0]['score'] or (score == teams_scores[team][0]['sco... | def best_entry_per_team(records):
# Filter out invalid records
valid_records = [rec for rec in records if all(key in rec for key in ['team', 'player', 'score'])]
# Group the valid records by team
grouped_records = {}
for rec in valid_records:
team = rec['team']
if team not in gr... | preference-annotator |
1.0 | pair-000035 | train-ledger_balances-0009 | Simulate a simple non-overdraft ledger. `start` is a non-negative integer opening balance. `txns` is a list of transactions, each a list `[kind, amount]` where `kind` is a string and `amount` is an integer. Process transactions in order: if `kind == "credit"` and `amount >= 0`, add `amount` to the balance; if `kind == ... | ledger_balances(start, txns) | def ledger_balances(start, txns):
balances = [start]
for txn in txns:
kind, amount = txn
if kind not in {"credit", "debit"} or amount < 0:
balances.append(balances[-1])
elif kind == "credit":
balances.append(balances[-1] + amount)
else:
adjuste... | def ledger_balances(start, txns):
answer = [start]
balance = start
for t in range(len(txns)):
kind, amount = txns[t]
# Check if the transaction can be processed
if (
kind == "credit"
and amount > 0
and balance + amount >= 0
):
... | preference-annotator |
1.0 | pair-000036 | train-ledger_balances-0009 | Simulate a simple non-overdraft ledger. `start` is a non-negative integer opening balance. `txns` is a list of transactions, each a list `[kind, amount]` where `kind` is a string and `amount` is an integer. Process transactions in order: if `kind == "credit"` and `amount >= 0`, add `amount` to the balance; if `kind == ... | ledger_balances(start, txns) | def ledger_balances(start, txns):
answer = [start]
balance = start
for t in range(len(txns)):
kind, amount = txns[t]
# Check if the transaction can be processed
if (
kind == "credit"
and amount > 0
and balance + amount >= 0
):
... | def ledger_balances(start, txns):
balances = [start]
for txn_kind, txn_amount in txns:
if txn_kind not in {"credit", "debit"} or txn_amount < 0:
balances.append(balances[-1])
elif txn_kind == "debit":
new_balance = balances[-1] - txn_amount if balances[-1] - txn_amount >=... | preference-annotator |
1.0 | pair-000037 | train-late_order_stats-0011 | orders is a list of dicts, each with keys "customer" (string) and "days" (integer delivery time, may be zero or negative). threshold is an integer. An order is considered late when days is strictly greater than threshold (days == threshold is NOT late). For each customer that has at least one late order, produce a thre... | late_order_stats(orders, threshold) | def late_order_stats(orders, threshold):
late_orders = []
for order in orders:
days = order.get('days', 0)
if days > threshold:
last_name = order.get('customer')
if last_name not in late_orders:
late_orders.append((last_name, 1, 1))
else:
... | def late_order_stats(orders, threshold):
from collections import defaultdict
customers_info = defaultdict(lambda: {'count': 0, 'total': 0})
for order in orders:
if order['days'] > threshold and 'customer' in order:
customer_name = order['customer']
customers_info[customer_na... | preference-annotator |
1.0 | pair-000038 | train-late_order_stats-0011 | orders is a list of dicts, each with keys "customer" (string) and "days" (integer delivery time, may be zero or negative). threshold is an integer. An order is considered late when days is strictly greater than threshold (days == threshold is NOT late). For each customer that has at least one late order, produce a thre... | late_order_stats(orders, threshold) | def late_order_stats(orders, threshold):
from collections import defaultdict
customers_info = defaultdict(lambda: {'count': 0, 'total': 0})
for order in orders:
if order['days'] > threshold and 'customer' in order:
customer_name = order['customer']
customers_info[customer_na... | def late_order_stats(orders, threshold):
late_list = []
# Filter out orders with days <= threshold and count them for each customer
orders_by_customer = {}
for order in orders:
if order['days'] > threshold:
if order['customer'] not in orders_by_customer:
orders_by_cu... | preference-annotator |
1.0 | pair-000039 | train-late_order_stats-0011 | orders is a list of dicts, each with keys "customer" (string) and "days" (integer delivery time, may be zero or negative). threshold is an integer. An order is considered late when days is strictly greater than threshold (days == threshold is NOT late). For each customer that has at least one late order, produce a thre... | late_order_stats(orders, threshold) | def late_order_stats(orders, threshold):
from collections import defaultdict
customers_info = defaultdict(lambda: {'count': 0, 'total': 0})
for order in orders:
if order['days'] > threshold and 'customer' in order:
customer_name = order['customer']
customers_info[customer_na... | def late_order_stats(orders, threshold):
stats = {}
for order in orders:
customer = order['customer']
days = order.get('days', 0) # Default to 0 if 'days' doesn't exist
if customer not in stats:
stats[customer] = {'total': 1, 'late': 0}
else:
stats[custom... | preference-annotator |
1.0 | pair-000040 | train-late_order_stats-0011 | orders is a list of dicts, each with keys "customer" (string) and "days" (integer delivery time, may be zero or negative). threshold is an integer. An order is considered late when days is strictly greater than threshold (days == threshold is NOT late). For each customer that has at least one late order, produce a thre... | late_order_stats(orders, threshold) | def late_order_stats(orders, threshold):
from collections import defaultdict
customers_info = defaultdict(lambda: {'count': 0, 'total': 0})
for order in orders:
if order['days'] > threshold and 'customer' in order:
customer_name = order['customer']
customers_info[customer_na... | def late_order_stats(orders, threshold):
stats = {}
for order in orders:
customer = order.pop('customer', None)
if customer is None or 'days' not in order:
continue
days = order['days']
if days > threshold:
if customer not in stats:
stats[c... | preference-annotator |
1.0 | pair-000041 | train-late_order_stats-0011 | orders is a list of dicts, each with keys "customer" (string) and "days" (integer delivery time, may be zero or negative). threshold is an integer. An order is considered late when days is strictly greater than threshold (days == threshold is NOT late). For each customer that has at least one late order, produce a thre... | late_order_stats(orders, threshold) | def late_order_stats(orders, threshold):
late_list = []
# Filter out orders with days <= threshold and count them for each customer
orders_by_customer = {}
for order in orders:
if order['days'] > threshold:
if order['customer'] not in orders_by_customer:
orders_by_cu... | def late_order_stats(orders, threshold):
late_orders = []
for order in orders:
days = order.get('days', 0)
if days > threshold:
last_name = order.get('customer')
if last_name not in late_orders:
late_orders.append((last_name, 1, 1))
else:
... | preference-annotator |
1.0 | pair-000042 | train-late_order_stats-0011 | orders is a list of dicts, each with keys "customer" (string) and "days" (integer delivery time, may be zero or negative). threshold is an integer. An order is considered late when days is strictly greater than threshold (days == threshold is NOT late). For each customer that has at least one late order, produce a thre... | late_order_stats(orders, threshold) | def late_order_stats(orders, threshold):
stats = {}
for order in orders:
customer = order['customer']
days = order.get('days', 0) # Default to 0 if 'days' doesn't exist
if customer not in stats:
stats[customer] = {'total': 1, 'late': 0}
else:
stats[custom... | def late_order_stats(orders, threshold):
late_orders = []
for order in orders:
days = order.get('days', 0)
if days > threshold:
last_name = order.get('customer')
if last_name not in late_orders:
late_orders.append((last_name, 1, 1))
else:
... | preference-annotator |
1.0 | pair-000043 | train-csv_column_sum-0012 | Sum the integer values in one column of a simple comma-separated table given as a string. Split text on '\n' and discard every line that is empty after stripping whitespace. If no lines remain, return -1. The first remaining line is the header: split it on ',' and strip each field; the target column index is the FIRST ... | csv_column_sum(text, column) | def csv_column_sum(text, column):
lines = text.strip().split('\n')
if not lines:
return -1
header = lines[0]
headers = [h.strip() for h in header.split(',')]
if column not in headers:
return -1
target_index = headers.index(column)
total = 0
for li... | def csv_column_sum(text, column):
lines = [line.strip() for line in text.split('\n') if line]
if len(lines) == 0:
return -1
header = lines[0].split(',')
target_index = -1
for i, field in enumerate(header):
if field.upper() == column.upper():
target_index = i
... | preference-annotator |
1.0 | pair-000044 | train-csv_column_sum-0012 | Sum the integer values in one column of a simple comma-separated table given as a string. Split text on '\n' and discard every line that is empty after stripping whitespace. If no lines remain, return -1. The first remaining line is the header: split it on ',' and strip each field; the target column index is the FIRST ... | csv_column_sum(text, column) | def csv_column_sum(text, column):
lines = text.strip().split('\n')
if not lines:
return -1
header = lines[0]
headers = [h.strip() for h in header.split(',')]
if column not in headers:
return -1
target_index = headers.index(column)
total = 0
for li... | def csv_column_sum(text, column):
parts = text.strip().split('\n')
if len(parts) == 0:
return -1
header = parts.pop(0)
columns = header.split(',')
if column not in columns:
return -1
target_index = columns.index(column)
total = 0
for line in parts:
... | preference-annotator |
1.0 | pair-000045 | train-csv_column_sum-0012 | Sum the integer values in one column of a simple comma-separated table given as a string. Split text on '\n' and discard every line that is empty after stripping whitespace. If no lines remain, return -1. The first remaining line is the header: split it on ',' and strip each field; the target column index is the FIRST ... | csv_column_sum(text, column) | def csv_column_sum(text, column):
parts = text.strip().split('\n')
if len(parts) == 0:
return -1
header = parts.pop(0)
columns = header.split(',')
if column not in columns:
return -1
target_index = columns.index(column)
total = 0
for line in parts:
... | def csv_column_sum(text, column):
lines = [line.strip() for line in text.split('\n') if line]
if len(lines) == 0:
return -1
header = lines[0].split(',')
target_index = -1
for i, field in enumerate(header):
if field.upper() == column.upper():
target_index = i
... | preference-annotator |
1.0 | pair-000046 | train-csv_column_sum-0012 | Sum the integer values in one column of a simple comma-separated table given as a string. Split text on '\n' and discard every line that is empty after stripping whitespace. If no lines remain, return -1. The first remaining line is the header: split it on ',' and strip each field; the target column index is the FIRST ... | csv_column_sum(text, column) | def csv_column_sum(text, column):
import re
lines = text.strip().split('\n')
# Check if there's a header row
if len(lines) == 0:
return -1
# Split header into columns and find the target column index
header_parts = lines[0].strip().split(',')
target_index = None
for i, ... | def csv_column_sum(text, column):
lines = [line.strip() for line in text.split('\n') if line]
if len(lines) == 0:
return -1
header = lines[0].split(',')
target_index = -1
for i, field in enumerate(header):
if field.upper() == column.upper():
target_index = i
... | preference-annotator |
1.0 | pair-000047 | train-csv_column_sum-0012 | Sum the integer values in one column of a simple comma-separated table given as a string. Split text on '\n' and discard every line that is empty after stripping whitespace. If no lines remain, return -1. The first remaining line is the header: split it on ',' and strip each field; the target column index is the FIRST ... | csv_column_sum(text, column) | def csv_column_sum(text, column):
import re
lines = text.strip().split('\n')
# Check if there's a header row
if len(lines) == 0:
return -1
# Split header into columns and find the target column index
header_parts = lines[0].strip().split(',')
target_index = None
for i, ... | def csv_column_sum(text, column):
lines = text.strip().split('\n')
if not lines:
return -1
header = lines[0]
headers = [h.strip() for h in header.split(',')]
if column not in headers:
return -1
target_index = headers.index(column)
total = 0
for li... | preference-annotator |
1.0 | pair-000048 | train-csv_column_sum-0012 | Sum the integer values in one column of a simple comma-separated table given as a string. Split text on '\n' and discard every line that is empty after stripping whitespace. If no lines remain, return -1. The first remaining line is the header: split it on ',' and strip each field; the target column index is the FIRST ... | csv_column_sum(text, column) | def csv_column_sum(text, column):
import re
lines = text.strip().split('\n')
# Check if there's a header row
if len(lines) == 0:
return -1
# Split header into columns and find the target column index
header_parts = lines[0].strip().split(',')
target_index = None
for i, ... | def csv_column_sum(text, column):
parts = text.strip().split('\n')
if len(parts) == 0:
return -1
header = parts.pop(0)
columns = header.split(',')
if column not in columns:
return -1
target_index = columns.index(column)
total = 0
for line in parts:
... | preference-annotator |
1.0 | pair-000049 | train-slugify_custom-0016 | Build a URL-style slug from `text`. Steps, in order: (1) lowercase the whole string with str.lower(); (2) every maximal run of one or more characters that are NOT ASCII lowercase letters a-z or digits 0-9 is replaced by the single-character string `sep` (sep is guaranteed to be exactly one non-alphanumeric character su... | slugify_custom(text, sep, max_len) | def slugify_custom(text, sep, max_len):
text = text.lower()
# Replace all characters not ascii_lowercase or digits with 'sep'
slug = ''.join(c if c.isalnum() else sep for c in text)
# Remove leading and trailing separators
slug = slug.strip(sep)
# Trim to max_length if specified
... | def slugify_custom(text, sep, max_len):
import re
# Step 1: Lowercase the whole string
text = text.lower()
if not text:
return ""
# Step 2: Replace maximal runs of characters that are not_ascii_lowercase_letters a-z or digits 0-9 with sep
allow_letters_segments_pattern = '[^a-zA-Z0-9]... | preference-annotator |
1.0 | pair-000050 | train-slugify_custom-0016 | Build a URL-style slug from `text`. Steps, in order: (1) lowercase the whole string with str.lower(); (2) every maximal run of one or more characters that are NOT ASCII lowercase letters a-z or digits 0-9 is replaced by the single-character string `sep` (sep is guaranteed to be exactly one non-alphanumeric character su... | slugify_custom(text, sep, max_len) | def slugify_custom(text, sep, max_len):
text = text.lower()
# Replace all characters not ascii_lowercase or digits with 'sep'
slug = ''.join(c if c.isalnum() else sep for c in text)
# Remove leading and trailing separators
slug = slug.strip(sep)
# Trim to max_length if specified
... | def slugify_custom(text, sep, max_len):
# Step 1: Lowercase the whole string
text = text.lower()
# Step 2: Replace non-ASCII lowercase letters a-z or digits 0-9 with sep
import re
text = re.sub(r'[^a-z0-9]', sep, text)
# Step 3: Remove leading and trailing sep characters
text = tex... | preference-annotator |
1.0 | pair-000051 | train-slugify_custom-0016 | Build a URL-style slug from `text`. Steps, in order: (1) lowercase the whole string with str.lower(); (2) every maximal run of one or more characters that are NOT ASCII lowercase letters a-z or digits 0-9 is replaced by the single-character string `sep` (sep is guaranteed to be exactly one non-alphanumeric character su... | slugify_custom(text, sep, max_len) | def slugify_custom(text, sep, max_len):
text = text.lower()
# Replace all characters not ascii_lowercase or digits with 'sep'
slug = ''.join(c if c.isalnum() else sep for c in text)
# Remove leading and trailing separators
slug = slug.strip(sep)
# Trim to max_length if specified
... | def slugify_custom(text, sep, max_len):
text = text.lower()
def split_non_iso_chars(s):
return s.split(sep)
splits = split_non_iso_chars(text)
slug = ''.join(char_l for char_l in splits if char_l.isalnum())
slug = slug.strip(sep)
if max_len >= 0:
if len(slug) ... | preference-annotator |
1.0 | pair-000052 | train-best_unit_jobs-0017 | `jobs` is a list of two-element lists [deadline, profit] of integers. Every job takes exactly one time unit; time slots are numbered 1, 2, 3, ... and at most one job can be executed per slot, starting at slot 1. A job with deadline d is completed on time only if it runs in a slot number <= d. A subset of jobs is feasib... | best_unit_jobs(jobs) | def best_unit_jobs(jobs):
if not all(len(job) == 2 for job in jobs):
return [-1]
if not all(isinstance(x, int) for item in jobs for x in item):
return [-1]
if any(job[0] < 1 or job[1] < 1 for job in jobs):
return [-1]
remaining_slots = set(range(1, len(jobs) + 1))
max_profit... | def best_unit_jobs(jobs):
# Check initial conditions
if not jobs:
return []
if min(job[0] for job in jobs) < 1 or min(job[1] for job in jobs) < 1:
return [-1]
# Sort jobs by their profits decreasingly and by their deadlines incrementally
sorted_jobs = sorted(jobs, key=lambd... | preference-annotator |
1.0 | pair-000053 | train-best_unit_jobs-0017 | `jobs` is a list of two-element lists [deadline, profit] of integers. Every job takes exactly one time unit; time slots are numbered 1, 2, 3, ... and at most one job can be executed per slot, starting at slot 1. A job with deadline d is completed on time only if it runs in a slot number <= d. A subset of jobs is feasib... | best_unit_jobs(jobs) | def best_unit_jobs(jobs):
if not all(len(job) == 2 for job in jobs):
return [-1]
if not all(isinstance(x, int) for item in jobs for x in item):
return [-1]
if any(job[0] < 1 or job[1] < 1 for job in jobs):
return [-1]
remaining_slots = set(range(1, len(jobs) + 1))
max_profit... | def best_unit_jobs(jobs):
if not jobs or any(deadline < 1 for deadline, profit in jobs) or any(profit < 1 for deadline, profit in jobs):
return [-1]
# Sort jobs by their deadlines first
jobs.sort(key=lambda x: x[0])
result = []
max_profit = 0
# Use a greedy approach to sel... | preference-annotator |
1.0 | pair-000054 | train-best_unit_jobs-0017 | `jobs` is a list of two-element lists [deadline, profit] of integers. Every job takes exactly one time unit; time slots are numbered 1, 2, 3, ... and at most one job can be executed per slot, starting at slot 1. A job with deadline d is completed on time only if it runs in a slot number <= d. A subset of jobs is feasib... | best_unit_jobs(jobs) | def best_unit_jobs(jobs):
if not jobs or any(job[0] < 1 or job[1] < 1 for job in jobs):
return [-1]
n = len(jobs)
jobs.sort(key=lambda x: x[0])
result = []
max_profit = -float('inf')
current_rank = 0
for i in range(n):
# check if the current job fits in the current ... | def best_unit_jobs(jobs):
if not all(len(job) == 2 for job in jobs):
return [-1]
if not all(isinstance(x, int) for item in jobs for x in item):
return [-1]
if any(job[0] < 1 or job[1] < 1 for job in jobs):
return [-1]
remaining_slots = set(range(1, len(jobs) + 1))
max_profit... | preference-annotator |
1.0 | pair-000055 | train-best_unit_jobs-0017 | `jobs` is a list of two-element lists [deadline, profit] of integers. Every job takes exactly one time unit; time slots are numbered 1, 2, 3, ... and at most one job can be executed per slot, starting at slot 1. A job with deadline d is completed on time only if it runs in a slot number <= d. A subset of jobs is feasib... | best_unit_jobs(jobs) | def best_unit_jobs(jobs):
if not all(len(job) == 2 for job in jobs):
return [-1]
if not all(isinstance(x, int) for item in jobs for x in item):
return [-1]
if any(job[0] < 1 or job[1] < 1 for job in jobs):
return [-1]
remaining_slots = set(range(1, len(jobs) + 1))
max_profit... | def best_unit_jobs(jobs):
# Early termination if any job has an invalid deadline or profit
if not all([deadline >= 1 and profit >= 1 for deadline, profit in jobs]):
return [-1]
# Sort the jobs by their profits in descending order, then by their deadlines in ascending order
jobs.sort(key=lambda ... | preference-annotator |
1.0 | pair-000056 | train-best_unit_jobs-0017 | `jobs` is a list of two-element lists [deadline, profit] of integers. Every job takes exactly one time unit; time slots are numbered 1, 2, 3, ... and at most one job can be executed per slot, starting at slot 1. A job with deadline d is completed on time only if it runs in a slot number <= d. A subset of jobs is feasib... | best_unit_jobs(jobs) | def best_unit_jobs(jobs):
if not jobs or any(job[0] < 1 or job[1] < 1 for job in jobs):
return [-1]
n = len(jobs)
jobs.sort(key=lambda x: x[0])
result = []
max_profit = -float('inf')
current_rank = 0
for i in range(n):
# check if the current job fits in the current ... | def best_unit_jobs(jobs):
# Check initial conditions
if not jobs:
return []
if min(job[0] for job in jobs) < 1 or min(job[1] for job in jobs) < 1:
return [-1]
# Sort jobs by their profits decreasingly and by their deadlines incrementally
sorted_jobs = sorted(jobs, key=lambd... | preference-annotator |
1.0 | pair-000057 | train-best_unit_jobs-0017 | `jobs` is a list of two-element lists [deadline, profit] of integers. Every job takes exactly one time unit; time slots are numbered 1, 2, 3, ... and at most one job can be executed per slot, starting at slot 1. A job with deadline d is completed on time only if it runs in a slot number <= d. A subset of jobs is feasib... | best_unit_jobs(jobs) | def best_unit_jobs(jobs):
if not jobs or any(deadline < 1 for deadline, profit in jobs) or any(profit < 1 for deadline, profit in jobs):
return [-1]
# Sort jobs by their deadlines first
jobs.sort(key=lambda x: x[0])
result = []
max_profit = 0
# Use a greedy approach to sel... | def best_unit_jobs(jobs):
if not jobs or any(job[0] < 1 or job[1] < 1 for job in jobs):
return [-1]
n = len(jobs)
jobs.sort(key=lambda x: x[0])
result = []
max_profit = -float('inf')
current_rank = 0
for i in range(n):
# check if the current job fits in the current ... | preference-annotator |
1.0 | pair-000058 | train-odd_index_vowels-0018 | Given a string s, return the number of characters located at odd 0-based indices (1, 3, 5, ...) that are vowels. Vowels are exactly a, e, i, o, u in either uppercase or lowercase; 'y' is not a vowel. Characters at even indices are ignored entirely. Return 0 for the empty string or a string with no odd-index vowels. The... | odd_index_vowels(s) | def odd_index_vowels(s):
"""
Given a string s, return the number of characters located at odd 0-based indices
(1, 3, 5, ...) that are vowels. Vowels are exactly a, e, i, o, u in either uppercase
or lowercase; 'y' is not a vowel. Characters at even indices are ignored entirely.
Args:
s (str): T... | def odd_index_vowels(s):
return sum(1 for i, char in enumerate(s) if (i + 1) % 2 != 0 and char.lower() in 'aeiou') | preference-annotator |
1.0 | pair-000059 | train-odd_index_vowels-0018 | Given a string s, return the number of characters located at odd 0-based indices (1, 3, 5, ...) that are vowels. Vowels are exactly a, e, i, o, u in either uppercase or lowercase; 'y' is not a vowel. Characters at even indices are ignored entirely. Return 0 for the empty string or a string with no odd-index vowels. The... | odd_index_vowels(s) | def odd_index_vowels(s):
vowels = set('aeiouAEIOU')
count = 0
# Iterate over character indices starting from 1
for i in range(1, len(s), 2):
if s[i] in vowels:
count += 1
return count | def odd_index_vowels(s):
"""
Given a string s, return the number of characters located at odd 0-based indices
(1, 3, 5, ...) that are vowels. Vowels are exactly a, e, i, o, u in either uppercase
or lowercase; 'y' is not a vowel. Characters at even indices are ignored entirely.
Args:
s (str): T... | preference-annotator |
1.0 | pair-000060 | train-odd_index_vowels-0018 | Given a string s, return the number of characters located at odd 0-based indices (1, 3, 5, ...) that are vowels. Vowels are exactly a, e, i, o, u in either uppercase or lowercase; 'y' is not a vowel. Characters at even indices are ignored entirely. Return 0 for the empty string or a string with no odd-index vowels. The... | odd_index_vowels(s) | def odd_index_vowels(s):
"""
Given a string s, return the number of characters located at odd 0-based indices
(1, 3, 5, ...) that are vowels. Vowels are exactly a, e, i, o, u in either uppercase
or lowercase; 'y' is not a vowel. Characters at even indices are ignored entirely.
Args:
s (str): T... | def odd_index_vowels(s):
return sum(1 for i, char in enumerate(s) if i % 2 == 1 and char.lower() in 'aeiou') | preference-annotator |
1.0 | pair-000061 | train-odd_index_vowels-0018 | Given a string s, return the number of characters located at odd 0-based indices (1, 3, 5, ...) that are vowels. Vowels are exactly a, e, i, o, u in either uppercase or lowercase; 'y' is not a vowel. Characters at even indices are ignored entirely. Return 0 for the empty string or a string with no odd-index vowels. The... | odd_index_vowels(s) | def odd_index_vowels(s):
"""
Given a string s, return the number of characters located at odd 0-based indices
(1, 3, 5, ...) that are vowels. Vowels are exactly a, e, i, o, u in either uppercase
or lowercase; 'y' is not a vowel. Characters at even indices are ignored entirely.
Args:
s (str): T... | import re
def odd_index_vowels(s):
return sum(1 for i, c in enumerate(re.findall(r'[aeiouAEIOU]', s)) if i % 2 != 0) | preference-annotator |
1.0 | pair-000062 | train-odd_index_vowels-0018 | Given a string s, return the number of characters located at odd 0-based indices (1, 3, 5, ...) that are vowels. Vowels are exactly a, e, i, o, u in either uppercase or lowercase; 'y' is not a vowel. Characters at even indices are ignored entirely. Return 0 for the empty string or a string with no odd-index vowels. The... | odd_index_vowels(s) | def odd_index_vowels(s):
return sum(1 for c in s[1::2] if c.lower() in 'aeiou') | def odd_index_vowels(s):
"""
Given a string s, return the number of characters located at odd 0-based indices
(1, 3, 5, ...) that are vowels. Vowels are exactly a, e, i, o, u in either uppercase
or lowercase; 'y' is not a vowel. Characters at even indices are ignored entirely.
Args:
s (str): T... | preference-annotator |
1.0 | pair-000063 | train-pivot_count_table-0020 | records is a list of dicts. A record is valid only if it contains both row_field and col_field; other records are ignored. Row and column values are strings. Let rows be the sorted (ascending, plain string comparison) distinct row_field values among valid records and cols the sorted distinct col_field values. Return a ... | pivot_count_table(records, row_field, col_field) | def pivot_count_table(records, row_field, col_field):
def extract_fields(record):
if all(field in record for field in [row_field, col_field]):
return record[row_field], record[col_field]
else:
return None
# Filter out invalid records
valid_records = [record for recor... | def pivot_count_table(records, row_field, col_field):
if not records:
return []
# Extract unique row and column fields
rows = sorted(set(record[row_field] for record in records))
cols = sorted(set(record[col_field] for record in records if row_field in record))
# Create a pivot tab... | preference-annotator |
1.0 | pair-000064 | train-pivot_count_table-0020 | records is a list of dicts. A record is valid only if it contains both row_field and col_field; other records are ignored. Row and column values are strings. Let rows be the sorted (ascending, plain string comparison) distinct row_field values among valid records and cols the sorted distinct col_field values. Return a ... | pivot_count_table(records, row_field, col_field) | def pivot_count_table(records, row_field, col_field):
if not records:
return []
# Extract unique row and column fields
rows = sorted(set(record[row_field] for record in records))
cols = sorted(set(record[col_field] for record in records if row_field in record))
# Create a pivot tab... | def pivot_count_table(records, row_field, col_field):
if not records:
return []
unique_rows = sorted(set(record[row_field] for record in records))
unique_cols = sorted(set(record[col_field] for record in records))
header = [''] + unique_cols
result = []
for row in unique_rows:
... | preference-annotator |
1.0 | pair-000065 | train-pivot_count_table-0020 | records is a list of dicts. A record is valid only if it contains both row_field and col_field; other records are ignored. Row and column values are strings. Let rows be the sorted (ascending, plain string comparison) distinct row_field values among valid records and cols the sorted distinct col_field values. Return a ... | pivot_count_table(records, row_field, col_field) | def pivot_count_table(records, row_field, col_field):
if not records:
return []
# Extract unique rows, columns, and count of each record for those pairs that meet criteria
rows = {record[row_field]: record[col_field] for record in records if row_field in record and col_field in record} | {'': ''}
... | def pivot_count_table(records, row_field, col_field):
def extract_fields(record):
if all(field in record for field in [row_field, col_field]):
return record[row_field], record[col_field]
else:
return None
# Filter out invalid records
valid_records = [record for recor... | preference-annotator |
1.0 | pair-000066 | train-pivot_count_table-0020 | records is a list of dicts. A record is valid only if it contains both row_field and col_field; other records are ignored. Row and column values are strings. Let rows be the sorted (ascending, plain string comparison) distinct row_field values among valid records and cols the sorted distinct col_field values. Return a ... | pivot_count_table(records, row_field, col_field) | def pivot_count_table(records, row_field, col_field):
if not records:
return []
# Extract unique rows, columns, and count of each record for those pairs that meet criteria
rows = {record[row_field]: record[col_field] for record in records if row_field in record and col_field in record} | {'': ''}
... | def pivot_count_table(records, row_field, col_field):
if not records:
return []
unique_rows = sorted(set(record[row_field] for record in records))
unique_cols = sorted(set(record[col_field] for record in records))
header = [''] + unique_cols
result = []
for row in unique_rows:
... | preference-annotator |
1.0 | pair-000067 | train-pivot_count_table-0020 | records is a list of dicts. A record is valid only if it contains both row_field and col_field; other records are ignored. Row and column values are strings. Let rows be the sorted (ascending, plain string comparison) distinct row_field values among valid records and cols the sorted distinct col_field values. Return a ... | pivot_count_table(records, row_field, col_field) | def pivot_count_table(records, row_field, col_field):
if not records:
return []
# Extract unique rows, columns, and count of each record for those pairs that meet criteria
rows = {record[row_field]: record[col_field] for record in records if row_field in record and col_field in record} | {'': ''}
... | def pivot_count_table(records, row_field, col_field):
if not records:
return []
sorted_rows = sorted({rec[row_field] for rec in records} if row_field else [])
sorted_cols = sorted({rec[col_field] for rec in records} if col_field else [])
table_header = [''] + sorted_cols
table_data = [[row... | preference-annotator |
1.0 | pair-000068 | train-pivot_count_table-0020 | records is a list of dicts. A record is valid only if it contains both row_field and col_field; other records are ignored. Row and column values are strings. Let rows be the sorted (ascending, plain string comparison) distinct row_field values among valid records and cols the sorted distinct col_field values. Return a ... | pivot_count_table(records, row_field, col_field) | def pivot_count_table(records, row_field, col_field):
if not records:
return []
# Extract unique rows, columns, and count of each record for those pairs that meet criteria
rows = {record[row_field]: record[col_field] for record in records if row_field in record and col_field in record} | {'': ''}
... | def pivot_count_table(records, row_field, col_field):
if not records:
return []
# Extract unique row and column fields
rows = sorted(set(record[row_field] for record in records))
cols = sorted(set(record[col_field] for record in records if row_field in record))
# Create a pivot tab... | preference-annotator |
1.0 | pair-000069 | train-rollup_totals-0021 | `entries` is a list of two-element lists `[path, amount]` where `path` is a dotted string made of one or more non-empty segments separated by "." and `amount` is an int (possibly negative or zero). The same path may appear more than once. Every prefix of every path — that is, for a path with segments s1..sk, each of th... | rollup_totals(entries) | from typing import List
def rollup_totals(entries: List[List[str]]) -> List[List[str]]:
if not entries:
return []
nodes = {}
total = {}
# Populating nodes dictionary
for entry in entries:
path = '.'.join(entry[0].split('.'))
amount = entry[1]
if path not in nodes:... | def rollup_totals(entries):
totals = {}
for path, amount in entries:
current_total = totals.get(path, 0)
totals[path] = current_total + amount
nodes_with_total = [(path, total) for path, total in totals.items()]
nodes_with_total.sort()
return nodes_with_total | preference-annotator |
1.0 | pair-000070 | train-rollup_totals-0021 | `entries` is a list of two-element lists `[path, amount]` where `path` is a dotted string made of one or more non-empty segments separated by "." and `amount` is an int (possibly negative or zero). The same path may appear more than once. Every prefix of every path — that is, for a path with segments s1..sk, each of th... | rollup_totals(entries) | from typing import List
def rollup_totals(entries: List[List[str]]) -> List[List[str]]:
if not entries:
return []
nodes = {}
total = {}
# Populating nodes dictionary
for entry in entries:
path = '.'.join(entry[0].split('.'))
amount = entry[1]
if path not in nodes:... | def rollup_totals(entries):
if not entries:
return []
aggregated = {}
total_amounts = {}
for path, amount in entries:
current_node = ''
accumulated_amount = 0
while path:
current_node += '.' + path[0]
if current_node in aggregated:
... | preference-annotator |
1.0 | pair-000071 | train-rollup_totals-0021 | `entries` is a list of two-element lists `[path, amount]` where `path` is a dotted string made of one or more non-empty segments separated by "." and `amount` is an int (possibly negative or zero). The same path may appear more than once. Every prefix of every path — that is, for a path with segments s1..sk, each of th... | rollup_totals(entries) | from typing import List
def rollup_totals(entries: List[List[str]]) -> List[List[str]]:
if not entries:
return []
nodes = {}
total = {}
# Populating nodes dictionary
for entry in entries:
path = '.'.join(entry[0].split('.'))
amount = entry[1]
if path not in nodes:... | def rollup_totals(entries):
if not entries:
return []
node_totals = {}
for path, amount in entries:
current_total = 0
current_node = path
while '.' in current_node:
if current_node in node_totals:
current_total += node_totals[cur... | preference-annotator |
1.0 | pair-000072 | train-rollup_totals-0021 | `entries` is a list of two-element lists `[path, amount]` where `path` is a dotted string made of one or more non-empty segments separated by "." and `amount` is an int (possibly negative or zero). The same path may appear more than once. Every prefix of every path — that is, for a path with segments s1..sk, each of th... | rollup_totals(entries) | def rollup_totals(entries):
if not entries:
return []
aggregated = {}
total_amounts = {}
for path, amount in entries:
current_node = ''
accumulated_amount = 0
while path:
current_node += '.' + path[0]
if current_node in aggregated:
... | def rollup_totals(entries):
totals = {}
for path, amount in entries:
current_total = totals.get(path, 0)
totals[path] = current_total + amount
nodes_with_total = [(path, total) for path, total in totals.items()]
nodes_with_total.sort()
return nodes_with_total | preference-annotator |
1.0 | pair-000073 | train-rollup_totals-0021 | `entries` is a list of two-element lists `[path, amount]` where `path` is a dotted string made of one or more non-empty segments separated by "." and `amount` is an int (possibly negative or zero). The same path may appear more than once. Every prefix of every path — that is, for a path with segments s1..sk, each of th... | rollup_totals(entries) | def rollup_totals(entries):
if not entries:
return []
node_totals = {}
for path, amount in entries:
current_total = 0
current_node = path
while '.' in current_node:
if current_node in node_totals:
current_total += node_totals[cur... | def rollup_totals(entries):
totals = {}
for path, amount in entries:
current_total = totals.get(path, 0)
totals[path] = current_total + amount
nodes_with_total = [(path, total) for path, total in totals.items()]
nodes_with_total.sort()
return nodes_with_total | preference-annotator |
1.0 | pair-000074 | train-kebab_tag-0023 | Convert an arbitrary string s into a lowercase kebab-style tag. Treat ASCII letters (A-Z, a-z) and ASCII digits (0-9) as 'word characters'; every other character (spaces, tabs, newlines, punctuation, underscores, non-ASCII characters, etc.) is a separator. Replace every maximal run of one or more separator characters w... | kebab_tag(s) | import re
def kebab_tag(s):
# Simplify the process by using regular expressions
return ''.join(word.lower() for word in re.split(r'[^a-zA-Z0-9\-]+', s)).strip('-') | import re
def kebab_tag(s):
# Remove all characters that are not alphanumeric (or special ascii chars)
# Keep spaces as separators
s = re.sub(r"[^\w\s-]", '', s)
# On low level this would look something like
s = re.sub(r"\b[\s-,]+\b", "-", s)
# Join all words together
s = "-".join(s.s... | preference-annotator |
1.0 | pair-000075 | train-kebab_tag-0023 | Convert an arbitrary string s into a lowercase kebab-style tag. Treat ASCII letters (A-Z, a-z) and ASCII digits (0-9) as 'word characters'; every other character (spaces, tabs, newlines, punctuation, underscores, non-ASCII characters, etc.) is a separator. Replace every maximal run of one or more separator characters w... | kebab_tag(s) | def kebab_tag(s):
import re
# Remove more than two consecutive separators and replace remaining separators with hyphens
separators = r'\s+'
s = re.sub(separators, '-{}'.format(separators), s)
# Keep only the first character of each word if there are consecutive separators before words
s = re.s... | import re
def kebab_tag(s):
# Simplify the process by using regular expressions
return ''.join(word.lower() for word in re.split(r'[^a-zA-Z0-9\-]+', s)).strip('-') | preference-annotator |
1.0 | pair-000076 | train-kebab_tag-0023 | Convert an arbitrary string s into a lowercase kebab-style tag. Treat ASCII letters (A-Z, a-z) and ASCII digits (0-9) as 'word characters'; every other character (spaces, tabs, newlines, punctuation, underscores, non-ASCII characters, etc.) is a separator. Replace every maximal run of one or more separator characters w... | kebab_tag(s) | def kebab_tag(s):
import re
# Remove more than two consecutive separators and replace remaining separators with hyphens
separators = r'\s+'
s = re.sub(separators, '-{}'.format(separators), s)
# Keep only the first character of each word if there are consecutive separators before words
s = re.s... | import re
def kebab_tag(s):
# Remove all characters that are not alphanumeric (or special ascii chars)
# Keep spaces as separators
s = re.sub(r"[^\w\s-]", '', s)
# On low level this would look something like
s = re.sub(r"\b[\s-,]+\b", "-", s)
# Join all words together
s = "-".join(s.s... | preference-annotator |
1.0 | pair-000077 | train-kebab_tag-0023 | Convert an arbitrary string s into a lowercase kebab-style tag. Treat ASCII letters (A-Z, a-z) and ASCII digits (0-9) as 'word characters'; every other character (spaces, tabs, newlines, punctuation, underscores, non-ASCII characters, etc.) is a separator. Replace every maximal run of one or more separator characters w... | kebab_tag(s) | def kebab_tag(s):
import re
# Remove more than two consecutive separators and replace remaining separators with hyphens
separators = r'\s+'
s = re.sub(separators, '-{}'.format(separators), s)
# Keep only the first character of each word if there are consecutive separators before words
s = re.s... | def kebab_tag(s):
import re
def clean(text):
# Remove leading/trailing non-word characters
text = re.sub(r'^\W+', '', text)
text = re.sub(r'\W+$', '', text)
# Remove multiple separators become one
text = re.sub(r'-{2,}', '-', text)
return text.lower()
# Spli... | preference-annotator |
1.0 | pair-000078 | train-kebab_tag-0023 | Convert an arbitrary string s into a lowercase kebab-style tag. Treat ASCII letters (A-Z, a-z) and ASCII digits (0-9) as 'word characters'; every other character (spaces, tabs, newlines, punctuation, underscores, non-ASCII characters, etc.) is a separator. Replace every maximal run of one or more separator characters w... | kebab_tag(s) | import re
def kebab_tag(s):
# Simplify the process by using regular expressions
return ''.join(word.lower() for word in re.split(r'[^a-zA-Z0-9\-]+', s)).strip('-') | def kebab_tag(s):
import re
def clean(text):
# Remove leading/trailing non-word characters
text = re.sub(r'^\W+', '', text)
text = re.sub(r'\W+$', '', text)
# Remove multiple separators become one
text = re.sub(r'-{2,}', '-', text)
return text.lower()
# Spli... | preference-annotator |
1.0 | pair-000079 | train-kebab_tag-0023 | Convert an arbitrary string s into a lowercase kebab-style tag. Treat ASCII letters (A-Z, a-z) and ASCII digits (0-9) as 'word characters'; every other character (spaces, tabs, newlines, punctuation, underscores, non-ASCII characters, etc.) is a separator. Replace every maximal run of one or more separator characters w... | kebab_tag(s) | def kebab_tag(s):
import re
def clean(text):
# Remove leading/trailing non-word characters
text = re.sub(r'^\W+', '', text)
text = re.sub(r'\W+$', '', text)
# Remove multiple separators become one
text = re.sub(r'-{2,}', '-', text)
return text.lower()
# Spli... | import re
def kebab_tag(s):
# Remove all characters that are not alphanumeric (or special ascii chars)
# Keep spaces as separators
s = re.sub(r"[^\w\s-]", '', s)
# On low level this would look something like
s = re.sub(r"\b[\s-,]+\b", "-", s)
# Join all words together
s = "-".join(s.s... | preference-annotator |
1.0 | pair-000080 | train-parse_ranges-0025 | Expand a comma-separated list of integers and inclusive integer ranges into a sorted list of unique ints. Split s on ','. Strip whitespace from each item; skip items that are empty after stripping. A valid item is either a run of one or more ASCII digits 0-9 (a single non-negative integer, leading zeros allowed), or tw... | parse_ranges(s) | def parse_ranges(s):
def int_or_range(num_str):
if '-' not in num_str:
return int(num_str)
else:
lft, rht = map(int, num_str.split('-'))
if lft > rht:
return "ERROR"
return range(lft, rht + 1)
result = set()
for item in (n.stri... | import re
def parse_ranges(s):
if not s:
return []
def parse_range(r):
parts = r.split('-', maxsplit=1)
try:
start = int(parts[0])
end = int(parts[1]) if len(parts) > 1 else start
except ValueError:
return None
if start > end:
... | preference-annotator |
1.0 | pair-000081 | train-parse_ranges-0025 | Expand a comma-separated list of integers and inclusive integer ranges into a sorted list of unique ints. Split s on ','. Strip whitespace from each item; skip items that are empty after stripping. A valid item is either a run of one or more ASCII digits 0-9 (a single non-negative integer, leading zeros allowed), or tw... | parse_ranges(s) | def parse_ranges(s):
def int_or_range(num_str):
if '-' not in num_str:
return int(num_str)
else:
lft, rht = map(int, num_str.split('-'))
if lft > rht:
return "ERROR"
return range(lft, rht + 1)
result = set()
for item in (n.stri... | def parse_ranges(s: str) -> list:
def is_non_empty(item):
# Check if the item starts and ends with alphanumeric characters
return bool(re.match(r'^[A-Za-z\d]+$', item)) or len(item) > 0
def word_to_number(word):
# Convert 'word' to an integer or range of integers
if '-' in word:... | preference-annotator |
1.0 | pair-000082 | train-parse_ranges-0025 | Expand a comma-separated list of integers and inclusive integer ranges into a sorted list of unique ints. Split s on ','. Strip whitespace from each item; skip items that are empty after stripping. A valid item is either a run of one or more ASCII digits 0-9 (a single non-negative integer, leading zeros allowed), or tw... | parse_ranges(s) | def parse_ranges(s: str) -> list:
def is_non_empty(item):
# Check if the item starts and ends with alphanumeric characters
return bool(re.match(r'^[A-Za-z\d]+$', item)) or len(item) > 0
def word_to_number(word):
# Convert 'word' to an integer or range of integers
if '-' in word:... | import re
def parse_ranges(s):
if not s:
return []
def parse_range(r):
parts = r.split('-', maxsplit=1)
try:
start = int(parts[0])
end = int(parts[1]) if len(parts) > 1 else start
except ValueError:
return None
if start > end:
... | preference-annotator |
1.0 | pair-000083 | train-parse_ranges-0025 | Expand a comma-separated list of integers and inclusive integer ranges into a sorted list of unique ints. Split s on ','. Strip whitespace from each item; skip items that are empty after stripping. A valid item is either a run of one or more ASCII digits 0-9 (a single non-negative integer, leading zeros allowed), or tw... | parse_ranges(s) | def parse_ranges(s: str) -> list:
def is_non_empty(item):
# Check if the item starts and ends with alphanumeric characters
return bool(re.match(r'^[A-Za-z\d]+$', item)) or len(item) > 0
def word_to_number(word):
# Convert 'word' to an integer or range of integers
if '-' in word:... | def parse_ranges(s):
import re
def convert_range(ranges_str):
nums = re.findall(r'\d+-\d+', ranges_str)
errors = []
result = set()
for num in nums:
start, end = map(int, num.split('-'))
if start > end:
errors.append("ERROR")
... | preference-annotator |
End of preview.
No dataset card yet
- Downloads last month
- 762