prefix
stringlengths 65
1.8k
| suffix
stringclasses 839
values | solution
stringlengths 6
859
| test_cases
listlengths 0
100
| import_str
listlengths 0
1
| demos
listlengths 0
8
| entry_func
stringclasses 158
values | data_id
stringlengths 36
40
| doc_string
stringclasses 164
values | dataset_name
stringclasses 1
value | task_name
stringclasses 1
value | compare_func
listlengths 0
0
| src_lang
stringclasses 1
value | tgt_lang
stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 product of all factors
"""
import math
fact = []
i = 2
while i <= int(math.sqrt(n) + 1):
if n % i == 0:
fact.append(i)
n //= i
|
if n > 1:
fact.append(n)
return fact
|
else:
i += 1
|
[
[
"2",
"[2]"
],
[
"4",
"[2, 2]"
],
[
"8",
"[2, 2, 2]"
],
[
"3 * 19",
"[3, 19]"
],
[
"3 * 19 * 3 * 19",
"[3, 3, 19, 19]"
],
[
"3 * 19 * 3 * 19 * 3 * 19",
"[3, 3, 3, 19, 19, 19]"
],
[
"3 * 19 * 19 * 19",
"[3, 19, 19, 19]"
],
[
"3 * 2 * 3",
"[2, 3, 3]"
]
] |
[
"from typing import List"
] |
[
[
"8",
"[2, 2, 2]"
],
[
"25",
"[5, 5]"
],
[
"70",
"[2, 5, 7]"
]
] |
factorize
|
MultiLineInfilling/HumanEval/25/L7_L8
|
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 product of all factors
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 product of all factors
"""
import math
fact = []
i = 2
while i <= int(math.sqrt(n) + 1):
if n % i == 0:
fact.append(i)
n //= i
|
fact.append(n)
return fact
|
else:
i += 1
if n > 1:
|
[
[
"2",
"[2]"
],
[
"4",
"[2, 2]"
],
[
"8",
"[2, 2, 2]"
],
[
"3 * 19",
"[3, 19]"
],
[
"3 * 19 * 3 * 19",
"[3, 3, 19, 19]"
],
[
"3 * 19 * 3 * 19 * 3 * 19",
"[3, 3, 3, 19, 19, 19]"
],
[
"3 * 19 * 19 * 19",
"[3, 19, 19, 19]"
],
[
"3 * 2 * 3",
"[2, 3, 3]"
]
] |
[
"from typing import List"
] |
[
[
"8",
"[2, 2, 2]"
],
[
"25",
"[5, 5]"
],
[
"70",
"[2, 5, 7]"
]
] |
factorize
|
MultiLineInfilling/HumanEval/25/L7_L10
|
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 product of all factors
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 product of all factors
"""
import math
fact = []
i = 2
while i <= int(math.sqrt(n) + 1):
if n % i == 0:
fact.append(i)
n //= i
|
return fact
|
else:
i += 1
if n > 1:
fact.append(n)
|
[
[
"2",
"[2]"
],
[
"4",
"[2, 2]"
],
[
"8",
"[2, 2, 2]"
],
[
"3 * 19",
"[3, 19]"
],
[
"3 * 19 * 3 * 19",
"[3, 3, 19, 19]"
],
[
"3 * 19 * 3 * 19 * 3 * 19",
"[3, 3, 3, 19, 19, 19]"
],
[
"3 * 19 * 19 * 19",
"[3, 19, 19, 19]"
],
[
"3 * 2 * 3",
"[2, 3, 3]"
]
] |
[
"from typing import List"
] |
[
[
"8",
"[2, 2, 2]"
],
[
"25",
"[5, 5]"
],
[
"70",
"[2, 5, 7]"
]
] |
factorize
|
MultiLineInfilling/HumanEval/25/L7_L11
|
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 product of all factors
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 product of all factors
"""
import math
fact = []
i = 2
while i <= int(math.sqrt(n) + 1):
if n % i == 0:
fact.append(i)
n //= i
|
else:
i += 1
if n > 1:
fact.append(n)
return fact
|
[
[
"2",
"[2]"
],
[
"4",
"[2, 2]"
],
[
"8",
"[2, 2, 2]"
],
[
"3 * 19",
"[3, 19]"
],
[
"3 * 19 * 3 * 19",
"[3, 3, 19, 19]"
],
[
"3 * 19 * 3 * 19 * 3 * 19",
"[3, 3, 3, 19, 19, 19]"
],
[
"3 * 19 * 19 * 19",
"[3, 19, 19, 19]"
],
[
"3 * 2 * 3",
"[2, 3, 3]"
]
] |
[
"from typing import List"
] |
[
[
"8",
"[2, 2, 2]"
],
[
"25",
"[5, 5]"
],
[
"70",
"[2, 5, 7]"
]
] |
factorize
|
MultiLineInfilling/HumanEval/25/L7_L12
|
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 product of all factors
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
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 product of all factors
"""
import math
fact = []
i = 2
while i <= int(math.sqrt(n) + 1):
if n % i == 0:
fact.append(i)
n //= i
else:
|
if n > 1:
fact.append(n)
return fact
|
i += 1
|
[
[
"2",
"[2]"
],
[
"4",
"[2, 2]"
],
[
"8",
"[2, 2, 2]"
],
[
"3 * 19",
"[3, 19]"
],
[
"3 * 19 * 3 * 19",
"[3, 3, 19, 19]"
],
[
"3 * 19 * 3 * 19 * 3 * 19",
"[3, 3, 3, 19, 19, 19]"
],
[
"3 * 19 * 19 * 19",
"[3, 19, 19, 19]"
],
[
"3 * 2 * 3",
"[2, 3, 3]"
]
] |
[
"from typing import List"
] |
[
[
"8",
"[2, 2, 2]"
],
[
"25",
"[5, 5]"
],
[
"70",
"[2, 5, 7]"
]
] |
factorize
|
MultiLineInfilling/HumanEval/25/L8_L8
|
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 product of all factors
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 product of all factors
"""
import math
fact = []
i = 2
while i <= int(math.sqrt(n) + 1):
if n % i == 0:
fact.append(i)
n //= i
else:
|
fact.append(n)
return fact
|
i += 1
if n > 1:
|
[
[
"2",
"[2]"
],
[
"4",
"[2, 2]"
],
[
"8",
"[2, 2, 2]"
],
[
"3 * 19",
"[3, 19]"
],
[
"3 * 19 * 3 * 19",
"[3, 3, 19, 19]"
],
[
"3 * 19 * 3 * 19 * 3 * 19",
"[3, 3, 3, 19, 19, 19]"
],
[
"3 * 19 * 19 * 19",
"[3, 19, 19, 19]"
],
[
"3 * 2 * 3",
"[2, 3, 3]"
]
] |
[
"from typing import List"
] |
[
[
"8",
"[2, 2, 2]"
],
[
"25",
"[5, 5]"
],
[
"70",
"[2, 5, 7]"
]
] |
factorize
|
MultiLineInfilling/HumanEval/25/L8_L10
|
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 product of all factors
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 product of all factors
"""
import math
fact = []
i = 2
while i <= int(math.sqrt(n) + 1):
if n % i == 0:
fact.append(i)
n //= i
else:
|
return fact
|
i += 1
if n > 1:
fact.append(n)
|
[
[
"2",
"[2]"
],
[
"4",
"[2, 2]"
],
[
"8",
"[2, 2, 2]"
],
[
"3 * 19",
"[3, 19]"
],
[
"3 * 19 * 3 * 19",
"[3, 3, 19, 19]"
],
[
"3 * 19 * 3 * 19 * 3 * 19",
"[3, 3, 3, 19, 19, 19]"
],
[
"3 * 19 * 19 * 19",
"[3, 19, 19, 19]"
],
[
"3 * 2 * 3",
"[2, 3, 3]"
]
] |
[
"from typing import List"
] |
[
[
"8",
"[2, 2, 2]"
],
[
"25",
"[5, 5]"
],
[
"70",
"[2, 5, 7]"
]
] |
factorize
|
MultiLineInfilling/HumanEval/25/L8_L11
|
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 product of all factors
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 product of all factors
"""
import math
fact = []
i = 2
while i <= int(math.sqrt(n) + 1):
if n % i == 0:
fact.append(i)
n //= i
else:
|
i += 1
if n > 1:
fact.append(n)
return fact
|
[
[
"2",
"[2]"
],
[
"4",
"[2, 2]"
],
[
"8",
"[2, 2, 2]"
],
[
"3 * 19",
"[3, 19]"
],
[
"3 * 19 * 3 * 19",
"[3, 3, 19, 19]"
],
[
"3 * 19 * 3 * 19 * 3 * 19",
"[3, 3, 3, 19, 19, 19]"
],
[
"3 * 19 * 19 * 19",
"[3, 19, 19, 19]"
],
[
"3 * 2 * 3",
"[2, 3, 3]"
]
] |
[
"from typing import List"
] |
[
[
"8",
"[2, 2, 2]"
],
[
"25",
"[5, 5]"
],
[
"70",
"[2, 5, 7]"
]
] |
factorize
|
MultiLineInfilling/HumanEval/25/L8_L12
|
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 product of all factors
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
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 product of all factors
"""
import math
fact = []
i = 2
while i <= int(math.sqrt(n) + 1):
if n % i == 0:
fact.append(i)
n //= i
else:
i += 1
|
fact.append(n)
return fact
|
if n > 1:
|
[
[
"2",
"[2]"
],
[
"4",
"[2, 2]"
],
[
"8",
"[2, 2, 2]"
],
[
"3 * 19",
"[3, 19]"
],
[
"3 * 19 * 3 * 19",
"[3, 3, 19, 19]"
],
[
"3 * 19 * 3 * 19 * 3 * 19",
"[3, 3, 3, 19, 19, 19]"
],
[
"3 * 19 * 19 * 19",
"[3, 19, 19, 19]"
],
[
"3 * 2 * 3",
"[2, 3, 3]"
]
] |
[
"from typing import List"
] |
[
[
"8",
"[2, 2, 2]"
],
[
"25",
"[5, 5]"
],
[
"70",
"[2, 5, 7]"
]
] |
factorize
|
MultiLineInfilling/HumanEval/25/L10_L10
|
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 product of all factors
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 product of all factors
"""
import math
fact = []
i = 2
while i <= int(math.sqrt(n) + 1):
if n % i == 0:
fact.append(i)
n //= i
else:
i += 1
|
return fact
|
if n > 1:
fact.append(n)
|
[
[
"2",
"[2]"
],
[
"4",
"[2, 2]"
],
[
"8",
"[2, 2, 2]"
],
[
"3 * 19",
"[3, 19]"
],
[
"3 * 19 * 3 * 19",
"[3, 3, 19, 19]"
],
[
"3 * 19 * 3 * 19 * 3 * 19",
"[3, 3, 3, 19, 19, 19]"
],
[
"3 * 19 * 19 * 19",
"[3, 19, 19, 19]"
],
[
"3 * 2 * 3",
"[2, 3, 3]"
]
] |
[
"from typing import List"
] |
[
[
"8",
"[2, 2, 2]"
],
[
"25",
"[5, 5]"
],
[
"70",
"[2, 5, 7]"
]
] |
factorize
|
MultiLineInfilling/HumanEval/25/L10_L11
|
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 product of all factors
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 product of all factors
"""
import math
fact = []
i = 2
while i <= int(math.sqrt(n) + 1):
if n % i == 0:
fact.append(i)
n //= i
else:
i += 1
|
if n > 1:
fact.append(n)
return fact
|
[
[
"2",
"[2]"
],
[
"4",
"[2, 2]"
],
[
"8",
"[2, 2, 2]"
],
[
"3 * 19",
"[3, 19]"
],
[
"3 * 19 * 3 * 19",
"[3, 3, 19, 19]"
],
[
"3 * 19 * 3 * 19 * 3 * 19",
"[3, 3, 3, 19, 19, 19]"
],
[
"3 * 19 * 19 * 19",
"[3, 19, 19, 19]"
],
[
"3 * 2 * 3",
"[2, 3, 3]"
]
] |
[
"from typing import List"
] |
[
[
"8",
"[2, 2, 2]"
],
[
"25",
"[5, 5]"
],
[
"70",
"[2, 5, 7]"
]
] |
factorize
|
MultiLineInfilling/HumanEval/25/L10_L12
|
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 product of all factors
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
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 product of all factors
"""
import math
fact = []
i = 2
while i <= int(math.sqrt(n) + 1):
if n % i == 0:
fact.append(i)
n //= i
else:
i += 1
if n > 1:
|
return fact
|
fact.append(n)
|
[
[
"2",
"[2]"
],
[
"4",
"[2, 2]"
],
[
"8",
"[2, 2, 2]"
],
[
"3 * 19",
"[3, 19]"
],
[
"3 * 19 * 3 * 19",
"[3, 3, 19, 19]"
],
[
"3 * 19 * 3 * 19 * 3 * 19",
"[3, 3, 3, 19, 19, 19]"
],
[
"3 * 19 * 19 * 19",
"[3, 19, 19, 19]"
],
[
"3 * 2 * 3",
"[2, 3, 3]"
]
] |
[
"from typing import List"
] |
[
[
"8",
"[2, 2, 2]"
],
[
"25",
"[5, 5]"
],
[
"70",
"[2, 5, 7]"
]
] |
factorize
|
MultiLineInfilling/HumanEval/25/L11_L11
|
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 product of all factors
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 product of all factors
"""
import math
fact = []
i = 2
while i <= int(math.sqrt(n) + 1):
if n % i == 0:
fact.append(i)
n //= i
else:
i += 1
if n > 1:
|
fact.append(n)
return fact
|
[
[
"2",
"[2]"
],
[
"4",
"[2, 2]"
],
[
"8",
"[2, 2, 2]"
],
[
"3 * 19",
"[3, 19]"
],
[
"3 * 19 * 3 * 19",
"[3, 3, 19, 19]"
],
[
"3 * 19 * 3 * 19 * 3 * 19",
"[3, 3, 3, 19, 19, 19]"
],
[
"3 * 19 * 19 * 19",
"[3, 19, 19, 19]"
],
[
"3 * 2 * 3",
"[2, 3, 3]"
]
] |
[
"from typing import List"
] |
[
[
"8",
"[2, 2, 2]"
],
[
"25",
"[5, 5]"
],
[
"70",
"[2, 5, 7]"
]
] |
factorize
|
MultiLineInfilling/HumanEval/25/L11_L12
|
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 product of all factors
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
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 product of all factors
"""
import math
fact = []
i = 2
while i <= int(math.sqrt(n) + 1):
if n % i == 0:
fact.append(i)
n //= i
else:
i += 1
if n > 1:
fact.append(n)
|
return fact
|
[
[
"2",
"[2]"
],
[
"4",
"[2, 2]"
],
[
"8",
"[2, 2, 2]"
],
[
"3 * 19",
"[3, 19]"
],
[
"3 * 19 * 3 * 19",
"[3, 3, 19, 19]"
],
[
"3 * 19 * 3 * 19 * 3 * 19",
"[3, 3, 3, 19, 19, 19]"
],
[
"3 * 19 * 19 * 19",
"[3, 19, 19, 19]"
],
[
"3 * 2 * 3",
"[2, 3, 3]"
]
] |
[
"from typing import List"
] |
[
[
"8",
"[2, 2, 2]"
],
[
"25",
"[5, 5]"
],
[
"70",
"[2, 5, 7]"
]
] |
factorize
|
MultiLineInfilling/HumanEval/25/L12_L12
|
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 product of all factors
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
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.
"""
|
c = collections.Counter(numbers)
return [n for n in numbers if c[n] <= 1]
|
import collections
|
[
[
"[]",
"[]"
],
[
"[1, 2, 3, 4]",
"[1, 2, 3, 4]"
],
[
"[1, 2, 3, 2, 4, 3, 5]",
"[1, 4, 5]"
]
] |
[
"from typing import List"
] |
[
[
"[1, 2, 3, 2, 4]",
"[1, 3, 4]"
]
] |
remove_duplicates
|
MultiLineInfilling/HumanEval/26/L0_L0
|
From a list of integers, remove all elements that occur more than once.
Keep order of elements left the same as in the input.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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.
"""
|
return [n for n in numbers if c[n] <= 1]
|
import collections
c = collections.Counter(numbers)
|
[
[
"[]",
"[]"
],
[
"[1, 2, 3, 4]",
"[1, 2, 3, 4]"
],
[
"[1, 2, 3, 2, 4, 3, 5]",
"[1, 4, 5]"
]
] |
[
"from typing import List"
] |
[
[
"[1, 2, 3, 2, 4]",
"[1, 3, 4]"
]
] |
remove_duplicates
|
MultiLineInfilling/HumanEval/26/L0_L1
|
From a list of integers, remove all elements that occur more than once.
Keep order of elements left the same as in the input.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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.
"""
|
import collections
c = collections.Counter(numbers)
return [n for n in numbers if c[n] <= 1]
|
[
[
"[]",
"[]"
],
[
"[1, 2, 3, 4]",
"[1, 2, 3, 4]"
],
[
"[1, 2, 3, 2, 4, 3, 5]",
"[1, 4, 5]"
]
] |
[
"from typing import List"
] |
[
[
"[1, 2, 3, 2, 4]",
"[1, 3, 4]"
]
] |
remove_duplicates
|
MultiLineInfilling/HumanEval/26/L0_L2
|
From a list of integers, remove all elements that occur more than once.
Keep order of elements left the same as in the input.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
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.
"""
import collections
|
return [n for n in numbers if c[n] <= 1]
|
c = collections.Counter(numbers)
|
[
[
"[]",
"[]"
],
[
"[1, 2, 3, 4]",
"[1, 2, 3, 4]"
],
[
"[1, 2, 3, 2, 4, 3, 5]",
"[1, 4, 5]"
]
] |
[
"from typing import List"
] |
[
[
"[1, 2, 3, 2, 4]",
"[1, 3, 4]"
]
] |
remove_duplicates
|
MultiLineInfilling/HumanEval/26/L1_L1
|
From a list of integers, remove all elements that occur more than once.
Keep order of elements left the same as in the input.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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.
"""
import collections
|
c = collections.Counter(numbers)
return [n for n in numbers if c[n] <= 1]
|
[
[
"[]",
"[]"
],
[
"[1, 2, 3, 4]",
"[1, 2, 3, 4]"
],
[
"[1, 2, 3, 2, 4, 3, 5]",
"[1, 4, 5]"
]
] |
[
"from typing import List"
] |
[
[
"[1, 2, 3, 2, 4]",
"[1, 3, 4]"
]
] |
remove_duplicates
|
MultiLineInfilling/HumanEval/26/L1_L2
|
From a list of integers, remove all elements that occur more than once.
Keep order of elements left the same as in the input.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
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.
"""
import collections
c = collections.Counter(numbers)
|
return [n for n in numbers if c[n] <= 1]
|
[
[
"[]",
"[]"
],
[
"[1, 2, 3, 4]",
"[1, 2, 3, 4]"
],
[
"[1, 2, 3, 2, 4, 3, 5]",
"[1, 4, 5]"
]
] |
[
"from typing import List"
] |
[
[
"[1, 2, 3, 2, 4]",
"[1, 3, 4]"
]
] |
remove_duplicates
|
MultiLineInfilling/HumanEval/26/L2_L2
|
From a list of integers, remove all elements that occur more than once.
Keep order of elements left the same as in the input.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
def flip_case(string: str) -> str:
""" For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
"""
|
return string.swapcase()
|
[
[
"''",
"''"
],
[
"'Hello!'",
"'hELLO!'"
],
[
"'These violent delights have violent ends'",
"'tHESE VIOLENT DELIGHTS HAVE VIOLENT ENDS'"
]
] |
[] |
[
[
"'Hello'",
"'hELLO'"
]
] |
flip_case
|
MultiLineInfilling/HumanEval/27/L0_L0
|
For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
from typing import List
def concatenate(strings: List[str]) -> str:
""" Concatenate list of strings into a single string
"""
|
return ''.join(strings)
|
[
[
"[]",
"''"
],
[
"['x', 'y', 'z']",
"'xyz'"
],
[
"['x', 'y', 'z', 'w', 'k']",
"'xyzwk'"
]
] |
[
"from typing import List"
] |
[
[
"[]",
"''"
],
[
"['a', 'b', 'c']",
"'abc'"
]
] |
concatenate
|
MultiLineInfilling/HumanEval/28/L0_L0
|
Concatenate list of strings into a single string
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
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.
"""
|
return [x for x in strings if x.startswith(prefix)]
|
[
[
"[], 'john'",
"[]"
],
[
"['xxx', 'asd', 'xxy', 'john doe', 'xxxAAA', 'xxx'], 'xxx'",
"['xxx', 'xxxAAA', 'xxx']"
]
] |
[
"from typing import List"
] |
[
[
"[], 'a'",
"[]"
],
[
"['abc', 'bcd', 'cde', 'array'], 'a'",
"['abc', 'array']"
]
] |
filter_by_prefix
|
MultiLineInfilling/HumanEval/29/L0_L0
|
Filter an input list of strings only for ones that start with a given prefix.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
def get_positive(l: list):
"""Return only positive numbers in the list.
"""
|
return [e for e in l if e > 0]
|
[
[
"[-1, -2, 4, 5, 6]",
"[4, 5, 6]"
],
[
"[5, 3, -5, 2, 3, 3, 9, 0, 123, 1, -10]",
"[5, 3, 2, 3, 3, 9, 123, 1]"
],
[
"[-1, -2]",
"[]"
],
[
"[]",
"[]"
]
] |
[] |
[
[
"[-1, 2, -4, 5, 6]",
"[2, 5, 6]"
],
[
"[5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]",
"[5, 3, 2, 3, 9, 123, 1]"
]
] |
get_positive
|
MultiLineInfilling/HumanEval/30/L0_L0
|
Return only positive numbers in the list.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
|
return False
for k in range(2, n - 1):
if n % k == 0:
return False
return True
|
if n < 2:
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L0_L0
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
|
for k in range(2, n - 1):
if n % k == 0:
return False
return True
|
if n < 2:
return False
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L0_L1
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
|
if n % k == 0:
return False
return True
|
if n < 2:
return False
for k in range(2, n - 1):
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L0_L2
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
|
return False
return True
|
if n < 2:
return False
for k in range(2, n - 1):
if n % k == 0:
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L0_L3
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
|
return True
|
if n < 2:
return False
for k in range(2, n - 1):
if n % k == 0:
return False
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L0_L4
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
|
if n < 2:
return False
for k in range(2, n - 1):
if n % k == 0:
return False
return True
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L0_L5
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
if n < 2:
|
for k in range(2, n - 1):
if n % k == 0:
return False
return True
|
return False
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L1_L1
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
if n < 2:
|
if n % k == 0:
return False
return True
|
return False
for k in range(2, n - 1):
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L1_L2
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
if n < 2:
|
return False
return True
|
return False
for k in range(2, n - 1):
if n % k == 0:
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L1_L3
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
if n < 2:
|
return True
|
return False
for k in range(2, n - 1):
if n % k == 0:
return False
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L1_L4
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
if n < 2:
|
return False
for k in range(2, n - 1):
if n % k == 0:
return False
return True
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L1_L5
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
if n < 2:
return False
|
if n % k == 0:
return False
return True
|
for k in range(2, n - 1):
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L2_L2
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
if n < 2:
return False
|
return False
return True
|
for k in range(2, n - 1):
if n % k == 0:
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L2_L3
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
if n < 2:
return False
|
return True
|
for k in range(2, n - 1):
if n % k == 0:
return False
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L2_L4
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
if n < 2:
return False
|
for k in range(2, n - 1):
if n % k == 0:
return False
return True
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L2_L5
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
if n < 2:
return False
for k in range(2, n - 1):
|
return False
return True
|
if n % k == 0:
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L3_L3
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
if n < 2:
return False
for k in range(2, n - 1):
|
return True
|
if n % k == 0:
return False
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L3_L4
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
if n < 2:
return False
for k in range(2, n - 1):
|
if n % k == 0:
return False
return True
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L3_L5
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
if n < 2:
return False
for k in range(2, n - 1):
if n % k == 0:
|
return True
|
return False
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L4_L4
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
if n < 2:
return False
for k in range(2, n - 1):
if n % k == 0:
|
return False
return True
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L4_L5
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
def is_prime(n):
"""Return true if a given number is prime, and false otherwise.
"""
if n < 2:
return False
for k in range(2, n - 1):
if n % k == 0:
return False
|
return True
|
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
],
[
"5",
"True"
],
[
"11",
"True"
],
[
"17",
"True"
],
[
"5 * 17",
"False"
],
[
"11 * 7",
"False"
],
[
"13441 * 19",
"False"
]
] |
[] |
[
[
"6",
"False"
],
[
"101",
"True"
],
[
"11",
"True"
],
[
"13441",
"True"
],
[
"61",
"True"
],
[
"4",
"False"
],
[
"1",
"False"
]
] |
is_prime
|
MultiLineInfilling/HumanEval/31/L5_L5
|
Return true if a given number is prime, and false otherwise.
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
|
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
begin, end = -1., 1.
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L0_L0
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
|
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L0_L1
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
|
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L0_L2
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
|
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L0_L3
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
|
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L0_L4
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
|
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L0_L5
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
|
begin = center
else:
end = center
return begin
|
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L0_L6
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
|
else:
end = center
return begin
|
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L0_L7
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
|
end = center
return begin
|
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L0_L8
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
|
return begin
|
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L0_L9
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
|
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L0_L10
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
|
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
while poly(xs, begin) * poly(xs, end) > 0:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L1_L1
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
|
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L1_L2
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
|
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L1_L3
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
|
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L1_L4
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
|
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L1_L5
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
|
begin = center
else:
end = center
return begin
|
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L1_L6
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
|
else:
end = center
return begin
|
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L1_L7
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
|
end = center
return begin
|
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L1_L8
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
|
return begin
|
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L1_L9
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
|
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L1_L10
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
|
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
begin *= 2.0
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L2_L2
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
|
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
begin *= 2.0
end *= 2.0
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L2_L3
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
|
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L2_L4
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
|
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L2_L5
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
|
begin = center
else:
end = center
return begin
|
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L2_L6
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
|
else:
end = center
return begin
|
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L2_L7
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
|
end = center
return begin
|
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L2_L8
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
|
return begin
|
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L2_L9
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
|
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L2_L10
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
|
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
end *= 2.0
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L3_L3
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
|
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
end *= 2.0
while end - begin > 1e-10:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L3_L4
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
|
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L3_L5
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
|
begin = center
else:
end = center
return begin
|
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L3_L6
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
|
else:
end = center
return begin
|
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L3_L7
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
|
end = center
return begin
|
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L3_L8
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
|
return begin
|
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L3_L9
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
|
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L3_L10
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
|
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
while end - begin > 1e-10:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L4_L4
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
|
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
while end - begin > 1e-10:
center = (begin + end) / 2.0
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L4_L5
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
|
begin = center
else:
end = center
return begin
|
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L4_L6
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
|
else:
end = center
return begin
|
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L4_L7
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
|
end = center
return begin
|
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L4_L8
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
|
return begin
|
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L4_L9
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
|
while end - begin > 1e-10:
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L4_L10
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
|
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
center = (begin + end) / 2.0
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L5_L5
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
|
begin = center
else:
end = center
return begin
|
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L5_L6
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
|
else:
end = center
return begin
|
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L5_L7
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
|
end = center
return begin
|
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L5_L8
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
|
return begin
|
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L5_L9
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
|
center = (begin + end) / 2.0
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
return begin
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L5_L10
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
|
begin = center
else:
end = center
return begin
|
if poly(xs, center) * poly(xs, begin) > 0:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L6_L6
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
|
else:
end = center
return begin
|
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L6_L7
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
|
end = center
return begin
|
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L6_L8
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
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 polynomial.
find_zero find x such that poly(x) = 0.
find_zero returns only only zero point, even if there are many.
Moreover, find_zero only takes list xs having even number of coefficients
and largest non zero coefficient as it guarantees
a solution.
>>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
-0.5
>>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
1.0
"""
begin, end = -1., 1.
while poly(xs, begin) * poly(xs, end) > 0:
begin *= 2.0
end *= 2.0
while end - begin > 1e-10:
center = (begin + end) / 2.0
|
return begin
|
if poly(xs, center) * poly(xs, begin) > 0:
begin = center
else:
end = center
|
[] |
[
"import math"
] |
[
[
"x",
"0."
],
[
"find_zero([1, 2]), 2) # f(x",
"1 + 2x"
],
[
"find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3",
"-6 + 11x - 6x^2 + x^3"
]
] |
find_zero
|
MultiLineInfilling/HumanEval/32/L6_L9
|
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
|
HumanEval_MultiLineInfilling
|
code_infilling
|
[] |
python
|
python
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.