task_id stringlengths 11 13 | prompt stringlengths 141 1.4k | entry_point stringlengths 3 31 | canonical_solution stringlengths 24 865 | test stringlengths 117 1.8k | contract stringlengths 63 844 | base_input stringlengths 16 2.08k | plus_input stringlengths 12 199k | atol float64 0 0 | original_prompt stringlengths 115 1.36k | original_entry_point stringlengths 1 30 | rename_map stringlengths 30 98 |
|---|---|---|---|---|---|---|---|---|---|---|---|
HumanEval/0 | from typing import List
def yakin_iki_sayi_var_mi(sayilar: List[float], esik_deger: float) -> bool:
""" Verilen sayi listesinde, verilen esik degerden birbirine daha yakin olan herhangi iki sayi olup olmadigini kontrol edin.
>>> yakin_iki_sayi_var_mi([1.0, 2.0, 3.0], 0.5)
False
>>> yakin_iki_sayi_var_... | yakin_iki_sayi_var_mi |
sorted_numbers = sorted(sayilar)
for i in range(len(sorted_numbers) - 1):
if sorted_numbers[i + 1] - sorted_numbers[i] < esik_deger:
return True
return False
|
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,... |
assert isinstance(esik_deger, float) and esik_deger > 0, "invalid inputs" # $_CONTRACT_$
assert isinstance(sayilar, list), "invalid inputs" # $_CONTRACT_$
assert all([isinstance(v, (int, float)) for v in sayilar]), "invalid inputs" # $_CONTRACT_$
| [[[1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.3], [[1.0, 2.0, 3.9, 4.0, 5.0, 2.2], 0.05], [[1.0, 2.0, 5.9, 4.0, 5.0], 0.95], [[1.0, 2.0, 5.9, 4.0, 5.0], 0.8], [[1.0, 2.0, 3.0, 4.0, 5.0, 2.0], 0.1], [[1.1, 2.2, 3.1, 4.1, 5.1], 1.0], [[1.1, 2.2, 3.1, 4.1, 5.1], 0.5]] | [[[1.0, 2.5, 3.0, 4.5, 5.0, 6.5], 0.4], [[1.0, 2.0, 3.0, 2.9, 5.0, 6.0], 0.1], [[0.5, 0.6, 0.7, 0.8, 0.9], 0.05], [[10.5, 20.5, 30.5, 25.5, 40.5], 4.0], [[1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7], 0.2], [[0.1, 0.5, 1.0, 1.5, 2.0], 0.1], [[1.2, 2.4, 3.6, 4.8], 0.8], [[-1.0, -0.5, 0.0, 0.5, 1.0], 0.3], [[-2.0, 2.0, 3.0, 4.0], ... | 0 | from 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, ... | has_close_elements | {"has_close_elements": "yakin_iki_sayi_var_mi", "numbers": "sayilar", "threshold": "esik_deger"} |
HumanEval/1 | from typing import List
def ayir_parantez_gruplari(parantez_metni: str) -> List[str]:
""" Input bu fonksiyona icinde birden fazla parantez grubu iceren bir dizgi verir. Amaciniz
bu gruplari ayri dizgilere ayirmak ve bu dizgilerin listesini donmektir.
Ayri gruplar dengelidir (her acilma parantezi uygun sek... | ayir_parantez_gruplari |
cnt, group, results = 0, "", []
for ch in parantez_metni:
if ch == "(": cnt += 1
if ch == ")": cnt -= 1
if ch != " ": group += ch
if cnt == 0:
if group != "": results.append(group)
group = ""
return results
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('(()()) ((())) () ((())()())') == [
'(()())', '((()))', '()', '((())()())'
]
assert candidate('() (()) ((())) (((())))') == [
'()', '(())', '((()))', '(((())))'
]
assert candidate('(()... |
assert type(parantez_metni) == str, "invalid inputs" # $_CONTRACT_$
cnt = 0 # $_CONTRACT_$
for ch in parantez_metni: # $_CONTRACT_$
assert ch in ["(", ")", " "], "invalid inputs" # $_CONTRACT_$
if ch == "(": cnt += 1 # $_CONTRACT_$
if ch == ")": cnt -= 1 # $_CONTRACT_$
asse... | [["(()()) ((())) () ((())()())"], ["() (()) ((())) (((())))"], ["(()(())((())))"], ["( ) (( )) (( )( ))"]] | [["()"], ["(())"], ["((()))()"], ["()()()"], ["()(()())()"], ["(((()()((())))))"], ["((()()))(())"], ["()(()()((())))"], ["()()()(((()())))()(())"], ["(((())))()((()()))"], ["(((())))()(((())))()((()()))((()()))"], ["((((((())))()(((())))()((()()))((()())))()))(())"], ["()(()())()(()()((())))()"], ["()(()()((()))(((()(... | 0 | from 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... | separate_paren_groups | {"separate_paren_groups": "ayir_parantez_gruplari", "paren_string": "parantez_metni"} |
HumanEval/2 | def ondalik_bolum(sayi: float) -> float:
""" Pozitif bir kayan nokta sayi verildiginde, bu sayi
tam bir bolum (verilen sayidan kucuk en buyuk tam sayi) ve ondalik kisimlarina
(her zaman 1'den kucuk kalan kisim) ayrilabilir.
Sayinin ondalik kismini dondurun.
>>> ondalik_bolum(3.5)
0.5
"""
| ondalik_bolum |
return sayi - int(sayi)
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate(3.5) == 0.5
assert abs(candidate(1.33) - 0.33) < 1e-6
assert abs(candidate(123.456) - 0.456) < 1e-6
|
assert sayi > 0, "invalid inputs" # $_CONTRACT_$
assert isinstance(sayi, float), "invalid inputs" # $_CONTRACT_$
assert sayi != float("+inf"), "invalid inputs" # $_CONTRACT_$
| [[3.5], [1.33], [123.456]] | [[999.99999], [0.3333333], [1.0], [1.5], [0.5], [0.999999], [500.00678], [11.11], [0.25], [5.99], [1.284163165748358], [1.8517611088029418], [0.7713842427275083], [3.1842364304976463], [1.0738831860229472], [0.04320870526393539], [1.1369261836552624], [1.0630407193724771], [10.291122396192739], [1.7558893686701653], [0... | 0.000001 |
def truncate_number(number: float) -> float:
""" Given a positive floating point number, it can be decomposed into
and integer part (largest integer smaller than given number) and decimals
(leftover part always smaller than 1).
Return the decimal part of the number.
>>> truncate_number(3.5)
0... | truncate_number | {"truncate_number": "ondalik_bolum", "number": "sayi"} |
HumanEval/3 | from typing import List
def sifir_altti(islemler: List[int]) -> bool:
""" Sifir bakiye ile baslayan bir banka hesabina yapilan para yatirma ve para cekme islemlerinin listesini alirsiniz. Goreviniz, herhangi bir anda hesap bakiyesinin sifir altina dusup dusmedigini tespit etmektir. Bakiye sifir altina dusuldugund... | sifir_altti |
account = 0
for operation in islemler:
account += operation
if account < 0:
return True
return False
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([]) == False
assert candidate([1, 2, -3, 1, 2, -3]) == False
assert candidate([1, 2, -4, 5, 6]) == True
assert candidate([1, -1, 2, -2, 5, -5, 4, -4]) == False
assert candidate([1, -1, 2, -2, 5, -5, 4... |
assert type(islemler) == list, "invalid inputs" # $_CONTRACT_$
assert all([isinstance(v, int) for v in islemler]), "invalid inputs" # $_CONTRACT_$
| [[[]], [[1, 2, -3, 1, 2, -3]], [[1, 2, -4, 5, 6]], [[1, -1, 2, -2, 5, -5, 4, -4]], [[1, -1, 2, -2, 5, -5, 4, -5]], [[1, -2, 2, -2, 5, -5, 4, -4]]] | [[[0]], [[0, 0, 0, 0]], [[1, 2, 3, -6]], [[-1, -2, -3, 6]], [[1, 2, 3, 4, -10, 5, 6, -15]], [[10, -20, 30, -40, 50, -60]], [[5, -10, 15, -20, 25, -30, 35, -40, 45, -50]], [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1]], [[10, -15, 20, -25, 30, -35, 40, -45]], [[1, -2, 3, -4, 5, -6, 7, -8, 9, -10]], [[15, 2, 3, -6]], [[-1, -3, 6]... | 0 | from typing import List
def below_zero(operations: List[int]) -> bool:
""" You're given a list of deposit and withdrawal operations on a bank account that starts with
zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
at that point function should return Tru... | below_zero | {"below_zero": "sifir_altti", "operations": "islemler"} |
HumanEval/4 | from typing import List
def ortalama_mutlak_sapma(sayilar: List[float]) -> float:
""" Verilen bir girdi sayilari listesi icin, bu veri setinin ortalamasi etrafinda Ortalama Mutlak Sapma'yi hesaplayin.
Ortalama Mutlak Sapma, her bir eleman ile bir merkez nokta (bu durumda ortalama) arasindaki ortalama mutlak f... | ortalama_mutlak_sapma |
mean = sum(sayilar) / len(sayilar)
return sum(abs(x - mean) for x in sayilar) / len(sayilar)
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert abs(candidate([1.0, 2.0, 3.0]) - 2.0/3.0) < 1e-6
assert abs(candidate([1.0, 2.0, 3.0, 4.0]) - 1.0) < 1e-6
assert abs(candidate([1.0, 2.0, 3.0, 4.0, 5.0]) - 6.0/5.0) < 1e-6
|
assert all(isinstance(x, float) for x in sayilar), "invalid inputs" # $_CONTRACT_$
assert sayilar != [], "invalid inputs" # $_CONTRACT_$
| [[[1.0, 2.0, 3.0]], [[1.0, 2.0, 3.0, 4.0]], [[1.0, 2.0, 3.0, 4.0, 5.0]]] | [[[-1.0, 4.5, 0.0, 2.5, -3.0]], [[0.0, 0.0, 0.0, 0.0, 0.0]], [[-2.0, 2.0]], [[-1.0, -1.0, 1.0, 1.0]], [[1.0, 1.0, 1.0, 2.0, 2.0, 2.0]], [[-2.0, -1.0, 0.0, 1.0, 2.0]], [[0.5, 1.5, 2.5]], [[-5.5, 7.5, -5.5, 7.5]], [[-1.0, -2.0, -3.0, 4.0, 5.0]], [[10.0, 10.0, 10.0]], [[10.0, 10.0, 10.0, 10.0, 9.232092283615625]], [[-1.0,... | 0.000001 | from typing import List
def mean_absolute_deviation(numbers: List[float]) -> float:
""" For a given list of input numbers, calculate Mean Absolute Deviation
around the mean of this dataset.
Mean Absolute Deviation is the average absolute difference between each
element and a centerpoint (mean in this ... | mean_absolute_deviation | {"mean_absolute_deviation": "ortalama_mutlak_sapma", "numbers": "sayilar"} |
HumanEval/5 | from typing import List
def aralarina_ekle(sayilar: List[int], ayirac: int) -> List[int]:
""" 'ayirac' sayisini `sayilar` girdi listesindeki her iki ardisik elemanin arasina yerlestirir
>>> aralarina_ekle([], 4)
[]
>>> aralarina_ekle([1, 2, 3], 4)
[1, 4, 2, 4, 3]
"""
| aralarina_ekle |
res = []
for i in range(len(sayilar)):
res.append(sayilar[i])
if i != len(sayilar) - 1:
res.append(ayirac)
return res
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([], 7) == []
assert candidate([5, 6, 3, 2], 8) == [5, 8, 6, 8, 3, 8, 2]
assert candidate([2, 2, 2], 2) == [2, 2, 2, 2, 2]
|
assert all([isinstance(v, int) for v in sayilar]), "invalid inputs" # $_CONTRACT_$
assert isinstance(ayirac, int), "invalid inputs" # $_CONTRACT_$
| [[[], 7], [[5, 6, 3, 2], 8], [[2, 2, 2], 2]] | [[[1, 2, 3], 0], [[2, 4, 6, 8], 1], [[9, 9, 9, 9, 9, 9], 7], [[10], 5], [[5, 7], 2], [[1, 3, 5, 7], 4], [[2, 3], 1], [[5, 10, 15], 0], [[0, 0, 0], 7], [[1, 9, 5, 6], 3], [[2, 3], 0], [[0, 0, 0], 8], [[1, 2, 3, 2], 0], [[7], 2], [[3], 1], [[5, 7], 3], [[5, 7], 5], [[], 2], [[9, 9, 9, 9, 9, 9, 9], 7], [[5, 7], 15], [[3],... | 0 | from typing import List
def intersperse(numbers: List[int], delimeter: int) -> List[int]:
""" Insert a number 'delimeter' between every two consecutive elements of input list `numbers'
>>> intersperse([], 4)
[]
>>> intersperse([1, 2, 3], 4)
[1, 4, 2, 4, 3]
"""
| intersperse | {"intersperse": "aralarina_ekle", "numbers": "sayilar", "delimeter": "ayirac"} |
HumanEval/6 | from typing import List
def parantez_derinliklerini_bul(parantez_dizisi: str) -> List[int]:
""" Bu isleve girdi, bosluklarla ayrilmis birden fazla iceri ayrilmis parantez grubunu temsil eden bir dizidir.
Her bir grup icin, parantezlerin en derin yaslama seviyesini cikar.
Ornek. (()()) en fazla iki seviyey... | parantez_derinliklerini_bul |
def count_depth(s: str) -> int:
max_depth, cnt = 0, 0
for ch in s:
if ch == "(": cnt += 1
if ch == ")": cnt -= 1
max_depth = max(max_depth, cnt)
return max_depth
return [count_depth(s) for s in parantez_dizisi.split(" ") if s != ""]
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('(()()) ((())) () ((())()())') == [2, 3, 1, 3]
assert candidate('() (()) ((())) (((())))') == [1, 2, 3, 4]
assert candidate('(()(())((())))') == [4]
|
assert type(parantez_dizisi) == str, "invalid inputs" # $_CONTRACT_$
cnt = 0 # $_CONTRACT_$
for ch in parantez_dizisi: # $_CONTRACT_$
assert ch in ["(", ")", " "], "invalid inputs" # $_CONTRACT_$
if ch == "(": cnt += 1 # $_CONTRACT_$
if ch == ")": cnt -= 1 # $_CONTRACT_$
as... | [["(()()) ((())) () ((())()())"], ["() (()) ((())) (((())))"], ["(()(())((())))"]] | [[""], ["((()))"], ["(())(()())"], ["(())(()(()))((()()))"], ["(()()(((())))(()(())))()"], ["()((()))"], ["(())"], ["()()()"], ["()(())"], ["(((())(()(()))((()()))))(()(()))((()()))"], ["(()()(()(())((()()(((())))(()(())))())(((()))))(()(())))()"], ["((()(())(()(()))((()()))))"], ["(()()(((())))(()(())(((())(()(()))(((... | 0 | from typing import List
def parse_nested_parens(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum two levels of n... | parse_nested_parens | {"parse_nested_parens": "parantez_derinliklerini_bul", "paren_string": "parantez_dizisi"} |
HumanEval/7 | from typing import List
def alt_dizeye_gore_filtrele(dizeler: List[str], alt_dize: str) -> List[str]:
""" Verilen bir alt dizeyi iceren dizelerin listesini filtrele
>>> alt_dizeye_gore_filtrele([], 'a')
[]
>>> alt_dizeye_gore_filtrele(['abc', 'bacd', 'cde', 'array'], 'a')
['abc', 'bacd', 'array']
... | alt_dizeye_gore_filtrele |
return list(filter(lambda s: alt_dize in s, dizeler))
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([], 'john') == []
assert candidate(['xxx', 'asd', 'xxy', 'john doe', 'xxxAAA', 'xxx'], 'xxx') == ['xxx', 'xxxAAA', 'xxx']
assert candidate(['xxx', 'asd', 'aaaxxy', 'john doe', 'xxxAAA', 'xxx'], 'xx') == ['xxx... |
assert type(dizeler) == list, "invalid inputs" # $_CONTRACT_$
assert all(type(x) == str for x in dizeler), "invalid inputs" # $_CONTRACT_$
assert isinstance(alt_dize, str), "invalid inputs" # $_CONTRACT_$
| [[[], "john"], [["xxx", "asd", "xxy", "john doe", "xxxAAA", "xxx"], "xxx"], [["xxx", "asd", "aaaxxy", "john doe", "xxxAAA", "xxx"], "xx"], [["grunt", "trumpet", "prune", "gruesome"], "run"]] | [[["banana", "apple", "kiwi", "peach"], "a"], [["hello", "world", "python", "numpy", "pandas"], "py"], [[], ""], [["abc", "bcd", "cbd", "dbc", "cda"], "bc"], [["a", "ab", "abc", "abcd", "abcde", "bcde", "cde"], "cd"], [["123", "456", "789", "101112"], "12"], [["cat", "dog", "elephant", "rhinoceros", "seagull"], "e"], [... | 0 | from typing import List
def filter_by_substring(strings: List[str], substring: str) -> List[str]:
""" Filter an input list of strings only for ones that contain given substring
>>> filter_by_substring([], 'a')
[]
>>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')
['abc', 'bacd', 'array'... | filter_by_substring | {"filter_by_substring": "alt_dizeye_gore_filtrele", "strings": "dizeler", "substring": "alt_dize"} |
HumanEval/8 | from typing import List, Tuple
def toplam_carpim(sayilar: List[int]) -> Tuple[int, int]:
""" Verilen bir tam sayi listesi icin, listedeki tum tam sayilarin toplamini ve carpimini iceren bir demet dondurun.
Bos toplam 0'a, bos carpim ise 1'e esit olmalidir.
>>> toplam_carpim([])
(0, 1)
>>> toplam_c... | toplam_carpim |
s, p = 0, 1
for number in sayilar:
s += number
p *= number
return s, p
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([]) == (0, 1)
assert candidate([1, 1, 1]) == (3, 1)
assert candidate([100, 0]) == (100, 0)
assert candidate([3, 5, 7]) == (3 + 5 + 7, 3 * 5 * 7)
assert candidate([10]) == (10, 10)
|
assert all([isinstance(v, int) for v in sayilar]), "invalid inputs" # $_CONTRACT_$
| [[[]], [[1, 1, 1]], [[100, 0]], [[3, 5, 7]], [[10]]] | [[[2, 4, 6, 8, 10]], [[0, 1, 2, 3, 4, 5]], [[-1, 1, -2, 2, -3, 3]], [[2, 3, 5, 7, 11, 13]], [[1, 2, 4, 8, 16, 32]], [[1, 2, 3, 4, 5]], [[0, 0, 0, 0]], [[2, 4, 8, 16]], [[-1, -2, -3]], [[10, 20, 30, 40, 50]], [[-1, -3]], [[-1, 1, 0, 2, -3, 3]], [[2, 4, 8, 16, 16, 4]], [[0, 1, 2, 3, 4, 5, 0]], [[0, 0, 0, 0, -1]], [[2, 3,... | 0 | from typing import List, Tuple
def sum_product(numbers: List[int]) -> Tuple[int, int]:
""" For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.
Empty sum should be equal to 0 and empty product should be equal to 1.
>>> sum_product([])
(0, 1)
... | sum_product | {"sum_product": "toplam_carpim", "numbers": "sayilar"} |
HumanEval/9 | from typing import List, Tuple
def akiskan_maks(sayilar: List[int]) -> List[int]:
""" Verilen bir tamsayi listesinden, dizide o ana kadar bulunan akiskan maksimum elemanlarin listesini olusturun.
>>> akiskan_maks([1, 2, 3, 2, 3, 4, 2])
[1, 2, 3, 3, 3, 4, 4]
"""
| akiskan_maks |
return [max(sayilar[:(i+1)]) for i in range(len(sayilar))]
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([]) == []
assert candidate([1, 2, 3, 4]) == [1, 2, 3, 4]
assert candidate([4, 3, 2, 1]) == [4, 4, 4, 4]
assert candidate([3, 2, 3, 100, 3]) == [3, 3, 3, 100, 100]
|
assert isinstance(sayilar, list), "invalid inputs" # $_CONTRACT_$
assert all([isinstance(v, int) for v in sayilar]), "invalid inputs" # $_CONTRACT_$
| [[[]], [[1, 2, 3, 4]], [[4, 3, 2, 1]], [[3, 2, 3, 100, 3]]] | [[[1, 1, 1, 1, 1]], [[5, 4, 3, 2, 1]], [[1, 3, 2, 4, 3, 5, 4, 6]], [[10, 5, 20, 30, 25, 20, 15, 10]], [[7, 2, 4, 1, 8, 6, 9]], [[10, 20, 30, 40, 50]], [[50, 40, 30, 20, 10]], [[1, 2, 3, 4, 5, 4, 3, 2, 1]], [[1, 2, 3, 2, 1, 2, 3, 2, 1]], [[-1, -2, -3, -4, -5, -4, -3, -2, -1]], [[1, 2, 3, 2, 1, 3, 3, 2, 3]], [[0, -2, -3,... | 0 | from typing import List, Tuple
def rolling_max(numbers: List[int]) -> List[int]:
""" From a given list of integers, generate a list of rolling maximum element found until given moment
in the sequence.
>>> rolling_max([1, 2, 3, 2, 3, 4, 2])
[1, 2, 3, 3, 3, 4, 4]
"""
| rolling_max | {"rolling_max": "akiskan_maks", "numbers": "sayilar"} |
HumanEval/10 | def palindrom_mu(metin: str) -> bool:
""" Verilen metnin bir palindrom olup olmadigini test eder """
return metin == metin[::-1]
def palindrom_olustur(metin: str) -> str:
""" Verilen metinle baslayan en kisa palindromu bulun.
Algoritma yaklasimi basit:
- Verilen metnin palindrom olan en uzun son e... | palindrom_olustur |
if palindrom_mu(metin):
return metin
for i in range(len(metin)):
if palindrom_mu(metin[i:]):
return metin + metin[i-1::-1]
|
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'
|
assert type(metin) == str, "invalid inputs" # $_CONTRACT_$
| [[""], ["x"], ["xyz"], ["xyx"], ["jerry"]] | [["race"], ["level"], ["tenet"], ["noon"], ["redder"], ["refer"], ["dewed"], ["madam"], ["malayalam"], ["radar"], ["r"], ["rrefrerace"], ["erace"], ["raracece"], ["rrrefrear"], ["raceredder"], ["araracecae"], ["rradar"], ["racrrefreraceereddrce"], ["levevl"], ["lracrrefreraceereddrceevel"], ["rrefreracrefere"], ["rarda... | 0 |
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... | make_palindrome | {"is_palindrome": "palindrom_mu", "make_palindrome": "palindrom_olustur", "string": "metin"} |
HumanEval/11 | from typing import List
def iki_string_xor(dize_a: str, dize_b: str) -> str:
""" Girdi, yalnizca 1'ler ve 0'lar iceren dize_a ve dize_b adli iki dizedir.
Bu girdiler uzerinde ikili XOR islemi yapin ve sonucu yine bir dize olarak geri ver.
>>> iki_string_xor('010', '110')
'100'
"""
| iki_string_xor |
return "".join(str(int(dize_a[i]) ^ int(dize_b[i])) for i in range(len(dize_a)))
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('111000', '101010') == '010010'
assert candidate('1', '1') == '0'
assert candidate('0101', '0000') == '0101'
|
assert isinstance(dize_a, str) and isinstance(dize_b, str), "invalid inputs" # $_CONTRACT_$
assert len(dize_a) == len(dize_b), "invalid inputs" # $_CONTRACT_$
assert set(dize_a).issubset({"0", "1"}) and set(dize_b).issubset({"0", "1"}), "invalid inputs" # $_CONTRACT_$
| [["111000", "101010"], ["1", "1"], ["0101", "0000"]] | [["000", "000"], ["1111", "1111"], ["10101", "01010"], ["01010101", "11001100"], ["101010", "010101"], ["010", "001"], ["01100", "10011"], ["00000001", "11111110"], ["111", "000"], ["1", "0"], ["01100000", "01100000"], ["01010101", "01010101"], ["01010", "01010"], ["0101100000100000", "0110000010101010"], ["01100", "01... | 0 | from typing import List
def string_xor(a: str, b: str) -> str:
""" Input are two strings a and b consisting only of 1s and 0s.
Perform binary XOR on these inputs and return result also as a string.
>>> string_xor('010', '110')
'100'
"""
| string_xor | {"string_xor": "iki_string_xor", "a": "dize_a", "b": "dize_b"} |
HumanEval/12 | from typing import List, Optional
def en_uzun(metinler: List[str]) -> Optional[str]:
""" Metinler listesinden en uzun olanini dondur. Ayni uzunlukta birden fazla metin varsa ilkini dondur.
Giris listesi bos ise None dondur.
>>> en_uzun([])
>>> en_uzun(['a', 'b', 'c'])
'a'
>>> en_uzun(['a', 'b... | en_uzun |
if not metinler:
return None
maxlen = max(len(x) for x in metinler)
for s in metinler:
if len(s) == maxlen:
return s
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([]) == None
assert candidate(['x', 'y', 'z']) == 'x'
assert candidate(['x', 'yyy', 'zzzz', 'www', 'kkkk', 'abc']) == 'zzzz'
|
assert type(metinler) == list, "invalid inputs" # $_CONTRACT_$
assert all([isinstance(v, str) for v in metinler]), "invalid inputs" # $_CONTRACT_$
| [[[]], [["x", "y", "z"]], [["x", "yyy", "zzzz", "www", "kkkk", "abc"]]] | [[["", "a", "aa", "aaa"]], [["123456789", "1234", "12345", "123"]], [["a", "b", "aa", "bb"]], [["dog", "cat", "horse", "cow"]], [["apple", "banana", "pear"]], [["123", "12", "1234", "1", "12345"]], [["aa", "bb", "cc", "aaa", "bb", "cccc"]], [["aaa", "aa", "a", "aaaa"]], [["a"]], [["aa", "z", "p", "q"]], [["aa", "bb", "... | 0 | from typing import List, Optional
def longest(strings: List[str]) -> Optional[str]:
""" Out of list of strings, return the longest one. Return the first one in case of multiple
strings of the same length. Return None in case the input list is empty.
>>> longest([])
>>> longest(['a', 'b', 'c'])
'a... | longest | {"longest": "en_uzun", "strings": "metinler"} |
HumanEval/13 | def en_buyuk_ortak_bolen(a: int, b: int) -> int:
""" a ve b tamsayilarinin en buyuk ortak bolenini dondurur
>>> en_buyuk_ortak_bolen(3, 5)
1
>>> en_buyuk_ortak_bolen(25, 15)
5
"""
| en_buyuk_ortak_bolen |
def query_gcd(a: int, b: int) -> int:
return a if b == 0 else query_gcd(b, a % b)
return query_gcd(a, b)
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate(3, 7) == 1
assert candidate(10, 15) == 5
assert candidate(49, 14) == 7
assert candidate(144, 60) == 12
|
assert type(a) == int and type(b) == int, "invalid inputs" # $_CONTRACT_$
assert a > 0 and b > 0, "invalid inputs" # $_CONTRACT_$
| [[3, 7], [10, 15], [49, 14], [144, 60]] | [[100, 50], [98, 56], [540, 288], [81, 27], [33, 55], [7, 13], [14, 28], [10, 25], [12, 54], [21, 35], [100, 27], [98, 10], [49, 81], [33, 56], [55, 57], [13, 14], [540, 540], [81, 80], [34, 33], [287, 13], [80, 15], [49, 28], [14, 14], [54, 33], [57, 57], [10, 10], [13, 33], [14, 540], [49, 12], [56, 56], [33, 54], [1... | 0 |
def greatest_common_divisor(a: int, b: int) -> int:
""" Return a greatest common divisor of two integers a and b
>>> greatest_common_divisor(3, 5)
1
>>> greatest_common_divisor(25, 15)
5
"""
| greatest_common_divisor | {"greatest_common_divisor": "en_buyuk_ortak_bolen", "a": "a", "b": "b"} |
HumanEval/14 | from typing import List
def tum_on_ekler(metin: str) -> List[str]:
""" Girdi metninin en kisa en uzun siraya tum on eklerinin listesini dondurur
>>> tum_on_ekler('abc')
['a', 'ab', 'abc']
"""
| tum_on_ekler |
return [metin[:(i + 1)] for i in range(len(metin))]
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('') == []
assert candidate('asdfgh') == ['a', 'as', 'asd', 'asdf', 'asdfg', 'asdfgh']
assert candidate('WWW') == ['W', 'WW', 'WWW']
|
assert isinstance(metin, str), "invalid inputs" # $_CONTRACT_$
| [[""], ["asdfgh"], ["WWW"]] | [["Hello there!"], ["abracadabra"], ["12345"], [" "], ["racecar"], ["bananas"], ["abcdefg"], ["1234567890"], ["1234"], ["python"], ["1234567890 "], ["Hello therre!"], ["racecHello therre!ar"], ["Hellho the1234567890 re!"], ["Hello ther re!"], ["12345612347890"], ["uKB"], ["pythoHellho the1234567... | 0 | from typing import List
def all_prefixes(string: str) -> List[str]:
""" Return list of all prefixes from shortest to longest of the input string
>>> all_prefixes('abc')
['a', 'ab', 'abc']
"""
| all_prefixes | {"all_prefixes": "tum_on_ekler", "string": "metin"} |
HumanEval/15 | def metin_siralama(limit: int) -> str:
""" 0'dan limit'e kadar olan, boslukla ayriilmis sayilardan olusan bir dize dondurur.
>>> metin_siralama(0)
'0'
>>> metin_siralama(5)
'0 1 2 3 4 5'
"""
| metin_siralama |
return " ".join(map(str, range(limit + 1)))
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate(0) == '0'
assert candidate(3) == '0 1 2 3'
assert candidate(10) == '0 1 2 3 4 5 6 7 8 9 10'
|
assert type(limit) == int, "invalid inputs" # $_CONTRACT_$
assert limit >= 0, "invalid inputs" # $_CONTRACT_$
| [[0], [3], [10]] | [[1], [100], [500], [2], [99], [1000], [10000], [15], [20], [50000], [49999], [101], [50001], [102], [49998], [1001], [18], [37], [36], [501], [84], [16], [10001], [65], [19], [66], [499], [83], [21], [98], [97], [17], [82], [22], [999], [67], [998], [50002], [9999], [75], [38], [498], [502], [96], [23], [50003], [9998... | 0 |
def string_sequence(n: int) -> str:
""" Return a string containing space-delimited numbers starting from 0 upto n inclusive.
>>> string_sequence(0)
'0'
>>> string_sequence(5)
'0 1 2 3 4 5'
"""
| string_sequence | {"string_sequence": "metin_siralama", "n": "limit"} |
HumanEval/16 | def farkli_karakter_sayisi(metin: str) -> int:
""" Verilen bir metnin, buyuk/kucuk harf duyarsizligiyla kac farkli karakterden olustugunu bulun
>>> farkli_karakter_sayisi('xyzXYZ')
3
>>> farkli_karakter_sayisi('Jerry')
4
"""
| farkli_karakter_sayisi |
return len(set(metin.lower()))
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('') == 0
assert candidate('abcde') == 5
assert candidate('abcde' + 'cade' + 'CADE') == 5
assert candidate('aaaaAAAAaaaa') == 1
assert candidate('Jerry jERRY JeRRRY') == 5
|
assert isinstance(metin, str), "invalid inputs" # $_CONTRACT_$
| [[""], ["abcde"], ["abcdecadeCADE"], ["aaaaAAAAaaaa"], ["Jerry jERRY JeRRRY"]] | [["AbCdEfG"], ["banana"], ["1234567890"], ["hello123"], ["The quick brown fox jumps over the lazy dog"], ["THISISALONGSTRINGWITHNOSPACES"], ["aaaabbbbccccddddeeeeffffgggghhhhiiii"], ["AaBbCcDdEeFfGgHhIi"], ["hello world"], ["1,2,3... go!"], ["The quick brown fox jumps over the lazy doAbCdEfGg"], ["hellold"], ["1,2,3...... | 0 |
def count_distinct_characters(string: str) -> int:
""" Given a string, find out how many distinct characters (regardless of case) does it consist of
>>> count_distinct_characters('xyzXYZ')
3
>>> count_distinct_characters('Jerry')
4
"""
| count_distinct_characters | {"count_distinct_characters": "farkli_karakter_sayisi", "string": "metin"} |
HumanEval/17 | from typing import List
def notlari_parse(not_dizisi: str) -> List[int]:
""" Bu fonksiyona girdi, ozel bir ASCII formatinda muzik notlarini temsil eden bir dizidir.
Goreviniz, bu diziyi ayristirip her notun kac beat surdugunu gosteren bir tamsayi listesi dondurmektir.
Is here bir kildavuz:
'o' - tam ... | notlari_parse |
def count_beats(note: str) -> int:
if note == "o": return 4
elif note == "o|": return 2
elif note == ".|": return 1
if not_dizisi == "": return []
return list(map(count_beats, not_dizisi.split(" ")))
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('') == []
assert candidate('o o o o') == [4, 4, 4, 4]
assert candidate('.| .| .| .|') == [1, 1, 1, 1]
assert candidate('o| o| .| .| o o o o') == [2, 2, 1, 1, 4, 4, 4, 4]
assert candidate('o| .| o| .| ... |
assert isinstance(not_dizisi, str), "invalid inputs" # $_CONTRACT_$
assert not_dizisi == "" or all(map(lambda x: x in ["o", "o|", ".|"], not_dizisi.split(" "))), "invalid inputs" # $_CONTRACT_$
| [[""], ["o o o o"], [".| .| .| .|"], ["o| o| .| .| o o o o"], ["o| .| o| .| o o| o o|"]] | [["o o| o| o|"], [".| .| o| o| .|"], ["o| o| o| .| o| .|"], [".| .| o| o| o| o| .| .| o| o| o| o| o| o| o o o o"], [".| .| o| o| .| .| o| o|"], ["o| .| .| .| o| o|"], ["o| o| o| o| .| .| .| .|"], [".| o| .| o| o| .| o| .|"], ["o o| o| o| o| o| o| o|"], [".| .| o| o| o| o| o| .| o| o| o| o| o| o o o o o o o| o|"], [".| ... | 0 | from typing import List
def parse_music(music_string: str) -> List[int]:
""" Input to this function is a string representing musical notes in a special ASCII format.
Your task is to parse this string and return list of integers corresponding to how many beats does each
not last.
Here is a legend:
... | parse_music | {"parse_music": "notlari_parse", "music_string": "not_dizisi"} |
HumanEval/18 | def kac_kere(metin: str, alt_metin: str) -> int:
""" Verilen bir alt metnin orijinal metinde kac kere bulundugunu bulun. Cakisan durumu sayin.
>>> kac_kere('', 'a')
0
>>> kac_kere('aaa', 'a')
3
>>> kac_kere('aaaa', 'aa')
3
"""
| kac_kere |
occurences = 0
for i in range(len(metin)):
if metin[i:].startswith(alt_metin):
occurences += 1
return occurences
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('', 'x') == 0
assert candidate('xyxyxyx', 'x') == 4
assert candidate('cacacacac', 'cac') == 4
assert candidate('john doe', 'john') == 1
|
assert isinstance(metin, str) and isinstance(alt_metin, str), "invalid inputs" # $_CONTRACT_$
assert alt_metin != "", "invalid inputs" # $_CONTRACT_$
| [["", "x"], ["xyxyxyx", "x"], ["cacacacac", "cac"], ["john doe", "john"]] | [["ababa", "aba"], ["abcdefg", "efg"], ["abababab", "aba"], ["hello world", "o"], ["aaaabbbbcccc", "bb"], ["12211221122", "122"], ["racecar", "car"], ["mississippi", "ss"], ["thequickbrownfox", "fox"], ["fizzbuzz", "zz"], ["aaaabbbbccccc", "bb"], ["bbb", "bb"], ["zz", "bbb"], ["122", "zz"], ["bb", "bb"], ["misracecarsi... | 0 |
def how_many_times(string: str, substring: str) -> int:
""" Find how many times a given substring can be found in the original string. Count overlaping cases.
>>> how_many_times('', 'a')
0
>>> how_many_times('aaa', 'a')
3
>>> how_many_times('aaaa', 'aa')
3
"""
| how_many_times | {"how_many_times": "kac_kere", "string": "metin", "substring": "alt_metin"} |
HumanEval/19 | from typing import List
def sayilari_sirala(sayilar: str) -> str:
""" Girdi, 'zero' ile 'nine' arasindaki sayilardan olusan boslukla ayirilmis bir dizgidir.
Gecerli degerler 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' ve 'nine'.
Sayilari kucukten buyuge siralanmis sekilde dondur... | sayilari_sirala |
to_int = {'zero': 0, 'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9}
if sayilar == "": return ""
return " ".join(sorted(sayilar.split(" "), key=lambda n: to_int[n]))
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('') == ''
assert candidate('three') == 'three'
assert candidate('three five nine') == 'three five nine'
assert candidate('five zero four seven nine eight') == 'zero four five seven eight nine'
assert ... |
assert isinstance(sayilar, str), "invalid inputs" # $_CONTRACT_$
assert sayilar == "" or all(map(lambda x: x in ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"], sayilar.split(" "))), "invalid inputs" # $_CONTRACT_$
| [[""], ["three"], ["three five nine"], ["five zero four seven nine eight"], ["six five four three two one zero"]] | [["four eight two"], ["nine"], ["one six two four nine"], ["two seven eight zero five"], ["nine zero"], ["seven three one"], ["two two three three four five six"], ["zero five four one seven eight two six"], ["nine eight seven six five four three two one zero"], ["two zero nine four five six"], ["nine eight seven six f... | 0 | from typing import List
def sort_numbers(numbers: str) -> str:
""" Input is a space-delimited string of numberals from 'zero' to 'nine'.
Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
Return the string with numbers sorted from smallest to largest
>... | sort_numbers | {"sort_numbers": "sayilari_sirala", "numbers": "sayilar"} |
HumanEval/20 | from typing import List, Tuple
def en_yakin_iki_sayiyi_bul(sayilar: List[float]) -> Tuple[float, float]:
""" En az iki elemani olan bir sayi listesinde birbirine en yakin olan ikisini secin ve sirali olarak (kucuk sayi, buyuk sayi) geri donun.
>>> en_yakin_iki_sayiyi_bul([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])
(2... | en_yakin_iki_sayiyi_bul |
sayilar.sort()
min_diff = float("inf")
min_pair = None
for l, r in zip(sayilar[:-1], sayilar[1:]):
diff = r - l
if diff < min_diff:
min_diff = diff
min_pair = (l, r)
return min_pair
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([1.0, 2.0, 3.9, 4.0, 5.0, 2.2]) == (3.9, 4.0)
assert candidate([1.0, 2.0, 5.9, 4.0, 5.0]) == (5.0, 5.9)
assert candidate([1.0, 2.0, 3.0, 4.0, 5.0, 2.2]) == (2.0, 2.2)
assert candidate([1.0, 2.0, 3.0, 4.0,... |
assert all(type(x) in [int, float] for x in sayilar), "invalid inputs" # $_CONTRACT_$
assert len(sayilar) >= 2, "invalid inputs" # $_CONTRACT_$
| [[[1.0, 2.0, 3.9, 4.0, 5.0, 2.2]], [[1.0, 2.0, 5.9, 4.0, 5.0]], [[1.0, 2.0, 3.0, 4.0, 5.0, 2.2]], [[1.0, 2.0, 3.0, 4.0, 5.0, 2.0]], [[1.1, 2.2, 3.1, 4.1, 5.1]]] | [[[1.5, 2.5, 3.5, 4.5]], [[0.5, 1.0, 2.0, 3.0, 4.0, 5.0]], [[1.0, 1.2, 1.4, 1.6, 1.8]], [[3.4, 5.6, 8.1, 14.5, 21.7]], [[0.5, 0.9, 1.2, 1.8, 2.5, 2.9, 3.1]], [[2.0, 2.1, 2.2, 2.3, 2.4, 2.5]], [[1.1, 1.2, 1.3, 1.4, 10.0]], [[1.1, 2.2, 3.3, 5.1, 7.8, 9.9]], [[1.0, 3.0, 5.0, 7.0, 9.0]], [[1.5, 2.5, 3.5, 4.5, 5.5]], [[1.1,... | 0 | from typing import List, Tuple
def find_closest_elements(numbers: List[float]) -> Tuple[float, float]:
""" From a supplied list of numbers (of length at least two) select and return two that are the closest to each
other and return them in order (smaller number, larger number).
>>> find_closest_elements([... | find_closest_elements | {"find_closest_elements": "en_yakin_iki_sayiyi_bul", "numbers": "sayilar"} |
HumanEval/21 | from typing import List
def birim_araligina_cek(sayilar: List[float]) -> List[float]:
""" En az iki elemanli bir sayi listesi verildiginde, listeye lineer bir donusum uygulanir,
en kucuk elemanin 0 ve en buyuk elemanin 1 oldugu sekilde
>>> birim_araligina_cek([1.0, 2.0, 3.0, 4.0, 5.0])
[0.0, 0.25, 0.5... | birim_araligina_cek |
ma, mi = max(sayilar), min(sayilar)
k = 1 / (ma - mi)
return list(map(lambda x: (x - mi) * k, sayilar))
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([2.0, 49.9]) == [0.0, 1.0]
assert candidate([100.0, 49.9]) == [1.0, 0.0]
assert candidate([1.0, 2.0, 3.0, 4.0, 5.0]) == [0.0, 0.25, 0.5, 0.75, 1.0]
assert candidate([2.0, 1.0, 5.0, 3.0, 4.0]) == [0.25, 0.... |
assert all(type(x) in [int, float] for x in sayilar), "invalid inputs" # $_CONTRACT_$
assert len(sayilar) >= 2, "invalid inputs" # $_CONTRACT_$
assert max(sayilar) > min(sayilar), "invalid inputs" # $_CONTRACT_$
| [[[2.0, 49.9]], [[100.0, 49.9]], [[1.0, 2.0, 3.0, 4.0, 5.0]], [[2.0, 1.0, 5.0, 3.0, 4.0]], [[12.0, 11.0, 15.0, 13.0, 14.0]]] | [[[-10.0, 0.0, 10.0]], [[5.0, 2.0, 2.0, 5.0]], [[1.5, 2.0, 2.5, 3.0, 3.5]], [[10.0, 5.0, 2.5, 0.0, -2.5, -5.0, -10.0]], [[1.0, -1.0, 1.0, -1.0, 1.0]], [[0.1, 0.5, 0.9, 0.3, 0.7]], [[5.0, 10.0, 15.0, 20.0, 25.0]], [[-100.0, -50.0, 0.0, 50.0, 100.0]], [[1.0, 2.0, 3.0, 4.0]], [[7.0, 3.0, 8.0, 2.0]], [[1.5, 2.0, 2.5, 3.0, ... | 0 | from typing import List
def rescale_to_unit(numbers: List[float]) -> List[float]:
""" Given list of numbers (of at least two elements), apply a linear transform to that list,
such that the smallest number will become 0 and the largest will become 1
>>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])
[0.0, ... | rescale_to_unit | {"rescale_to_unit": "birim_araligina_cek", "numbers": "sayilar"} |
HumanEval/22 | from typing import List, Any
def tamsayilari_filtrele(degerler: List[Any]) -> List[int]:
""" Verilen herhangi bir python degeri listesinde sadece tamsayilari filtrele
>>> tamsayilari_filtrele(['a', 3.14, 5])
[5]
>>> tamsayilari_filtrele([1, 2, 3, 'abc', {}, []])
[1, 2, 3]
"""
| tamsayilari_filtrele |
return list(filter(lambda x: type(x) == int, degerler))
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([]) == []
assert candidate([4, {}, [], 23.2, 9, 'adasd']) == [4, 9]
assert candidate([3, 'c', 3, 3, 'a', 'b']) == [3, 3, 3]
|
assert type(degerler) == list, "invalid inputs" # $_CONTRACT_$
| [[[]], [[4, {}, [], 23.2, 9, "adasd"]], [[3, "c", 3, 3, "a", "b"]]] | [[[1, 2, 3, 4, 5]], [[2.5, 4.6, 7.8, "abc", {}, []]], [[true, false, null, 0, -10, "test", [], {}, 3.14]], [[1, "2", "3", 4, -5]], [[1000000, -1000000, 1.32, "-1", "-2", [1, 2, "three"]]], [["apple", 2.71828, null, false, "watermelon", 42]], [[1, -1, 0, 999]], [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], [[1.5, 2.7, 3.0, -4.6]], ... | 0 | from typing import List, Any
def filter_integers(values: List[Any]) -> List[int]:
""" Filter given list of any python values only for integers
>>> filter_integers(['a', 3.14, 5])
[5]
>>> filter_integers([1, 2, 3, 'abc', {}, []])
[1, 2, 3]
"""
| filter_integers | {"filter_integers": "tamsayilari_filtrele", "values": "degerler"} |
HumanEval/23 | def metin_uzunlugu(metin: str) -> int:
""" Verilen metnin uzunlugunu dondurur
>>> metin_uzunlugu('')
0
>>> metin_uzunlugu('abc')
3
"""
| metin_uzunlugu |
return len(metin)
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('') == 0
assert candidate('x') == 1
assert candidate('asdasnakj') == 9
|
assert isinstance(metin, str), "invalid inputs" # $_CONTRACT_$
| [[""], ["x"], ["asdasnakj"]] | [["Hello, World!"], ["12345"], [" "], ["This is a long string that has many characters in it"], ["abcdefghijklmnopqrstuvwxyz"], ["Testing testing 123"], ["The quick brown fox jumps over the lazy dog"], ["one\ntwo\nthree\nfour\nfive"], ["1234567890"], ["This string has a \n newline character"], ["one\ntwo\nthree\nf\nfoi... | 0 |
def strlen(string: str) -> int:
""" Return length of given string
>>> strlen('')
0
>>> strlen('abc')
3
"""
| strlen | {"strlen": "metin_uzunlugu", "string": "metin"} |
HumanEval/24 | def en_buyuk_bolucu(sayi: int) -> int:
""" Verilen bir sayi icin, sayiyi tam olarak bolen, sayidan kucuk en buyuk sayiyi bulunuz
>>> en_buyuk_bolucu(15)
5
"""
| en_buyuk_bolucu |
for i in range(2, sayi):
if sayi % i == 0: return sayi // i
return 1
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate(3) == 1
assert candidate(7) == 1
assert candidate(10) == 5
assert candidate(100) == 50
assert candidate(49) == 7
|
assert type(sayi) == int, "invalid inputs" # $_CONTRACT_$
assert sayi > 1, "invalid inputs" # $_CONTRACT_$
| [[3], [7], [10], [100], [49]] | [[2], [27], [101], [235], [500], [999], [1000], [36], [72], [81], [499], [234], [73], [998], [35], [22], [23], [1001], [74], [236], [82], [75], [99], [76], [77], [24], [28], [80], [238], [29], [237], [56], [57], [3], [997], [30], [4], [102], [37], [233], [103], [78], [55], [5], [58], [21], [83], [25], [1003], [996], [1... | 0 |
def largest_divisor(n: int) -> int:
""" For a given number n, find the largest number that divides n evenly, smaller than n
>>> largest_divisor(15)
5
"""
| largest_divisor | {"largest_divisor": "en_buyuk_bolucu", "n": "sayi"} |
HumanEval/25 | from typing import List
def carpanlaraAyir(sayi: int) -> List[int]:
""" Verilen tam sayinin asal carpanlarini kucukten buyuge dogru sirali olarak listeleyen bir liste dondurur.
Her bir carpan, carpanlara ayirma islemindeki sayisi kadar listelenmelidir.
Girdi sayisi tum carpanlarin carpimiyla esit olmalidi... | carpanlaraAyir |
import math
fact = []
i = 2
while i <= int(math.sqrt(sayi) + 1):
if sayi % i == 0:
fact.append(i)
sayi //= i
else:
i += 1
if sayi > 1:
fact.append(sayi)
return fact
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate(2) == [2]
assert candidate(4) == [2, 2]
assert candidate(8) == [2, 2, 2]
assert candidate(3 * 19) == [3, 19]
assert candidate(3 * 19 * 3 * 19) == [3, 3, 19, 19]
assert candidate(3 * 19 * 3 * 19 * ... |
assert type(sayi) == int, "invalid inputs" # $_CONTRACT_$
assert sayi >= 2, "invalid inputs" # $_CONTRACT_$
| [[2], [4], [8], [57], [3249], [185193], [20577], [18]] | [[10], [15], [28], [1024], [131], [33], [1000], [100], [123456789], [987654321], [1025], [11], [1026], [29], [1027], [14], [34], [13], [99], [132], [123456790], [1023], [123456788], [32], [31], [1022], [987654320], [123456791], [1028], [123456787], [123456792], [27], [39], [12], [30], [2147483647], [1207943], [11223436... | 0 | from typing import List
def factorize(n: int) -> List[int]:
""" Return list of prime factors of given integer in the order from smallest to largest.
Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
Input number should be equal to the produc... | factorize | {"factorize": "carpanlaraAyir", "n": "sayi"} |
HumanEval/26 | from typing import List
def tekrarlananlari_kaldir(sayilar: List[int]) -> List[int]:
""" Bir tamsayi listesinden, birden fazla kez gorunen tum elemanlari kaldirin.
Elemanlarin sirasini girdideki gibi koruyun.
>>> tekrarlananlari_kaldir([1, 2, 3, 2, 4])
[1, 3, 4]
"""
| tekrarlananlari_kaldir |
num_cnt = dict()
for number in sayilar:
if number not in num_cnt:
num_cnt[number] = 0
num_cnt[number] += 1
return [number for number in sayilar if num_cnt[number] == 1]
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([]) == []
assert candidate([1, 2, 3, 4]) == [1, 2, 3, 4]
assert candidate([1, 2, 3, 2, 4, 3, 5]) == [1, 4, 5]
|
assert type(sayilar) == list, "invalid inputs" # $_CONTRACT_$
assert all(type(x) == int for x in sayilar), "invalid inputs" # $_CONTRACT_$
| [[[]], [[1, 2, 3, 4]], [[1, 2, 3, 2, 4, 3, 5]]] | [[[1, 1, 2, 2, 3, 3, 4, 4]], [[1, 2, 3, 4, 5, 6, 7, 8, 9]], [[1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4]], [[2, 2, 2, 2]], [[1, 1, 1, 1]], [[-1, 0, 1, 0, -1, 1]], [[1, 1, 1, 1, 1]], [[1, 2, 3, 4, 5, 6, 6, 7, 8]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9]], [[1, 2, 3, 4, 4, 6, 7, 8, 9]], [[1, 2, 3, 4, 6, 7, 8, 9]], [[1, 2, 3, 4, 4... | 0 | from typing import List
def remove_duplicates(numbers: List[int]) -> List[int]:
""" From a list of integers, remove all elements that occur more than once.
Keep order of elements left the same as in the input.
>>> remove_duplicates([1, 2, 3, 2, 4])
[1, 3, 4]
"""
| remove_duplicates | {"remove_duplicates": "tekrarlananlari_kaldir", "numbers": "sayilar"} |
HumanEval/27 | def harf_buyuk_kucuk_degistir(metin: str) -> str:
""" Verilen bir metin icin, kucuk harfleri buyuk harfe ve buyuk harfleri kucuk harfe cevirin.
>>> harf_buyuk_kucuk_degistir('Hello')
'hELLO'
"""
| harf_buyuk_kucuk_degistir |
return "".join(map(lambda x: x.swapcase(), metin))
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('') == ''
assert candidate('Hello!') == 'hELLO!'
assert candidate('These violent delights have violent ends') == 'tHESE VIOLENT DELIGHTS HAVE VIOLENT ENDS'
|
assert type(metin) == str, "invalid inputs" # $_CONTRACT_$
| [[""], ["Hello!"], ["These violent delights have violent ends"]] | [["123abc"], ["Toggle Me"], ["Flipping cases is so easy!"], ["Flipping Cases Is So Easy!"], ["Python Is Fun"], ["toGGlE Me"], ["fLiP YOuR cAsE"], ["1234"], ["TOGGLE ME"], ["toggle me"], ["123toggle me4"], ["Togg"], ["totggle me"], ["tgoggle me"], ["PtoGGlE Meython Is Fun"], ["PtuoGGlE Meython Is Fun"], ["togglTOGGLE ME... | 0 |
def flip_case(string: str) -> str:
""" For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
>>> flip_case('Hello')
'hELLO'
"""
| flip_case | {"flip_case": "harf_buyuk_kucuk_degistir", "string": "metin"} |
HumanEval/28 | from typing import List
def birlestir(dizgeler: List[str]) -> str:
""" Dizgelerin listesini tek bir dizgeye birlestir
>>> birlestir([])
''
>>> birlestir(['a', 'b', 'c'])
'abc'
"""
| birlestir |
return "".join(dizgeler)
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([]) == ''
assert candidate(['x', 'y', 'z']) == 'xyz'
assert candidate(['x', 'y', 'z', 'w', 'k']) == 'xyzwk'
|
assert all(isinstance(s, str) for s in dizgeler), "invalid inputs" # $_CONTRACT_$
assert isinstance(dizgeler, list), "invalid inputs" # $_CONTRACT_$
| [[[]], [["x", "y", "z"]], [["x", "y", "z", "w", "k"]]] | [[["apple", "banana", "orange"]], [["python", "is", "a", "great", "language"]], [["Rock", "Paper", "Scissors"]], [["123", "456", "789"]], [["Hello"]], [["hello"]], [["", "world"]], [["Python", "is", "a", "programming", "language"]], [["a"]], [["", "", ""]], [[]], [["python", "is", "pythonhello", "a", "great", "language... | 0 | from typing import List
def concatenate(strings: List[str]) -> str:
""" Concatenate list of strings into a single string
>>> concatenate([])
''
>>> concatenate(['a', 'b', 'c'])
'abc'
"""
| concatenate | {"concatenate": "birlestir", "strings": "dizgeler"} |
HumanEval/29 | from typing import List
def onek_ile_filtrele(dizeler: List[str], onek: str) -> List[str]:
""" Girilen bir dize listesini, verilen bir onekle baslayan dizelerle sinirlayin.
>>> onek_ile_filtrele([], 'a')
[]
>>> onek_ile_filtrele(['abc', 'bcd', 'cde', 'array'], 'a')
['abc', 'array']
"""
| onek_ile_filtrele |
return list(filter(lambda x: x.startswith(onek), dizeler))
|
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate([], 'john') == []
assert candidate(['xxx', 'asd', 'xxy', 'john doe', 'xxxAAA', 'xxx'], 'xxx') == ['xxx', 'xxxAAA', 'xxx']
|
assert all(isinstance(s, str) for s in dizeler), "invalid inputs" # $_CONTRACT_$
assert isinstance(onek, str), "invalid inputs" # $_CONTRACT_$
| [[[], "john"], [["xxx", "asd", "xxy", "john doe", "xxxAAA", "xxx"], "xxx"]] | [[[], ""], [["abc", "abcd", "abcde"], "abc"], [["xyz", "efg", "hij"], "a"], [["cat", "dog", "bat"], "elephant"], [["apple", "banana", "orange", "apricot", "kiwi"], "ap"], [["a", "ab", "abc", "ba", "bb", "bc"], "a"], [["zzz", "zzz", "zzz"], "z"], [["hello", "world", "house"], "h"], [["apple", "orange", "banana"], "b"], ... | 0 | from typing import List
def filter_by_prefix(strings: List[str], prefix: str) -> List[str]:
""" Filter an input list of strings only for ones that start with a given prefix.
>>> filter_by_prefix([], 'a')
[]
>>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')
['abc', 'array']
"""
| filter_by_prefix | {"filter_by_prefix": "onek_ile_filtrele", "strings": "dizeler", "prefix": "onek"} |
HumanEval/30 | def pozitifleri_getir(liste: list):
"""Listedeki pozitif sayilari dondurur.
>>> pozitifleri_getir([-1, 2, -4, 5, 6])
[2, 5, 6]
>>> pozitifleri_getir([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
[5, 3, 2, 3, 9, 123, 1]
"""
| pozitifleri_getir |
return list(filter(lambda x: x > 0, liste))
|
METADATA = {}
def check(candidate):
assert candidate([-1, -2, 4, 5, 6]) == [4, 5, 6]
assert candidate([5, 3, -5, 2, 3, 3, 9, 0, 123, 1, -10]) == [5, 3, 2, 3, 3, 9, 123, 1]
assert candidate([-1, -2]) == []
assert candidate([]) == []
|
assert type(liste) == list, "invalid inputs" # $_CONTRACT_$
| [[[-1, -2, 4, 5, 6]], [[5, 3, -5, 2, 3, 3, 9, 0, 123, 1, -10]], [[-1, -2]], [[]]] | [[[0, 1, -1, 2, -2, 3, -3, 4, -4]], [[1, -1, 2, -2, 3, -3, 4, -4, 0]], [[1, 2, 3, 4]], [[0, 0, 0]], [[-1, -2, -3, -4]], [[-5, -4, -1, 0, 1, 4, 5]], [[7, 8, 10, 11, 12, 15, 17, -1]], [[5, 9, -3, -6, 2, 3, 8, 1, 0]], [[-2, -4, -6, 0, 2, 4, 6]], [[10, -10, 15, -15, 20, -20, 25, -25]], [[10, -10, 15, -3, 20, -20, 25, -25]]... | 0 |
def get_positive(l: list):
"""Return only positive numbers in the list.
>>> get_positive([-1, 2, -4, 5, 6])
[2, 5, 6]
>>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
[5, 3, 2, 3, 9, 123, 1]
"""
| get_positive | {"get_positive": "pozitifleri_getir", "l": "liste"} |
HumanEval/31 | def asal_mi(sayi):
"""Verilen bir sayinin asal olup olmadigini dondurur. Asal ise true, degilse false doner.
>>> asal_mi(6)
False
>>> asal_mi(101)
True
>>> asal_mi(11)
True
>>> asal_mi(13441)
True
>>> asal_mi(61)
True
>>> asal_mi(4)
False
>>> asal_mi(1)
False
... | asal_mi |
if sayi <= 1: return False
n_sqrt = 1
while n_sqrt ** 2 < sayi: n_sqrt += 1
for i in range(2, min(n_sqrt + 1, sayi)):
if sayi % i == 0:
return False
return True
|
METADATA = {}
def check(candidate):
assert candidate(6) == False
assert candidate(101) == True
assert candidate(11) == True
assert candidate(13441) == True
assert candidate(61) == True
assert candidate(4) == False
assert candidate(1) == False
assert candidate(5) == True
assert ca... |
assert type(sayi) == int, "invalid inputs" # $_CONTRACT_$
| [[6], [101], [11], [13441], [61], [4], [1], [5], [11], [17], [85], [77], [255379]] | [[-5], [0], [2], [31], [40], [103], [199], [1009], [8999], [1234567], [9000], [32], [9001], [-1], [39], [1234566], [-4], [9002], [-6], [102], [101], [200], [56], [38], [37], [1010], [1234568], [1008], [33], [35], [64], [63], [1234564], [34], [1011], [1234569], [197], [-3], [1], [8998], [57], [28], [-2], [3], [1234563],... | 0 |
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
>>> is_prime(6)
False
>>> is_prime(101)
True
>>> is_prime(11)
True
>>> is_prime(13441)
True
>>> is_prime(61)
True
>>> is_prime(4)
False
>>> is_prime(1)
False
"""
| is_prime | {"is_prime": "asal_mi", "n": "sayi"} |
HumanEval/32 | import math
def polinom(katsayilar: list, nokta: float):
"""
katsayilar listesine sahip polinomi nokta degerinde degerlendirir.
return katsayilar[0] + katsayilar[1] * nokta + katsayilar[1] * nokta^2 + .... katsayilar[n] * nokta^n
"""
return sum([kat * math.pow(nokta, i) for i, kat in enumerate(kat... | sifir_bul |
dxs = [katsayilar[i] * i for i in range(1, len(katsayilar))]
def func(x):
return polinom(katsayilar, x)
def derivative(x):
return polinom(dxs, x)
x, tol = 0, 1e-5
for _ in range(1000):
fx = func(x)
dfx = derivative(x)
if abs(fx) < tol: break
x =... |
METADATA = {}
def check(candidate):
import math
import random
rng = random.Random(42)
import copy
for _ in range(100):
ncoeff = 2 * rng.randint(1, 4)
coeffs = []
for _ in range(ncoeff):
coeff = rng.randint(-10, 10)
if coeff == 0:
co... |
assert isinstance(katsayilar, list) and len(katsayilar) > 0 and len(katsayilar) % 2 == 0, "invalid inputs" # $_CONTRACT_$
assert katsayilar[-1] != 0, "invalid inputs" # $_CONTRACT_$
assert all(type(x) == int for x in katsayilar), "invalid inputs" # $_CONTRACT_$
dxs = [katsayilar[i] * i for i in range(1... | [[[-10, -2]], [[-3, -6, -7, 7]], [[8, 3]], [[-10, -8]], [[-3, 6, 9, -10]], [[10, 7, 3, -3]], [[8, -2, -10, -5, 3, 1, -2, -6]], [[1, -7, -8, 2]], [[1, 1]], [[-9, 4, 7, -7, 2, -8]], [[10, 9, 1, 8, -4, -8]], [[-3, -1]], [[-3, -7]], [[-2, 4, 10, 1, -5, 1, 1, -4]], [[10, -8, 9, 10, -5, 7]], [[-5, 4, 2, -2]], [[1, -9, -3, -9... | [[[5, 10, -3, 1]], [[1, -20, 156, -864, 2667, -4392, 3744, -1440]], [[0, 2]], [[-1, -1, 1, 1]], [[1, -1, 0, 1]], [[6, -1, 2, 1, -3, 1]], [[-1, 10, 1, 1]], [[-1, -36, 6, -1440, 1, 1]], [[3744, 1, 0, 2]], [[1, -20, 156, -864, 2667, -4391, 3743, -1440]], [[1, -20, 156, -864, 2667, -4391, 3743, -4, -1440, -4391]], [[0, -36... | 0.0001 | import math
def poly(xs: list, x: float):
"""
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
"""
return sum([coeff * math.pow(x, i) for i, coeff in enumerate(xs)])
def find_zero(xs: list):
""" xs are coefficients of a polynomia... | find_zero | {"poly": "polinom", "find_zero": "sifir_bul", "xs": "katsayilar"} |
HumanEval/33 | def uc_indis_sirala(liste: list):
"""Bu fonksiyon bir liste alir ve liste_bir dondurur. liste_bir, ucle bolunmeyen indislerde liste ile aynidir; ucle bolunen indislerdeki degerleri ise
liste'nin karsilikli indislerindeki degerlerdir, ancak siralanmis haldedir.
>>> uc_indis_sirala([1, 2, 3])
[1, 2, 3]
... | uc_indis_sirala |
third = [liste[i] for i in range(len(liste)) if i % 3 == 0]
third.sort()
return [third[i // 3] if i % 3 == 0 else liste[i] for i in range(len(liste))]
|
METADATA = {}
def check(candidate):
assert tuple(candidate([1, 2, 3])) == tuple(uc_indis_sirala([1, 2, 3]))
assert tuple(candidate([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])) == tuple(uc_indis_sirala([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]))
assert tuple(candidate([5, 8, -12, 4, 23, 2, 3, 11, 12, -10])) =... |
assert type(liste) == list, "invalid inputs" # $_CONTRACT_$
| [[[1, 2, 3]], [[1, 2, 3]], [[5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]], [[5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]], [[5, 8, -12, 4, 23, 2, 3, 11, 12, -10]], [[5, 8, -12, 4, 23, 2, 3, 11, 12, -10]], [[5, 6, 3, 4, 8, 9, 2]], [[5, 8, 3, 4, 6, 9, 2]], [[5, 6, 9, 4, 8, 3, 2]], [[5, 6, 3, 4, 8, 9, 2, 1]]] | [[[9, 12, 15, 6, 3, 8, 10, 23, 7]], [[2, 1, 3, 7, 8, 9, 10]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]], [[9, 12, 15, 6, 3, 8, 13, 18, 7]], [[2, 10, 20, 15, 18, 13, 7]], [[5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]], [[3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36]], [[11, 22, 33, 44, 55, 66, 77, 88, 99]]... | 0 |
def sort_third(l: list):
"""This function takes a list l and returns a list l' such that
l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
to the values of the corresponding indicies of l, but sorted.
>>> sort_t... | sort_third | {"sort_third": "uc_indis_sirala", "l": "liste"} |
HumanEval/34 | def tekil(liste: list):
"""Bir listedeki benzersiz elemanlari sirali olarak dondurur
>>> tekil([5, 3, 5, 2, 3, 3, 9, 0, 123])
[0, 2, 3, 5, 9, 123]
"""
| tekil |
return sorted(set(liste))
|
METADATA = {}
def check(candidate):
assert candidate([5, 3, 5, 2, 3, 3, 9, 0, 123]) == [0, 2, 3, 5, 9, 123]
|
assert type(liste) == list, "invalid inputs" # $_CONTRACT_$
| [[[5, 3, 5, 2, 3, 3, 9, 0, 123]]] | [[[1, 1, 1, 1]], [[2, 1, 2, 1]], [[0, 0, 0, 0]], [[-1, 5, -1, 3, 5, 2, 5]], [["a", "b", "b", "c", "d", "d"]], [[1.1, 2.2, 3.3, 4.4, 4.4]], [[true, false, false, true]], [[]], [[2, 2, 2, 2, 2, 2]], [["apple", "banana", "orange"]], [[true]], [[2, 1, 2, 1, 1, 1]], [["apple", "banana", "d", "orange"]], [["apple", "banana",... | 0 |
def unique(l: list):
"""Return sorted unique elements in a list
>>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])
[0, 2, 3, 5, 9, 123]
"""
| unique | {"unique": "tekil", "l": "liste"} |
HumanEval/35 | def maks_eleman(liste: list):
"""Listedeki en buyuk elemani dondurur.
>>> maks_eleman([1, 2, 3])
3
>>> maks_eleman([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
123
"""
| maks_eleman |
return max(liste)
|
METADATA = {}
def check(candidate):
assert candidate([1, 2, 3]) == 3
assert candidate([5, 3, -5, 2, -3, 3, 9, 0, 124, 1, -10]) == 124
|
assert type(liste) == list, "invalid inputs" # $_CONTRACT_$
assert len(liste) != 0, "invalid inputs" # $_CONTRACT_$
assert all(type(x) in [int, float] for x in liste), "invalid inputs" # $_CONTRACT_$
| [[[1, 2, 3]], [[5, 3, -5, 2, -3, 3, 9, 0, 124, 1, -10]]] | [[[0, 0, 0, 0]], [[-1, -2, -3, -4, -5]], [[1, 2, 9, 4, 5, 6, 7]], [[8, 7, 6, 5, 4, 3]], [[100]], [[100, 100, 99, 98, 97, 96]], [[1.5, 3, 2, -4, -3.5, 0, 2.5]], [[1, 1, 1, 1]], [[2, 2, 2, 1, 2, 2]], [[50, 49, 48, 47, 46]], [[50, 49, 100, 48, 47, 46]], [[101]], [[-5, 2, 9, 4, 5, 6, 7]], [[50, 49, 49, 47, 47]], [[50, 49, ... | 0 |
def max_element(l: list):
"""Return maximum element in the list.
>>> max_element([1, 2, 3])
3
>>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
123
"""
| max_element | {"max_element": "maks_eleman", "l": "liste"} |
HumanEval/36 | def yedi_gorunum_sayisi(sinir: int):
"""11 veya 13'e bolunen ve sinir'den kucuk olan tamsayilar icin 7 rakaminin kac kez gorundugunu dondurur.
>>> yedi_gorunum_sayisi(50)
0
>>> yedi_gorunum_sayisi(78)
2
>>> yedi_gorunum_sayisi(79)
3
"""
| yedi_gorunum_sayisi |
cnt = 0
for i in range(sinir):
if i % 11 == 0 or i % 13 == 0:
cnt += len(list(filter(lambda c: c == "7", str(i))))
return cnt
|
METADATA = {}
def check(candidate):
assert candidate(50) == 0
assert candidate(78) == 2
assert candidate(79) == 3
assert candidate(100) == 3
assert candidate(200) == 6
assert candidate(4000) == 192
assert candidate(10000) == 639
assert candidate(100000) == 8026
|
assert type(sinir) == int and sinir > 0, "invalid inputs" # $_CONTRACT_$
| [[50], [78], [79], [100], [200], [4000], [10000], [100000]] | [[1], [10], [20], [30], [70], [71], [72], [73], [74], [75], [31], [69], [9], [77], [78], [76], [8], [2], [21], [68], [22], [29], [23], [32], [3], [11], [33], [19], [86], [7], [12], [4], [79], [28], [6], [60], [85], [5], [80], [61], [59], [62], [63], [84], [18], [27], [81], [64], [26], [83], [82], [13], [66], [24], [34]... | 0 |
def fizz_buzz(n: int):
"""Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
>>> fizz_buzz(50)
0
>>> fizz_buzz(78)
2
>>> fizz_buzz(79)
3
"""
| fizz_buzz | {"fizz_buzz": "yedi_gorunum_sayisi", "n": "sinir"} |
HumanEval/37 | def cift_indisler_sirala(liste: list):
"""Bu fonksiyon bir liste alir ve liste_cikti listesini dondurur.
liste_cikti listesi, tek indislerdeki degerler liste ile ayni olacak sekilde, cift indislerdeki degerleri ise listenin cift indislerindeki degerlerin siralanmis haliyle
esit olur.
>>> cift_indisler_s... | cift_indisler_sirala |
even = [liste[i] for i in range(len(liste)) if i % 2 == 0]
even.sort()
return [even[i // 2] if i % 2 == 0 else liste[i] for i in range(len(liste))]
|
METADATA = {}
def check(candidate):
assert tuple(candidate([1, 2, 3])) == tuple([1, 2, 3])
assert tuple(candidate([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])) == tuple([-10, 3, -5, 2, -3, 3, 5, 0, 9, 1, 123])
assert tuple(candidate([5, 8, -12, 4, 23, 2, 3, 11, 12, -10])) == tuple([-12, 8, 3, 4, 5, 2, 12, 1... |
assert type(liste) == list, "invalid inputs" # $_CONTRACT_$
assert all(type(x) in [int, float] for x in liste), "invalid inputs" # $_CONTRACT_$
| [[[1, 2, 3]], [[5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]], [[5, 8, -12, 4, 23, 2, 3, 11, 12, -10]]] | [[[2, 6, 4, 8, 10]], [[1, 0, 3, 6, 5]], [[3, 3, 2, 2, 1, 1]], [[11, 7, 6, 9, 14, -1]], [[]], [[3]], [[5, 9, 3, 8, -1, 12, -14, 7]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]], [[8, 7, 6, 5, 4, 3, 2, 1]], [[0, 0, 0, -1, -1, -1, 2, 2, 2]], [[1, 0, 3, 4, 6, 5]], [[4, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]], [[3, 3, 2, 2, 1, 1... | 0 |
def sort_even(l: list):
"""This function takes a list l and returns a list l' such that
l' is identical to l in the odd indicies, while its values at the even indicies are equal
to the values of the even indicies of l, but sorted.
>>> sort_even([1, 2, 3])
[1, 2, 3]
>>> sort_even([5, 6, 3, 4])
... | sort_even | {"sort_even": "cift_indisler_sirala", "l": "liste"} |
HumanEval/38 | def kaydir_kodla(metin: str):
"""
uc karakterlik gruplari donguleyerek kodlanmis dizgiyi donduru.
"""
# dizgiyi gruplara ayir. Her biri 3 uzunlugunda.
gruplar = [metin[(3 * i):min((3 * i + 3), len(metin))] for i in range((len(metin) + 2) // 3)]
# her gruptaki elemanlari dongule. Grup 3ten az ele... | kaydir_coz |
groups = [metin[(3 * i):min((3 * i + 3), len(metin))] for i in range((len(metin) + 2) // 3)]
groups = [(group[2] + group[:2]) if len(group) == 3 else group for group in groups]
return "".join(groups)
|
METADATA = {}
def check(candidate):
from random import randint, choice
import string
letters = string.ascii_lowercase
for _ in range(100):
str = ''.join(choice(letters) for i in range(randint(10, 20)))
encoded_str = encode_cyclic(str)
assert candidate(encoded_str) == str
|
assert isinstance(metin, str), "invalid inputs" # $_CONTRACT_$
| [["uzfplzjfzcltmdly"], ["nzyegaghrzqwrdzxckn"], ["zxolecqvzyausohgzdod"], ["cjhzuelsabstpbq"], ["lfgmjpqnvzwvbusr"], ["cvxcvhmtgbeweum"], ["jgjvebqagrtwheytsyff"], ["swbkfgqnvuahcnqgpcu"], ["ssjgajmprs"], ["enrrdusnffcnkotf"], ["cpfgdusjrzf"], ["gconqokfgb"], ["effmnsvrgsdbhffn"], ["zwsrgynxlmh"], ["nqdjadvhlu"], ["fpk... | [["abcdefghijk"], ["abcdefghijklmnopqrstuvwxyz"], ["1234567890"], ["The quick brown fox jumps over the lazy dog."], ["Testing 123, testing 123."], ["abc"], ["ab"], ["a"], [""], ["foo bar"], ["5670"], ["Testing 123, testi3ng 123."], ["aaTesting 123, testi3ng 123.b"], ["Testing5670 123, testingabc 123."], ["DQVw"], ["bc"... | 0 |
def encode_cyclic(s: str):
"""
returns encoded string by cycling groups of three characters.
"""
# split string to groups. Each of length 3.
groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) // 3)]
# cycle elements in each group. Unless group has fewer elements than 3.
... | decode_cyclic | {"encode_cyclic": "kaydir_kodla", "decode_cyclic": "kaydir_coz", "s": "metin"} |
HumanEval/39 | def asal_fib(n: int):
"""
asal_fib, fibonacci sayisi olup ayni zamanda asal olan ninci sayiyi geri doner.
>>> asal_fib(1)
2
>>> asal_fib(2)
3
>>> asal_fib(3)
5
>>> asal_fib(4)
13
>>> asal_fib(5)
89
"""
| asal_fib |
import random
def miller_rabin(n, k=10):
"""Test if n is prime using the Miller-Rabin primality test."""
if n < 2:
return False
if n == 2 or n == 3:
return True
if n % 2 == 0:
return False
r = 0
d = n - 1
while d % 2 ... |
METADATA = {}
def check(candidate):
assert candidate(1) == 2
assert candidate(2) == 3
assert candidate(3) == 5
assert candidate(4) == 13
assert candidate(5) == 89
assert candidate(6) == 233
assert candidate(7) == 1597
assert candidate(8) == 28657
assert candidate(9) == 514229
... |
assert type(n) == int, "invalid inputs" # $_CONTRACT_$
assert 1 <= n <= 12, "invalid inputs" # $_CONTRACT_$
| [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]] | [[11], [12]] | 0 |
def prime_fib(n: int):
"""
prime_fib returns n-th number that is a Fibonacci number and it's also prime.
>>> prime_fib(1)
2
>>> prime_fib(2)
3
>>> prime_fib(3)
5
>>> prime_fib(4)
13
>>> prime_fib(5)
89
"""
| prime_fib | {"prime_fib": "asal_fib", "n": "n"} |
HumanEval/40 | def uclu_toplam_sifir(liste: list):
"""
uclu_toplam_sifir bir tamsayi listesini girdi olarak alir.
listede toplamlari sifira esit olan uc farkli eleman varsa True,
yoksa False dondurur.
>>> uclu_toplam_sifir([1, 3, 5, 0])
False
>>> uclu_toplam_sifir([1, 3, -2, 1])
True
>>> uclu_topl... | uclu_toplam_sifir |
for i in range(len(liste)):
for j in range(len(liste)):
for k in range(len(liste)):
if i != j and i != k and j != k and liste[i] + liste[j] + liste[k] == 0:
return True
return False
|
METADATA = {}
def check(candidate):
assert candidate([1, 3, 5, 0]) == False
assert candidate([1, 3, 5, -1]) == False
assert candidate([1, 3, -2, 1]) == True
assert candidate([1, 2, 3, 7]) == False
assert candidate([1, 2, 5, 7]) == False
assert candidate([2, 4, -5, 3, 9, 7]) == True
asser... |
assert type(liste) == list, "invalid inputs" # $_CONTRACT_$
| [[[1, 3, 5, 0]], [[1, 3, 5, -1]], [[1, 3, -2, 1]], [[1, 2, 3, 7]], [[1, 2, 5, 7]], [[2, 4, -5, 3, 9, 7]], [[1]], [[1, 3, 5, -100]], [[100, 3, 5, -100]]] | [[[0, 0, 0]], [[1, 1, -2, -2]], [[2, 3, -5, 0, 1, -1]], [[5, -5, 10, 0, -10]], [[1, 2, -3, -4, 5, 6]], [[1, 1, 1, -2, -2, -2]], [[1, 2, 3, -6, 7, 0, -1]], [[1, -1, 0, 0, 2, -2]], [[10, -20, 30, -40, 50, -60]], [[1, 2, 3, 4, 5, -9]], [[0, 1, 0, 0]], [[1, 2, 3, -6, 7, -1]], [[-2, -2]], [[5, -5, -60, 0, -10]], [[-2, -1]],... | 0 |
def triples_sum_to_zero(l: list):
"""
triples_sum_to_zero takes a list of integers as an input.
it returns True if there are three distinct elements in the list that
sum to zero, and False otherwise.
>>> triples_sum_to_zero([1, 3, 5, 0])
False
>>> triples_sum_to_zero([1, 3, -2, 1])
Tr... | triples_sum_to_zero | {"triples_sum_to_zero": "uclu_toplam_sifir", "l": "liste"} |
HumanEval/41 | def araba_yaris_carpisma(araba_sayisi: int):
"""
Mukemmel derecede duz ve sonsuz uzunlukta bir yol hayal edin.
araba_sayisi tane araba soldan saga surmektedir; ayni anda, farkli bir set araba_sayisi tane araba
sagdan sola surmektedir. Iki araba grubu baslangicta birbirinden cok uzaktir.
birbirind... | araba_yaris_carpisma |
return araba_sayisi ** 2
|
METADATA = {}
def check(candidate):
assert candidate(2) == 4
assert candidate(3) == 9
assert candidate(4) == 16
assert candidate(8) == 64
assert candidate(10) == 100
|
assert type(araba_sayisi) == int, "invalid inputs" # $_CONTRACT_$
assert araba_sayisi >= 1, "invalid inputs" # $_CONTRACT_$
| [[2], [3], [4], [8], [10]] | [[5], [6], [12], [15], [20], [1], [25], [7], [100], [500], [24], [101], [14], [99], [4], [8], [3], [23], [19], [47], [48], [46], [26], [499], [27], [98], [28], [18], [45], [498], [13], [102], [11], [17], [501], [68], [21], [30], [10000], [987654], [1000], [1002], [97], [9999], [987653], [22], [29], [10001], [16], [31],... | 0 |
def car_race_collision(n: int):
"""
Imagine a road that's a perfectly straight infinitely long line.
n cars are driving left to right; simultaneously, a different set of n cars
are driving right to left. The two sets of cars start out being very far from
each other. All cars move in the same s... | car_race_collision | {"car_race_collision": "araba_yaris_carpisma", "n": "araba_sayisi"} |
HumanEval/42 | def artir_liste(liste: list):
"""Elemanlari 1 artirilmis liste dondurur.
>>> artir_liste([1, 2, 3])
[2, 3, 4]
>>> artir_liste([5, 3, 5, 2, 3, 3, 9, 0, 123])
[6, 4, 6, 3, 4, 4, 10, 1, 124]
"""
| artir_liste |
return [x + 1 for x in liste]
|
METADATA = {}
def check(candidate):
assert candidate([]) == []
assert candidate([3, 2, 1]) == [4, 3, 2]
assert candidate([5, 2, 5, 2, 3, 3, 9, 0, 123]) == [6, 3, 6, 3, 4, 4, 10, 1, 124]
|
assert type(liste) == list, "invalid inputs" # $_CONTRACT_$
| [[[]], [[3, 2, 1]], [[5, 2, 5, 2, 3, 3, 9, 0, 123]]] | [[[100, 200, 300, 400, 500]], [[-1, -2, -3, -4, -5]], [[0, 0, 0, 0]], [[2.5, 3.7, 8.9, 1.2, 0.5]], [[1, 2, 3, 4, 5, 6]], [[10, 100, 1000, 10000]], [[0.1, 0.2, 0.3]], [[-10, 0, 10]], [[2, 2, 2, 2]], [[1, 1, 1, 1, 1, 1, 1, 1]], [[4, -2, -3, -4]], [[1, 1, 1, 1, 1, 1, 1]], [[-1, -5, -3, -5]], [[-1, -5, -3, -5, -3]], [[0.1,... | 0 |
def incr_list(l: list):
"""Return list with elements incremented by 1.
>>> incr_list([1, 2, 3])
[2, 3, 4]
>>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])
[6, 4, 6, 3, 4, 4, 10, 1, 124]
"""
| incr_list | {"incr_list": "artir_liste", "l": "liste"} |
HumanEval/43 | def ciftler_sifira_topluyor_mu(liste):
"""
ciftler_sifira_topluyor_mu bir tamsayi listesi alur.
liste icinde sifira toplaman iki farkli eleman varsa True,
aksi takdirde False doner.
>>> ciftler_sifira_topluyor_mu([1, 3, 5, 0])
False
>>> ciftler_sifira_topluyor_mu([1, 3, -2, 1])
False
... | ciftler_sifira_topluyor_mu |
for i in range(len(liste)):
for j in range(len(liste)):
if i != j and liste[i] + liste[j] == 0:
return True
return False
|
METADATA = {}
def check(candidate):
assert candidate([1, 3, 5, 0]) == False
assert candidate([1, 3, -2, 1]) == False
assert candidate([1, 2, 3, 7]) == False
assert candidate([2, 4, -5, 3, 5, 7]) == True
assert candidate([1]) == False
assert candidate([-3, 9, -1, 3, 2, 30]) == True
asser... |
assert all([isinstance(v, int) for v in liste]), "invalid inputs" # $_CONTRACT_$
| [[[1, 3, 5, 0]], [[1, 3, -2, 1]], [[1, 2, 3, 7]], [[2, 4, -5, 3, 5, 7]], [[1]], [[-3, 9, -1, 3, 2, 30]], [[-3, 9, -1, 3, 2, 31]], [[-3, 9, -1, 4, 2, 30]], [[-3, 9, -1, 4, 2, 31]]] | [[[0, 0]], [[0, 1, -1]], [[1, -1]], [[1, -1, 0]], [[2, 4, -2, -4]], [[2, 4, -2, -4, 0]], [[2, 4, -2, -4, 6, -6]], [[-2, 2, -4, 4]], [[]], [[2, 3, 4, 5, -9]], [[2, -4, 4, -2]], [[2, 4, -2, -4, -2]], [[2, -4, 5, 4, -2, -4, 6, -6, 2]], [[0]], [[2, 4, -4, 6, -6]], [[2, 4, -2, -4, 1, -2]], [[2, 4, 5, -4, 5]], [[2, 4, -4, 6,... | 0 |
def pairs_sum_to_zero(l):
"""
pairs_sum_to_zero takes a list of integers as an input.
it returns True if there are two distinct elements in the list that
sum to zero, and False otherwise.
>>> pairs_sum_to_zero([1, 3, 5, 0])
False
>>> pairs_sum_to_zero([1, 3, -2, 1])
False
>>> pairs... | pairs_sum_to_zero | {"pairs_sum_to_zero": "ciftler_sifira_topluyor_mu", "l": "liste"} |
HumanEval/44 | def taban_degistir(sayi: int, taban: int):
"""Girilen sayi sayisinin tabanini verilen tabana degistirir.
Donusum sonrasi string gosterimini dondurur.
Taban 10'dan kucuktur.
>>> taban_degistir(8, 3)
'22'
>>> taban_degistir(8, 2)
'1000'
>>> taban_degistir(7, 2)
'111'
"""
| taban_degistir |
if sayi == 0: return "0"
ret = ""
while sayi != 0:
ret = str(sayi % taban) + ret
sayi //= taban
return ret
|
METADATA = {}
def check(candidate):
assert candidate(8, 3) == "22"
assert candidate(9, 3) == "100"
assert candidate(234, 2) == "11101010"
assert candidate(16, 2) == "10000"
assert candidate(8, 2) == "1000"
assert candidate(7, 2) == "111"
for x in range(2, 8):
assert candidate(x, ... |
assert type(sayi) == int and type(taban) == int, "invalid inputs" # $_CONTRACT_$
assert sayi >= 0, "invalid inputs" # $_CONTRACT_$
assert 2 <= taban <= 9, "invalid inputs" # $_CONTRACT_$
| [[8, 3], [9, 3], [234, 2], [16, 2], [8, 2], [7, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]] | [[10, 5], [15, 4], [25, 6], [33, 7], [45, 8], [50, 9], [13, 5], [17, 3], [42, 8], [15, 2], [8, 4], [2, 3], [17, 8], [7, 8], [9, 5], [7, 6], [5, 8], [45, 7], [4, 9], [3, 3], [8, 8], [2, 8], [15, 7], [50, 5], [8, 7], [25, 5], [17, 9], [5, 9], [2, 6], [9, 9], [4, 4], [7, 7], [5, 4], [3, 7], [13, 7], [15, 3], [2, 2], [17, ... | 0 |
def change_base(x: int, base: int):
"""Change numerical base of input number x to base.
return string representation after the conversion.
base numbers are less than 10.
>>> change_base(8, 3)
'22'
>>> change_base(8, 2)
'1000'
>>> change_base(7, 2)
'111'
"""
| change_base | {"change_base": "taban_degistir", "x": "sayi", "base": "taban"} |
HumanEval/45 | def ucgen_alan(kenar, yukseklik):
"""Bir kenar uzunlugu ve yukseklik verilerek bir ucgenin alanini dondurur.
>>> ucgen_alan(5, 3)
7.5
"""
| ucgen_alan |
return kenar * yukseklik / 2
|
METADATA = {}
def check(candidate):
assert candidate(5, 3) == 7.5
assert candidate(2, 2) == 2.0
assert candidate(10, 8) == 40.0
|
assert isinstance(kenar, (int, float)) and isinstance(yukseklik, (int, float)), "invalid inputs" # $_CONTRACT_$
assert kenar > 0 and yukseklik > 0, "invalid inputs" # $_CONTRACT_$
| [[5, 3], [2, 2], [10, 8]] | [[4, 6], [7, 2], [12, 5], [3, 4], [6, 10], [9, 12], [15, 20], [25, 30], [1, 1], [10, 7], [30, 30], [12, 4], [26, 25], [1, 4], [4, 7], [19, 20], [6, 6], [10, 1], [20, 20], [12, 12], [6, 5], [7, 7], [4, 12], [10, 10], [19, 12], [26, 11], [2, 11], [11, 7], [5, 19], [6, 2], [26, 12], [1, 25], [16, 15], [4, 3], [9, 9], [12,... | 0 |
def triangle_area(a, h):
"""Given length of a side and high return area for a triangle.
>>> triangle_area(5, 3)
7.5
"""
| triangle_area | {"triangle_area": "ucgen_alan", "a": "kenar", "h": "yukseklik"} |
HumanEval/46 | def fib_dort(sayi: int):
"""Dortlu fib sayi dizisi, asagidaki gibi tanimlanan Fibonacci dizisine benzer bir dizidir:
fib_dort(0) -> 0
fib_dort(1) -> 0
fib_dort(2) -> 2
fib_dort(3) -> 0
fib_dort(sayi) -> fib_dort(sayi-1) + fib_dort(sayi-2) + fib_dort(sayi-3) + fib_dort(sayi-4).
Lutfen fib_dor... | fib_dort |
if sayi == 0:
return 0
elif sayi == 1:
return 0
elif sayi == 2:
return 2
elif sayi == 3:
return 0
else:
a, b, c, d = 0, 0, 2, 0
for i in range(4, sayi + 1):
a, b, c, d = b, c, d, a + b + c + d
return d
|
METADATA = {}
def check(candidate):
assert candidate(5) == 4
assert candidate(8) == 28
assert candidate(10) == 104
assert candidate(12) == 386
|
assert type(sayi) == int, "invalid inputs" # $_CONTRACT_$
assert sayi >= 0, "invalid inputs" # $_CONTRACT_$
| [[5], [8], [10], [12]] | [[1], [2], [3], [4], [6], [7], [9], [11], [15], [20], [5], [19], [21], [16], [17], [14], [18], [22], [10], [8], [0], [12], [13], [23], [24], [41], [25], [98], [26], [27], [82], [81], [80], [40], [99], [83], [84], [39], [100], [28], [29], [97], [85], [86], [30], [95], [87], [31], [32], [33], [34], [42], [43], [101], [79... | 0 |
def fib4(n: int):
"""The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
fib4(0) -> 0
fib4(1) -> 0
fib4(2) -> 2
fib4(3) -> 0
fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
Please write a function to efficiently compute the n-th el... | fib4 | {"fib4": "fib_dort", "n": "sayi"} |
HumanEval/47 | def medyan(liste: list):
"""liste elemanlarinin medyanini dondurur.
>>> medyan([3, 1, 2, 4, 5])
3
>>> medyan([-10, 4, 6, 1000, 10, 20])
15.0
"""
| medyan |
sorted_l = sorted(liste)
if len(liste) % 2 == 1:
return sorted_l[len(liste) // 2]
else:
return (sorted_l[len(liste) // 2 - 1] + sorted_l[len(liste) // 2]) / 2
|
METADATA = {}
def check(candidate):
assert candidate([3, 1, 2, 4, 5]) == 3
assert candidate([-10, 4, 6, 1000, 10, 20]) == 8.0
assert candidate([5]) == 5
assert candidate([6, 5]) == 5.5
assert candidate([8, 1, 3, 9, 9, 2, 7]) == 7
|
assert len(liste) > 0, "invalid inputs" # $_CONTRACT_$
assert all([isinstance(v, (int, float)) for v in liste]), "invalid inputs" # $_CONTRACT_$
| [[[3, 1, 2, 4, 5]], [[-10, 4, 6, 1000, 10, 20]], [[5]], [[6, 5]], [[8, 1, 3, 9, 9, 2, 7]]] | [[[10, 20, 30, 40, 50]], [[-5, -3, 0, 3, 5]], [[1, 3, 7, 8, 10, 10]], [[2, 2, 2, 2, 2, 2]], [[2, 5, 8, 11, 14]], [[1, 1, 1, 2, 3, 4]], [[-1, 0, 1]], [[100]], [[7, 9, 3, 5]], [[0, 0, 0, 0, 0, 0, 1]], [[1, 11, 3, 7, 8, 10, 10]], [[1, 1, 1, 3, 4]], [[0, 0, 0, 0, 1]], [[1, 1, 2, 2, 3, 4, 1]], [[100, 100]], [[1, 3, -1, 7, 8... | 0 |
def median(l: list):
"""Return median of elements in the list l.
>>> median([3, 1, 2, 4, 5])
3
>>> median([-10, 4, 6, 1000, 10, 20])
15.0
"""
| median | {"median": "medyan", "l": "liste"} |
HumanEval/48 | def palindrom_mu(metin: str):
"""
Verilen dizginin palindrom olup olmadigini kontrol eder
>>> palindrom_mu('')
True
>>> palindrom_mu('aba')
True
>>> palindrom_mu('aaaaa')
True
>>> palindrom_mu('zbcd')
False
"""
| palindrom_mu |
return metin == metin[::-1]
|
METADATA = {}
def check(candidate):
assert candidate('') == True
assert candidate('aba') == True
assert candidate('aaaaa') == True
assert candidate('zbcd') == False
assert candidate('xywyx') == True
assert candidate('xywyz') == False
assert candidate('xywzx') == False
|
assert isinstance(metin, str), "invalid inputs" # $_CONTRACT_$
| [[""], ["aba"], ["aaaaa"], ["zbcd"], ["xywyx"], ["xywyz"], ["xywzx"]] | [["a"], ["ab"], ["abc"], ["abca"], ["racecar"], ["never odd or even"], ["step on no pets"], ["Was it a car or a cat I saw?"], ["radar"], ["refer"], ["bab"], ["aabc"], ["Was it a car or a cat I saw?refer"], ["Was it a car or a sacat I saw?"], ["aabca"], ["Was it a car ostep on no petsr a ca t I saw?"], ["Was ait a car o... | 0 |
def is_palindrome(text: str):
"""
Checks if given string is a palindrome
>>> is_palindrome('')
True
>>> is_palindrome('aba')
True
>>> is_palindrome('aaaaa')
True
>>> is_palindrome('zbcd')
False
"""
| is_palindrome | {"is_palindrome": "palindrom_mu", "text": "metin"} |
HumanEval/49 | def mod_p(us: int, modul: int):
"""2^us modulo modul sonucunu dondur (sayisal hassasiyete dikkat et).
>>> mod_p(3, 5)
3
>>> mod_p(1101, 101)
2
>>> mod_p(0, 101)
1
>>> mod_p(3, 11)
8
>>> mod_p(100, 101)
1
"""
| mod_p |
res, x = 1, 2
while us != 0:
if us % 2 == 1:
res = res * x % modul
x = x * x % modul
us //= 2
return res % modul
|
METADATA = {}
def check(candidate):
assert candidate(3, 5) == 3
assert candidate(1101, 101) == 2
assert candidate(0, 101) == 1
assert candidate(3, 11) == 8
assert candidate(100, 101) == 1
assert candidate(30, 5) == 4
assert candidate(31, 5) == 3
|
assert type(us) == int and type(modul) == int, "invalid inputs" # $_CONTRACT_$
assert us >= 0 and modul >= 1, "invalid inputs" # $_CONTRACT_$
| [[3, 5], [1101, 101], [0, 101], [3, 11], [100, 101], [30, 5], [31, 5]] | [[5, 17], [10, 23], [20, 37], [50, 79], [100, 89], [200, 113], [7, 3], [12, 7], [50, 23], [101, 103], [20, 20], [37, 37], [200, 112], [19, 19], [3, 3], [200, 200], [79, 79], [17, 20], [100, 20], [100, 3], [6, 6], [23, 200], [78, 79], [6, 78], [5, 5], [6, 19], [5, 6], [7, 78], [113, 112], [3, 20], [6, 20], [7, 101], [10... | 0 |
def modp(n: int, p: int):
"""Return 2^n modulo p (be aware of numerics).
>>> modp(3, 5)
3
>>> modp(1101, 101)
2
>>> modp(0, 101)
1
>>> modp(3, 11)
8
>>> modp(100, 101)
1
"""
| modp | {"modp": "mod_p", "n": "us", "p": "modul"} |
HumanEval/50 | def sifrele_kaydir(metin: str):
"""
alfabede her karakteri 5 kaydirarak sifrelenmis metni dondurur.
"""
return "".join([chr(((ord(karakter) + 5 - ord("a")) % 26) + ord("a")) for karakter in metin])
def sifre_coz_kaydir(metin: str):
"""
sifrele_kaydir fonksiyonu ile sifrelenmis metni girdi olar... | sifre_coz_kaydir |
return "".join([chr((ord(ch) - ord("a") - 5 + 26) % 26 + ord("a")) for ch in metin])
|
METADATA = {}
def check(candidate):
from random import randint, choice
import copy
import string
letters = string.ascii_lowercase
for _ in range(100):
str = ''.join(choice(letters) for i in range(randint(10, 20)))
encoded_str = encode_shift(str)
assert candidate(copy.dee... |
assert metin == "" or metin.islower(), "invalid inputs" # $_CONTRACT_$
| [["tantywccpjkimslotpzs"], ["clknfxdnox"], ["dtzqyosaovdbafbg"], ["dffjvztknohzf"], ["brhkdngfwd"], ["amlcrporykmgbhzctpnh"], ["ondbgojmipwoofzeyrh"], ["atobiwyiitrvhuctz"], ["kyrzjawonglfbsedmhmk"], ["esusgpgnaelf"], ["jbocbcqiuggvenbq"], ["zmmcumljlx"], ["ibrcruwukgetv"], ["ncbelcfjqcgxshtdiz"], ["xgcckzjdfp"], ["gzl... | [["abcdefghijklmnopqrstuvwxyz"], ["encoded message with shift"], ["abcde"], ["vwxyz"], ["hello world"], ["the quick brown fox jumps over the lazy dog"], ["éîøüñ"], [""], ["hello"], ["world"], ["the quick brown fox jumps over the abcdefghijklmnopqrstuvwxyzlazy dog"], ["éîøühello worldñ"], ["worlencoded message with shif... | 0 |
def encode_shift(s: str):
"""
returns encoded string by shifting every character by 5 in the alphabet.
"""
return "".join([chr(((ord(ch) + 5 - ord("a")) % 26) + ord("a")) for ch in s])
def decode_shift(s: str):
"""
takes as input string encoded with encode_shift function. Returns decoded str... | decode_shift | {"encode_shift": "sifrele_kaydir", "decode_shift": "sifre_coz_kaydir", "s": "metin"} |
HumanEval/51 | def sesli_harf_cikar(metin):
"""
sesli_harf_cikar, bir dizeyi alan ve sesli harfler olmadan bir dize donduren bir islevdir.
>>> sesli_harf_cikar('')
''
>>> sesli_harf_cikar("abcdef\nghijklm")
'bcdf\nghjklm'
>>> sesli_harf_cikar('abcdef')
'bcdf'
>>> sesli_harf_cikar('aaaaa')
''
... | sesli_harf_cikar |
return "".join(list(filter(lambda ch: ch not in "aeiouAEIOU", metin)))
|
METADATA = {}
def check(candidate):
assert candidate('') == ''
assert candidate("abcdef\nghijklm") == 'bcdf\nghjklm'
assert candidate('fedcba') == 'fdcb'
assert candidate('eeeee') == ''
assert candidate('acBAA') == 'cB'
assert candidate('EcBOO') == 'cB'
assert candidate('ybcd') == 'ybcd'... |
assert type(metin) == str, "invalid inputs" # $_CONTRACT_$
| [[""], ["abcdef\nghijklm"], ["fedcba"], ["eeeee"], ["acBAA"], ["EcBOO"], ["ybcd"]] | [["hello"], ["This is a Test!"], ["i am using python"], ["The quick brown fox jumps over the lazy dog."], ["This sentence has vowels: aeiou"], ["strawberries and cream"], ["Programming is fun"], ["1234567890"], ["Python is awesome!"], ["How are you today?"], ["This is ai am using python Test!"], ["1234561207890"], ["12... | 0 |
def remove_vowels(text):
"""
remove_vowels is a function that takes string and returns string without vowels.
>>> remove_vowels('')
''
>>> remove_vowels("abcdef\nghijklm")
'bcdf\nghjklm'
>>> remove_vowels('abcdef')
'bcdf'
>>> remove_vowels('aaaaa')
''
>>> remove_vowels('aaB... | remove_vowels | {"remove_vowels": "sesli_harf_cikar", "text": "metin"} |
HumanEval/52 | def esik_degerin_altinda(liste: list, esik_deger: int):
"""True dondur, eger listedeki tum sayilar esik_deger degerinin altinda ise.
>>> esik_degerin_altinda([1, 2, 4, 10], 100)
True
>>> esik_degerin_altinda([1, 20, 4, 10], 5)
False
"""
| esik_degerin_altinda |
return all(x < esik_deger for x in liste)
|
METADATA = {}
def check(candidate):
assert candidate([1, 2, 4, 10], 100)
assert not candidate([1, 20, 4, 10], 5)
assert candidate([1, 20, 4, 10], 21)
assert candidate([1, 20, 4, 10], 22)
assert candidate([1, 8, 4, 10], 11)
assert not candidate([1, 8, 4, 10], 10)
|
assert type(liste) == list, "invalid inputs" # $_CONTRACT_$
assert type(esik_deger) == int, "invalid inputs" # $_CONTRACT_$
assert all(isinstance(x, (int, float, bool)) for x in liste), "invalid inputs" # $_CONTRACT_$
| [[[1, 2, 4, 10], 100], [[1, 20, 4, 10], 5], [[1, 20, 4, 10], 21], [[1, 20, 4, 10], 22], [[1, 8, 4, 10], 11], [[1, 8, 4, 10], 10]] | [[[0, 0, 0, 0], 1], [[1, 3, 5, 7], 10], [[-1, -2, -3, -4], 0], [[2, 4, 6, 8], 7], [[], 5], [[1, 2, 3, 4], 4], [[-4, -3, -2, -1], -5], [[1, 2, 4, 10], 0], [[1, 4, 7, 10], 6], [[3.5, 2.2, 1.1], 5], [[1, 3, 4], 4], [[1, 4, 7, 10], -2], [[1, 4, -4, 7, 10], 6], [[1, 2, 3, -1, 4], 4], [[1, 3, 5, 7, 5], 10], [[4, -4, 7, 10], ... | 0 |
def below_threshold(l: list, t: int):
"""Return True if all numbers in the list l are below threshold t.
>>> below_threshold([1, 2, 4, 10], 100)
True
>>> below_threshold([1, 20, 4, 10], 5)
False
"""
| below_threshold | {"below_threshold": "esik_degerin_altinda", "l": "liste", "t": "esik_deger"} |
HumanEval/53 | def topla(birinci: int, ikinci: int):
"""birinci ve ikinci sayilarini topla
>>> topla(2, 3)
5
>>> topla(5, 7)
12
"""
| topla |
return birinci + ikinci
|
METADATA = {}
def check(candidate):
import random
assert candidate(0, 1) == 1
assert candidate(1, 0) == 1
assert candidate(2, 3) == 5
assert candidate(5, 7) == 12
assert candidate(7, 5) == 12
for i in range(100):
x, y = random.randint(0, 1000), random.randint(0, 1000)
a... |
assert isinstance(birinci, int), "invalid inputs" # $_CONTRACT_$
assert isinstance(ikinci, int), "invalid inputs" # $_CONTRACT_$
| [[0, 1], [1, 0], [2, 3], [5, 7], [7, 5], [480, 593], [139, 579], [300, 77], [569, 756], [911, 703], [197, 326], [123, 102], [671, 705], [101, 721], [735, 413], [923, 369], [938, 221], [59, 772], [540, 790], [244, 6], [705, 148], [890, 180], [342, 129], [946, 559], [623, 593], [825, 294], [124, 732], [333, 987], [269, 3... | [[-2, 3], [0, 0], [-5, -7], [10, -15], [999, 1], [-10, 10], [10000, -1000], [1, -1], [-5, 10], [-100, -250], [-250, -1], [-1, -2], [-6, -5], [-5, -8], [-15, -15], [-15, -250], [-10, -5], [-10, 1], [-1, -1], [-2, -2], [10000, -15], [10, 10], [-15, -2], [-6, -6], [-6, -8], [10000, -16], [-1000, 10], [-3, -2], [-1000, -25... | 0 |
def add(x: int, y: int):
"""Add two numbers x and y
>>> add(2, 3)
5
>>> add(5, 7)
12
"""
| add | {"add": "topla", "x": "birinci", "y": "ikinci"} |
HumanEval/54 | def ayni_karakterler(ilk_dize: str, ikinci_dize: str):
"""
Iki kelimenin ayni karakterlere sahip olup olmadigini kontrol edin.
>>> ayni_karakterler('eabcdzzzz', 'dddzzzzzzzddeddabc')
True
>>> ayni_karakterler('abcd', 'dddddddabc')
True
>>> ayni_karakterler('dddddddabc', 'abcd')
True
... | ayni_karakterler |
return set(ilk_dize) == set(ikinci_dize)
|
METADATA = {}
def check(candidate):
assert candidate('eabcdzzzz', 'dddzzzzzzzddeddabc') == True
assert candidate('abcd', 'dddddddabc') == True
assert candidate('dddddddabc', 'abcd') == True
assert candidate('eabcd', 'dddddddabc') == False
assert candidate('abcd', 'dddddddabcf') == False
asse... |
assert type(ilk_dize) == type(ikinci_dize) == str, "invalid inputs" # $_CONTRACT_$
| [["eabcdzzzz", "dddzzzzzzzddeddabc"], ["abcd", "dddddddabc"], ["dddddddabc", "abcd"], ["eabcd", "dddddddabc"], ["abcd", "dddddddabcf"], ["eabcdzzzz", "dddzzzzzzzddddabc"], ["aabb", "aaccc"]] | [["ab", "cd"], ["abcd", "cbad"], ["aaa", "aaa"], ["abc", "def"], ["aaabbbccc", "abbabcbc"], ["abcdefg", "gfedcba"], ["abbcccddddeeeee", "abcde"], ["12345", "54321"], ["hello", "world"], ["", ""], ["524321", "5432"], ["cdcd", ""], ["aaabbbccc", "abbbabcbc"], ["abbabcbc", "abc"], ["123445", "54321"], ["hoelldefo", "helld... | 0 |
def same_chars(s0: str, s1: str):
"""
Check if two words have the same characters.
>>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')
True
>>> same_chars('abcd', 'dddddddabc')
True
>>> same_chars('dddddddabc', 'abcd')
True
>>> same_chars('eabcd', 'dddddddabc')
False
>>> same... | same_chars | {"same_chars": "ayni_karakterler", "s0": "ilk_dize", "s1": "ikinci_dize"} |
HumanEval/55 | def fibonacci_sayisi(index: int):
"""n'inci Fibonacci sayisini dondurur.
>>> fibonacci_sayisi(10)
55
>>> fibonacci_sayisi(1)
1
>>> fibonacci_sayisi(8)
21
"""
| fibonacci_sayisi |
if index == 0: return 0
if index <= 2: return 1
a, b = 1, 1
for _ in range(3, index + 1):
a, b, = b, a + b
return b
|
METADATA = {}
def check(candidate):
assert candidate(10) == 55
assert candidate(1) == 1
assert candidate(8) == 21
assert candidate(11) == 89
assert candidate(12) == 144
|
assert index >= 0, "invalid inputs" # $_CONTRACT_$
assert isinstance(index, int), "invalid inputs" # $_CONTRACT_$
| [[10], [1], [8], [11], [12]] | [[0], [1], [false], [true], [16], [2], [17], [15], [14], [63], [64], [13], [3], [71], [72], [70], [35], [62], [69], [12], [36], [34], [61], [67], [4], [5], [11], [66], [10], [65], [74], [73], [75], [44], [28], [18], [6], [45], [68], [8], [29], [7], [27], [86], [60]] | 0 |
def fib(n: int):
"""Return n-th Fibonacci number.
>>> fib(10)
55
>>> fib(1)
1
>>> fib(8)
21
"""
| fib | {"fib": "fibonacci_sayisi", "n": "index"} |
HumanEval/56 | def parantez_duzelt(parantezler: str):
""" parantezler "<" ve ">" karakterlerinden olusan bir dizidir.
her bir acik parantezin karsiligi gelen bir kapanis parantezi varsa True dondurur.
>>> parantez_duzelt("<")
False
>>> parantez_duzelt("<>")
True
>>> parantez_duzelt("<<><>>")
True
... | parantez_duzelt |
cnt = 0
for x in parantezler:
if x == "<": cnt += 1
if x == ">": cnt -= 1
if cnt < 0: return False
return cnt == 0
|
METADATA = {}
def check(candidate):
assert candidate("<>")
assert candidate("<<><>>")
assert candidate("<><><<><>><>")
assert candidate("<><><<<><><>><>><<><><<>>>")
assert not candidate("<<<><>>>>")
assert not candidate("><<>")
assert not candidate("<")
assert not candidate("<<<<")
... |
assert type(parantezler) == str, "invalid inputs" # $_CONTRACT_$
assert all(x in "<>" for x in parantezler) # $_CONTRACT_$
| [["<>"], ["<<><>>"], ["<><><<><>><>"], ["<><><<<><><>><>><<><><<>>>"], ["<<<><>>>>"], ["><<>"], ["<"], ["<<<<"], [">"], ["<<>"], ["<><><<><>><>><<>"], ["<><><<><>><>>><>"]] | [["><"], ["<<<>>>"], ["><<<>>"], ["<<>>><><><><>>>><"], ["<<><><><>>>><>"], ["<<<"], [">><<"], ["<><>>>><<<<><>>><<>><>>>><<<<><>>>><<<<><>>>><<<<><>>>><"], [">>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"], ["<<>><>"], ["<<<<>><>>><>"], ["<<>>><><><>>>>><"], ["><<><><><>>>><><"], [""], ["<<><<"], ["<<<<"]... | 0 |
def correct_bracketing(brackets: str):
""" brackets is a string of "<" and ">".
return True if every opening bracket has a corresponding closing bracket.
>>> correct_bracketing("<")
False
>>> correct_bracketing("<>")
True
>>> correct_bracketing("<<><>>")
True
>>> correct_bracketin... | correct_bracketing | {"correct_bracketing": "parantez_duzelt", "brackets": "parantezler"} |
HumanEval/57 | def monoton(liste: list):
"""Liste elemanlarinin monoton artan veya azalan olup olmadigini dondurur.
>>> monoton([1, 2, 4, 20])
True
>>> monoton([1, 20, 4, 10])
False
>>> monoton([4, 1, 0, -10])
True
"""
| monoton |
inc, dec = True, True
for i in range(len(liste) - 1):
if liste[i] > liste[i + 1]: inc = False
if liste[i] < liste[i + 1]: dec = False
return inc or dec
|
METADATA = {}
def check(candidate):
assert candidate([1, 2, 4, 10]) == True
assert candidate([1, 2, 4, 20]) == True
assert candidate([1, 20, 4, 10]) == False
assert candidate([4, 1, 0, -10]) == True
assert candidate([4, 1, 1, 0]) == True
assert candidate([1, 2, 3, 2, 5, 60]) == False
ass... |
assert type(liste) == list, "invalid inputs" # $_CONTRACT_$
assert all(type(x) in (int, float, bool) for x in liste), "invalid inputs" # $_CONTRACT_$
| [[[1, 2, 4, 10]], [[1, 2, 4, 20]], [[1, 20, 4, 10]], [[4, 1, 0, -10]], [[4, 1, 1, 0]], [[1, 2, 3, 2, 5, 60]], [[1, 2, 3, 4, 5, 60]], [[9, 9, 9, 9]]] | [[[10, 9, 8, 7, 6]], [[1, 1, 1, 1, 1]], [[-5, -7, -9, -11]], [[1, 1, 2, 3, 3, 3, 4, 5]], [[5, 4, 3, 3, 3, 2, 1, 1]], [[1, 1, 1, 2, 1, 1, 1]], [[1, 1, 1, 1]], [[1, 2, 2, 3]], [[3, 2, 2, 1]], [[1, 3, 2, 4]], [[3, 4, 4]], [[2]], [[5, 1, 1, -7, 1, 5]], [[2, 1, 2]], [[1, 1]], [[1, 1, 1]], [[5, 1, -7, -9, 1, 5, 5]], [[5, 1, ... | 0 |
def monotonic(l: list):
"""Return True is list elements are monotonically increasing or decreasing.
>>> monotonic([1, 2, 4, 20])
True
>>> monotonic([1, 20, 4, 10])
False
>>> monotonic([4, 1, 0, -10])
True
"""
| monotonic | {"monotonic": "monoton", "l": "liste"} |
HumanEval/58 | def ortak(liste1: list, liste2: list):
"""Iki liste icin siralanmis benzersiz ortak elemanlari dondurur.
>>> ortak([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])
[1, 5, 653]
>>> ortak([5, 3, 2, 8], [3, 2])
[2, 3]
"""
| ortak |
return sorted(list(set(liste1).intersection(set(liste2))))
|
METADATA = {}
def check(candidate):
assert candidate([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121]) == [1, 5, 653]
assert candidate([5, 3, 2, 8], [3, 2]) == [2, 3]
assert candidate([4, 3, 2, 8], [3, 2, 4]) == [2, 3, 4]
assert candidate([4, 3, 2, 8], []) == []
|
assert type(liste1) == type(liste2) == list, "invalid inputs" # $_CONTRACT_$
| [[[1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121]], [[5, 3, 2, 8], [3, 2]], [[4, 3, 2, 8], [3, 2, 4]], [[4, 3, 2, 8], []]] | [[[1, 2, 3], [1, 2, 3]], [[], [1, 2, 3]], [[1, 2, 3], []], [[], []], [[1, 1, 2, 2, 3, 3], [2, 2, 3, 3, 4, 4]], [[1, 5, 10], [5, 7, 8]], [[1, 2, 3, 4, 5], [6, 7, 8, 9]], [[1, 1, 2, 3, 3, 3, 4], [1, 3, 5, 6]], [[1, 2, 3, 4], [1, 2, 3, 4]], [[1, 2, 3, 4], []], [["SgmW", "wdIIZAXJqx", "sRbO", "mqbFo", "", "vZmyAs", "dajGeq... | 0 |
def common(l1: list, l2: list):
"""Return sorted unique common elements for two lists.
>>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])
[1, 5, 653]
>>> common([5, 3, 2, 8], [3, 2])
[2, 3]
"""
| common | {"common": "ortak", "l1": "liste1", "l2": "liste2"} |
HumanEval/59 | def en_buyuk_asal_carpan(sayi: int):
"""sayinin en buyuk asal carpanini dondurur. sayi > 1 oldugu ve asal olmadigi varsayilir.
>>> en_buyuk_asal_carpan(13195)
29
>>> en_buyuk_asal_carpan(2048)
2
"""
| en_buyuk_asal_carpan |
isprime = [True] * (sayi + 1)
for i in range(2, sayi + 1):
if isprime[i]:
for j in range(i + i, sayi, i):
isprime[j] = False
for i in range(sayi - 1, 0, -1):
if isprime[i] and sayi % i == 0:
return i
|
METADATA = {}
def check(candidate):
assert candidate(15) == 5
assert candidate(27) == 3
assert candidate(63) == 7
assert candidate(330) == 11
assert candidate(13195) == 29
|
assert isinstance(sayi, int), "invalid inputs" # $_CONTRACT_$
def is_prime(a): # $_CONTRACT_$
return not (a < 2 or any(a % x == 0 for x in range(2, int(a ** 0.5) + 1))) # $_CONTRACT_$
assert sayi > 1 and not is_prime(sayi), "invalid inputs" # $_CONTRACT_$
| [[15], [27], [63], [330], [13195]] | [[100], [256], [500], [873], [9999], [121], [1764], [4096], [243], [1024], [4097], [1765], [120], [501], [4095], [10000], [255], [1025], [4094], [242], [1763], [254], [9998], [872], [9997], [502], [119], [9996], [874], [253], [252], [1762], [122], [4098], [871], [1023], [9995], [870], [99], [98], [118], [1761], [117], ... | 0 |
def largest_prime_factor(n: int):
"""Return the largest prime factor of n. Assume n > 1 and is not a prime.
>>> largest_prime_factor(13195)
29
>>> largest_prime_factor(2048)
2
"""
| largest_prime_factor | {"largest_prime_factor": "en_buyuk_asal_carpan", "n": "sayi"} |
HumanEval/60 | def n_kadar_topla(sayi_n: int):
"""n_kadar_topla, 1'den sayi_n'e kadar olan sayilari toplayan bir islevdir.
>>> n_kadar_topla(30)
465
>>> n_kadar_topla(100)
5050
>>> n_kadar_topla(5)
15
>>> n_kadar_topla(10)
55
>>> n_kadar_topla(1)
1
"""
| n_kadar_topla |
return (sayi_n + 1) * sayi_n // 2
|
METADATA = {}
def check(candidate):
assert candidate(1) == 1
assert candidate(6) == 21
assert candidate(11) == 66
assert candidate(30) == 465
assert candidate(100) == 5050
|
assert type(sayi_n) == int, "invalid inputs" # $_CONTRACT_$
assert sayi_n >= 1, "invalid inputs" # $_CONTRACT_$
| [[1], [6], [11], [30], [100]] | [[2], [3], [4], [7], [15], [20], [25], [50], [75], [1000], [14], [5], [16], [6], [26], [92], [19], [93], [94], [999], [51], [17], [21], [22], [8], [74], [52], [23], [91], [76], [24], [90], [18], [13], [27], [998], [55], [65], [1], [66], [73], [89], [56], [57], [997], [996], [77], [28], [87], [88], [72], [54], [53], [86... | 0 |
def sum_to_n(n: int):
"""sum_to_n is a function that sums numbers from 1 to n.
>>> sum_to_n(30)
465
>>> sum_to_n(100)
5050
>>> sum_to_n(5)
15
>>> sum_to_n(10)
55
>>> sum_to_n(1)
1
"""
| sum_to_n | {"sum_to_n": "n_kadar_topla", "n": "sayi_n"} |
HumanEval/61 | def parantez_duzgun(parantezler: str):
""" parantezler, '(' ve ')' karakterlerinden olusan bir dizgidir.
her acil parantez icin bir kapanis parantezi varsa True dondurur.
>>> parantez_duzgun("(")
False
>>> parantez_duzgun("()")
True
>>> parantez_duzgun("(()())")
True
>>> parantez_du... | parantez_duzgun |
cnt = 0
for x in parantezler:
if x == "(": cnt += 1
if x == ")": cnt -= 1
if cnt < 0: return False
return cnt == 0
|
METADATA = {}
def check(candidate):
assert candidate("()")
assert candidate("(()())")
assert candidate("()()(()())()")
assert candidate("()()((()()())())(()()(()))")
assert not candidate("((()())))")
assert not candidate(")(()")
assert not candidate("(")
assert not candidate("((((")
... |
assert type(parantezler) == str, "invalid inputs" # $_CONTRACT_$
assert all(x in "()" for x in parantezler) # $_CONTRACT_$
| [["()"], ["(()())"], ["()()(()())()"], ["()()((()()())())(()()(()))"], ["((()())))"], [")(()"], ["("], ["(((("], [")"], ["(()"], ["()()(()())())(()"], ["()()(()())()))()"]] | [["()()()()()"], ["((((()))))"], ["((())))("], [")()()))("], ["((())"], ["(()))()"], ["((()))"], [")()()()"], [")("], [")))))))"], ["((())((())"], [")()()))()()()()()"], ["))("], ["(())))()"], [")()()))()()()())(()"], ["()(()))"], ["((()))()()))()()()())(()"], ["((())))()"], ["(("], ["((()))()(())))"], ["()(((())))()))... | 0 |
def correct_bracketing(brackets: str):
""" brackets is a string of "(" and ")".
return True if every opening bracket has a corresponding closing bracket.
>>> correct_bracketing("(")
False
>>> correct_bracketing("()")
True
>>> correct_bracketing("(()())")
True
>>> correct_bracketin... | correct_bracketing | {"correct_bracketing": "parantez_duzgun", "brackets": "parantezler"} |
HumanEval/62 | def turev(katsayilar: list):
""" katsayilar bir polinomin katsayilarini temsil eder.
katsayilar[0] + katsayilar[1] * x + katsayilar[2] * x^2 + ....
Bu polinomin turevini ayni formda dondurun.
>>> turev([3, 1, 2, 4, 5])
[1, 4, 12, 20]
>>> turev([1, 2, 3])
[2, 6]
"""
| turev |
return [katsayilar[i] * i for i in range(1, len(katsayilar))]
|
METADATA = {}
def check(candidate):
assert candidate([3, 1, 2, 4, 5]) == [1, 4, 12, 20]
assert candidate([1, 2, 3]) == [2, 6]
assert candidate([3, 2, 1]) == [2, 2]
assert candidate([3, 2, 1, 0, 4]) == [2, 2, 0, 16]
assert candidate([1]) == []
|
assert len(katsayilar) > 0, "invalid inputs" # $_CONTRACT_$
assert all(type(x) in (int, float) for x in katsayilar), "invalid inputs" # $_CONTRACT_$
| [[[3, 1, 2, 4, 5]], [[1, 2, 3]], [[3, 2, 1]], [[3, 2, 1, 0, 4]], [[1]]] | [[[0, 0, 0, 0, 0, 5]], [[1, 0, 0, 0, 0, 0, 0]], [[0, 2, 0, 3, 0, 4, 0, 5]], [[0, 0, 0, 6, 0, 0, 0, 7, 0, 0, 0, 8, 0]], [[0, 0, 0, 0, 0]], [[1, 0, -2, 0, 5, 0, 0, 10]], [[2, 0, 3, 0, 1, 0, 0, -2, 0, 6]], [[1, -1, 1, -1, 1, -1, 1]], [[4, 0, 1, 0, 4]], [[6, 2, 0, 7]], [[0, 0, 0, 0, 0, 0]], [[0, 2, 0, 0, 4, 0, 5]], [[2, 0,... | 0 |
def derivative(xs: list):
""" xs represent coefficients of a polynomial.
xs[0] + xs[1] * x + xs[2] * x^2 + ....
Return derivative of this polynomial in the same form.
>>> derivative([3, 1, 2, 4, 5])
[1, 4, 12, 20]
>>> derivative([1, 2, 3])
[2, 6]
"""
| derivative | {"derivative": "turev", "xs": "katsayilar"} |
HumanEval/63 | def fibfib_sayisi(sayi: int):
"""FibFib sayi dizisi, asagidaki gibi tanimlanan Fibonacci dizisine benzer bir dizidir:
fibfib_sayisi(0) == 0
fibfib_sayisi(1) == 0
fibfib_sayisi(2) == 1
fibfib_sayisi(sayi) == fibfib_sayisi(sayi-1) + fibfib_sayisi(sayi-2) + fibfib_sayisi(sayi-3).
Lutfen fibfib... | fibfib_sayisi |
if sayi == 0 or sayi == 1:
return 0
elif sayi == 2:
return 1
a, b, c = 0, 0, 1
for _ in range(3, sayi + 1):
a, b, c = b, c, a + b + c
return c
|
METADATA = {}
def check(candidate):
assert candidate(2) == 1
assert candidate(1) == 0
assert candidate(5) == 4
assert candidate(8) == 24
assert candidate(10) == 81
assert candidate(12) == 274
assert candidate(14) == 927
|
assert isinstance(sayi, int), "invalid inputs" # $_CONTRACT_$
assert sayi >= 0, "invalid inputs" # $_CONTRACT_$
| [[2], [1], [5], [8], [10], [12], [14]] | [[20], [0], [15], [23], [21], [25], [1], [14], [13], [19], [57], [22], [24], [56], [18], [false], [true], [58], [12], [11], [2], [26], [60], [4], [59], [16], [27], [28], [3], [17], [61], [10], [62], [29], [30], [31], [32], [48], [47], [46], [55], [49], [50], [51], [52], [53], [54], [33], [73], [34], [63], [45], [72], [... | 0 |
def fibfib(n: int):
"""The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
fibfib(0) == 0
fibfib(1) == 0
fibfib(2) == 1
fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
Please write a function to efficiently compute the n-th element of th... | fibfib | {"fibfib": "fibfib_sayisi", "n": "sayi"} |
HumanEval/64 | DUZELTME = """
Daha fazla test durumu ekleyin.
"""
def unlu_harf_sayisi(kelime):
"""Bir kelimeyi temsil eden bir string alan ve stringdeki unlu harf sayisini donduren
unlu_harf_sayisi fonksiyonunu yaziniz. Bu durumda unlu harfler 'a', 'e', 'i', 'o', 'u'dur. Burada 'y' de bir
unlu harftir, ancak sadece veri... | unlu_harf_sayisi |
if kelime == "": return 0
cnt = len(list(filter(lambda ch: ch in "aeiouAEIOU", kelime)))
if kelime[-1] in "yY": cnt += 1
return cnt
| def check(candidate):
# Check some simple cases
assert candidate("abcde") == 2, "Test 1"
assert candidate("Alone") == 3, "Test 2"
assert candidate("key") == 2, "Test 3"
assert candidate("bye") == 1, "Test 4"
assert candidate("keY") == 2, "Test 5"
assert candidate("bYe") == 1, "Test 6"
a... |
assert type(kelime) == str, "invalid inputs" # $_CONTRACT_$
| [["abcde"], ["Alone"], ["key"], ["bye"], ["keY"], ["bYe"], ["ACEDY"]] | [["hello"], ["apple"], ["time"], ["glue"], ["candy"], ["parody"], ["monkey"], ["why"], ["bay"], ["aeiouy"], ["JBXFOFH"], ["c"], ["aeiouyaeiouy"], ["aeiouoy"], ["applebay"], ["eaeiouy"], ["applebaglue"], ["glumonkeye"], ["ndy"], ["ctieme"], ["wyhy"], ["parpody"], ["apndyple"], ["glumonglluekeye"], ["ctiparpodyecme"], ["... | 0 |
FIX = """
Add more test cases.
"""
def vowels_count(s):
"""Write a function vowels_count which takes a string representing
a word as input and returns the number of vowels in the string.
Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
vowel, but only when it is at the end of the g... | vowels_count | {"vowels_count": "unlu_harf_sayisi", "s": "kelime"} |
HumanEval/65 | def dairesel_kaydir(sayi, kaydir):
"""tamsayi sayi'nin basamaklarini dairesel olarak kaydir, basamaklari kaydir kadar saga kaydir
ve sonucu bir dize olarak dondur.
Eger kaydir > basamak sayisi ise, basamaklari ters cevrilmis olarak dondur.
>>> dairesel_kaydir(12, 1)
"21"
>>> dairesel_kaydir(12, ... | dairesel_kaydir |
s = str(sayi)
if kaydir > len(s): return s[::-1]
kaydir %= len(s)
if kaydir == 0:
return s
else:
return s[len(s) - kaydir:] + s[:len(s) - kaydir]
| def check(candidate):
# Check some simple cases
assert candidate(100, 2) == "001"
assert candidate(12, 2) == "12"
assert candidate(97, 8) == "79"
assert candidate(12, 1) == "21", "This prints if this assert fails 1 (good for debugging!)"
# Check some edge cases that are easy to work out by han... |
assert type(sayi) == type(kaydir) == int, "invalid inputs" # $_CONTRACT_$
assert sayi >= 0 and kaydir >= 0, "invalid inputs" # $_CONTRACT_$
| [[100, 2], [12, 2], [97, 8], [12, 1], [11, 101]] | [[16, 3], [1234, 6], [341209, 4], [789456123, 10], [500, 4], [345, 1], [86314, 3], [22, 4], [987654321, 9], [777, 10], [23, 789456124], [341209, 3], [341209, 341209], [789456123, 23], [789456122, 789456123], [500, 3], [23, 16], [789456123, 777], [15, 2], [789456122, 789456122], [23, 22], [789456124, 789456124], [2, 3],... | 0 |
def circular_shift(x, shift):
"""Circular shift the digits of the integer x, shift the digits right by shift
and return the result as a string.
If shift > number of digits, return digits reversed.
>>> circular_shift(12, 1)
"21"
>>> circular_shift(12, 2)
"12"
"""
| circular_shift | {"circular_shift": "dairesel_kaydir", "x": "sayi", "shift": "kaydir"} |
HumanEval/66 | def buyukHarfAsciiToplami(metin):
"""Gorev
Girdi olarak bir metin alan ve sadece buyuk harflerin ASCII kodlarinin toplamini donduren bir fonksiyon yazin.
Ornekler:
buyukHarfAsciiToplami("") => 0
buyukHarfAsciiToplami("abAB") => 131
buyukHarfAsciiToplami("abcCd") => 67
buyukH... | buyukHarfAsciiToplami |
return sum([ord(ch) for ch in metin if ch.isupper()])
| def check(candidate):
# Check some simple cases
assert True, "This prints if this assert fails 1 (good for debugging!)"
assert candidate("") == 0, "Error"
assert candidate("abAB") == 131, "Error"
assert candidate("abcCd") == 67, "Error"
assert candidate("helloE") == 69, "Error"
assert candi... |
assert type(metin) == str, "invalid inputs" # $_CONTRACT_$
| [[""], ["abAB"], ["abcCd"], ["helloE"], ["woArBld"], ["aAaaaXa"], [" How are yOu?"], ["You arE Very Smart"]] | [["123"], ["ABCD"], ["abcd"], ["HELLOworld"], [":;<=>?@[\\]^_`{|}~"], ["ABC123def456GHI"], [" A B C D "], ["UPPER"], ["lowercase"], ["Ab56"], ["lowrcase"], ["ABC123def45l6GHlowrcaseI"], ["1123"], [":;<=>?@[\\]^_`{ABC123def456GHI"], ["HELLOworrld"], ["lowercalowercasese"], [" A B C D "], [" A B C D "], ["1Ab... | 0 |
def digitSum(s):
"""Task
Write a function that takes a string as input and returns the sum of the upper characters only'
ASCII codes.
Examples:
digitSum("") => 0
digitSum("abAB") => 131
digitSum("abcCd") => 67
digitSum("helloE") => 69
digitSum("woArBld") => 131
... | digitSum | {"digitSum": "buyukHarfAsciiToplami", "s": "metin"} |
HumanEval/67 | def meyve_dagilimi(meyve_metni,toplam_meyve):
"""
Bu gorevde, bir meyve sepetinde dagitilan elma ve portakal sayisini temsil eden bir metin alacaksiniz. Bu sepet elma, portakal ve mangodan olusmaktadir. Portakal ve elma sayilarini temsil eden metin ve sepetteki toplam meyve sayisini temsil eden bir tamsayi veri... | meyve_dagilimi |
words = meyve_metni.split(" ")
c1, c2 = int(words[0]), int(words[3])
assert toplam_meyve - c1 - c2 >= 0, "invalid inputs" # $_CONTRACT_$
return toplam_meyve - c1 - c2
| def check(candidate):
# Check some simple cases
assert candidate("5 apples and 6 oranges",19) == 8
assert candidate("5 apples and 6 oranges",21) == 10
assert candidate("0 apples and 1 oranges",3) == 2
assert candidate("1 apples and 0 oranges",3) == 2
assert candidate("2 apples and 3 oranges",10... |
assert type(meyve_metni) == str and type(toplam_meyve) == int, "invalid inputs" # $_CONTRACT_$
words = meyve_metni.split(" ") # $_CONTRACT_$
assert len(words) == 5, "invalid inputs" # $_CONTRACT_$
assert words[1] == "apples" and words[2] == "and" and words[4] == "oranges", "invalid inputs" # $_CONTRACT... | [["5 apples and 6 oranges", 19], ["5 apples and 6 oranges", 21], ["0 apples and 1 oranges", 3], ["1 apples and 0 oranges", 3], ["2 apples and 3 oranges", 100], ["2 apples and 3 oranges", 5], ["1 apples and 100 oranges", 120]] | [["10 apples and 20 oranges", 50], ["3 apples and 4 oranges", 9], ["7 apples and 8 oranges", 30], ["2 apples and 0 oranges", 5], ["0 apples and 0 oranges", 10], ["0 apples and 1 oranges", 1], ["10 apples and 0 oranges", 15], ["3 apples and 5 oranges", 12], ["5 apples and 5 oranges", 12], ["8 apples and 2 oranges", 15],... | 0 |
def fruit_distribution(s,n):
"""
In this task, you will be given a string that represents a number of apples and oranges
that are distributed in a basket of fruit this basket contains
apples, oranges, and mango fruits. Given the string that represents the total number of
the oranges and apples a... | fruit_distribution | {"fruit_distribution": "meyve_dagilimi", "s": "meyve_metni", "n": "toplam_meyve"} |
HumanEval/68 | def budak_sec(dizisi):
"""
"Bir agacin budagini temsil eden ve negatif olmayan tamsayi dugumleri iceren bir dizi verildiginde,
goreviniz dugumlerden birini secip dondurmektir.
Secilen dugum, en kucuk cift degeri olan dugum olmalidir.
Ayni en kucuk cift degeri birden fazla dugum bulun... | budak_sec |
if all(val % 2 == 1 for val in dizisi): return []
min_even = min(filter(lambda x: x % 2 == 0, dizisi))
for i in range(len(dizisi)):
if dizisi[i] == min_even:
return [min_even, i]
| def check(candidate):
# Check some simple cases
assert True, "This prints if this assert fails 1 (good for debugging!)"
assert candidate([4,2,3]) == [2, 1], "Error"
assert candidate([1,2,3]) == [2, 1], "Error"
assert candidate([]) == [], "Error"
assert candidate([5, 0, 3, 0, 4, 2]) == [0, 1], "... |
assert len(dizisi) <= 10000, "invalid inputs" # $_CONTRACT_$
assert all(type(val) == int and val >= 0 for val in dizisi), "invalid inputs" # $_CONTRACT_$
| [[[4, 2, 3]], [[1, 2, 3]], [[]], [[5, 0, 3, 0, 4, 2]], [[1, 2, 3, 0, 5, 3]], [[5, 4, 8, 4, 8]], [[7, 6, 7, 1]], [[7, 9, 7, 1]]] | [[[1, 3, 5, 7, 9]], [[2, 2, 2, 2, 2, 2]], [[7, 15, 12, 21, 8, 13]], [[2, 5, 7, 9, 11]], [[0, 0, 0, 0, 0]], [[6, 4, 2, 0, 8, 10]], [[101, 202, 303]], [[6, 4, 2, 0, 8, 10, 1, 3, 5, 7, 9, 11]], [[2, 4, 6, 8]], [[5, 10, 15, 20]], [[2, 2, 2, 2, 2]], [[2, 4, 7, 6, 8]], [[101, 202]], [[1, 3, 5, 9]], [[5, 10, 15, 20, 15]], [[2... | 0 |
def pluck(arr):
"""
"Given an array representing a branch of a tree that has non-negative integer nodes
your task is to pluck one of the nodes and return it.
The plucked node should be the node with the smallest even value.
If multiple nodes with the same smallest even value are found return the no... | pluck | {"pluck": "budak_sec", "arr": "dizisi"} |
HumanEval/69 | def ara(liste):
'''
Pozitif tam sayilardan olusan bos olmayan bir liste veriliyor. Sifirdan buyuk olan ve degeri kadar ya da daha fazla frekansa sahip olan en buyuk tam sayiyi dondurun.
Bir tam sayinin frekansi, listede ne kadar kez gorundugunun sayisidir.
Boyle bir deger yoksa, -1 dondurun.
Ornekle... | ara |
count = dict()
for num in liste:
if num not in count:
count[num] = 0
count[num] += 1
ans = -1
for num, cnt in count.items():
if cnt >= num:
ans = max(ans, num)
return ans
| def check(candidate):
# manually generated tests
assert candidate([5, 5, 5, 5, 1]) == 1
assert candidate([4, 1, 4, 1, 4, 4]) == 4
assert candidate([3, 3]) == -1
assert candidate([8, 8, 8, 8, 8, 8, 8, 8]) == 8
assert candidate([2, 3, 3, 2, 2]) == 2
# automatically generated tests
assert... |
assert all(type(val) == int and val > 0 for val in liste), "invalid inputs" # $_CONTRACT_$
| [[[5, 5, 5, 5, 1]], [[4, 1, 4, 1, 4, 4]], [[3, 3]], [[8, 8, 8, 8, 8, 8, 8, 8]], [[2, 3, 3, 2, 2]], [[2, 7, 8, 8, 4, 8, 7, 3, 9, 6, 5, 10, 4, 3, 6, 7, 1, 7, 4, 10, 8, 1]], [[3, 2, 8, 2]], [[6, 7, 1, 8, 8, 10, 5, 8, 5, 3, 10]], [[8, 8, 3, 6, 5, 6, 4]], [[6, 9, 6, 7, 1, 4, 7, 1, 8, 8, 9, 8, 10, 10, 8, 4, 10, 4, 10, 1, 2, ... | [[[3, 2, 1, 1, 1, 1, 1]], [[5, 5, 5, 5, 5, 5, 5]], [[2, 2, 2, 2, 2, 2, 2, 2]], [[1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]], [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]], [[1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 4, 4, 4]], [[2, 2, 2, 2, 2, 2, 2, 2, 2]], [[1, 2, 4, 4, 4, 4]], [[1, 1, 1, 2, 2, ... | 0 |
def search(lst):
'''
You are given a non-empty list of positive integers. Return the greatest integer that is greater than
zero, and has a frequency greater than or equal to the value of the integer itself.
The frequency of an integer is the number of times it appears in the list.
If no such a va... | search | {"search": "ara", "lst": "liste"} |
HumanEval/70 | def tuhaf_siralama_listesi(liste):
'''
Verilen tamsayi listesini, tuhaf bir sirada dondurun.
Tuhaf siralama, minimum degerle baslayip,
kalan tamsayilarin maksimumunu, ardindan minimumunu ve boylece devam etmenizi gerektirir.
Ornekler:
tuhaf_siralama_listesi([1, 2, 3, 4]) == [1, 4, 2, 3]
tuh... | tuhaf_siralama_listesi |
sorted_list = sorted(liste)
ans, i, j = [], 0, len(sorted_list) - 1
while i < j:
ans.append(sorted_list[i])
ans.append(sorted_list[j])
i += 1
j -= 1
if i == j: ans.append(sorted_list[i])
return ans
| def check(candidate):
# Check some simple cases
assert candidate([1, 2, 3, 4]) == [1, 4, 2, 3]
assert candidate([5, 6, 7, 8, 9]) == [5, 9, 6, 8, 7]
assert candidate([1, 2, 3, 4, 5]) == [1, 5, 2, 4, 3]
assert candidate([5, 6, 7, 8, 9, 1]) == [1, 9, 5, 8, 6, 7]
assert candidate([5, 5, 5, 5]) == [... |
assert type(liste) == list, "invalid inputs" # $_CONTRACT_$
assert all(type(x) == int for x in liste), "invalid inputs" # $_CONTRACT_$
| [[[1, 2, 3, 4]], [[5, 6, 7, 8, 9]], [[1, 2, 3, 4, 5]], [[5, 6, 7, 8, 9, 1]], [[5, 5, 5, 5]], [[]], [[1, 2, 3, 4, 5, 6, 7, 8]], [[0, 2, 2, 2, 5, 5, -5, -5]], [[111111]]] | [[[-5, 0, 5, 10]], [[10, 9, 8, 7, 6, 5]], [[2, 4, 6, 8, 10, 12]], [[1, 3, 5, 2, 4, 6]], [[100, 200, 300, 150, 75, 35, 10]], [[8, 4, 2, 6, 10]], [[2, 1, 4, 3, 6, 5]], [[-1, 0, 1, 2, 3, 4]], [[8, 8, 8, 8]], [[1]], [[10, 9, 8, 75, 6, 5]], [[-5, 0, 150, 5]], [[10, 9, 8, 150, 6, 5]], [[-5, 0, 5, 10, -5]], [[8, 4, 2, 6, 10, ... | 0 |
def strange_sort_list(lst):
'''
Given list of integers, return list in strange order.
Strange sorting, is when you start with the minimum value,
then maximum of the remaining integers, then minimum and so on.
Examples:
strange_sort_list([1, 2, 3, 4]) == [1, 4, 2, 3]
strange_sort_list([5, 5... | strange_sort_list | {"strange_sort_list": "tuhaf_siralama_listesi", "lst": "liste"} |
HumanEval/71 | def ucgen_alani(kenar_a, kenar_b, kenar_c):
'''
Bir ucgenin uc kenarinin uzunluklarini alin. Gecerli bir ucgen olusturuyorsa,
ucgenin alanini 2 ondalik basamak yuvarlanmis sekilde dondurun.
Aksi takdirde -1 dondurun.
Uc kenar, herhangi iki kenarin toplami ucuncu kenardan buyuk oldugunda gecerli bir... | ucgen_alani |
if kenar_a + kenar_b <= kenar_c or kenar_a + kenar_c <= kenar_b or kenar_b + kenar_c <= kenar_a: return -1
p = (kenar_a + kenar_b + kenar_c) / 2
return round((p * (p - kenar_a) * (p - kenar_b) * (p - kenar_c)) ** 0.5, 2)
| def check(candidate):
# Check some simple cases
assert candidate(3, 4, 5) == 6.00, "This prints if this assert fails 1 (good for debugging!)"
assert candidate(1, 2, 10) == -1
assert candidate(4, 8, 5) == 8.18
assert candidate(2, 2, 2) == 1.73
assert candidate(1, 2, 3) == -1
assert candidate... |
assert kenar_a > 0 and kenar_b > 0 and kenar_c > 0, "invalid inputs" # $_CONTRACT_$
| [[3, 4, 5], [1, 2, 10], [4, 8, 5], [2, 2, 2], [1, 2, 3], [10, 5, 7], [2, 6, 3], [1, 1, 1], [2, 2, 10]] | [[8, 9, 15], [10, 12, 15], [7, 7, 10], [3.6, 4.8, 6.1], [8, 15, 17], [6, 8, 10], [5, 5, 8], [9, 12, 15], [7, 24, 25], [2, 3, 4], [24, 23, 25], [7, 7, 7], [3, 5, 4], [24, 24, 25], [9, 11, 15], [6, 8, 4], [3, 23, 25], [2, 5, 4], [8, 9, 17], [3, 2, 3], [2, 9, 2], [5, 8, 8], [8, 15, 2], [10, 12, 3], [6, 17, 4], [7, 7, 11],... | 0 |
def triangle_area(a, b, c):
'''
Given the lengths of the three sides of a triangle. Return the area of
the triangle rounded to 2 decimal points if the three sides form a valid triangle.
Otherwise return -1
Three sides make a valid triangle when the sum of any two sides is greater
than the thi... | triangle_area | {"triangle_area": "ucgen_alani", "a": "kenar_a", "b": "kenar_b", "c": "kenar_c"} |
HumanEval/72 | def ucuyor_mu(nesne, maks_agirlik):
'''
Nesnenin ucup ukmayacagini belirten True veya False degerini donduren bir fonksiyon yazin.
Nesne dengeli (palindromik bir liste) ve elemanlarinin toplami maksimum agirlik maks_agirlik'den kucuk veya esitse ucar.
Ornek:
ucuyor_mu([1, 2], 5) ➞ False
# 1+2 ... | ucuyor_mu |
return nesne == nesne[::-1] and sum(nesne) <= maks_agirlik
| def check(candidate):
# Check some simple cases
assert candidate([3, 2, 3], 9) is True
assert candidate([1, 2], 5) is False
assert candidate([3], 5) is True
assert candidate([3, 2, 3], 1) is False
# Check some edge cases that are easy to work out by hand.
assert candidate([1, 2, 3], 6) is... |
assert type(nesne) == list and all(type(x) in [int, float] for x in nesne), "invalid inputs" # $_CONTRACT_$
assert type(maks_agirlik) in [int, float], "invalid inputs" # $_CONTRACT_$
| [[[3, 2, 3], 9], [[1, 2], 5], [[3], 5], [[3, 2, 3], 1], [[1, 2, 3], 6], [[5], 5]] | [[[0], 0], [[1, 2, 1], 4], [[2, 3, 2], 7], [[1], 0], [[4, 2, 1, 2, 4], 13], [[4, 2, 1, 2, 4], 12], [[1, 2, 3, 2, 1], 7], [[1, 2, 3], 10], [[1, 2, 3, 2, 1], 10], [[1, 1, 1, 1, 1, 1, 1], 7], [[4, 2, 1, 2, 4, 4], 14], [[1, 0], 0], [[1, 2, 3], 0], [[1, 1, 0], 0], [[7, 2, 3], 0], [[1, 1], 0], [[1, 1], 3], [[1, 0], 7], [[1, ... | 0 |
def will_it_fly(q,w):
'''
Write a function that returns True if the object q will fly, and False otherwise.
The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w.
Example:
will_it_fly([1, 2], 5) ➞ False
... | will_it_fly | {"will_it_fly": "ucuyor_mu", "q": "nesne", "w": "maks_agirlik"} |
HumanEval/73 | def en_kucuk_degisim(dizi):
"""
Tam sayi iceren bir dizi verildiginde, diziyi palindromik hale getirmek icin degistirilmesi gereken minimum eleman sayisini bulun. Palindromik bir dizi, geriye ve ileriye dogru okundugunda ayni olan bir dizidir. Bir degisimde, bir elemani herhangi bir baska elemana degistirebilir... | en_kucuk_degisim |
arr_reversed, cnt = dizi[::-1], 0
for i in range(len(dizi) // 2):
if dizi[i] != arr_reversed[i]:
cnt += 1
return cnt
| def check(candidate):
# Check some simple cases
assert candidate([1,2,3,5,4,7,9,6]) == 4
assert candidate([1, 2, 3, 4, 3, 2, 2]) == 1
assert candidate([1, 4, 2]) == 1
assert candidate([1, 4, 4, 2]) == 1
# Check some edge cases that are easy to work out by hand.
assert candidate([1, 2, 3, 2... |
assert type(dizi) == list, "invalid inputs" # $_CONTRACT_$
assert all(type(x) == int for x in dizi), "invalid inputs" # $_CONTRACT_$
| [[[1, 2, 3, 5, 4, 7, 9, 6]], [[1, 2, 3, 4, 3, 2, 2]], [[1, 4, 2]], [[1, 4, 4, 2]], [[1, 2, 3, 2, 1]], [[3, 1, 1, 3]], [[1]], [[0, 1]]] | [[[1, 2, 3, 4, 5]], [[1, 2, 2, 1]], [[1, 1, 1, 1]], [[1, 2, 3, 4, 4, 3, 2, 1]], [[1, 2, 3, 4, 2, 3, 2, 1]], [[1, 2, 3, 3, 3, 3, 2, 1]], [[1, 2, 3, 2, 2, 2, 2, 1]], [[1, 2, 2, 2, 2, 2, 3, 4]], [[1, 1, 2, 2, 3, 3, 4, 4]], [[5, 4, 3, 2, 1]], [[2, 2, 3, 4, 4, 3, 2, 1]], [[1, 2, 2, 1, 2]], [[1, 2, 2, 2, 1]], [[1, 1, 2, 2, 1... | 0 |
def smallest_change(arr):
"""
Given an array arr of integers, find the minimum number of elements that
need to be changed to make the array palindromic. A palindromic array is an array that
is read the same backwards and forwards. In one change, you can change one element to any other element.
For... | smallest_change | {"smallest_change": "en_kucuk_degisim", "arr": "dizi"} |
HumanEval/74 | def toplam_eslesme(liste1, liste2):
'''
Iki dize listesi alan ve listedeki tum dizelerin toplam karakter sayisi diger listeden daha az olan listeyi donduren bir fonksiyon yazin.
Eger iki listedeki toplam karakter sayisi ayni ise, ilk listeyi dondurun.
Ornekler
toplam_eslesme([], []) ➞ []
topla... | toplam_eslesme |
c1, c2 = sum(map(lambda s: len(s), liste1)), sum(map(lambda s: len(s), liste2))
return liste1 if c1 <= c2 else liste2
| def check(candidate):
# Check some simple cases
assert True, "This prints if this assert fails 1 (good for debugging!)"
assert candidate([], []) == []
assert candidate(['hi', 'admin'], ['hi', 'hi']) == ['hi', 'hi']
assert candidate(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) == ['hi', 'admin... |
assert type(liste1) == type(liste2) == list, "invalid inputs" # $_CONTRACT_$
assert all(type(x) == str for x in liste1), "invalid inputs" # $_CONTRACT_$
assert all(type(x) == str for x in liste2), "invalid inputs" # $_CONTRACT_$
| [[[], []], [["hi", "admin"], ["hi", "hi"]], [["hi", "admin"], ["hi", "hi", "admin", "project"]], [["4"], ["1", "2", "3", "4", "5"]], [["hi", "admin"], ["hI", "Hi"]], [["hi", "admin"], ["hI", "hi", "hi"]], [["hi", "admin"], ["hI", "hi", "hii"]], [[], ["this"]], [["this"], []]] | [[[""], ["hello"]], [["hello", "world"], ["hi", "there"]], [["coding", "is", "fun"], ["coding", "is", "awesome"]], [["abc"], ["abcdefghijklmnopqrstuvwxyz"]], [["happy", "new", "year"], ["merry", "christmas"]], [["happy", "new", "year"], ["happy", "new", "year", "2022"]], [["happy", "birthday", "sarah"], ["happy", "birt... | 0 |
def total_match(lst1, lst2):
'''
Write a function that accepts two lists of strings and returns the list that has
total number of chars in the all strings of the list less than the other list.
if the two lists have the same number of chars, return the first list.
Examples
total_match([], [])... | total_match | {"total_match": "toplam_eslesme", "lst1": "liste1", "lst2": "liste2"} |
HumanEval/75 | def uc_asal_carpan_mi(sayi):
"""Verilen sayinin 3 asal sayinin carpimi olup olmadigini kontrol eden ve dogruysa true, degilse false donduren bir fonksiyon yazin.
(sayi) 100'den kucuk oldugunu biliyoruz.
Ornek:
uc_asal_carpan_mi(30) == True
30 = 2 * 3 * 5
"""
| uc_asal_carpan_mi |
if sayi <= 1: return False
isprime = [True] * (sayi + 1)
for i in range(2, sayi + 1):
if isprime[i]:
for j in range(i + i, sayi + 1, i):
isprime[j] = False
cnt, tmp = 0, sayi
for i in range(2, sayi + 1):
while isprime[i] and tmp % i == 0:
tmp ... | def check(candidate):
assert candidate(5) == False
assert candidate(30) == True
assert candidate(8) == True
assert candidate(10) == False
assert candidate(125) == True
assert candidate(3 * 5 * 7) == True
assert candidate(3 * 6 * 7) == False
assert candidate(9 * 9 * 9) == False
asser... |
assert type(sayi) == int, "invalid inputs" # $_CONTRACT_$
assert sayi < 100, "invalid inputs" # $_CONTRACT_$
| [[5], [30], [8], [10]] | [[33], [49], [77], [91], [99], [6], [90], [98], [25], [21], [48], [20], [22], [32], [26], [78], [19], [47], [31], [5], [29], [-98], [-37], [-38], [28], [18], [23], [-92], [-2], [57], [-99], [58], [56], [-1], [92], [1], [-80], [34], [-75], [-100], [-95], [16], [-94], [17], [59], [-7], [93], [-82], [-15], [-81], [-96], [... | 0 |
def is_multiply_prime(a):
"""Write a function that returns true if the given number is the multiplication of 3 prime numbers
and false otherwise.
Knowing that (a) is less then 100.
Example:
is_multiply_prime(30) == True
30 = 2 * 3 * 5
"""
| is_multiply_prime | {"is_multiply_prime": "uc_asal_carpan_mi", "a": "sayi"} |
HumanEval/76 | def basit_kuvvet_mi(sayi, taban):
"""Goreviniz, bir sayinin tabanin basit kuvveti olup olmadigini kontrol eden ve dogru durumda true,
diger durumlarda false donduren bir fonksiyon yazmaktir.
sayi, tabanin basit kuvvetidir eger taban**int=sayi ise.
Ornek olarak:
basit_kuvvet_mi(1, 4) => true
basi... | basit_kuvvet_mi |
if sayi == 1: return True
if taban == 0: return sayi == 0
if taban == 1: return sayi == 1
if taban == -1: return abs(sayi) == 1
p = taban
while abs(p) <= abs(sayi):
if p == sayi: return True
p = p * taban
return False
| def check(candidate):
# Check some simple cases
assert candidate(16, 2)== True, "This prints if this assert fails 1 (good for debugging!)"
assert candidate(143214, 16)== False, "This prints if this assert fails 1 (good for debugging!)"
assert candidate(4, 2)==True, "This prints if this assert fails 1 (... |
assert type(sayi) == int and type(taban) == int, "invalid inputs" # $_CONTRACT_$
| [[16, 2], [143214, 16], [4, 2], [9, 3], [16, 4], [24, 2], [128, 4], [12, 6], [1, 1], [1, 12]] | [[25, 5], [81, 3], [64, 4], [36, 6], [10, 2], [20, 5], [15, 3], [35, 5], [49, 7], [125, 5], [5, 5], [23, 5], [25, 23], [23, 2], [21, 2], [6, 5], [6, 7], [81, 6], [64, 6], [2, 2], [2, 5], [23, 23], [25, 6], [82, 3], [82, 7], [81, 81], [10, 3], [36, 5], [15, 23], [7, 15], [82, 2], [10, 81], [49, 8], [81, 7], [21, 35], [2... | 0 |
def is_simple_power(x, n):
"""Your task is to write a function that returns true if a number x is a simple
power of n and false in other cases.
x is a simple power of n if n**int=x
For example:
is_simple_power(1, 4) => true
is_simple_power(2, 2) => true
is_simple_power(8, 2) => true
is_... | is_simple_power | {"is_simple_power": "basit_kuvvet_mi", "x": "sayi", "n": "taban"} |
HumanEval/77 | def kubemiotur(sayi):
'''
Bir tamsayi sayi alan ve True donduren bir fonksiyon yazin
bu sayinin baska bir tamsayinin kupu olmasi durumunda.
Not: Girdinin her zaman gecerli oldugunu varsayabilirsiniz.
Ornekler:
kubemiotur(1) ==> True
kubemiotur(2) ==> False
kubemiotur(-1) ==> True
ku... | kubemiotur |
sayi = abs(sayi)
return int(round(sayi ** (1. / 3))) ** 3 == sayi
| def check(candidate):
# Check some simple cases
assert candidate(1) == True, "First test error: " + str(candidate(1))
assert candidate(2) == False, "Second test error: " + str(candidate(2))
assert candidate(-1) == True, "Third test error: " + str(candidate(-1))
assert candidate(64) == True, "Fourth... |
assert type(sayi) == int, "invalid inputs" # $_CONTRACT_$
| [[1], [1], [2], [2], [-1], [-1], [64], [64], [180], [180], [1000], [1000], [0], [0], [1729], [1728]] | [[-8], [27], [125], [729], [512], [-27], [-64], [1000000], [-1000000], [120], [57], [-63], [510], [728], [999999], [-999999], [55], [123], [56], [26], [-1000001], [730], [-7], [119], [-28], [126], [-6], [-62], [58], [-5], [727], [-26], [-39], [-1000002], [-46], [999998], [726], [731], [54], [725], [-29], [59], [-47], [... | 0 |
def iscube(a):
'''
Write a function that takes an integer a and returns True
if this ingeger is a cube of some integer number.
Note: you may assume the input is always valid.
Examples:
iscube(1) ==> True
iscube(2) ==> False
iscube(-1) ==> True
iscube(64) ==> True
iscube(0) ==> ... | iscube | {"iscube": "kubemiotur", "a": "sayi"} |
HumanEval/78 | def onaltilik_primer_basamak(onaltilik_dizgi):
"""Goreviniz, onaltilik bir sayiyi dizgi olarak alan ve onaltilik
basamaklardan kacinin asal sayi oldugunu sayan bir islev yazmaktir.
(asal sayi, 1'den buyuk ve iki kucuk dogal sayinin carpimi olmayan dogal sayidir).
Onaltilik basamaklar 0, 1, 2, 3, 4, 5,... | onaltilik_primer_basamak |
return len(list(filter(lambda x: x in "2357BD", onaltilik_dizgi)))
| def check(candidate):
# Check some simple cases
assert candidate("AB") == 1, "First test error: " + str(candidate("AB"))
assert candidate("1077E") == 2, "Second test error: " + str(candidate("1077E"))
assert candidate("ABED1A33") == 4, "Third test error: " + str(candidate("ABED1A33"))
... |
assert all(x in "0123456789ABCDEF" for x in onaltilik_dizgi), "invalid inputs" # $_CONTRACT_$
| [["AB"], ["AB"], ["1077E"], ["1077E"], ["ABED1A33"], ["ABED1A33"], ["2020"], ["2020"], ["123456789ABCDEF0"], ["123456789ABCDEF0"], ["112233445566778899AABBCCDDEEFF00"], ["112233445566778899AABBCCDDEEFF00"], [[]]] | [["ABCDEF"], ["999999"], ["77777"], ["898989"], ["67ABCD23"], ["111"], ["444"], [""], ["1"], ["9"], ["777777"], ["1111"], ["8998989"], ["8898989"], ["11111"], ["7767ABCD237777"], ["11111777777"], ["444444"], ["679D99999ABCD23"], ["1679D99999ABCD23"], ["89679D99999ABCD2398989"], ["6979D99999ABCD23"], ["7767ABCD23777"], ... | 0 |
def hex_key(num):
"""You have been tasked to write a function that receives
a hexadecimal number as a string and counts the number of hexadecimal
digits that are primes (prime number, or a prime, is a natural number
greater than 1 that is not a product of two smaller natural numbers).
Hexadecima... | hex_key | {"hex_key": "onaltilik_primer_basamak", "num": "onaltilik_dizgi"} |
HumanEval/79 | def onluk_to_ikilik(onluk_sayi):
"""Onluk formatta bir sayi verilecek ve goreviniz onu ikilik formata cevirmeaktir. Fonksiyon, her karakteri bir ikilik sayiyi temsil eden bir string donmelidir. Stringdeki her karakter '0' veya '1' olacak.
Stringin basinda ve sonunda 'db' adinda ekstra iki karakter bulunacak. B... | onluk_to_ikilik |
return "db" + bin(onluk_sayi)[2:] + "db"
| def check(candidate):
# Check some simple cases
assert candidate(0) == "db0db"
assert candidate(32) == "db100000db"
assert candidate(103) == "db1100111db"
assert candidate(15) == "db1111db", "This prints if this assert fails 1 (good for debugging!)"
# Check some edge cases that are easy to wor... |
assert type(onluk_sayi) == int, "invalid inputs" # $_CONTRACT_$
assert onluk_sayi >= 0, "invalid inputs" # $_CONTRACT_$
| [[0], [32], [103], [15]] | [[100001], [255], [999999999], [1000000000000], [7], [1023], [1], [2], [3], [4], [1000000000], [6], [1000000001], [1000000000002], [5], [100002], [100000], [1022], [8], [1000000002], [0], [1024], [100003], [1000000000001], [999999998], [999999999999], [256], [257], [1021], [259], [1000000000003], [1000000004], [1000000... | 0 |
def decimal_to_binary(decimal):
"""You will be given a number in decimal form and your task is to convert it to
binary format. The function should return a string, with each character representing a binary
number. Each character in the string will be '0' or '1'.
There will be an extra couple of charac... | decimal_to_binary | {"decimal_to_binary": "onluk_to_ikilik", "decimal": "onluk_sayi"} |
HumanEval/80 | def mutlu_mu(dize):
"""Bir dize verilir.
Goreviniz, dizenin mutlu olup olmadigini kontrol etmektir.
Bir dize, uzunlugu en az 3 ise ve ard arda gelen her 3 harf farkliysa mutlu kabul edilir.
Ornek:
mutlu_mu(a) => False
mutlu_mu(aa) => False
mutlu_mu(abcd) => True
mutlu_mu(aabb) => False
... | mutlu_mu |
if len(dize) < 3: return False
for i in range(len(dize) - 2):
if dize[i] == dize[i + 1] or dize[i] == dize[i + 2] or dize[i + 1] == dize[i + 2]:
return False
return True
| def check(candidate):
# Check some simple cases
assert candidate("a") == False , "a"
assert candidate("aa") == False , "aa"
assert candidate("abcd") == True , "abcd"
assert candidate("aabb") == False , "aabb"
assert candidate("adb") == True , "adb"
assert candidate("xyy") == False , "xyy"
... |
assert type(dize) == str, "invalid inputs" # $_CONTRACT_$
| [["a"], ["aa"], ["abcd"], ["aabb"], ["adb"], ["xyy"], ["iopaxpoi"], ["iopaxioi"]] | [["xyz"], ["tim"], ["abcabc"], ["bjmpzkfak"], ["cadbfe"], ["agbebf"], [" this is a comment"], ["yyyyy"], ["xycxyz"], ["bacbacb"], ["xy"], ["xxy"], ["baacbacb"], ["bjmzpzkfak"], ["xxyzycxyz"], ["bacacbacb"], ["tibacacbacbm"], ["bagbebf"], ["tibaagbebfcacbacbmm"], ["baaacbacb"], [" this is bacbacba comment"], ["abbaacbac... | 0 |
def is_happy(s):
"""You are given a string s.
Your task is to check if the string is happy or not.
A string is happy if its length is at least 3 and every 3 consecutive letters are distinct
For example:
is_happy(a) => False
is_happy(aa) => False
is_happy(abcd) => True
is_happy(aabb) => ... | is_happy | {"is_happy": "mutlu_mu", "s": "dize"} |
HumanEval/81 | def sayisal_harf_notu(gpalar):
"""Ders yilinin son haftasi ve ogretmen ogrencilere notlarini vermesi gerekiyor.
Ogretmen notlandirma icin kendi algoritmasini olusturuyor.
Tek sorun, notlandirma icin kullandigi kodu kaybetmis.
Size bazi ogrencilerin GPA listelerini verdi ve asagidaki tabloyu kullanarak
... | sayisal_harf_notu |
def to_letter_grade(score):
if score == 4.0:
return "A+"
elif score > 3.7:
return "A"
elif score > 3.3:
return "A-"
elif score > 3.0:
return "B+"
elif score > 2.7:
return "B"
elif score > 2.3:
return "B-"
elif score > 2.0:
... | def check(candidate):
# Check some simple cases
assert candidate([4.0, 3, 1.7, 2, 3.5]) == ['A+', 'B', 'C-', 'C', 'A-']
assert candidate([1.2]) == ['D+']
assert candidate([0.5]) == ['D-']
assert candidate([0.0]) == ['E']
assert candidate([1, 0.3, 1.5, 2.8, 3.3]) == ['D', 'D-', 'C-', 'B', 'B+']
... |
assert all(0.0 <= x <= 4.0 for x in gpalar), "invalid inputs" # $_CONTRACT_$
| [[[4.0, 3, 1.7, 2, 3.5]], [[1.2]], [[0.5]], [[0.0]], [[1, 0.3, 1.5, 2.8, 3.3]], [[0, 0.7]]] | [[[3.8, 2.5, 3.9, 2.2, 1.0]], [[3.1, 2.7, 1.8, 0.9, 0.5, 4.0]], [[2.2, 1.0, 0.8, 3.5, 0.9, 1.8]], [[2.7, 1.5, 0.7, 3.3, 3.9]], [[3.2, 3.1, 3.0, 2.9, 2.8, 2.7]], [[3.3, 2.8, 2.5, 1.9, 1.0]], [[4.0, 4.0, 4.0, 4.0]], [[1.7, 1.7, 1.7, 1.7]], [[2.0, 2.0, 2.0, 2.0]], [[3.8, 3.5, 3.2, 2.5, 1.8]], [[3.3, 2.5, 1.9, 1.0]], [[2.2... | 0 |
def numerical_letter_grade(grades):
"""It is the last week of the semester and the teacher has to give the grades
to students. The teacher has been making her own algorithm for grading.
The only problem is, she has lost the code she used for grading.
She has given you a list of GPAs for some students a... | numerical_letter_grade | {"numerical_letter_grade": "sayisal_harf_notu", "grades": "gpalar"} |
HumanEval/82 | def asal_uzunluk(metin):
"""Bir metin alan ve metin uzunlugu asal sayi ise True,
degilse False donduren bir fonksiyon yazin.
Ornekler
asal_uzunluk('Hello') == True
asal_uzunluk('abcdcba') == True
asal_uzunluk('kittens') == True
asal_uzunluk('orange') == False
"""
| asal_uzunluk |
def is_prime(a):
return not (a < 2 or any(a % x == 0 for x in range(2, int(a ** 0.5) + 1)))
return is_prime(len(metin))
| def check(candidate):
# Check some simple cases
assert candidate('Hello') == True
assert candidate('abcdcba') == True
assert candidate('kittens') == True
assert candidate('orange') == False
assert candidate('wow') == True
assert candidate('world') == True
assert candidate('MadaM') == Tr... |
assert type(metin) == str, "invalid inputs" # $_CONTRACT_$
| [["Hello"], ["abcdcba"], ["kittens"], ["orange"], ["wow"], ["world"], ["MadaM"], ["Wow"], [""], ["HI"], ["go"], ["gogo"], ["aaaaaaaaaaaaaaa"], ["Madam"], ["M"], ["0"]] | [["a"], ["ab"], ["abc"], ["abcd"], ["abcde"], ["abcdef"], ["abcdefg"], ["abcdefgh"], ["abcdefghi"], ["zyxwvutsrqponmlkjihgfedcba"], ["abcddefghi"], ["abcdefabcddefghi"], ["abcdeabcabcdefgfabcddefghi"], ["abcdefghiab"], ["abcdeabcabcdeabc"], ["zyxwvutsrqponmledcba"], ["aabcbcde"], ["abcdefga"], ["abcddefg"], ["abcdeabcd... | 0 |
def prime_length(string):
"""Write a function that takes a string and returns True if the string
length is a prime number or False otherwise
Examples
prime_length('Hello') == True
prime_length('abcdcba') == True
prime_length('kittens') == True
prime_length('orange') == False
"""
| prime_length | {"prime_length": "asal_uzunluk", "string": "metin"} |
HumanEval/83 | def birle_baslar_biter(basamak_sayisi):
"""
Pozitif bir tamsayi basamak_sayisi icin, basamak sayisi basamak_sayisi olan
pozitif tam sayilardan 1 ile baslayan veya bitenlerin sayisini dondurun.
"""
| birle_baslar_biter |
if basamak_sayisi == 1: return 1
return 18 * 10 ** (basamak_sayisi - 2)
| def check(candidate):
# Check some simple cases
assert True, "This prints if this assert fails 1 (good for debugging!)"
assert candidate(1) == 1
assert candidate(2) == 18
assert candidate(3) == 180
assert candidate(4) == 1800
assert candidate(5) == 18000
# Check some edge cases that ar... |
assert type(basamak_sayisi) == int and basamak_sayisi > 0, "invalid inputs" # $_CONTRACT_$
| [[1], [2], [3], [4], [5]] | [[6], [10], [12], [15], [20], [30], [8], [25], [100], [500], [29], [14], [26], [19], [13], [9], [101], [28], [21], [24], [7], [102], [99], [16], [501], [17], [22], [98], [11], [499], [1000], [1234], [9876], [31415], [1000000], [99999], [9877], [9878], [1235], [1001], [9879], [9880], [999999], [9881], [31414], [78], [99... | 0 |
def starts_one_ends(n):
"""
Given a positive integer n, return the count of the numbers of n-digit
positive integers that start or end with 1.
"""
| starts_one_ends | {"starts_one_ends": "birle_baslar_biter", "n": "basamak_sayisi"} |
HumanEval/84 | def cozumle(n):
"""Pozitif bir tam sayi olan n icin, basamaklarinin toplamini ikilik sistemde dondurun.
Ornek
n = 1000 icin, basamaklar toplami 1 olur ve cikti "1" olmalidir.
n = 150 icin, basamaklar toplami 6 olur ve cikti "110" olmalidir.
n = 147 icin, basamaklar toplami 12 olur v... | cozumle |
s = sum(map(lambda x: int(x), str(n)))
return bin(s)[2:]
| def check(candidate):
# Check some simple cases
assert True, "This prints if this assert fails 1 (good for debugging!)"
assert candidate(1000) == "1", "Error"
assert candidate(150) == "110", "Error"
assert candidate(147) == "1100", "Error"
# Check some edge cases that are easy to work out by h... |
assert type(n) == int, "invalid inputs" # $_CONTRACT_$
assert 0 < n <= 10000, "invalid inputs" # $_CONTRACT_$
| [[1000], [150], [147], [333], [963]] | [[1], [10], [101], [1111], [5000], [9999], [819], [15], [75], [820], [818], [16], [1112], [17], [9998], [9997], [821], [2], [1110], [1113], [74], [11], [14], [10000], [100], [73], [27], [35], [817], [1114], [9996], [1115], [12], [18], [816], [13], [36], [28], [1109], [96], [97], [5001], [76], [1116], [9], [815], [822],... | 0 |
def solve(N):
"""Given a positive integer N, return the total sum of its digits in binary.
Example
For N = 1000, the sum of digits will be 1 the output should be "1".
For N = 150, the sum of digits will be 6 the output should be "110".
For N = 147, the sum of digits will be 12 the ... | solve | {"solve": "cozumle", "N": "n"} |
HumanEval/85 | def topla(sayi_listesi):
"""Verilen bos olmayan bir tam sayi listesi sayi_listesi icin. tek indislerde bulunan cift elemanlari toplayin..
Examples:
topla([4, 2, 6, 7]) ==> 2
"""
| topla |
s = 0
for i in range(1, len(sayi_listesi), 2):
if sayi_listesi[i] % 2 == 0:
s += sayi_listesi[i]
return s
| def check(candidate):
# Check some simple cases
assert candidate([4, 88]) == 88
assert candidate([4, 5, 6, 7, 2, 122]) == 122
assert candidate([4, 0, 6, 7]) == 0
assert candidate([4, 4, 6, 8]) == 12
# Check some edge cases that are easy to work out by hand.
|
assert len(sayi_listesi) > 0, "invalid inputs" # $_CONTRACT_$
assert all(type(x) == int for x in sayi_listesi), "invalid inputs" # $_CONTRACT_$
| [[[4, 88]], [[4, 5, 6, 7, 2, 122]], [[4, 0, 6, 7]], [[4, 4, 6, 8]]] | [[[3, 5, 7, 9]], [[2, 4, 6, 8]], [[1, 2, 3, 4]], [[5, 4, 7, 2, 1]], [[0, 0, 0, 0, 0]], [[1, 3, 5, 7]], [[2, 3, 4, 5]], [[0]], [[1, 2, 3, 4, 5, 6]], [[2, 4, 6, 8, 10]], [[2, 4, 0, 8]], [[2, 3, 6, 8]], [[2, 3, 5, 4]], [[2, 3, 4, 5, 2]], [[8]], [[10, 2, 3, 5, 4]], [[10, 4, 3, 5, 4]], [[9, 9, 5, 7]], [[1, 3, 4]], [[1, 2, 3... | 0 |
def add(lst):
"""Given a non-empty list of integers lst. add the even elements that are at odd indices..
Examples:
add([4, 2, 6, 7]) ==> 2
"""
| add | {"add": "topla", "lst": "sayi_listesi"} |
HumanEval/86 | def harfleri_sirala(metin):
"""
Bir metin alan ve ona gore siralanmis bir versiyonunu donduren bir fonksiyon yazin.
Siralanmis metin, tum kelimeler (bosluk ile ayrilmis) yeni bir kelimeyle degistirilmis bir metindir.
Bu yeni kelimede tum karakterler ascii degerlerine gore artan sirada duzenlenmistir.
... | harfleri_sirala |
words = metin.split(" ")
return " ".join(map(lambda x: "".join(sorted(x, key=lambda ch: ord(ch))), words))
| def check(candidate):
# Check some simple cases
assert candidate('Hi') == 'Hi'
assert candidate('hello') == 'ehllo'
assert candidate('number') == 'bemnru'
assert candidate('abcd') == 'abcd'
assert candidate('Hello World!!!') == 'Hello !!!Wdlor'
assert candidate('') == ''
assert candidat... |
assert type(metin) == str, "invalid inputs" # $_CONTRACT_$
| [["Hi"], ["hello"], ["number"], ["abcd"], ["Hello World!!!"], [""], ["Hi. My name is Mister Robot. How are you?"]] | [["12345"], ["\n\n123 456\n789\n"], ["Mary had a little lamb"], ["Racecar"], ["!!!"], ["The quick brown fox jumps over the lazy dog."], ["This is a test."], ["1, 2, 3, testing!"], ["Quick brown fox"], ["The quick brown fox jumps over the lazy dog"], ["The quick brown fox jumps over thhe lazy dog"], ["r"], ["Raccecar"],... | 0 |
def anti_shuffle(s):
"""
Write a function that takes a string and returns an ordered version of it.
Ordered version of string, is a string where all words (separated by space)
are replaced by a new word where all the characters arranged in
ascending order based on ascii value.
Note: You should ... | anti_shuffle | {"anti_shuffle": "harfleri_sirala", "s": "metin"} |
HumanEval/87 | def x_koordinatlari_bul(veri_listesi, aranan_x):
"""
Iki boyutlu bir veri, ic ic listeler olarak verilir.
Bu bir matrise benzer, ancak matrislerden farkli olarak,
her satir farkli sayida sutun icerir.
veri_listesi ve aranan_x tamsayisi verildiginde, listedeki x degerlerini bulun,
ve [(x1, y1), (... | x_koordinatlari_bul |
res = []
for i, l in enumerate(veri_listesi):
for j in range(len(l) - 1, -1, -1):
if l[j] == aranan_x: res.append((i, j))
return res
| def check(candidate):
# Check some simple cases
assert candidate([
[1,2,3,4,5,6],
[1,2,3,4,1,6],
[1,2,3,4,5,1]
], 1) == [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]
assert candidate([
[1,2,3,4,5,6],
[1,2,3,4,5,6],
[1,2,3,4,5,6],
[1,2,3,4,5,6],
... |
assert type(aranan_x) == int, "invalid inputs" # $_CONTRACT_$
assert type(veri_listesi) == list, "invalid inputs" # $_CONTRACT_$
assert all(type(y) == list for y in veri_listesi), "invalid inputs" # $_CONTRACT_$
| [[[[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 1, 6], [1, 2, 3, 4, 5, 1]], 1], [[[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]], 2], [[[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6], [1, 1, 3, 4, 5, 6], [1, 2, 1, 4, 5, 6], [1, 2, 3, 1, 5, 6], [1, 2, 3, 4, 1, 6], [1,... | [[[[], [], [], []], 10], [[[1, 2, 3], [4, 5, 6]], 5], [[[1, 1], [1, 2, 3], [4, 5, 6, 7]], 1], [[[1, 0, 4], [4, 8, -1, 1], [0], [5, 5, 5, -3]], 0], [[[0, 0, 0, 0, 0], [0, 1, 2], [0, 1, 2, 3, 4, 5, 6, 7, 8], [], [0, 0, 0]], 0], [[[1, 2, 3], [4, 5, 6], [7, 8]], 3], [[], 5], [[[], [], []], 1], [[[1, 2], [2, 3, 4], [4, 5, 6... | 0 |
def get_row(lst, x):
"""
You are given a 2 dimensional data, as a nested lists,
which is similar to matrix, however, unlike matrices,
each row may contain a different number of columns.
Given lst, and integer x, find integers x in the list,
and return list of tuples, [(x1, y1), (x2, y2) ...] su... | get_row | {"get_row": "x_koordinatlari_bul", "lst": "veri_listesi", "x": "aranan_x"} |
HumanEval/88 | def dizi_sirala(dizi):
"""
Negatif olmayan tam sayilardan olusan bir dizi verildiginde, siralanmis dizinin bir kopyasini dondurun,
ilk eleman ile son elemanin toplami tek ise diziyi artan siraya,
cift ise azalan siraya gore siralayin.
Not:
* verilen diziyi degistirmeyin.
Ornekler:
* di... | dizi_sirala |
if dizi == []: return []
return sorted(dizi, reverse=(dizi[0]+dizi[-1]) % 2 == 0)
| def check(candidate):
# Check some simple cases
assert True, "This prints if this assert fails 1 (good for debugging!)"
assert candidate([]) == [], "Error"
assert candidate([5]) == [5], "Error"
assert candidate([2, 4, 3, 0, 1, 5]) == [0, 1, 2, 3, 4, 5], "Error"
assert candidate([2, 4, 3, 0, 1, ... |
assert all(x >= 0 for x in dizi), "invalid inputs" # $_CONTRACT_$
| [[[]], [[5]], [[2, 4, 3, 0, 1, 5]], [[2, 4, 3, 0, 1, 5, 6]], [[2, 1]], [[15, 42, 87, 32, 11, 0]], [[21, 14, 23, 11]]] | [[[0, 0, 0, 0]], [[1, 2, 3, 4]], [[4, 3, 2, 1]], [[4, 2, 3, 1]], [[1, 9, 2, 8, 3, 7, 4, 6, 5]], [[1, 1, 1, 1, 1, 1, 1]], [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], [[1, 2, 3]], [[5, 7, 9, 11]], [[30, 20, 10, 5]], [[0, 1, 11, 0, 0, 0]], [[7, 9, 11]], [[7, 9, 9]], [[9, 7, 9]], [[30, 2, 20, 10, 5]], [[7, 9, 11, 11]], [[10, 9, 7, 9... | 0 |
def sort_array(array):
"""
Given an array of non-negative integers, return a copy of the given array after sorting,
you will sort the given array in ascending order if the sum( first index value, last index value) is odd,
or sort it in descending order if the sum( first index value, last index value) i... | sort_array | {"sort_array": "dizi_sirala", "array": "dizi"} |
HumanEval/89 | def sifrele(metin):
"""Alfabe kaydirilarak sifrelenmis bir dizgi donduren, bir dizgiyi arguman olarak alan sifrele adinda bir fonksiyon olusturun.
Harfler, iki ile carpilan iki kadar kaydirilarak alfabe kaydirilmalidir.
Ornek olarak:
sifrele('hi') 'lm' dondurur
sifrele('asdfghjkl') 'ewhjklnop' dond... | sifrele |
d = 'abcdefghijklmnopqrstuvwxyz'
return "".join(map(lambda ch: chr((ord(ch) - ord("a") + 4) % 26 + ord("a")) if ch in d else ch, metin))
| def check(candidate):
# Check some simple cases
assert candidate('hi') == 'lm', "This prints if this assert fails 1 (good for debugging!)"
assert candidate('asdfghjkl') == 'ewhjklnop', "This prints if this assert fails 1 (good for debugging!)"
assert candidate('gf') == 'kj', "This prints if this assert... |
assert metin == "" or metin.islower(), "invalid inputs" # $_CONTRACT_$
| [["hi"], ["asdfghjkl"], ["gf"], ["et"], ["faewfawefaewg"], ["hellomyfriend"], ["dxzdlmnilfuhmilufhlihufnmlimnufhlimnufhfucufh"], ["a"]] | [["abcde"], ["uvwxyz"], [""], ["test123"], ["1a2b3c"], ["hello world"], ["monitor"], ["abc"], ["kmt"], ["park"], ["mtkmt"], ["testpark123"], ["uvuvwxyzwxyz"], ["abcdetest123"], ["testpark1233"], ["parrte1a2b3cstpark123"], ["pamonitork"], ["uvwabcxyuz"], ["uvuvwxyzwxz"], ["t"], ["uvz"], ["kuvz"], ["kkuvz"], ["abct"], ["... | 0 |
def encrypt(s):
"""Create a function encrypt that takes a string as an argument and
returns a string encrypted with the alphabet being rotated.
The alphabet should be rotated in a manner such that the letters
shift down by two multiplied to two places.
For example:
encrypt('hi') returns 'lm'
... | encrypt | {"encrypt": "sifrele", "s": "metin"} |
HumanEval/90 | def ikinci_en_kucuk(liste):
"""
Tamsayilardan olusan bir liste verilir.
Listedeki 2. kucuk elemani donduren ikinci_en_kucuk() fonksiyonunu yazin.
Bunu gibi bir eleman yoksa None dondurun.
ikinci_en_kucuk([1, 2, 3, 4, 5]) == 2
ikinci_en_kucuk([5, 1, 4, 3, 2]) == 2
ikinci_en_kucuk([]) == ... | ikinci_en_kucuk |
if len(liste) <= 1: return None
sorted_list = sorted(liste)
for x in sorted_list:
if x != sorted_list[0]:
return x
| def check(candidate):
# Check some simple cases
assert candidate([1, 2, 3, 4, 5]) == 2
assert candidate([5, 1, 4, 3, 2]) == 2
assert candidate([]) == None
assert candidate([1, 1]) == None
assert candidate([1,1,1,1,0]) == 1
assert candidate([1, 0**0]) == None
assert candidate([-35, 34, 1... |
assert all(type(x) == int for x in liste), "invalid inputs" # $_CONTRACT_$
| [[[1, 2, 3, 4, 5]], [[5, 1, 4, 3, 2]], [[]], [[1, 1]], [[1, 1, 1, 1, 0]], [[1, 1]], [[-35, 34, 12, -45]]] | [[[1, 2, 3, 4, 5, 6]], [[10, 8, 14, 9, 7, 15]], [[-5, -3, -2, -8, -1]], [[2, 2, 2, 2, 2, 2, 3, 3, 3, 3]], [[4, 4, 4, 4, 4, 4, 4]], [[2, 2, 2, 3, 3, 3]], [[5, 5, 5, 5, 1]], [[7, 6, 5, 4]], [[0, 0, 0, 0, 1, 1, 1]], [[1, 4, 2, 6, 9, 0, -1, -5]], [[4, 15, 4, 4, 3, 4, 4, 4]], [[7, 5, 4, 5]], [[7, 6, 5, 4, 4]], [[2, 2, 2, 2,... | 0 |
def next_smallest(lst):
"""
You are given a list of integers.
Write a function next_smallest() that returns the 2nd smallest element of the list.
Return None if there is no such element.
next_smallest([1, 2, 3, 4, 5]) == 2
next_smallest([5, 1, 4, 3, 2]) == 2
next_smallest([]) == None
... | next_smallest | {"next_smallest": "ikinci_en_kucuk", "lst": "liste"} |
HumanEval/91 | def can_sikintisi(metin):
"""
Bir kelime dizisi alacaksiniz ve goreviniz can_sikintisi sayisini saymaktir.
Bir can_sikintisi, "I" kelimesiyle baslayan bir cumledir.
Cumleler '.', '?' veya '!' ile sinirlanir.
Ornek olarak:
>>> can_sikintisi("Hello world")
0
>>> can_sikintisi("The sky ... | can_sikintisi |
sentences = map(lambda x: x.strip(), ((metin.replace("?", ".")).replace("!", ".")).split("."))
return len([s for s in sentences if s.startswith("I ")])
| def check(candidate):
# Check some simple cases
assert candidate("Hello world") == 0, "Test 1"
assert candidate("Is the sky blue?") == 0, "Test 2"
assert candidate("I love It !") == 1, "Test 3"
assert candidate("bIt") == 0, "Test 4"
assert candidate("I feel good today. I will be productive. wil... |
assert type(metin) == str, "invalid inputs" # $_CONTRACT_$
| [["Hello world"], ["Is the sky blue?"], ["I love It !"], ["bIt"], ["I feel good today. I will be productive. will kill It"], ["You and I are going for a walk"]] | [["I am very happy today. I love spending time with my friends."], ["I want to eat pizza for dinner. What do you think, should we order pizza?"], ["I enjoy reading books. They help me learn new things."], ["I forgot my phone in the car. Oh no, now I have to go back and get it."], ["In the morning, I like to have a cup ... | 0 |
def is_bored(S):
"""
You'll be given a string of words, and your task is to count the number
of boredoms. A boredom is a sentence that starts with the word "I".
Sentences are delimited by '.', '?' or '!'.
For example:
>>> is_bored("Hello world")
0
>>> is_bored("The sky is blue. The ... | is_bored | {"is_bored": "can_sikintisi", "S": "metin"} |
HumanEval/92 | def toplam_kontrol(sayi_bir, sayi_iki, sayi_uc):
'''
3 sayi alan bir fonksiyon olusturun.
Eger sayilardan biri diger ikisinin toplamina esit ise ve tum sayilar tam sayi ise True dondurur.
Diger tum durumlarda False dondurur.
Ornekler
toplam_kontrol(5, 2, 7) ➞ True
toplam_kontrol(3,... | toplam_kontrol |
if type(sayi_bir) != int or type(sayi_iki) != int or type(sayi_uc) != int: return False
return sayi_bir == sayi_iki + sayi_uc or sayi_iki == sayi_bir + sayi_uc or sayi_uc == sayi_iki + sayi_bir
| def check(candidate):
# Check some simple cases
assert candidate(2, 3, 1)==True, "This prints if this assert fails 1 (good for debugging!)"
assert candidate(2.5, 2, 3)==False, "This prints if this assert fails 2 (good for debugging!)"
assert candidate(1.5, 5, 3.5)==False, "This prints if this assert fa... |
assert all(isinstance(v, (int, float, bool)) for v in [sayi_bir, sayi_iki, sayi_uc]), "invalid inputs" # $_CONTRACT_$
| [[2, 3, 1], [2.5, 2, 3], [1.5, 5, 3.5], [2, 6, 2], [4, 2, 2], [2.2, 2.2, 2.2], [-4, 6, 2], [2, 1, 1], [3, 4, 7], [3.0, 4, 7]] | [[-1, 8, 7], [-2, -2, -4], [0, 0, 0], [1, 1, 1], [-3, -4, -7], [50, -20, -30], [-5, 10, -5], [7, 1, 8], [-2, 5, 7], [4, 5, 9], [-2, -1, -4], [-5, 8, 10], [-2, 1, 7], [-5, 8, 8], [7, 11, 11], [50, -19, -30], [-3, 8, -3], [-5, 50, -4], [8, 7, 8], [6, -30, 10], [6, 10, 6], [6, 6, 6], [-3, -4, -6], [6, 7, 7], [-3, -4, 9], ... | 0 |
def any_int(x, y, z):
'''
Create a function that takes 3 numbers.
Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
Returns false in any other cases.
Examples
any_int(5, 2, 7) ➞ True
any_int(3, 2, 2) ➞ False
any_int(3, -2, ... | any_int | {"any_int": "toplam_kontrol", "x": "sayi_bir", "y": "sayi_iki", "z": "sayi_uc"} |
HumanEval/93 | def sifrele(mesaj):
"""
Bir fonksiyon yazin ki bir mesaj alsin ve onu su sekilde sifrelesin: tum harflerin buyuk/kucuk harf durumunu degistirsin, mesajdaki tum sesli harfleri ingiliz alfabesinde o sesli harften 2 basamak ilerde gelen harfle degistirsin.
Yalnizca harf oldugunu kabul edin.
Ornekler:
... | sifrele |
def switch_case(ch):
if ord("A") <= ord(ch) <= ord("Z"):
return chr(ord(ch) + 32)
elif ord("a") <= ord(ch) <= ord("z"):
return chr(ord(ch) - 32)
else:
return ch
def vowel_change(ch):
return ch if ch not in "aeiouAEIOU" else chr(ord(ch) +... | def check(candidate):
# Check some simple cases
assert candidate('TEST') == 'tgst', "This prints if this assert fails 1 (good for debugging!)"
assert candidate('Mudasir') == 'mWDCSKR', "This prints if this assert fails 2 (good for debugging!)"
assert candidate('YES') == 'ygs', "This prints if this asse... |
assert type(mesaj) == str, "invalid inputs" # $_CONTRACT_$
assert all(ch == " " or ch.isalpha() for ch in mesaj), "invalid inputs" # $_CONTRACT_$
| [["TEST"], ["Mudasir"], ["YES"], ["This is a message"], ["I DoNt KnOw WhAt tO WrItE"]] | [["abcdefghijklmnopqrstuvwxyz"], ["ZYXWVUTSRQPONMLKJIHGFEDCBA"], ["Python is awesome"], ["Quick brown fox jumps over the lazy dog"], ["The quick brown fox jumps over the lazy dog"], ["Every good boy does fine"], ["ABCDEF"], ["The cat in the hat"], ["to be or not to be"], ["Testing encode function"], ["ZYXWVUTSRQPONMLKJ... | 0 |
def encode(message):
"""
Write a function that takes a message, and encodes in such a
way that it swaps case of all letters, replaces all vowels in
the message with the letter that appears 2 places ahead of that
vowel in the english alphabet.
Assume only letters.
Examples:
>>>... | encode | {"encode": "sifrele", "message": "mesaj"} |
HumanEval/94 | def buyuk_asal_rakam_toplami(tamsayi_listesi):
"""Bir tam sayi listesi alirsiniz.
En buyuk asal sayiyi bulmaniz ve onun rakamlarinin toplamini dondurmeniz gerekmektedir.
Ornekler:
tamsayi_listesi = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] icin cikti 10 olmalidir
tamsayi_listesi = [1,0,1... | buyuk_asal_rakam_toplami |
def is_prime(a):
return not (a < 2 or any(a % x == 0 for x in range(2, int(a ** 0.5) + 1)))
sorted_list = sorted(tamsayi_listesi)[::-1]
for x in sorted_list:
if is_prime(x):
return sum(map(lambda ch: int(ch), str(x)))
| def check(candidate):
# Check some simple cases
assert candidate([0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3]) == 10, "This prints if this assert fails 1 (good for debugging!)"
# Check some edge cases that are easy to work out by hand.
assert candidate([1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1]... |
def is_prime(a): # $_CONTRACT_$
return not (a < 2 or any(a % x == 0 for x in range(2, int(a ** 0.5) + 1))) # $_CONTRACT_$
assert any(is_prime(x) for x in tamsayi_listesi), "invalid inputs" # $_CONTRACT_$
| [[[0, 3, 2, 1, 3, 5, 7, 4, 5, 5, 5, 2, 181, 32, 4, 32, 3, 2, 32, 324, 4, 3]], [[1, 0, 1, 8, 2, 4597, 2, 1, 3, 40, 1, 2, 1, 2, 4, 2, 5, 1]], [[1, 3, 1, 32, 5107, 34, 83278, 109, 163, 23, 2323, 32, 30, 1, 9, 3]], [[0, 724, 32, 71, 99, 32, 6, 0, 5, 91, 83, 0, 5, 6]], [[0, 81, 12, 3, 1, 21]], [[0, 8, 1, 2, 1, 7]], [[8191]]... | [[[1, 2, 3, 4, 5, 6, 7, 8, 9]], [[10, 12, 73, 4, 6, 8, 10, 12]], [[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]], [[7, 9, 13, 17, 19, 23, 29, 31, 37, 41]], [[97, 101, 103, 107, 109, 113, 127, 131, 137, 139]], [[181, 233, 293, 307, 331, 367, 379, 397, 433, 449]], [[1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]], [[0, 0, 0, 2, 5, 7, 11, 13... | 0 |
def skjkasdkd(lst):
"""You are given a list of integers.
You need to find the largest prime value and return the sum of its digits.
Examples:
For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 10
For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output shoul... | skjkasdkd | {"skjkasdkd": "buyuk_asal_rakam_toplami", "lst": "tamsayi_listesi"} |
HumanEval/95 | def sozluk_buyuk_kucuk_harf_kontrol(sozluk):
"""
Verilen bir sozluk icin tum anahtarlar kucuk harf ise veya tum anahtarlar buyuk harf ise True dondur, aksi takdirde False dondur.
Fonksiyon bos sozluk icin False donmelidir.
Ornekler:
sozluk_buyuk_kucuk_harf_kontrol({"a":"apple", "b":"banana"}) True d... | sozluk_buyuk_kucuk_harf_kontrol |
keys = list(sozluk.keys())
if keys == []: return False
lower, upper = True, True
for k in keys:
if type(k) != str:
lower = upper = False
break
if not k.islower(): lower = False
if not k.isupper(): upper = False
return lower or upper
| def check(candidate):
# Check some simple cases
assert candidate({"p":"pineapple", "b":"banana"}) == True, "First test error: " + str(candidate({"p":"pineapple", "b":"banana"}))
assert candidate({"p":"pineapple", "A":"banana", "B":"banana"}) == False, "Second test error: " + str(candidate({"p":"pineapple",... |
assert type(sozluk).__name__ == "dict", "invalid inputs" # $_CONTRACT_$
| [[{"p": "pineapple", "b": "banana"}], [{"p": "pineapple", "b": "banana"}], [{"p": "pineapple", "A": "banana", "B": "banana"}], [{"p": "pineapple", "A": "banana", "B": "banana"}], [{"p": "pineapple", "5": "banana", "a": "apple"}], [{"p": "pineapple", "5": "banana", "a": "apple"}], [{"Name": "John", "Age": "36", "City": ... | [[{"FIRST_NAME": "John", "LAST_NAME": "DOE", "AGE": 35, "CITY": "NEW YORK", "INCOME": "$50,000"}], [{"first_name": "John", "last_name": "Doe", "age": 35, "city": "New York", "income": "$50,000"}], [{"firstName": "John", "LASTNAME": "DOE", "Age": 35, "cItY": "new york", "Income": "$50,000"}], [{"first_name": "John", "La... | 0 |
def check_dict_case(dict):
"""
Given a dictionary, return True if all keys are strings in lower
case or all keys are strings in upper case, else return False.
The function should return False is the given dictionary is empty.
Examples:
check_dict_case({"a":"apple", "b":"banana"}) should return... | check_dict_case | {"check_dict_case": "sozluk_buyuk_kucuk_harf_kontrol", "dict": "sozluk"} |
HumanEval/96 | def asal_sayilari_listele(deger):
"""Negatif olmayan bir tamsayi alan ve bu tamsayidan kucuk asal sayilari iceren bir dizi donduren bir fonksiyon uygulayin.
ornek olarak:
asal_sayilari_listele(5) => [2,3]
asal_sayilari_listele(11) => [2,3,5,7]
asal_sayilari_listele(0) => []
asal_sayilari_listele... | asal_sayilari_listele |
ans = []
isprime = [True] * (deger + 1)
for i in range(2, deger):
if isprime[i]:
ans.append(i)
for j in range(i + i, deger, i):
isprime[j] = False
return ans
| def check(candidate):
assert candidate(5) == [2,3]
assert candidate(6) == [2,3,5]
assert candidate(7) == [2,3,5]
assert candidate(10) == [2,3,5,7]
assert candidate(0) == []
assert candidate(22) == [2,3,5,7,11,13,17,19]
assert candidate(1) == []
assert candidate(18) == [2,3,5,7,11,13,17]... |
assert type(deger) == int and deger >= 0, "invalid inputs" # $_CONTRACT_$
| [[5], [6], [7], [10], [0], [22], [1], [18], [47], [101]] | [[2], [3], [12], [17], [50], [500], [1000], [25], [30], [100], [18], [999], [49], [19], [13], [499], [998], [1001], [1], [99], [31], [101], [16], [48], [47], [997], [498], [15], [11], [83], [51], [996], [995], [24], [98], [102], [52], [82], [14], [97], [81], [29], [96], [28], [20], [23], [26], [4], [497], [46], [32], [... | 0 |
def count_up_to(n):
"""Implement a function that takes an non-negative integer and returns an array of the first n
integers that are prime numbers and less than n.
for example:
count_up_to(5) => [2,3]
count_up_to(11) => [2,3,5,7]
count_up_to(0) => []
count_up_to(20) => [2,3,5,7,11,13,17,19]... | count_up_to | {"count_up_to": "asal_sayilari_listele", "n": "deger"} |
HumanEval/97 | def carp(a, b):
"""Iki tam sayi alan ve birler basamaklarinin carpimini donduren islevi tamamlayin.
Girdi her zaman gecerli oldugu varsayilir.
Ornekler:
carp(148, 412) 16 dondurur.
carp(19, 28) 72 dondurur.
carp(2020, 1851) 0 dondurur.
carp(14,-15) 20 dondurur.
"""
| carp |
return int(str(a)[-1]) * int(str(b)[-1])
| def check(candidate):
# Check some simple cases
assert candidate(148, 412) == 16, "First test error: " + str(candidate(148, 412))
assert candidate(19, 28) == 72, "Second test error: " + str(candidate(19, 28))
assert candidate(2020, 1851) == 0, "Third test error: " + str(c... |
assert type(a) == type(b) == int, "invalid inputs" # $_CONTRACT_$
| [[148, 412], [148, 412], [19, 28], [19, 28], [2020, 1851], [2020, 1851], [14, -15], [14, -15], [76, 67], [76, 67], [17, 27], [17, 27], [0, 1], [0, 1], [0, 0], [0, 0]] | [[-6, -9], [-87, 5], [39, 25], [1, 100], [-15, -12], [-5, 9], [-12, -16], [0, 8], [8, 0], [123, 321], [-6, -5], [-9, 0], [8, 8], [-87, -87], [123, -12], [5, 25], [1, 0], [1, -16], [125, 124], [-6, -4], [123, 5], [8, -9], [124, 100], [-7, -9], [-7, -6], [8, -16], [8, -10], [0, -7], [-15, -6], [-86, -87], [-15, -7], [0, ... | 0 |
def multiply(a, b):
"""Complete the function that takes two integers and returns
the product of their unit digits.
Assume the input is always valid.
Examples:
multiply(148, 412) should return 16.
multiply(19, 28) should return 72.
multiply(2020, 1851) should return 0.
multiply(14,-15) ... | multiply | {"multiply": "carp", "a": "a", "b": "b"} |
HumanEval/98 | def cift_indis_buyuk_sesli_sayisi(dize):
"""
Verilen bir dize icin, cift indislerdeki buyuk sesli harflerin sayisini bulun.
Ornek olarak:
cift_indis_buyuk_sesli_sayisi('aBCdEf') 1 dondurur
cift_indis_buyuk_sesli_sayisi('abcdefg') 0 dondurur
cift_indis_buyuk_sesli_sayisi('dBBE') 0 dondurur
... | cift_indis_buyuk_sesli_sayisi |
cnt = 0
for i in range(0, len(dize), 2):
if dize[i] in "AEIOU":
cnt += 1
return cnt
| def check(candidate):
# Check some simple cases
assert candidate('aBCdEf') == 1
assert candidate('abcdefg') == 0
assert candidate('dBBE') == 0
assert candidate('B') == 0
assert candidate('U') == 1
assert candidate('') == 0
assert candidate('EEEE') == 2
# Check some edge cases th... |
assert type(dize) == str, "invalid inputs" # $_CONTRACT_$
| [["aBCdEf"], ["abcdefg"], ["dBBE"], ["B"], ["U"], [""], ["EEEE"]] | [["DbdOH"], ["abcDEf"], ["AEOIU"], ["XYZ"], ["uEi"], ["ABCD"], ["hhEErrRR"], ["AbCdEfGhIjKlMnOpQrStUvWxYz"], ["UOIEA"], ["bbcefg"], ["AbCdEOfGhIjKlMnOpQrStUvWxYz"], ["AAEOIUBCD"], ["AbCdEfGhIjKlMnOpQrStUv"], ["AbCdEfGhIjKlMABCDnOpQrStUv"], ["ABCAbCdEfGhIjKlMABCDnOpQrStUabcDEfvD"], ["CABCD"], ["AEOIUIEA"], ["AbCdEfGhIjK... | 0 |
def count_upper(s):
"""
Given a string s, count the number of uppercase vowels in even indices.
For example:
count_upper('aBCdEf') returns 1
count_upper('abcdefg') returns 0
count_upper('dBBE') returns 0
"""
| count_upper | {"count_upper": "cift_indis_buyuk_sesli_sayisi", "s": "dize"} |
HumanEval/99 | def en_yakin_tamsayi(deger):
'''
Bir sayiyi temsil eden bir deger (string) alan ve buna en yakin tamsayi
donduren bir fonksiyon olusturun. Sayi iki tamsayidan esit uzaklikta ise,
sifirdan uzaklasacak sekilde yuvarlayin.
Ornekler
>>> en_yakin_tamsayi("10")
10
>>> en_yakin_tamsayi("15.3")... | en_yakin_tamsayi |
def rounding(val):
if abs(val - int(val)) != 0.5:
return round(val)
if val > 0:
return int(val) + 1
else:
return int(val) - 1
return rounding(float(deger))
| def check(candidate):
# Check some simple cases
assert candidate("10") == 10, "Test 1"
assert candidate("14.5") == 15, "Test 2"
assert candidate("-15.5") == -16, "Test 3"
assert candidate("15.3") == 15, "Test 3"
# Check some edge cases that are easy to work out by hand.
assert candidate("0... |
try: # $_CONTRACT_$
assert isinstance(deger, str) # $_CONTRACT_$
deger = float(deger) # $_CONTRACT_$
except: # $_CONTRACT_$
raise Exception("invalid inputs") # $_CONTRACT_$
import math # $_CONTRACT_$
assert not (math.isinf(deger) or math.isnan(deger)), "invalid inputs" # $_CONTR... | [["10"], ["14.5"], ["-15.5"], ["15.3"], ["0"]] | [["-2.8"], ["3.6"], ["5.5"], ["-6.5"], ["0.5"], ["1.6"], ["-1.6"], ["0.0003"], ["99.99"], ["-99.99"], ["0"], ["-99.9"], ["00"], ["999.99"], ["99.9999"], ["99.999"], ["9.999"], ["999.999"], ["000"], ["09.99900"], ["-999.99"], ["99.9"], ["-99"], ["-6."], ["0900"], ["0000"], ["-6.00000"], ["6"], ["-999"], ["999"], ["11.6"... | 0 |
def closest_integer(value):
'''
Create a function that takes a value (string) representing a number
and returns the closest integer to it. If the number is equidistant
from two integers, round it away from zero.
Examples
>>> closest_integer("10")
10
>>> closest_integer("15.3")
15
... | closest_integer | {"closest_integer": "en_yakin_tamsayi", "value": "deger"} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.