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
evens: list<item: string>
child 0, item: string
odds: list<item: string>
child 0, item: string
pos: list<item: string>
child 0, item: string
neg: list<item: string>
child 0, item: string
double: list<item: string>
child 0, item: string
halve: list<item: string>
child 0, item: string
square: list<item: string>
child 0, item: string
inc: list<item: string>
child 0, item: string
dec: list<item: string>
child 0, item: string
negate: list<item: string>
child 0, item: string
absval: list<item: string>
child 0, item: string
rev: list<item: string>
child 0, item: string
sorta: list<item: string>
child 0, item: string
sortd: list<item: string>
child 0, item: string
uniq: list<item: string>
child 0, item: string
first3: list<item: string>
child 0, item: string
dropfirst: list<item: string>
child 0, item: string
clamp10: list<item: string>
child 0, item: string
sum: list<item: string>
child 0, item: string
max: list<item: string>
child 0, item: string
min: list<item: string>
child 0, item: string
len: list<item: string>
child 0, item: string
range_: list<item: string>
child 0, item: string
lower: list<item: string>
child 0, item: string
upper: list<item: string>
child 0, item: string
strip: list<item: string>
child 0, item: string
nonempty: list<item: string>
child 0, item: string
sortlen: list<item: string>
child 0, item: string
revstr: list<item: string>
child 0, item: string
uniqs: list<item: string>
child 0, item: string
fi
...
string
takewhilepos: list<item: string>
child 0, item: string
dropwhileneg: list<item: string>
child 0, item: string
beforezero: list<item: string>
child 0, item: string
oremptyzero: list<item: string>
child 0, item: string
padto3: list<item: string>
child 0, item: string
anyeven: list<item: string>
child 0, item: string
allpos: list<item: string>
child 0, item: string
haszero: list<item: string>
child 0, item: string
issorted: list<item: string>
child 0, item: string
alldistinct: list<item: string>
child 0, item: string
prod: list<item: string>
child 0, item: string
firsteven: list<item: string>
child 0, item: string
counteven: list<item: string>
child 0, item: string
title: list<item: string>
child 0, item: string
sortalpha: list<item: string>
child 0, item: string
dropshort: list<item: string>
child 0, item: string
prefixup: list<item: string>
child 0, item: string
anyempty: list<item: string>
child 0, item: string
maxlen: list<item: string>
child 0, item: string
ages: list<item: string>
child 0, item: string
names: list<item: string>
child 0, item: string
adults: list<item: string>
child 0, item: string
sortage: list<item: string>
child 0, item: string
countrl: list<item: string>
child 0, item: string
oldest: list<item: string>
child 0, item: string
entry_point: string
split: string
difficulty: int64
prompt: string
id: string
primitives: list<item: string>
child 0, item: string
type: string
solution: string
tests: string
to
{'id': Value('string'), 'entry_point': Value('string'), 'primitives': List(Value('string')), 'difficulty': Value('int64'), 'split': Value('string'), 'type': Value('string'), 'prompt': Value('string'), 'solution': Value('string'), 'tests': 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 1816, 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 2369, in table_cast
return cast_table_to_schema(table, schema)
File "/usr/local/lib/python3.14/site-packages/datasets/table.py", line 2297, in cast_table_to_schema
raise CastError(
...<3 lines>...
)
datasets.table.CastError: Couldn't cast
evens: list<item: string>
child 0, item: string
odds: list<item: string>
child 0, item: string
pos: list<item: string>
child 0, item: string
neg: list<item: string>
child 0, item: string
double: list<item: string>
child 0, item: string
halve: list<item: string>
child 0, item: string
square: list<item: string>
child 0, item: string
inc: list<item: string>
child 0, item: string
dec: list<item: string>
child 0, item: string
negate: list<item: string>
child 0, item: string
absval: list<item: string>
child 0, item: string
rev: list<item: string>
child 0, item: string
sorta: list<item: string>
child 0, item: string
sortd: list<item: string>
child 0, item: string
uniq: list<item: string>
child 0, item: string
first3: list<item: string>
child 0, item: string
dropfirst: list<item: string>
child 0, item: string
clamp10: list<item: string>
child 0, item: string
sum: list<item: string>
child 0, item: string
max: list<item: string>
child 0, item: string
min: list<item: string>
child 0, item: string
len: list<item: string>
child 0, item: string
range_: list<item: string>
child 0, item: string
lower: list<item: string>
child 0, item: string
upper: list<item: string>
child 0, item: string
strip: list<item: string>
child 0, item: string
nonempty: list<item: string>
child 0, item: string
sortlen: list<item: string>
child 0, item: string
revstr: list<item: string>
child 0, item: string
uniqs: list<item: string>
child 0, item: string
fi
...
string
takewhilepos: list<item: string>
child 0, item: string
dropwhileneg: list<item: string>
child 0, item: string
beforezero: list<item: string>
child 0, item: string
oremptyzero: list<item: string>
child 0, item: string
padto3: list<item: string>
child 0, item: string
anyeven: list<item: string>
child 0, item: string
allpos: list<item: string>
child 0, item: string
haszero: list<item: string>
child 0, item: string
issorted: list<item: string>
child 0, item: string
alldistinct: list<item: string>
child 0, item: string
prod: list<item: string>
child 0, item: string
firsteven: list<item: string>
child 0, item: string
counteven: list<item: string>
child 0, item: string
title: list<item: string>
child 0, item: string
sortalpha: list<item: string>
child 0, item: string
dropshort: list<item: string>
child 0, item: string
prefixup: list<item: string>
child 0, item: string
anyempty: list<item: string>
child 0, item: string
maxlen: list<item: string>
child 0, item: string
ages: list<item: string>
child 0, item: string
names: list<item: string>
child 0, item: string
adults: list<item: string>
child 0, item: string
sortage: list<item: string>
child 0, item: string
countrl: list<item: string>
child 0, item: string
oldest: list<item: string>
child 0, item: string
entry_point: string
split: string
difficulty: int64
prompt: string
id: string
primitives: list<item: string>
child 0, item: string
type: string
solution: string
tests: string
to
{'id': Value('string'), 'entry_point': Value('string'), 'primitives': List(Value('string')), 'difficulty': Value('int64'), 'split': Value('string'), 'type': Value('string'), 'prompt': Value('string'), 'solution': Value('string'), 'tests': 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 1683, 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 1869, 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.
id string | entry_point string | primitives list | difficulty int64 | split string | type string | prompt string | solution string | tests string |
|---|---|---|---|---|---|---|---|---|
op_sortalpha | op_sortalpha | [
"sortalpha"
] | 0 | train | SL | Take a list of strings; sort alphabetically. | def op_sortalpha(xs):
r = list(xs)
r = sorted(r)
return r | assert op_sortalpha(['Hello', 'world']) == ['Hello', 'world']
assert op_sortalpha([]) == []
assert op_sortalpha([' a ', '', 'BC', 'bc']) == ['', ' a ', 'BC', 'bc']
assert op_sortalpha(['one', 'one', 'Two']) == ['Two', 'one', 'one']
assert op_sortalpha(['x']) == ['x']
assert op_sortalpha(['abc', 'de', '']) == ['', 'ab... |
op_dropzeros | op_dropzeros | [
"dropzeros"
] | 0 | train | IL | Take a list of integers; drop the zeros. | def op_dropzeros(xs):
r = list(xs)
r = [x for x in r if x != 0]
return r | assert op_dropzeros([1, 2, 3, 4]) == [1, 2, 3, 4]
assert op_dropzeros([]) == []
assert op_dropzeros([-2, -1, 0, 1, 2]) == [-2, -1, 1, 2]
assert op_dropzeros([5, 5, 5]) == [5, 5, 5]
assert op_dropzeros([3, 1, 2]) == [3, 1, 2]
assert op_dropzeros([10]) == [10]
assert op_dropzeros([2, 4, 6]) == [2, 4, 6]
assert op_dropzer... |
op_neg | op_neg | [
"neg"
] | 0 | train | IL | Take a list of integers; keep the negative numbers. | def op_neg(xs):
r = list(xs)
r = [x for x in r if x < 0]
return r | assert op_neg([1, 2, 3, 4]) == []
assert op_neg([]) == []
assert op_neg([-2, -1, 0, 1, 2]) == [-2, -1]
assert op_neg([5, 5, 5]) == []
assert op_neg([3, 1, 2]) == []
assert op_neg([10]) == []
assert op_neg([2, 4, 6]) == []
assert op_neg([-7, 12, -7]) == [-7, -7] |
op_issorted | op_issorted | [
"issorted"
] | 0 | train | IL | Take a list of integers; return whether the list is sorted ascending. | def op_issorted(xs):
r = list(xs)
return r == sorted(r) | assert op_issorted([1, 2, 3, 4]) == True
assert op_issorted([]) == True
assert op_issorted([-2, -1, 0, 1, 2]) == True
assert op_issorted([5, 5, 5]) == True
assert op_issorted([3, 1, 2]) == False
assert op_issorted([10]) == True
assert op_issorted([2, 4, 6]) == True
assert op_issorted([-7, 12, -7]) == False |
op_sortabs | op_sortabs | [
"sortabs"
] | 0 | train | IL | Take a list of integers; sort by absolute value. | def op_sortabs(xs):
r = list(xs)
r = sorted(r, key=abs)
return r | assert op_sortabs([1, 2, 3, 4]) == [1, 2, 3, 4]
assert op_sortabs([]) == []
assert op_sortabs([-2, -1, 0, 1, 2]) == [0, -1, 1, -2, 2]
assert op_sortabs([5, 5, 5]) == [5, 5, 5]
assert op_sortabs([3, 1, 2]) == [1, 2, 3]
assert op_sortabs([10]) == [10]
assert op_sortabs([2, 4, 6]) == [2, 4, 6]
assert op_sortabs([-7, 12, -... |
op_ages | op_ages | [
"ages"
] | 0 | train | RL | Take a list of people records (name, age); extract the ages. | def op_ages(xs):
r = list(xs)
r = [d['age'] for d in r]
return r | assert op_ages([{'name': 'Ada', 'age': 36}, {'name': 'Bo', 'age': 12}]) == [36, 12]
assert op_ages([]) == []
assert op_ages([{'name': 'Cy', 'age': 18}, {'name': 'Dee', 'age': 65}, {'name': 'El', 'age': 17}]) == [18, 65, 17]
assert op_ages([{'name': 'Fi', 'age': 41}]) == [41] |
op_firstchar | op_firstchar | [
"firstchar"
] | 0 | train | SL | Take a list of strings; keep the first character of each (dropping empties). | def op_firstchar(xs):
r = list(xs)
r = [s[0] for s in r if s]
return r | assert op_firstchar(['Hello', 'world']) == ['H', 'w']
assert op_firstchar([]) == []
assert op_firstchar([' a ', '', 'BC', 'bc']) == [' ', 'B', 'b']
assert op_firstchar(['one', 'one', 'Two']) == ['o', 'o', 'T']
assert op_firstchar(['x']) == ['x']
assert op_firstchar(['abc', 'de', '']) == ['a', 'd'] |
op_square | op_square | [
"square"
] | 0 | train | IL | Take a list of integers; square each. | def op_square(xs):
r = list(xs)
r = [x * x for x in r]
return r | assert op_square([1, 2, 3, 4]) == [1, 4, 9, 16]
assert op_square([]) == []
assert op_square([-2, -1, 0, 1, 2]) == [4, 1, 0, 1, 4]
assert op_square([5, 5, 5]) == [25, 25, 25]
assert op_square([3, 1, 2]) == [9, 1, 4]
assert op_square([10]) == [100]
assert op_square([2, 4, 6]) == [4, 16, 36]
assert op_square([-7, 12, -7])... |
op_dec | op_dec | [
"dec"
] | 0 | train | IL | Take a list of integers; subtract one from each. | def op_dec(xs):
r = list(xs)
r = [x - 1 for x in r]
return r | assert op_dec([1, 2, 3, 4]) == [0, 1, 2, 3]
assert op_dec([]) == []
assert op_dec([-2, -1, 0, 1, 2]) == [-3, -2, -1, 0, 1]
assert op_dec([5, 5, 5]) == [4, 4, 4]
assert op_dec([3, 1, 2]) == [2, 0, 1]
assert op_dec([10]) == [9]
assert op_dec([2, 4, 6]) == [1, 3, 5]
assert op_dec([-7, 12, -7]) == [-8, 11, -8] |
op_padto3 | op_padto3 | [
"padto3"
] | 0 | train | IL | Take a list of integers; pad with zeros to at least three elements. | def op_padto3(xs):
r = list(xs)
r = r + [0] * (3 - len(r)) if len(r) < 3 else r
return r | assert op_padto3([1, 2, 3, 4]) == [1, 2, 3, 4]
assert op_padto3([]) == [0, 0, 0]
assert op_padto3([-2, -1, 0, 1, 2]) == [-2, -1, 0, 1, 2]
assert op_padto3([5, 5, 5]) == [5, 5, 5]
assert op_padto3([3, 1, 2]) == [3, 1, 2]
assert op_padto3([10]) == [10, 0, 0]
assert op_padto3([2, 4, 6]) == [2, 4, 6]
assert op_padto3([-7, ... |
op_sortage | op_sortage | [
"sortage"
] | 0 | train | RL | Take a list of people records (name, age); sort records by age, youngest first. | def op_sortage(xs):
r = list(xs)
r = sorted(r, key=lambda d: d['age'])
return r | assert op_sortage([{'name': 'Ada', 'age': 36}, {'name': 'Bo', 'age': 12}]) == [{'name': 'Bo', 'age': 12}, {'name': 'Ada', 'age': 36}]
assert op_sortage([]) == []
assert op_sortage([{'name': 'Cy', 'age': 18}, {'name': 'Dee', 'age': 65}, {'name': 'El', 'age': 17}]) == [{'name': 'El', 'age': 17}, {'name': 'Cy', 'age': 18}... |
op_lens | op_lens | [
"lens"
] | 0 | train | SL | Take a list of strings; return the total number of characters. | def op_lens(xs):
r = list(xs)
return sum(len(s) for s in r) | assert op_lens(['Hello', 'world']) == 10
assert op_lens([]) == 0
assert op_lens([' a ', '', 'BC', 'bc']) == 8
assert op_lens(['one', 'one', 'Two']) == 9
assert op_lens(['x']) == 1
assert op_lens(['abc', 'de', '']) == 5 |
op_strip | op_strip | [
"strip"
] | 0 | train | SL | Take a list of strings; trim whitespace from each. | def op_strip(xs):
r = list(xs)
r = [s.strip() for s in r]
return r | assert op_strip(['Hello', 'world']) == ['Hello', 'world']
assert op_strip([]) == []
assert op_strip([' a ', '', 'BC', 'bc']) == ['a', '', 'BC', 'bc']
assert op_strip(['one', 'one', 'Two']) == ['one', 'one', 'Two']
assert op_strip(['x']) == ['x']
assert op_strip(['abc', 'de', '']) == ['abc', 'de', ''] |
op_counts | op_counts | [
"counts"
] | 0 | train | SL | Take a list of strings; return how many strings remain. | def op_counts(xs):
r = list(xs)
return len(r) | assert op_counts(['Hello', 'world']) == 2
assert op_counts([]) == 0
assert op_counts([' a ', '', 'BC', 'bc']) == 4
assert op_counts(['one', 'one', 'Two']) == 3
assert op_counts(['x']) == 1
assert op_counts(['abc', 'de', '']) == 3 |
op_allpos | op_allpos | [
"allpos"
] | 0 | train | IL | Take a list of integers; return whether all values are positive. | def op_allpos(xs):
r = list(xs)
return all(x > 0 for x in r) | assert op_allpos([1, 2, 3, 4]) == True
assert op_allpos([]) == True
assert op_allpos([-2, -1, 0, 1, 2]) == False
assert op_allpos([5, 5, 5]) == True
assert op_allpos([3, 1, 2]) == True
assert op_allpos([10]) == True
assert op_allpos([2, 4, 6]) == True
assert op_allpos([-7, 12, -7]) == False |
op_sortd | op_sortd | [
"sortd"
] | 0 | train | IL | Take a list of integers; sort descending. | def op_sortd(xs):
r = list(xs)
r = sorted(r, reverse=True)
return r | assert op_sortd([1, 2, 3, 4]) == [4, 3, 2, 1]
assert op_sortd([]) == []
assert op_sortd([-2, -1, 0, 1, 2]) == [2, 1, 0, -1, -2]
assert op_sortd([5, 5, 5]) == [5, 5, 5]
assert op_sortd([3, 1, 2]) == [3, 2, 1]
assert op_sortd([10]) == [10]
assert op_sortd([2, 4, 6]) == [6, 4, 2]
assert op_sortd([-7, 12, -7]) == [12, -7, ... |
op_names | op_names | [
"names"
] | 0 | train | RL | Take a list of people records (name, age); extract the names. | def op_names(xs):
r = list(xs)
r = [d['name'] for d in r]
return r | assert op_names([{'name': 'Ada', 'age': 36}, {'name': 'Bo', 'age': 12}]) == ['Ada', 'Bo']
assert op_names([]) == []
assert op_names([{'name': 'Cy', 'age': 18}, {'name': 'Dee', 'age': 65}, {'name': 'El', 'age': 17}]) == ['Cy', 'Dee', 'El']
assert op_names([{'name': 'Fi', 'age': 41}]) == ['Fi'] |
op_evens | op_evens | [
"evens"
] | 0 | train | IL | Take a list of integers; keep the even numbers. | def op_evens(xs):
r = list(xs)
r = [x for x in r if x % 2 == 0]
return r | assert op_evens([1, 2, 3, 4]) == [2, 4]
assert op_evens([]) == []
assert op_evens([-2, -1, 0, 1, 2]) == [-2, 0, 2]
assert op_evens([5, 5, 5]) == []
assert op_evens([3, 1, 2]) == [2]
assert op_evens([10]) == [10]
assert op_evens([2, 4, 6]) == [2, 4, 6]
assert op_evens([-7, 12, -7]) == [12] |
op_countrl | op_countrl | [
"countrl"
] | 0 | train | RL | Take a list of people records (name, age); return how many records remain. | def op_countrl(xs):
r = list(xs)
return len(r) | assert op_countrl([{'name': 'Ada', 'age': 36}, {'name': 'Bo', 'age': 12}]) == 2
assert op_countrl([]) == 0
assert op_countrl([{'name': 'Cy', 'age': 18}, {'name': 'Dee', 'age': 65}, {'name': 'El', 'age': 17}]) == 3
assert op_countrl([{'name': 'Fi', 'age': 41}]) == 1 |
op_odds | op_odds | [
"odds"
] | 0 | train | IL | Take a list of integers; keep the odd numbers. | def op_odds(xs):
r = list(xs)
r = [x for x in r if x % 2 != 0]
return r | assert op_odds([1, 2, 3, 4]) == [1, 3]
assert op_odds([]) == []
assert op_odds([-2, -1, 0, 1, 2]) == [-1, 1]
assert op_odds([5, 5, 5]) == [5, 5, 5]
assert op_odds([3, 1, 2]) == [3, 1]
assert op_odds([10]) == []
assert op_odds([2, 4, 6]) == []
assert op_odds([-7, 12, -7]) == [-7, -7] |
op_oremptyzero | op_oremptyzero | [
"oremptyzero"
] | 0 | train | IL | Take a list of integers; if empty, use a single zero. | def op_oremptyzero(xs):
r = list(xs)
r = r if r else [0]
return r | assert op_oremptyzero([1, 2, 3, 4]) == [1, 2, 3, 4]
assert op_oremptyzero([]) == [0]
assert op_oremptyzero([-2, -1, 0, 1, 2]) == [-2, -1, 0, 1, 2]
assert op_oremptyzero([5, 5, 5]) == [5, 5, 5]
assert op_oremptyzero([3, 1, 2]) == [3, 1, 2]
assert op_oremptyzero([10]) == [10]
assert op_oremptyzero([2, 4, 6]) == [2, 4, 6]... |
op_dropwhileneg | op_dropwhileneg | [
"dropwhileneg"
] | 0 | train | IL | Take a list of integers; drop the leading negative values. | def op_dropwhileneg(xs):
r = list(xs)
r = r[next((i for i, x in enumerate(r) if x >= 0), len(r)):]
return r | assert op_dropwhileneg([1, 2, 3, 4]) == [1, 2, 3, 4]
assert op_dropwhileneg([]) == []
assert op_dropwhileneg([-2, -1, 0, 1, 2]) == [0, 1, 2]
assert op_dropwhileneg([5, 5, 5]) == [5, 5, 5]
assert op_dropwhileneg([3, 1, 2]) == [3, 1, 2]
assert op_dropwhileneg([10]) == [10]
assert op_dropwhileneg([2, 4, 6]) == [2, 4, 6]
a... |
op_first3 | op_first3 | [
"first3"
] | 0 | train | IL | Take a list of integers; keep only the first three. | def op_first3(xs):
r = list(xs)
r = r[:3]
return r | assert op_first3([1, 2, 3, 4]) == [1, 2, 3]
assert op_first3([]) == []
assert op_first3([-2, -1, 0, 1, 2]) == [-2, -1, 0]
assert op_first3([5, 5, 5]) == [5, 5, 5]
assert op_first3([3, 1, 2]) == [3, 1, 2]
assert op_first3([10]) == [10]
assert op_first3([2, 4, 6]) == [2, 4, 6]
assert op_first3([-7, 12, -7]) == [-7, 12, -... |
op_dropfirst | op_dropfirst | [
"dropfirst"
] | 0 | train | IL | Take a list of integers; drop the first element. | def op_dropfirst(xs):
r = list(xs)
r = r[1:]
return r | assert op_dropfirst([1, 2, 3, 4]) == [2, 3, 4]
assert op_dropfirst([]) == []
assert op_dropfirst([-2, -1, 0, 1, 2]) == [-1, 0, 1, 2]
assert op_dropfirst([5, 5, 5]) == [5, 5]
assert op_dropfirst([3, 1, 2]) == [1, 2]
assert op_dropfirst([10]) == []
assert op_dropfirst([2, 4, 6]) == [4, 6]
assert op_dropfirst([-7, 12, -7]... |
op_sum | op_sum | [
"sum"
] | 0 | train | IL | Take a list of integers; return their sum. | def op_sum(xs):
r = list(xs)
return sum(r) | assert op_sum([1, 2, 3, 4]) == 10
assert op_sum([]) == 0
assert op_sum([-2, -1, 0, 1, 2]) == 0
assert op_sum([5, 5, 5]) == 15
assert op_sum([3, 1, 2]) == 6
assert op_sum([10]) == 10
assert op_sum([2, 4, 6]) == 12
assert op_sum([-7, 12, -7]) == -2 |
op_dropshort | op_dropshort | [
"dropshort"
] | 0 | train | SL | Take a list of strings; drop strings shorter than three characters. | def op_dropshort(xs):
r = list(xs)
r = [s for s in r if len(s) >= 3]
return r | assert op_dropshort(['Hello', 'world']) == ['Hello', 'world']
assert op_dropshort([]) == []
assert op_dropshort([' a ', '', 'BC', 'bc']) == [' a ']
assert op_dropshort(['one', 'one', 'Two']) == ['one', 'one', 'Two']
assert op_dropshort(['x']) == []
assert op_dropshort(['abc', 'de', '']) == ['abc'] |
op_len | op_len | [
"len"
] | 0 | train | IL | Take a list of integers; return how many remain. | def op_len(xs):
r = list(xs)
return len(r) | assert op_len([1, 2, 3, 4]) == 4
assert op_len([]) == 0
assert op_len([-2, -1, 0, 1, 2]) == 5
assert op_len([5, 5, 5]) == 3
assert op_len([3, 1, 2]) == 3
assert op_len([10]) == 1
assert op_len([2, 4, 6]) == 3
assert op_len([-7, 12, -7]) == 3 |
op_gt5 | op_gt5 | [
"gt5"
] | 0 | train | IL | Take a list of integers; keep values greater than five. | def op_gt5(xs):
r = list(xs)
r = [x for x in r if x > 5]
return r | assert op_gt5([1, 2, 3, 4]) == []
assert op_gt5([]) == []
assert op_gt5([-2, -1, 0, 1, 2]) == []
assert op_gt5([5, 5, 5]) == []
assert op_gt5([3, 1, 2]) == []
assert op_gt5([10]) == [10]
assert op_gt5([2, 4, 6]) == [6]
assert op_gt5([-7, 12, -7]) == [12] |
op_rev | op_rev | [
"rev"
] | 0 | train | IL | Take a list of integers; reverse the order. | def op_rev(xs):
r = list(xs)
r = list(reversed(r))
return r | assert op_rev([1, 2, 3, 4]) == [4, 3, 2, 1]
assert op_rev([]) == []
assert op_rev([-2, -1, 0, 1, 2]) == [2, 1, 0, -1, -2]
assert op_rev([5, 5, 5]) == [5, 5, 5]
assert op_rev([3, 1, 2]) == [2, 1, 3]
assert op_rev([10]) == [10]
assert op_rev([2, 4, 6]) == [6, 4, 2]
assert op_rev([-7, 12, -7]) == [-7, 12, -7] |
op_haszero | op_haszero | [
"haszero"
] | 0 | train | IL | Take a list of integers; return whether the list contains a zero. | def op_haszero(xs):
r = list(xs)
return 0 in r | assert op_haszero([1, 2, 3, 4]) == False
assert op_haszero([]) == False
assert op_haszero([-2, -1, 0, 1, 2]) == True
assert op_haszero([5, 5, 5]) == False
assert op_haszero([3, 1, 2]) == False
assert op_haszero([10]) == False
assert op_haszero([2, 4, 6]) == False
assert op_haszero([-7, 12, -7]) == False |
op_sorta | op_sorta | [
"sorta"
] | 0 | train | IL | Take a list of integers; sort ascending. | def op_sorta(xs):
r = list(xs)
r = sorted(r)
return r | assert op_sorta([1, 2, 3, 4]) == [1, 2, 3, 4]
assert op_sorta([]) == []
assert op_sorta([-2, -1, 0, 1, 2]) == [-2, -1, 0, 1, 2]
assert op_sorta([5, 5, 5]) == [5, 5, 5]
assert op_sorta([3, 1, 2]) == [1, 2, 3]
assert op_sorta([10]) == [10]
assert op_sorta([2, 4, 6]) == [2, 4, 6]
assert op_sorta([-7, 12, -7]) == [-7, -7, ... |
op_trimends | op_trimends | [
"trimends"
] | 0 | train | IL | Take a list of integers; drop the first and last elements. | def op_trimends(xs):
r = list(xs)
r = r[1:-1]
return r | assert op_trimends([1, 2, 3, 4]) == [2, 3]
assert op_trimends([]) == []
assert op_trimends([-2, -1, 0, 1, 2]) == [-1, 0, 1]
assert op_trimends([5, 5, 5]) == [5]
assert op_trimends([3, 1, 2]) == [1]
assert op_trimends([10]) == []
assert op_trimends([2, 4, 6]) == [4]
assert op_trimends([-7, 12, -7]) == [12] |
op_prod | op_prod | [
"prod"
] | 0 | train | IL | Take a list of integers; return their product. | def op_prod(xs):
r = list(xs)
return __import__('math').prod(r) | assert op_prod([1, 2, 3, 4]) == 24
assert op_prod([]) == 1
assert op_prod([-2, -1, 0, 1, 2]) == 0
assert op_prod([5, 5, 5]) == 125
assert op_prod([3, 1, 2]) == 6
assert op_prod([10]) == 10
assert op_prod([2, 4, 6]) == 48
assert op_prod([-7, 12, -7]) == 588 |
op_lower | op_lower | [
"lower"
] | 0 | train | SL | Take a list of strings; lowercase each string. | def op_lower(xs):
r = list(xs)
r = [s.lower() for s in r]
return r | assert op_lower(['Hello', 'world']) == ['hello', 'world']
assert op_lower([]) == []
assert op_lower([' a ', '', 'BC', 'bc']) == [' a ', '', 'bc', 'bc']
assert op_lower(['one', 'one', 'Two']) == ['one', 'one', 'two']
assert op_lower(['x']) == ['x']
assert op_lower(['abc', 'de', '']) == ['abc', 'de', ''] |
op_double | op_double | [
"double"
] | 0 | train | IL | Take a list of integers; double each. | def op_double(xs):
r = list(xs)
r = [x * 2 for x in r]
return r | assert op_double([1, 2, 3, 4]) == [2, 4, 6, 8]
assert op_double([]) == []
assert op_double([-2, -1, 0, 1, 2]) == [-4, -2, 0, 2, 4]
assert op_double([5, 5, 5]) == [10, 10, 10]
assert op_double([3, 1, 2]) == [6, 2, 4]
assert op_double([10]) == [20]
assert op_double([2, 4, 6]) == [4, 8, 12]
assert op_double([-7, 12, -7]) ... |
op_beforezero | op_beforezero | [
"beforezero"
] | 0 | train | IL | Take a list of integers; keep everything before the first zero. | def op_beforezero(xs):
r = list(xs)
r = r[:r.index(0)] if 0 in r else r
return r | assert op_beforezero([1, 2, 3, 4]) == [1, 2, 3, 4]
assert op_beforezero([]) == []
assert op_beforezero([-2, -1, 0, 1, 2]) == [-2, -1]
assert op_beforezero([5, 5, 5]) == [5, 5, 5]
assert op_beforezero([3, 1, 2]) == [3, 1, 2]
assert op_beforezero([10]) == [10]
assert op_beforezero([2, 4, 6]) == [2, 4, 6]
assert op_before... |
op_counteven | op_counteven | [
"counteven"
] | 0 | train | IL | Take a list of integers; return how many values are even. | def op_counteven(xs):
r = list(xs)
return sum(1 for x in r if x % 2 == 0) | assert op_counteven([1, 2, 3, 4]) == 2
assert op_counteven([]) == 0
assert op_counteven([-2, -1, 0, 1, 2]) == 3
assert op_counteven([5, 5, 5]) == 0
assert op_counteven([3, 1, 2]) == 1
assert op_counteven([10]) == 1
assert op_counteven([2, 4, 6]) == 3
assert op_counteven([-7, 12, -7]) == 1 |
op_absval | op_absval | [
"absval"
] | 0 | train | IL | Take a list of integers; take the absolute value of each. | def op_absval(xs):
r = list(xs)
r = [abs(x) for x in r]
return r | assert op_absval([1, 2, 3, 4]) == [1, 2, 3, 4]
assert op_absval([]) == []
assert op_absval([-2, -1, 0, 1, 2]) == [2, 1, 0, 1, 2]
assert op_absval([5, 5, 5]) == [5, 5, 5]
assert op_absval([3, 1, 2]) == [3, 1, 2]
assert op_absval([10]) == [10]
assert op_absval([2, 4, 6]) == [2, 4, 6]
assert op_absval([-7, 12, -7]) == [7,... |
op_last3 | op_last3 | [
"last3"
] | 0 | train | IL | Take a list of integers; keep only the last three. | def op_last3(xs):
r = list(xs)
r = r[-3:]
return r | assert op_last3([1, 2, 3, 4]) == [2, 3, 4]
assert op_last3([]) == []
assert op_last3([-2, -1, 0, 1, 2]) == [0, 1, 2]
assert op_last3([5, 5, 5]) == [5, 5, 5]
assert op_last3([3, 1, 2]) == [3, 1, 2]
assert op_last3([10]) == [10]
assert op_last3([2, 4, 6]) == [2, 4, 6]
assert op_last3([-7, 12, -7]) == [-7, 12, -7] |
op_anyempty | op_anyempty | [
"anyempty"
] | 0 | train | SL | Take a list of strings; return whether any string is empty. | def op_anyempty(xs):
r = list(xs)
return any(s == '' for s in r) | assert op_anyempty(['Hello', 'world']) == False
assert op_anyempty([]) == False
assert op_anyempty([' a ', '', 'BC', 'bc']) == True
assert op_anyempty(['one', 'one', 'Two']) == False
assert op_anyempty(['x']) == False
assert op_anyempty(['abc', 'de', '']) == True |
op_takewhilepos | op_takewhilepos | [
"takewhilepos"
] | 0 | train | IL | Take a list of integers; take values while they are positive. | def op_takewhilepos(xs):
r = list(xs)
r = r[:next((i for i, x in enumerate(r) if x <= 0), len(r))]
return r | assert op_takewhilepos([1, 2, 3, 4]) == [1, 2, 3, 4]
assert op_takewhilepos([]) == []
assert op_takewhilepos([-2, -1, 0, 1, 2]) == []
assert op_takewhilepos([5, 5, 5]) == [5, 5, 5]
assert op_takewhilepos([3, 1, 2]) == [3, 1, 2]
assert op_takewhilepos([10]) == [10]
assert op_takewhilepos([2, 4, 6]) == [2, 4, 6]
assert o... |
op_inc | op_inc | [
"inc"
] | 0 | train | IL | Take a list of integers; add one to each. | def op_inc(xs):
r = list(xs)
r = [x + 1 for x in r]
return r | assert op_inc([1, 2, 3, 4]) == [2, 3, 4, 5]
assert op_inc([]) == []
assert op_inc([-2, -1, 0, 1, 2]) == [-1, 0, 1, 2, 3]
assert op_inc([5, 5, 5]) == [6, 6, 6]
assert op_inc([3, 1, 2]) == [4, 2, 3]
assert op_inc([10]) == [11]
assert op_inc([2, 4, 6]) == [3, 5, 7]
assert op_inc([-7, 12, -7]) == [-6, 13, -6] |
op_anyeven | op_anyeven | [
"anyeven"
] | 0 | train | IL | Take a list of integers; return whether any value is even. | def op_anyeven(xs):
r = list(xs)
return any(x % 2 == 0 for x in r) | assert op_anyeven([1, 2, 3, 4]) == True
assert op_anyeven([]) == False
assert op_anyeven([-2, -1, 0, 1, 2]) == True
assert op_anyeven([5, 5, 5]) == False
assert op_anyeven([3, 1, 2]) == True
assert op_anyeven([10]) == True
assert op_anyeven([2, 4, 6]) == True
assert op_anyeven([-7, 12, -7]) == True |
op_max | op_max | [
"max"
] | 0 | train | IL | Take a list of integers; return the maximum (0 if empty). | def op_max(xs):
r = list(xs)
return max(r) if r else 0 | assert op_max([1, 2, 3, 4]) == 4
assert op_max([]) == 0
assert op_max([-2, -1, 0, 1, 2]) == 2
assert op_max([5, 5, 5]) == 5
assert op_max([3, 1, 2]) == 3
assert op_max([10]) == 10
assert op_max([2, 4, 6]) == 6
assert op_max([-7, 12, -7]) == 12 |
op_negate | op_negate | [
"negate"
] | 0 | train | IL | Take a list of integers; negate each. | def op_negate(xs):
r = list(xs)
r = [-x for x in r]
return r | assert op_negate([1, 2, 3, 4]) == [-1, -2, -3, -4]
assert op_negate([]) == []
assert op_negate([-2, -1, 0, 1, 2]) == [2, 1, 0, -1, -2]
assert op_negate([5, 5, 5]) == [-5, -5, -5]
assert op_negate([3, 1, 2]) == [-3, -1, -2]
assert op_negate([10]) == [-10]
assert op_negate([2, 4, 6]) == [-2, -4, -6]
assert op_negate([-7,... |
op_oldest | op_oldest | [
"oldest"
] | 0 | train | RL | Take a list of people records (name, age); return the name of the oldest person (empty if none). | def op_oldest(xs):
r = list(xs)
return max(r, key=lambda d: d['age'])['name'] if r else '' | assert op_oldest([{'name': 'Ada', 'age': 36}, {'name': 'Bo', 'age': 12}]) == 'Ada'
assert op_oldest([]) == ''
assert op_oldest([{'name': 'Cy', 'age': 18}, {'name': 'Dee', 'age': 65}, {'name': 'El', 'age': 17}]) == 'Dee'
assert op_oldest([{'name': 'Fi', 'age': 41}]) == 'Fi' |
op_uniq | op_uniq | [
"uniq"
] | 0 | train | IL | Take a list of integers; drop duplicates keeping first occurrence. | def op_uniq(xs):
r = list(xs)
r = list(dict.fromkeys(r))
return r | assert op_uniq([1, 2, 3, 4]) == [1, 2, 3, 4]
assert op_uniq([]) == []
assert op_uniq([-2, -1, 0, 1, 2]) == [-2, -1, 0, 1, 2]
assert op_uniq([5, 5, 5]) == [5]
assert op_uniq([3, 1, 2]) == [3, 1, 2]
assert op_uniq([10]) == [10]
assert op_uniq([2, 4, 6]) == [2, 4, 6]
assert op_uniq([-7, 12, -7]) == [-7, 12] |
op_add10 | op_add10 | [
"add10"
] | 0 | train | IL | Take a list of integers; add ten to each. | def op_add10(xs):
r = list(xs)
r = [x + 10 for x in r]
return r | assert op_add10([1, 2, 3, 4]) == [11, 12, 13, 14]
assert op_add10([]) == []
assert op_add10([-2, -1, 0, 1, 2]) == [8, 9, 10, 11, 12]
assert op_add10([5, 5, 5]) == [15, 15, 15]
assert op_add10([3, 1, 2]) == [13, 11, 12]
assert op_add10([10]) == [20]
assert op_add10([2, 4, 6]) == [12, 14, 16]
assert op_add10([-7, 12, -7]... |
op_upper | op_upper | [
"upper"
] | 0 | train | SL | Take a list of strings; uppercase each string. | def op_upper(xs):
r = list(xs)
r = [s.upper() for s in r]
return r | assert op_upper(['Hello', 'world']) == ['HELLO', 'WORLD']
assert op_upper([]) == []
assert op_upper([' a ', '', 'BC', 'bc']) == [' A ', '', 'BC', 'BC']
assert op_upper(['one', 'one', 'Two']) == ['ONE', 'ONE', 'TWO']
assert op_upper(['x']) == ['X']
assert op_upper(['abc', 'de', '']) == ['ABC', 'DE', ''] |
op_joinc | op_joinc | [
"joinc"
] | 0 | train | SL | Take a list of strings; join them with commas. | def op_joinc(xs):
r = list(xs)
return ','.join(r) | assert op_joinc(['Hello', 'world']) == 'Hello,world'
assert op_joinc([]) == ''
assert op_joinc([' a ', '', 'BC', 'bc']) == ' a ,,BC,bc'
assert op_joinc(['one', 'one', 'Two']) == 'one,one,Two'
assert op_joinc(['x']) == 'x'
assert op_joinc(['abc', 'de', '']) == 'abc,de,' |
op_min | op_min | [
"min"
] | 0 | train | IL | Take a list of integers; return the minimum (0 if empty). | def op_min(xs):
r = list(xs)
return min(r) if r else 0 | assert op_min([1, 2, 3, 4]) == 1
assert op_min([]) == 0
assert op_min([-2, -1, 0, 1, 2]) == -2
assert op_min([5, 5, 5]) == 5
assert op_min([3, 1, 2]) == 1
assert op_min([10]) == 10
assert op_min([2, 4, 6]) == 2
assert op_min([-7, 12, -7]) == -7 |
op_firsteven | op_firsteven | [
"firsteven"
] | 0 | train | IL | Take a list of integers; return the first even value (0 if none). | def op_firsteven(xs):
r = list(xs)
return next((x for x in r if x % 2 == 0), 0) | assert op_firsteven([1, 2, 3, 4]) == 2
assert op_firsteven([]) == 0
assert op_firsteven([-2, -1, 0, 1, 2]) == -2
assert op_firsteven([5, 5, 5]) == 0
assert op_firsteven([3, 1, 2]) == 2
assert op_firsteven([10]) == 10
assert op_firsteven([2, 4, 6]) == 2
assert op_firsteven([-7, 12, -7]) == 12 |
op_sortlen | op_sortlen | [
"sortlen"
] | 0 | train | SL | Take a list of strings; sort by length, shortest first. | def op_sortlen(xs):
r = list(xs)
r = sorted(r, key=len)
return r | assert op_sortlen(['Hello', 'world']) == ['Hello', 'world']
assert op_sortlen([]) == []
assert op_sortlen([' a ', '', 'BC', 'bc']) == ['', 'BC', 'bc', ' a ']
assert op_sortlen(['one', 'one', 'Two']) == ['one', 'one', 'Two']
assert op_sortlen(['x']) == ['x']
assert op_sortlen(['abc', 'de', '']) == ['', 'de', 'abc'] |
op_longest | op_longest | [
"longest"
] | 0 | train | SL | Take a list of strings; return the longest string (empty if none). | def op_longest(xs):
r = list(xs)
return max(r, key=len) if r else '' | assert op_longest(['Hello', 'world']) == 'Hello'
assert op_longest([]) == ''
assert op_longest([' a ', '', 'BC', 'bc']) == ' a '
assert op_longest(['one', 'one', 'Two']) == 'one'
assert op_longest(['x']) == 'x'
assert op_longest(['abc', 'de', '']) == 'abc' |
op_div3 | op_div3 | [
"div3"
] | 0 | train | IL | Take a list of integers; keep multiples of three. | def op_div3(xs):
r = list(xs)
r = [x for x in r if x % 3 == 0]
return r | assert op_div3([1, 2, 3, 4]) == [3]
assert op_div3([]) == []
assert op_div3([-2, -1, 0, 1, 2]) == [0]
assert op_div3([5, 5, 5]) == []
assert op_div3([3, 1, 2]) == [3]
assert op_div3([10]) == []
assert op_div3([2, 4, 6]) == [6]
assert op_div3([-7, 12, -7]) == [12] |
op_clamp10 | op_clamp10 | [
"clamp10"
] | 0 | train | IL | Take a list of integers; cap each value at 10. | def op_clamp10(xs):
r = list(xs)
r = [min(x, 10) for x in r]
return r | assert op_clamp10([1, 2, 3, 4]) == [1, 2, 3, 4]
assert op_clamp10([]) == []
assert op_clamp10([-2, -1, 0, 1, 2]) == [-2, -1, 0, 1, 2]
assert op_clamp10([5, 5, 5]) == [5, 5, 5]
assert op_clamp10([3, 1, 2]) == [3, 1, 2]
assert op_clamp10([10]) == [10]
assert op_clamp10([2, 4, 6]) == [2, 4, 6]
assert op_clamp10([-7, 12, -... |
op_pos | op_pos | [
"pos"
] | 0 | train | IL | Take a list of integers; keep the positive numbers. | def op_pos(xs):
r = list(xs)
r = [x for x in r if x > 0]
return r | assert op_pos([1, 2, 3, 4]) == [1, 2, 3, 4]
assert op_pos([]) == []
assert op_pos([-2, -1, 0, 1, 2]) == [1, 2]
assert op_pos([5, 5, 5]) == [5, 5, 5]
assert op_pos([3, 1, 2]) == [3, 1, 2]
assert op_pos([10]) == [10]
assert op_pos([2, 4, 6]) == [2, 4, 6]
assert op_pos([-7, 12, -7]) == [12] |
op_uniqs | op_uniqs | [
"uniqs"
] | 0 | train | SL | Take a list of strings; drop duplicate strings keeping the first. | def op_uniqs(xs):
r = list(xs)
r = list(dict.fromkeys(r))
return r | assert op_uniqs(['Hello', 'world']) == ['Hello', 'world']
assert op_uniqs([]) == []
assert op_uniqs([' a ', '', 'BC', 'bc']) == [' a ', '', 'BC', 'bc']
assert op_uniqs(['one', 'one', 'Two']) == ['one', 'Two']
assert op_uniqs(['x']) == ['x']
assert op_uniqs(['abc', 'de', '']) == ['abc', 'de', ''] |
op_maxlen | op_maxlen | [
"maxlen"
] | 0 | train | SL | Take a list of strings; return the length of the longest string (0 if none). | def op_maxlen(xs):
r = list(xs)
return max((len(s) for s in r), default=0) | assert op_maxlen(['Hello', 'world']) == 5
assert op_maxlen([]) == 0
assert op_maxlen([' a ', '', 'BC', 'bc']) == 4
assert op_maxlen(['one', 'one', 'Two']) == 3
assert op_maxlen(['x']) == 1
assert op_maxlen(['abc', 'de', '']) == 3 |
op_alldistinct | op_alldistinct | [
"alldistinct"
] | 0 | train | IL | Take a list of integers; return whether all values are distinct. | def op_alldistinct(xs):
r = list(xs)
return len(r) == len(set(r)) | assert op_alldistinct([1, 2, 3, 4]) == True
assert op_alldistinct([]) == True
assert op_alldistinct([-2, -1, 0, 1, 2]) == True
assert op_alldistinct([5, 5, 5]) == False
assert op_alldistinct([3, 1, 2]) == True
assert op_alldistinct([10]) == True
assert op_alldistinct([2, 4, 6]) == True
assert op_alldistinct([-7, 12, -7... |
op_nonempty | op_nonempty | [
"nonempty"
] | 0 | train | SL | Take a list of strings; drop empty strings. | def op_nonempty(xs):
r = list(xs)
r = [s for s in r if s]
return r | assert op_nonempty(['Hello', 'world']) == ['Hello', 'world']
assert op_nonempty([]) == []
assert op_nonempty([' a ', '', 'BC', 'bc']) == [' a ', 'BC', 'bc']
assert op_nonempty(['one', 'one', 'Two']) == ['one', 'one', 'Two']
assert op_nonempty(['x']) == ['x']
assert op_nonempty(['abc', 'de', '']) == ['abc', 'de'] |
op_prefixup | op_prefixup | [
"prefixup"
] | 0 | train | SL | Take a list of strings; prefix each with a hash. | def op_prefixup(xs):
r = list(xs)
r = ['#' + s for s in r]
return r | assert op_prefixup(['Hello', 'world']) == ['#Hello', '#world']
assert op_prefixup([]) == []
assert op_prefixup([' a ', '', 'BC', 'bc']) == ['# a ', '#', '#BC', '#bc']
assert op_prefixup(['one', 'one', 'Two']) == ['#one', '#one', '#Two']
assert op_prefixup(['x']) == ['#x']
assert op_prefixup(['abc', 'de', '']) == ['#a... |
op_uniq_oremptyzero | op_uniq_oremptyzero | [
"uniq",
"oremptyzero"
] | 1 | train | IL | Take a list of integers; drop duplicates keeping first occurrence, then if empty, use a single zero. | def op_uniq_oremptyzero(xs):
r = list(xs)
r = list(dict.fromkeys(r))
r = r if r else [0]
return r | assert op_uniq_oremptyzero([1, 2, 3, 4]) == [1, 2, 3, 4]
assert op_uniq_oremptyzero([]) == [0]
assert op_uniq_oremptyzero([-2, -1, 0, 1, 2]) == [-2, -1, 0, 1, 2]
assert op_uniq_oremptyzero([5, 5, 5]) == [5]
assert op_uniq_oremptyzero([3, 1, 2]) == [3, 1, 2]
assert op_uniq_oremptyzero([10]) == [10]
assert op_uniq_orempt... |
op_oremptyzero_padto3 | op_oremptyzero_padto3 | [
"oremptyzero",
"padto3"
] | 1 | train | IL | Take a list of integers; if empty, use a single zero, then pad with zeros to at least three elements. | def op_oremptyzero_padto3(xs):
r = list(xs)
r = r if r else [0]
r = r + [0] * (3 - len(r)) if len(r) < 3 else r
return r | assert op_oremptyzero_padto3([1, 2, 3, 4]) == [1, 2, 3, 4]
assert op_oremptyzero_padto3([]) == [0, 0, 0]
assert op_oremptyzero_padto3([-2, -1, 0, 1, 2]) == [-2, -1, 0, 1, 2]
assert op_oremptyzero_padto3([5, 5, 5]) == [5, 5, 5]
assert op_oremptyzero_padto3([3, 1, 2]) == [3, 1, 2]
assert op_oremptyzero_padto3([10]) == [1... |
op_ages_square | op_ages_square | [
"ages",
"square"
] | 1 | train | RL | Take a list of people records (name, age); extract the ages, then square each. | def op_ages_square(xs):
r = list(xs)
r = [d['age'] for d in r]
r = [x * x for x in r]
return r | assert op_ages_square([{'name': 'Ada', 'age': 36}, {'name': 'Bo', 'age': 12}]) == [1296, 144]
assert op_ages_square([]) == []
assert op_ages_square([{'name': 'Cy', 'age': 18}, {'name': 'Dee', 'age': 65}, {'name': 'El', 'age': 17}]) == [324, 4225, 289]
assert op_ages_square([{'name': 'Fi', 'age': 41}]) == [1681] |
op_strip_sortlen | op_strip_sortlen | [
"strip",
"sortlen"
] | 1 | train | SL | Take a list of strings; trim whitespace from each, then sort by length, shortest first. | def op_strip_sortlen(xs):
r = list(xs)
r = [s.strip() for s in r]
r = sorted(r, key=len)
return r | assert op_strip_sortlen(['Hello', 'world']) == ['Hello', 'world']
assert op_strip_sortlen([]) == []
assert op_strip_sortlen([' a ', '', 'BC', 'bc']) == ['', 'a', 'BC', 'bc']
assert op_strip_sortlen(['one', 'one', 'Two']) == ['one', 'one', 'Two']
assert op_strip_sortlen(['x']) == ['x']
assert op_strip_sortlen(['abc', '... |
op_last3_trimends | op_last3_trimends | [
"last3",
"trimends"
] | 1 | train | IL | Take a list of integers; keep only the last three, then drop the first and last elements. | def op_last3_trimends(xs):
r = list(xs)
r = r[-3:]
r = r[1:-1]
return r | assert op_last3_trimends([1, 2, 3, 4]) == [3]
assert op_last3_trimends([]) == []
assert op_last3_trimends([-2, -1, 0, 1, 2]) == [1]
assert op_last3_trimends([5, 5, 5]) == [5]
assert op_last3_trimends([3, 1, 2]) == [1]
assert op_last3_trimends([10]) == []
assert op_last3_trimends([2, 4, 6]) == [4]
assert op_last3_trimen... |
op_first3_sum | op_first3_sum | [
"first3",
"sum"
] | 1 | train | IL | Take a list of integers; keep only the first three, then return their sum. | def op_first3_sum(xs):
r = list(xs)
r = r[:3]
return sum(r) | assert op_first3_sum([1, 2, 3, 4]) == 6
assert op_first3_sum([]) == 0
assert op_first3_sum([-2, -1, 0, 1, 2]) == -3
assert op_first3_sum([5, 5, 5]) == 15
assert op_first3_sum([3, 1, 2]) == 6
assert op_first3_sum([10]) == 10
assert op_first3_sum([2, 4, 6]) == 12
assert op_first3_sum([-7, 12, -7]) == -2 |
op_neg_div3 | op_neg_div3 | [
"neg",
"div3"
] | 1 | train | IL | Take a list of integers; keep the negative numbers, then keep multiples of three. | def op_neg_div3(xs):
r = list(xs)
r = [x for x in r if x < 0]
r = [x for x in r if x % 3 == 0]
return r | assert op_neg_div3([1, 2, 3, 4]) == []
assert op_neg_div3([]) == []
assert op_neg_div3([-2, -1, 0, 1, 2]) == []
assert op_neg_div3([5, 5, 5]) == []
assert op_neg_div3([3, 1, 2]) == []
assert op_neg_div3([10]) == []
assert op_neg_div3([2, 4, 6]) == []
assert op_neg_div3([-7, 12, -7]) == [] |
op_negate_takewhilepos | op_negate_takewhilepos | [
"negate",
"takewhilepos"
] | 1 | train | IL | Take a list of integers; negate each, then take values while they are positive. | def op_negate_takewhilepos(xs):
r = list(xs)
r = [-x for x in r]
r = r[:next((i for i, x in enumerate(r) if x <= 0), len(r))]
return r | assert op_negate_takewhilepos([1, 2, 3, 4]) == []
assert op_negate_takewhilepos([]) == []
assert op_negate_takewhilepos([-2, -1, 0, 1, 2]) == [2, 1]
assert op_negate_takewhilepos([5, 5, 5]) == []
assert op_negate_takewhilepos([3, 1, 2]) == []
assert op_negate_takewhilepos([10]) == []
assert op_negate_takewhilepos([2, 4... |
op_pos_dropzeros | op_pos_dropzeros | [
"pos",
"dropzeros"
] | 1 | train | IL | Take a list of integers; keep the positive numbers, then drop the zeros. | def op_pos_dropzeros(xs):
r = list(xs)
r = [x for x in r if x > 0]
r = [x for x in r if x != 0]
return r | assert op_pos_dropzeros([1, 2, 3, 4]) == [1, 2, 3, 4]
assert op_pos_dropzeros([]) == []
assert op_pos_dropzeros([-2, -1, 0, 1, 2]) == [1, 2]
assert op_pos_dropzeros([5, 5, 5]) == [5, 5, 5]
assert op_pos_dropzeros([3, 1, 2]) == [3, 1, 2]
assert op_pos_dropzeros([10]) == [10]
assert op_pos_dropzeros([2, 4, 6]) == [2, 4, ... |
op_last3_div3 | op_last3_div3 | [
"last3",
"div3"
] | 1 | train | IL | Take a list of integers; keep only the last three, then keep multiples of three. | def op_last3_div3(xs):
r = list(xs)
r = r[-3:]
r = [x for x in r if x % 3 == 0]
return r | assert op_last3_div3([1, 2, 3, 4]) == [3]
assert op_last3_div3([]) == []
assert op_last3_div3([-2, -1, 0, 1, 2]) == [0]
assert op_last3_div3([5, 5, 5]) == []
assert op_last3_div3([3, 1, 2]) == [3]
assert op_last3_div3([10]) == []
assert op_last3_div3([2, 4, 6]) == [6]
assert op_last3_div3([-7, 12, -7]) == [12] |
op_rev_issorted | op_rev_issorted | [
"rev",
"issorted"
] | 1 | train | IL | Take a list of integers; reverse the order, then return whether the list is sorted ascending. | def op_rev_issorted(xs):
r = list(xs)
r = list(reversed(r))
return r == sorted(r) | assert op_rev_issorted([1, 2, 3, 4]) == False
assert op_rev_issorted([]) == True
assert op_rev_issorted([-2, -1, 0, 1, 2]) == False
assert op_rev_issorted([5, 5, 5]) == True
assert op_rev_issorted([3, 1, 2]) == False
assert op_rev_issorted([10]) == True
assert op_rev_issorted([2, 4, 6]) == False
assert op_rev_issorted(... |
op_lower_upper | op_lower_upper | [
"lower",
"upper"
] | 1 | train | SL | Take a list of strings; lowercase each string, then uppercase each string. | def op_lower_upper(xs):
r = list(xs)
r = [s.lower() for s in r]
r = [s.upper() for s in r]
return r | assert op_lower_upper(['Hello', 'world']) == ['HELLO', 'WORLD']
assert op_lower_upper([]) == []
assert op_lower_upper([' a ', '', 'BC', 'bc']) == [' A ', '', 'BC', 'BC']
assert op_lower_upper(['one', 'one', 'Two']) == ['ONE', 'ONE', 'TWO']
assert op_lower_upper(['x']) == ['X']
assert op_lower_upper(['abc', 'de', ''])... |
op_oremptyzero_counteven | op_oremptyzero_counteven | [
"oremptyzero",
"counteven"
] | 1 | train | IL | Take a list of integers; if empty, use a single zero, then return how many values are even. | def op_oremptyzero_counteven(xs):
r = list(xs)
r = r if r else [0]
return sum(1 for x in r if x % 2 == 0) | assert op_oremptyzero_counteven([1, 2, 3, 4]) == 2
assert op_oremptyzero_counteven([]) == 1
assert op_oremptyzero_counteven([-2, -1, 0, 1, 2]) == 3
assert op_oremptyzero_counteven([5, 5, 5]) == 0
assert op_oremptyzero_counteven([3, 1, 2]) == 1
assert op_oremptyzero_counteven([10]) == 1
assert op_oremptyzero_counteven([... |
op_nonempty_lower | op_nonempty_lower | [
"nonempty",
"lower"
] | 1 | train | SL | Take a list of strings; drop empty strings, then lowercase each string. | def op_nonempty_lower(xs):
r = list(xs)
r = [s for s in r if s]
r = [s.lower() for s in r]
return r | assert op_nonempty_lower(['Hello', 'world']) == ['hello', 'world']
assert op_nonempty_lower([]) == []
assert op_nonempty_lower([' a ', '', 'BC', 'bc']) == [' a ', 'bc', 'bc']
assert op_nonempty_lower(['one', 'one', 'Two']) == ['one', 'one', 'two']
assert op_nonempty_lower(['x']) == ['x']
assert op_nonempty_lower(['ab... |
op_beforezero_gt5 | op_beforezero_gt5 | [
"beforezero",
"gt5"
] | 1 | train | IL | Take a list of integers; keep everything before the first zero, then keep values greater than five. | def op_beforezero_gt5(xs):
r = list(xs)
r = r[:r.index(0)] if 0 in r else r
r = [x for x in r if x > 5]
return r | assert op_beforezero_gt5([1, 2, 3, 4]) == []
assert op_beforezero_gt5([]) == []
assert op_beforezero_gt5([-2, -1, 0, 1, 2]) == []
assert op_beforezero_gt5([5, 5, 5]) == []
assert op_beforezero_gt5([3, 1, 2]) == []
assert op_beforezero_gt5([10]) == [10]
assert op_beforezero_gt5([2, 4, 6]) == [6]
assert op_beforezero_gt5... |
op_uniqs_sortlen | op_uniqs_sortlen | [
"uniqs",
"sortlen"
] | 1 | train | SL | Take a list of strings; drop duplicate strings keeping the first, then sort by length, shortest first. | def op_uniqs_sortlen(xs):
r = list(xs)
r = list(dict.fromkeys(r))
r = sorted(r, key=len)
return r | assert op_uniqs_sortlen(['Hello', 'world']) == ['Hello', 'world']
assert op_uniqs_sortlen([]) == []
assert op_uniqs_sortlen([' a ', '', 'BC', 'bc']) == ['', 'BC', 'bc', ' a ']
assert op_uniqs_sortlen(['one', 'one', 'Two']) == ['one', 'Two']
assert op_uniqs_sortlen(['x']) == ['x']
assert op_uniqs_sortlen(['abc', 'de',... |
op_inc_max | op_inc_max | [
"inc",
"max"
] | 1 | train | IL | Take a list of integers; add one to each, then return the maximum (0 if empty). | def op_inc_max(xs):
r = list(xs)
r = [x + 1 for x in r]
return max(r) if r else 0 | assert op_inc_max([1, 2, 3, 4]) == 5
assert op_inc_max([]) == 0
assert op_inc_max([-2, -1, 0, 1, 2]) == 3
assert op_inc_max([5, 5, 5]) == 6
assert op_inc_max([3, 1, 2]) == 4
assert op_inc_max([10]) == 11
assert op_inc_max([2, 4, 6]) == 7
assert op_inc_max([-7, 12, -7]) == 13 |
op_sortd_evens | op_sortd_evens | [
"sortd",
"evens"
] | 1 | train | IL | Take a list of integers; sort descending, then keep the even numbers. | def op_sortd_evens(xs):
r = list(xs)
r = sorted(r, reverse=True)
r = [x for x in r if x % 2 == 0]
return r | assert op_sortd_evens([1, 2, 3, 4]) == [4, 2]
assert op_sortd_evens([]) == []
assert op_sortd_evens([-2, -1, 0, 1, 2]) == [2, 0, -2]
assert op_sortd_evens([5, 5, 5]) == []
assert op_sortd_evens([3, 1, 2]) == [2]
assert op_sortd_evens([10]) == [10]
assert op_sortd_evens([2, 4, 6]) == [6, 4, 2]
assert op_sortd_evens([-7,... |
op_trimends_issorted | op_trimends_issorted | [
"trimends",
"issorted"
] | 1 | train | IL | Take a list of integers; drop the first and last elements, then return whether the list is sorted ascending. | def op_trimends_issorted(xs):
r = list(xs)
r = r[1:-1]
return r == sorted(r) | assert op_trimends_issorted([1, 2, 3, 4]) == True
assert op_trimends_issorted([]) == True
assert op_trimends_issorted([-2, -1, 0, 1, 2]) == True
assert op_trimends_issorted([5, 5, 5]) == True
assert op_trimends_issorted([3, 1, 2]) == True
assert op_trimends_issorted([10]) == True
assert op_trimends_issorted([2, 4, 6]) ... |
op_pos_inc | op_pos_inc | [
"pos",
"inc"
] | 1 | train | IL | Take a list of integers; keep the positive numbers, then add one to each. | def op_pos_inc(xs):
r = list(xs)
r = [x for x in r if x > 0]
r = [x + 1 for x in r]
return r | assert op_pos_inc([1, 2, 3, 4]) == [2, 3, 4, 5]
assert op_pos_inc([]) == []
assert op_pos_inc([-2, -1, 0, 1, 2]) == [2, 3]
assert op_pos_inc([5, 5, 5]) == [6, 6, 6]
assert op_pos_inc([3, 1, 2]) == [4, 2, 3]
assert op_pos_inc([10]) == [11]
assert op_pos_inc([2, 4, 6]) == [3, 5, 7]
assert op_pos_inc([-7, 12, -7]) == [13] |
op_prefixup_joinc | op_prefixup_joinc | [
"prefixup",
"joinc"
] | 1 | train | SL | Take a list of strings; prefix each with a hash, then join them with commas. | def op_prefixup_joinc(xs):
r = list(xs)
r = ['#' + s for s in r]
return ','.join(r) | assert op_prefixup_joinc(['Hello', 'world']) == '#Hello,#world'
assert op_prefixup_joinc([]) == ''
assert op_prefixup_joinc([' a ', '', 'BC', 'bc']) == '# a ,#,#BC,#bc'
assert op_prefixup_joinc(['one', 'one', 'Two']) == '#one,#one,#Two'
assert op_prefixup_joinc(['x']) == '#x'
assert op_prefixup_joinc(['abc', 'de', ''... |
op_evens_trimends | op_evens_trimends | [
"evens",
"trimends"
] | 1 | train | IL | Take a list of integers; keep the even numbers, then drop the first and last elements. | def op_evens_trimends(xs):
r = list(xs)
r = [x for x in r if x % 2 == 0]
r = r[1:-1]
return r | assert op_evens_trimends([1, 2, 3, 4]) == []
assert op_evens_trimends([]) == []
assert op_evens_trimends([-2, -1, 0, 1, 2]) == [0]
assert op_evens_trimends([5, 5, 5]) == []
assert op_evens_trimends([3, 1, 2]) == []
assert op_evens_trimends([10]) == []
assert op_evens_trimends([2, 4, 6]) == [4]
assert op_evens_trimends(... |
op_inc_negate | op_inc_negate | [
"inc",
"negate"
] | 1 | train | IL | Take a list of integers; add one to each, then negate each. | def op_inc_negate(xs):
r = list(xs)
r = [x + 1 for x in r]
r = [-x for x in r]
return r | assert op_inc_negate([1, 2, 3, 4]) == [-2, -3, -4, -5]
assert op_inc_negate([]) == []
assert op_inc_negate([-2, -1, 0, 1, 2]) == [1, 0, -1, -2, -3]
assert op_inc_negate([5, 5, 5]) == [-6, -6, -6]
assert op_inc_negate([3, 1, 2]) == [-4, -2, -3]
assert op_inc_negate([10]) == [-11]
assert op_inc_negate([2, 4, 6]) == [-3, ... |
op_dropzeros_haszero | op_dropzeros_haszero | [
"dropzeros",
"haszero"
] | 1 | train | IL | Take a list of integers; drop the zeros, then return whether the list contains a zero. | def op_dropzeros_haszero(xs):
r = list(xs)
r = [x for x in r if x != 0]
return 0 in r | assert op_dropzeros_haszero([1, 2, 3, 4]) == False
assert op_dropzeros_haszero([]) == False
assert op_dropzeros_haszero([-2, -1, 0, 1, 2]) == False
assert op_dropzeros_haszero([5, 5, 5]) == False
assert op_dropzeros_haszero([3, 1, 2]) == False
assert op_dropzeros_haszero([10]) == False
assert op_dropzeros_haszero([2, 4... |
op_dec_prod | op_dec_prod | [
"dec",
"prod"
] | 1 | train | IL | Take a list of integers; subtract one from each, then return their product. | def op_dec_prod(xs):
r = list(xs)
r = [x - 1 for x in r]
return __import__('math').prod(r) | assert op_dec_prod([1, 2, 3, 4]) == 0
assert op_dec_prod([]) == 1
assert op_dec_prod([-2, -1, 0, 1, 2]) == 0
assert op_dec_prod([5, 5, 5]) == 64
assert op_dec_prod([3, 1, 2]) == 0
assert op_dec_prod([10]) == 9
assert op_dec_prod([2, 4, 6]) == 15
assert op_dec_prod([-7, 12, -7]) == 704 |
op_double_dropfirst | op_double_dropfirst | [
"double",
"dropfirst"
] | 1 | train | IL | Take a list of integers; double each, then drop the first element. | def op_double_dropfirst(xs):
r = list(xs)
r = [x * 2 for x in r]
r = r[1:]
return r | assert op_double_dropfirst([1, 2, 3, 4]) == [4, 6, 8]
assert op_double_dropfirst([]) == []
assert op_double_dropfirst([-2, -1, 0, 1, 2]) == [-2, 0, 2, 4]
assert op_double_dropfirst([5, 5, 5]) == [10, 10]
assert op_double_dropfirst([3, 1, 2]) == [2, 4]
assert op_double_dropfirst([10]) == []
assert op_double_dropfirst([2... |
op_oremptyzero_odds | op_oremptyzero_odds | [
"oremptyzero",
"odds"
] | 1 | train | IL | Take a list of integers; if empty, use a single zero, then keep the odd numbers. | def op_oremptyzero_odds(xs):
r = list(xs)
r = r if r else [0]
r = [x for x in r if x % 2 != 0]
return r | assert op_oremptyzero_odds([1, 2, 3, 4]) == [1, 3]
assert op_oremptyzero_odds([]) == []
assert op_oremptyzero_odds([-2, -1, 0, 1, 2]) == [-1, 1]
assert op_oremptyzero_odds([5, 5, 5]) == [5, 5, 5]
assert op_oremptyzero_odds([3, 1, 2]) == [3, 1]
assert op_oremptyzero_odds([10]) == []
assert op_oremptyzero_odds([2, 4, 6])... |
op_uniq_trimends | op_uniq_trimends | [
"uniq",
"trimends"
] | 1 | train | IL | Take a list of integers; drop duplicates keeping first occurrence, then drop the first and last elements. | def op_uniq_trimends(xs):
r = list(xs)
r = list(dict.fromkeys(r))
r = r[1:-1]
return r | assert op_uniq_trimends([1, 2, 3, 4]) == [2, 3]
assert op_uniq_trimends([]) == []
assert op_uniq_trimends([-2, -1, 0, 1, 2]) == [-1, 0, 1]
assert op_uniq_trimends([5, 5, 5]) == []
assert op_uniq_trimends([3, 1, 2]) == [1]
assert op_uniq_trimends([10]) == []
assert op_uniq_trimends([2, 4, 6]) == [4]
assert op_uniq_trime... |
op_gt5_sum | op_gt5_sum | [
"gt5",
"sum"
] | 1 | train | IL | Take a list of integers; keep values greater than five, then return their sum. | def op_gt5_sum(xs):
r = list(xs)
r = [x for x in r if x > 5]
return sum(r) | assert op_gt5_sum([1, 2, 3, 4]) == 0
assert op_gt5_sum([]) == 0
assert op_gt5_sum([-2, -1, 0, 1, 2]) == 0
assert op_gt5_sum([5, 5, 5]) == 0
assert op_gt5_sum([3, 1, 2]) == 0
assert op_gt5_sum([10]) == 10
assert op_gt5_sum([2, 4, 6]) == 6
assert op_gt5_sum([-7, 12, -7]) == 12 |
op_oremptyzero_div3 | op_oremptyzero_div3 | [
"oremptyzero",
"div3"
] | 1 | train | IL | Take a list of integers; if empty, use a single zero, then keep multiples of three. | def op_oremptyzero_div3(xs):
r = list(xs)
r = r if r else [0]
r = [x for x in r if x % 3 == 0]
return r | assert op_oremptyzero_div3([1, 2, 3, 4]) == [3]
assert op_oremptyzero_div3([]) == [0]
assert op_oremptyzero_div3([-2, -1, 0, 1, 2]) == [0]
assert op_oremptyzero_div3([5, 5, 5]) == []
assert op_oremptyzero_div3([3, 1, 2]) == [3]
assert op_oremptyzero_div3([10]) == []
assert op_oremptyzero_div3([2, 4, 6]) == [6]
assert o... |
op_dropzeros_odds | op_dropzeros_odds | [
"dropzeros",
"odds"
] | 1 | train | IL | Take a list of integers; drop the zeros, then keep the odd numbers. | def op_dropzeros_odds(xs):
r = list(xs)
r = [x for x in r if x != 0]
r = [x for x in r if x % 2 != 0]
return r | assert op_dropzeros_odds([1, 2, 3, 4]) == [1, 3]
assert op_dropzeros_odds([]) == []
assert op_dropzeros_odds([-2, -1, 0, 1, 2]) == [-1, 1]
assert op_dropzeros_odds([5, 5, 5]) == [5, 5, 5]
assert op_dropzeros_odds([3, 1, 2]) == [3, 1]
assert op_dropzeros_odds([10]) == []
assert op_dropzeros_odds([2, 4, 6]) == []
assert ... |
op_negate_first3 | op_negate_first3 | [
"negate",
"first3"
] | 1 | train | IL | Take a list of integers; negate each, then keep only the first three. | def op_negate_first3(xs):
r = list(xs)
r = [-x for x in r]
r = r[:3]
return r | assert op_negate_first3([1, 2, 3, 4]) == [-1, -2, -3]
assert op_negate_first3([]) == []
assert op_negate_first3([-2, -1, 0, 1, 2]) == [2, 1, 0]
assert op_negate_first3([5, 5, 5]) == [-5, -5, -5]
assert op_negate_first3([3, 1, 2]) == [-3, -1, -2]
assert op_negate_first3([10]) == [-10]
assert op_negate_first3([2, 4, 6]) ... |
op_square_beforezero | op_square_beforezero | [
"square",
"beforezero"
] | 1 | train | IL | Take a list of integers; square each, then keep everything before the first zero. | def op_square_beforezero(xs):
r = list(xs)
r = [x * x for x in r]
r = r[:r.index(0)] if 0 in r else r
return r | assert op_square_beforezero([1, 2, 3, 4]) == [1, 4, 9, 16]
assert op_square_beforezero([]) == []
assert op_square_beforezero([-2, -1, 0, 1, 2]) == [4, 1]
assert op_square_beforezero([5, 5, 5]) == [25, 25, 25]
assert op_square_beforezero([3, 1, 2]) == [9, 1, 4]
assert op_square_beforezero([10]) == [100]
assert op_square... |
op_dropwhileneg_padto3 | op_dropwhileneg_padto3 | [
"dropwhileneg",
"padto3"
] | 1 | train | IL | Take a list of integers; drop the leading negative values, then pad with zeros to at least three elements. | def op_dropwhileneg_padto3(xs):
r = list(xs)
r = r[next((i for i, x in enumerate(r) if x >= 0), len(r)):]
r = r + [0] * (3 - len(r)) if len(r) < 3 else r
return r | assert op_dropwhileneg_padto3([1, 2, 3, 4]) == [1, 2, 3, 4]
assert op_dropwhileneg_padto3([]) == [0, 0, 0]
assert op_dropwhileneg_padto3([-2, -1, 0, 1, 2]) == [0, 1, 2]
assert op_dropwhileneg_padto3([5, 5, 5]) == [5, 5, 5]
assert op_dropwhileneg_padto3([3, 1, 2]) == [3, 1, 2]
assert op_dropwhileneg_padto3([10]) == [10,... |
op_negate_padto3 | op_negate_padto3 | [
"negate",
"padto3"
] | 1 | train | IL | Take a list of integers; negate each, then pad with zeros to at least three elements. | def op_negate_padto3(xs):
r = list(xs)
r = [-x for x in r]
r = r + [0] * (3 - len(r)) if len(r) < 3 else r
return r | assert op_negate_padto3([1, 2, 3, 4]) == [-1, -2, -3, -4]
assert op_negate_padto3([]) == [0, 0, 0]
assert op_negate_padto3([-2, -1, 0, 1, 2]) == [2, 1, 0, -1, -2]
assert op_negate_padto3([5, 5, 5]) == [-5, -5, -5]
assert op_negate_padto3([3, 1, 2]) == [-3, -1, -2]
assert op_negate_padto3([10]) == [-10, 0, 0]
assert op_... |
op_absval_clamp10 | op_absval_clamp10 | [
"absval",
"clamp10"
] | 1 | train | IL | Take a list of integers; take the absolute value of each, then cap each value at 10. | def op_absval_clamp10(xs):
r = list(xs)
r = [abs(x) for x in r]
r = [min(x, 10) for x in r]
return r | assert op_absval_clamp10([1, 2, 3, 4]) == [1, 2, 3, 4]
assert op_absval_clamp10([]) == []
assert op_absval_clamp10([-2, -1, 0, 1, 2]) == [2, 1, 0, 1, 2]
assert op_absval_clamp10([5, 5, 5]) == [5, 5, 5]
assert op_absval_clamp10([3, 1, 2]) == [3, 1, 2]
assert op_absval_clamp10([10]) == [10]
assert op_absval_clamp10([2, 4... |
op_dropzeros_beforezero | op_dropzeros_beforezero | [
"dropzeros",
"beforezero"
] | 1 | train | IL | Take a list of integers; drop the zeros, then keep everything before the first zero. | def op_dropzeros_beforezero(xs):
r = list(xs)
r = [x for x in r if x != 0]
r = r[:r.index(0)] if 0 in r else r
return r | assert op_dropzeros_beforezero([1, 2, 3, 4]) == [1, 2, 3, 4]
assert op_dropzeros_beforezero([]) == []
assert op_dropzeros_beforezero([-2, -1, 0, 1, 2]) == [-2, -1, 1, 2]
assert op_dropzeros_beforezero([5, 5, 5]) == [5, 5, 5]
assert op_dropzeros_beforezero([3, 1, 2]) == [3, 1, 2]
assert op_dropzeros_beforezero([10]) == ... |
op_nonempty_anyempty | op_nonempty_anyempty | [
"nonempty",
"anyempty"
] | 1 | train | SL | Take a list of strings; drop empty strings, then return whether any string is empty. | def op_nonempty_anyempty(xs):
r = list(xs)
r = [s for s in r if s]
return any(s == '' for s in r) | assert op_nonempty_anyempty(['Hello', 'world']) == False
assert op_nonempty_anyempty([]) == False
assert op_nonempty_anyempty([' a ', '', 'BC', 'bc']) == False
assert op_nonempty_anyempty(['one', 'one', 'Two']) == False
assert op_nonempty_anyempty(['x']) == False
assert op_nonempty_anyempty(['abc', 'de', '']) == False |
End of preview.
Glyph — task bank
67 single-function list-of-integers tasks (45 train, 22 held-out compositional). Each: id, primitives, entry_point, difficulty, split, solution, executable tests. Reference solutions + tests derived by execution. Held-out tasks recombine train-only primitives in novel orders (compositional generalization test). Code: https://github.com/robertkeus/glyph-ai
- Downloads last month
- 31