Publish humaneval: 164 task(s) (openai/openai_humaneval)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- HumanEval_0/instruction.mdAdded+17
- HumanEval_0/solution/__init__.pyAdded+1
- HumanEval_0/solution/solution.pyAdded+19
- HumanEval_0/task.tomlAdded+19
- HumanEval_0/tests/__init__.pyAdded
- HumanEval_0/tests/conftest.pyAdded+3
- HumanEval_0/tests/test_humaneval.pyAdded+23
- HumanEval_1/instruction.mdAdded+17
- HumanEval_1/solution/__init__.pyAdded+1
- HumanEval_1/solution/solution.pyAdded+28
- HumanEval_1/task.tomlAdded+19
- HumanEval_1/tests/__init__.pyAdded
- HumanEval_1/tests/conftest.pyAdded+3
- HumanEval_1/tests/test_humaneval.pyAdded+25
- HumanEval_10/instruction.mdAdded+25
- HumanEval_10/solution/__init__.pyAdded+1
- HumanEval_10/solution/solution.pyAdded+28
- HumanEval_10/task.tomlAdded+19
- HumanEval_10/tests/__init__.pyAdded
- HumanEval_10/tests/conftest.pyAdded+3
- HumanEval_10/tests/test_humaneval.pyAdded+20
- HumanEval_100/instruction.mdAdded+21
- HumanEval_100/solution/__init__.pyAdded+1
- HumanEval_100/solution/solution.pyAdded+16
- HumanEval_100/task.tomlAdded+19
- HumanEval_100/tests/__init__.pyAdded
- HumanEval_100/tests/conftest.pyAdded+3
- HumanEval_100/tests/test_humaneval.pyAdded+18
- HumanEval_101/instruction.mdAdded+16
- HumanEval_101/solution/__init__.pyAdded+1
- HumanEval_101/solution/solution.pyAdded+23
- HumanEval_101/task.tomlAdded+19
- HumanEval_101/tests/__init__.pyAdded
- HumanEval_101/tests/conftest.pyAdded+3
- HumanEval_101/tests/test_humaneval.pyAdded+20
- HumanEval_102/instruction.mdAdded+16
- HumanEval_102/solution/__init__.pyAdded+1
- HumanEval_102/solution/solution.pyAdded+17
- HumanEval_102/task.tomlAdded+19
- HumanEval_102/tests/__init__.pyAdded
- HumanEval_102/tests/conftest.pyAdded+3
- HumanEval_102/tests/test_humaneval.pyAdded+20
- HumanEval_103/instruction.mdAdded+18
- HumanEval_103/solution/__init__.pyAdded+1
- HumanEval_103/solution/solution.pyAdded+18
- HumanEval_103/task.tomlAdded+19
- HumanEval_103/tests/__init__.pyAdded
- HumanEval_103/tests/conftest.pyAdded+3
- HumanEval_103/tests/test_humaneval.pyAdded+25
- HumanEval_104/instruction.mdAdded+19
1234567891011121314151617# HumanEval — HumanEval/0
Complete the following Python function so that it satisfies its docstring.
```pythonfrom typing import List
def has_close_elements(numbers: List[float], threshold: float) -> bool: """ Check if in given list of numbers, are any two numbers closer to each other than given threshold. >>> has_close_elements([1.0, 2.0, 3.0], 0.5) False >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3) True """```1from solution.solution import has_close_elements12345678910111213141516171819from typing import List
def has_close_elements(numbers: List[float], threshold: float) -> bool: """ Check if in given list of numbers, are any two numbers closer to each other than given threshold. >>> has_close_elements([1.0, 2.0, 3.0], 0.5) False >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3) True """ for idx, elem in enumerate(numbers): for idx2, elem2 in enumerate(numbers): if idx != idx2: distance = abs(elem - elem2) if distance < threshold: return True
return False12345678910111213141516171819schema_version = "1"
[task]id = "humaneval/HumanEval/0"name = "HumanEval — HumanEval/0"
[environment]os = "linux"docker_image = "python:3.11-slim"
[agent]name = "oracle"
[verifier]name = "pytest"
[[steps]]name = "main"artifacts = ["solution/solution.py"]123import sysfrom pathlib import Pathsys.path.insert(0, str(Path(__file__).parent.parent))1234567891011121314151617181920212223from solution import has_close_elements as candidate
METADATA = { 'author': 'jt', 'dataset': 'test'}
def check(candidate): assert candidate([1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.3) == True assert candidate([1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.05) == False assert candidate([1.0, 2.0, 5.9, 4.0, 5.0], 0.95) == True assert candidate([1.0, 2.0, 5.9, 4.0, 5.0], 0.8) == False assert candidate([1.0, 2.0, 3.0, 4.0, 5.0, 2.0], 0.1) == True assert candidate([1.1, 2.2, 3.1, 4.1, 5.1], 1.0) == True assert candidate([1.1, 2.2, 3.1, 4.1, 5.1], 0.5) == False
def test_check() -> None: check(candidate)1234567891011121314151617# HumanEval — HumanEval/1
Complete the following Python function so that it satisfies its docstring.
```pythonfrom typing import List
def separate_paren_groups(paren_string: str) -> List[str]: """ Input to this function is a string containing multiple groups of nested parentheses. Your goal is to separate those group into separate strings and return the list of those. Separate groups are balanced (each open brace is properly closed) and not nested within each other Ignore any spaces in the input string. >>> separate_paren_groups('( ) (( )) (( )( ))') ['()', '(())', '(()())'] """```1from solution.solution import separate_paren_groups12345678910111213141516171819202122232425262728from typing import List
def separate_paren_groups(paren_string: str) -> List[str]: """ Input to this function is a string containing multiple groups of nested parentheses. Your goal is to separate those group into separate strings and return the list of those. Separate groups are balanced (each open brace is properly closed) and not nested within each other Ignore any spaces in the input string. >>> separate_paren_groups('( ) (( )) (( )( ))') ['()', '(())', '(()())'] """ result = [] current_string = [] current_depth = 0
for c in paren_string: if c == '(': current_depth += 1 current_string.append(c) elif c == ')': current_depth -= 1 current_string.append(c)
if current_depth == 0: result.append(''.join(current_string)) current_string.clear()
return result12345678910111213141516171819schema_version = "1"
[task]id = "humaneval/HumanEval/1"name = "HumanEval — HumanEval/1"
[environment]os = "linux"docker_image = "python:3.11-slim"
[agent]name = "oracle"
[verifier]name = "pytest"
[[steps]]name = "main"artifacts = ["solution/solution.py"]123import sysfrom pathlib import Pathsys.path.insert(0, str(Path(__file__).parent.parent))12345678910111213141516171819202122232425from solution import separate_paren_groups as candidate
METADATA = { 'author': 'jt', 'dataset': 'test'}
def check(candidate): assert candidate('(()()) ((())) () ((())()())') == [ '(()())', '((()))', '()', '((())()())' ] assert candidate('() (()) ((())) (((())))') == [ '()', '(())', '((()))', '(((())))' ] assert candidate('(()(())((())))') == [ '(()(())((())))' ] assert candidate('( ) (( )) (( )( ))') == ['()', '(())', '(()())']
def test_check() -> None: check(candidate)12345678910111213141516171819202122232425# HumanEval — HumanEval/10
Complete the following Python function so that it satisfies its docstring.
```python
def is_palindrome(string: str) -> bool: """ Test if given string is a palindrome """ return string == string[::-1]
def make_palindrome(string: str) -> str: """ Find the shortest palindrome that begins with a supplied string. Algorithm idea is simple: - Find the longest postfix of supplied string that is a palindrome. - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix. >>> make_palindrome('') '' >>> make_palindrome('cat') 'catac' >>> make_palindrome('cata') 'catac' """```1from solution.solution import make_palindrome12345678910111213141516171819202122232425262728
def is_palindrome(string: str) -> bool: """ Test if given string is a palindrome """ return string == string[::-1]
def make_palindrome(string: str) -> str: """ Find the shortest palindrome that begins with a supplied string. Algorithm idea is simple: - Find the longest postfix of supplied string that is a palindrome. - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix. >>> make_palindrome('') '' >>> make_palindrome('cat') 'catac' >>> make_palindrome('cata') 'catac' """ if not string: return ''
beginning_of_suffix = 0
while not is_palindrome(string[beginning_of_suffix:]): beginning_of_suffix += 1
return string + string[:beginning_of_suffix][::-1]12345678910111213141516171819schema_version = "1"
[task]id = "humaneval/HumanEval/10"name = "HumanEval — HumanEval/10"
[environment]os = "linux"docker_image = "python:3.11-slim"
[agent]name = "oracle"
[verifier]name = "pytest"
[[steps]]name = "main"artifacts = ["solution/solution.py"]123import sysfrom pathlib import Pathsys.path.insert(0, str(Path(__file__).parent.parent))1234567891011121314151617181920from solution import make_palindrome as candidate
METADATA = { 'author': 'jt', 'dataset': 'test'}
def check(candidate): assert candidate('') == '' assert candidate('x') == 'x' assert candidate('xyz') == 'xyzyx' assert candidate('xyx') == 'xyx' assert candidate('jerry') == 'jerryrrej'
def test_check() -> None: check(candidate)123456789101112131415161718192021# HumanEval — HumanEval/100
Complete the following Python function so that it satisfies its docstring.
```python
def make_a_pile(n): """ Given a positive integer n, you have to make a pile of n levels of stones. The first level has n stones. The number of stones in the next level is: - the next odd number if n is odd. - the next even number if n is even. Return the number of stones in each level in a list, where element at index i represents the number of stones in the level (i+1).
Examples: >>> make_a_pile(3) [3, 5, 7] """```1from solution.solution import make_a_pile12345678910111213141516
def make_a_pile(n): """ Given a positive integer n, you have to make a pile of n levels of stones. The first level has n stones. The number of stones in the next level is: - the next odd number if n is odd. - the next even number if n is even. Return the number of stones in each level in a list, where element at index i represents the number of stones in the level (i+1).
Examples: >>> make_a_pile(3) [3, 5, 7] """ return [n + 2*i for i in range(n)]12345678910111213141516171819schema_version = "1"
[task]id = "humaneval/HumanEval/100"name = "HumanEval — HumanEval/100"
[environment]os = "linux"docker_image = "python:3.11-slim"
[agent]name = "oracle"
[verifier]name = "pytest"
[[steps]]name = "main"artifacts = ["solution/solution.py"]123import sysfrom pathlib import Pathsys.path.insert(0, str(Path(__file__).parent.parent))123456789101112131415161718from solution import make_a_pile as candidate
def check(candidate):
# Check some simple cases assert candidate(3) == [3, 5, 7], "Test 3" assert candidate(4) == [4,6,8,10], "Test 4" assert candidate(5) == [5, 7, 9, 11, 13] assert candidate(6) == [6, 8, 10, 12, 14, 16] assert candidate(8) == [8, 10, 12, 14, 16, 18, 20, 22]
# Check some edge cases that are easy to work out by hand. assert True, "This prints if this assert fails 2 (also good for debugging!)"
def test_check() -> None: check(candidate)12345678910111213141516# HumanEval — HumanEval/101
Complete the following Python function so that it satisfies its docstring.
```python
def words_string(s): """ You will be given a string of words separated by commas or spaces. Your task is to split the string into words and return an array of the words. For example: words_string("Hi, my name is John") == ["Hi", "my", "name", "is", "John"] words_string("One, two, three, four, five, six") == ["One", "two", "three", "four", "five", "six"] """```1from solution.solution import words_string1234567891011121314151617181920212223
def words_string(s): """ You will be given a string of words separated by commas or spaces. Your task is to split the string into words and return an array of the words. For example: words_string("Hi, my name is John") == ["Hi", "my", "name", "is", "John"] words_string("One, two, three, four, five, six") == ["One", "two", "three", "four", "five", "six"] """ if not s: return []
s_list = []
for letter in s: if letter == ',': s_list.append(' ') else: s_list.append(letter)
s_list = "".join(s_list) return s_list.split()12345678910111213141516171819schema_version = "1"
[task]id = "humaneval/HumanEval/101"name = "HumanEval — HumanEval/101"
[environment]os = "linux"docker_image = "python:3.11-slim"
[agent]name = "oracle"
[verifier]name = "pytest"
[[steps]]name = "main"artifacts = ["solution/solution.py"]123import sysfrom pathlib import Pathsys.path.insert(0, str(Path(__file__).parent.parent))1234567891011121314151617181920from solution import words_string as candidate
def check(candidate):
# Check some simple cases assert True, "This prints if this assert fails 1 (good for debugging!)" assert candidate("Hi, my name is John") == ["Hi", "my", "name", "is", "John"] assert candidate("One, two, three, four, five, six") == ["One", "two", "three", "four", "five", "six"] assert candidate("Hi, my name") == ["Hi", "my", "name"] assert candidate("One,, two, three, four, five, six,") == ["One", "two", "three", "four", "five", "six"]
# Check some edge cases that are easy to work out by hand. assert True, "This prints if this assert fails 2 (also good for debugging!)" assert candidate("") == [] assert candidate("ahmed , gamal") == ["ahmed", "gamal"]
def test_check() -> None: check(candidate)12345678910111213141516# HumanEval — HumanEval/102
Complete the following Python function so that it satisfies its docstring.
```python
def choose_num(x, y): """This function takes two positive numbers x and y and returns the biggest even integer number that is in the range [x, y] inclusive. If there's no such number, then the function should return -1.
For example: choose_num(12, 15) = 14 choose_num(13, 12) = -1 """```1from solution.solution import choose_num1234567891011121314151617
def choose_num(x, y): """This function takes two positive numbers x and y and returns the biggest even integer number that is in the range [x, y] inclusive. If there's no such number, then the function should return -1.
For example: choose_num(12, 15) = 14 choose_num(13, 12) = -1 """ if x > y: return -1 if y % 2 == 0: return y if x == y: return -1 return y - 112345678910111213141516171819schema_version = "1"
[task]id = "humaneval/HumanEval/102"name = "HumanEval — HumanEval/102"
[environment]os = "linux"docker_image = "python:3.11-slim"
[agent]name = "oracle"
[verifier]name = "pytest"
[[steps]]name = "main"artifacts = ["solution/solution.py"]123import sysfrom pathlib import Pathsys.path.insert(0, str(Path(__file__).parent.parent))1234567891011121314151617181920from solution import choose_num as candidate
def check(candidate):
# Check some simple cases assert candidate(12, 15) == 14 assert candidate(13, 12) == -1 assert candidate(33, 12354) == 12354 assert candidate(5234, 5233) == -1 assert candidate(6, 29) == 28 assert candidate(27, 10) == -1
# Check some edge cases that are easy to work out by hand. assert candidate(7, 7) == -1 assert candidate(546, 546) == 546
def test_check() -> None: check(candidate)123456789101112131415161718# HumanEval — HumanEval/103
Complete the following Python function so that it satisfies its docstring.
```python
def rounded_avg(n, m): """You are given two positive integers n and m, and your task is to compute the average of the integers from n through m (including n and m). Round the answer to the nearest integer and convert that to binary. If n is greater than m, return -1. Example: rounded_avg(1, 5) => "0b11" rounded_avg(7, 5) => -1 rounded_avg(10, 20) => "0b1111" rounded_avg(20, 33) => "0b11010" """```1from solution.solution import rounded_avg123456789101112131415161718
def rounded_avg(n, m): """You are given two positive integers n and m, and your task is to compute the average of the integers from n through m (including n and m). Round the answer to the nearest integer and convert that to binary. If n is greater than m, return -1. Example: rounded_avg(1, 5) => "0b11" rounded_avg(7, 5) => -1 rounded_avg(10, 20) => "0b1111" rounded_avg(20, 33) => "0b11010" """ if m < n: return -1 summation = 0 for i in range(n, m+1): summation += i return bin(round(summation/(m - n + 1)))12345678910111213141516171819schema_version = "1"
[task]id = "humaneval/HumanEval/103"name = "HumanEval — HumanEval/103"
[environment]os = "linux"docker_image = "python:3.11-slim"
[agent]name = "oracle"
[verifier]name = "pytest"
[[steps]]name = "main"artifacts = ["solution/solution.py"]123import sysfrom pathlib import Pathsys.path.insert(0, str(Path(__file__).parent.parent))12345678910111213141516171819202122232425from solution import rounded_avg as candidate
def check(candidate):
# Check some simple cases assert candidate(1, 5) == "0b11" assert candidate(7, 13) == "0b1010" assert candidate(964,977) == "0b1111001010" assert candidate(996,997) == "0b1111100100" assert candidate(560,851) == "0b1011000010" assert candidate(185,546) == "0b101101110" assert candidate(362,496) == "0b110101101" assert candidate(350,902) == "0b1001110010" assert candidate(197,233) == "0b11010111"
# Check some edge cases that are easy to work out by hand. assert candidate(7, 5) == -1 assert candidate(5, 1) == -1 assert candidate(5, 5) == "0b101"
def test_check() -> None: check(candidate)12345678910111213141516171819# HumanEval — HumanEval/104
Complete the following Python function so that it satisfies its docstring.
```python
def unique_digits(x): """Given a list of positive integers x. return a sorted list of all elements that hasn't any even digit.
Note: Returned list should be sorted in increasing order. For example: >>> unique_digits([15, 33, 1422, 1]) [1, 15, 33] >>> unique_digits([152, 323, 1422, 10]) [] """```HumanEval_0/instruction.mdAdded+17
HumanEval_0/solution/__init__.pyAdded+1
HumanEval_0/solution/solution.pyAdded+19
HumanEval_0/task.tomlAdded+19
HumanEval_0/tests/__init__.pyAdded
HumanEval_0/tests/conftest.pyAdded+3
HumanEval_0/tests/test_humaneval.pyAdded+23
HumanEval_1/instruction.mdAdded+17
HumanEval_1/solution/__init__.pyAdded+1
HumanEval_1/solution/solution.pyAdded+28
HumanEval_1/task.tomlAdded+19
HumanEval_1/tests/__init__.pyAdded
HumanEval_1/tests/conftest.pyAdded+3
HumanEval_1/tests/test_humaneval.pyAdded+25
HumanEval_10/instruction.mdAdded+25
HumanEval_10/solution/__init__.pyAdded+1
HumanEval_10/solution/solution.pyAdded+28
HumanEval_10/task.tomlAdded+19
HumanEval_10/tests/__init__.pyAdded
HumanEval_10/tests/conftest.pyAdded+3
HumanEval_10/tests/test_humaneval.pyAdded+20
HumanEval_100/instruction.mdAdded+21
HumanEval_100/solution/__init__.pyAdded+1
HumanEval_100/solution/solution.pyAdded+16
HumanEval_100/task.tomlAdded+19
HumanEval_100/tests/__init__.pyAdded
HumanEval_100/tests/conftest.pyAdded+3
HumanEval_100/tests/test_humaneval.pyAdded+18
HumanEval_101/instruction.mdAdded+16
HumanEval_101/solution/__init__.pyAdded+1
HumanEval_101/solution/solution.pyAdded+23
HumanEval_101/task.tomlAdded+19
HumanEval_101/tests/__init__.pyAdded
HumanEval_101/tests/conftest.pyAdded+3
HumanEval_101/tests/test_humaneval.pyAdded+20
HumanEval_102/instruction.mdAdded+16
HumanEval_102/solution/__init__.pyAdded+1
HumanEval_102/solution/solution.pyAdded+17
HumanEval_102/task.tomlAdded+19
HumanEval_102/tests/__init__.pyAdded
HumanEval_102/tests/conftest.pyAdded+3
HumanEval_102/tests/test_humaneval.pyAdded+20
HumanEval_103/instruction.mdAdded+18
HumanEval_103/solution/__init__.pyAdded+1
HumanEval_103/solution/solution.pyAdded+18
HumanEval_103/task.tomlAdded+19
HumanEval_103/tests/__init__.pyAdded
HumanEval_103/tests/conftest.pyAdded+3
HumanEval_103/tests/test_humaneval.pyAdded+25
HumanEval_104/instruction.mdAdded+19