task_id
stringlengths
36
40
entry_point
stringlengths
1
30
prompt
stringlengths
116
1.98k
suffix
stringlengths
0
837
canonical_solution
stringlengths
6
859
test
stringlengths
117
1.8k
MultiLineInfilling/HumanEval/161/L11_L11
solve
def solve(s): """You are given a string s. if s[i] is a letter, reverse its case from lower to upper or vise versa, otherwise keep it as it is. If the string contains no letters, reverse the string. The function should return the resulted string. Examples solve("1234") = "4321" solve("ab") = "AB" solve("#a@C") = "#A@c" """ flg = 0 idx = 0 new_str = list(s) for i in s: if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 1 s = "" for i in new_str: s += i
return s[len(s)::-1] return s
if flg == 0:
def check(candidate): # Check some simple cases assert candidate("AsDf") == "aSdF" assert candidate("1234") == "4321" assert candidate("ab") == "AB" assert candidate("#a@C") == "#A@c" assert candidate("#AsdfW^45") == "#aSDFw^45" assert candidate("#6@2") == "2@6#" # Check some edge cases that are easy to work out by hand. assert candidate("#$a^D") == "#$A^d" assert candidate("#ccc") == "#CCC" # Don't remove this line:
MultiLineInfilling/HumanEval/161/L11_L12
solve
def solve(s): """You are given a string s. if s[i] is a letter, reverse its case from lower to upper or vise versa, otherwise keep it as it is. If the string contains no letters, reverse the string. The function should return the resulted string. Examples solve("1234") = "4321" solve("ab") = "AB" solve("#a@C") = "#A@c" """ flg = 0 idx = 0 new_str = list(s) for i in s: if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 1 s = "" for i in new_str: s += i
return s
if flg == 0: return s[len(s)::-1]
def check(candidate): # Check some simple cases assert candidate("AsDf") == "aSdF" assert candidate("1234") == "4321" assert candidate("ab") == "AB" assert candidate("#a@C") == "#A@c" assert candidate("#AsdfW^45") == "#aSDFw^45" assert candidate("#6@2") == "2@6#" # Check some edge cases that are easy to work out by hand. assert candidate("#$a^D") == "#$A^d" assert candidate("#ccc") == "#CCC" # Don't remove this line:
MultiLineInfilling/HumanEval/161/L11_L13
solve
def solve(s): """You are given a string s. if s[i] is a letter, reverse its case from lower to upper or vise versa, otherwise keep it as it is. If the string contains no letters, reverse the string. The function should return the resulted string. Examples solve("1234") = "4321" solve("ab") = "AB" solve("#a@C") = "#A@c" """ flg = 0 idx = 0 new_str = list(s) for i in s: if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 1 s = "" for i in new_str: s += i
if flg == 0: return s[len(s)::-1] return s
def check(candidate): # Check some simple cases assert candidate("AsDf") == "aSdF" assert candidate("1234") == "4321" assert candidate("ab") == "AB" assert candidate("#a@C") == "#A@c" assert candidate("#AsdfW^45") == "#aSDFw^45" assert candidate("#6@2") == "2@6#" # Check some edge cases that are easy to work out by hand. assert candidate("#$a^D") == "#$A^d" assert candidate("#ccc") == "#CCC" # Don't remove this line:
MultiLineInfilling/HumanEval/161/L12_L12
solve
def solve(s): """You are given a string s. if s[i] is a letter, reverse its case from lower to upper or vise versa, otherwise keep it as it is. If the string contains no letters, reverse the string. The function should return the resulted string. Examples solve("1234") = "4321" solve("ab") = "AB" solve("#a@C") = "#A@c" """ flg = 0 idx = 0 new_str = list(s) for i in s: if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 1 s = "" for i in new_str: s += i if flg == 0:
return s
return s[len(s)::-1]
def check(candidate): # Check some simple cases assert candidate("AsDf") == "aSdF" assert candidate("1234") == "4321" assert candidate("ab") == "AB" assert candidate("#a@C") == "#A@c" assert candidate("#AsdfW^45") == "#aSDFw^45" assert candidate("#6@2") == "2@6#" # Check some edge cases that are easy to work out by hand. assert candidate("#$a^D") == "#$A^d" assert candidate("#ccc") == "#CCC" # Don't remove this line:
MultiLineInfilling/HumanEval/161/L12_L13
solve
def solve(s): """You are given a string s. if s[i] is a letter, reverse its case from lower to upper or vise versa, otherwise keep it as it is. If the string contains no letters, reverse the string. The function should return the resulted string. Examples solve("1234") = "4321" solve("ab") = "AB" solve("#a@C") = "#A@c" """ flg = 0 idx = 0 new_str = list(s) for i in s: if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 1 s = "" for i in new_str: s += i if flg == 0:
return s[len(s)::-1] return s
def check(candidate): # Check some simple cases assert candidate("AsDf") == "aSdF" assert candidate("1234") == "4321" assert candidate("ab") == "AB" assert candidate("#a@C") == "#A@c" assert candidate("#AsdfW^45") == "#aSDFw^45" assert candidate("#6@2") == "2@6#" # Check some edge cases that are easy to work out by hand. assert candidate("#$a^D") == "#$A^d" assert candidate("#ccc") == "#CCC" # Don't remove this line:
MultiLineInfilling/HumanEval/161/L13_L13
solve
def solve(s): """You are given a string s. if s[i] is a letter, reverse its case from lower to upper or vise versa, otherwise keep it as it is. If the string contains no letters, reverse the string. The function should return the resulted string. Examples solve("1234") = "4321" solve("ab") = "AB" solve("#a@C") = "#A@c" """ flg = 0 idx = 0 new_str = list(s) for i in s: if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 1 s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1]
return s
def check(candidate): # Check some simple cases assert candidate("AsDf") == "aSdF" assert candidate("1234") == "4321" assert candidate("ab") == "AB" assert candidate("#a@C") == "#A@c" assert candidate("#AsdfW^45") == "#aSDFw^45" assert candidate("#6@2") == "2@6#" # Check some edge cases that are easy to work out by hand. assert candidate("#$a^D") == "#$A^d" assert candidate("#ccc") == "#CCC" # Don't remove this line:
MultiLineInfilling/HumanEval/162/L0_L0
string_to_md5
def string_to_md5(text): """ Given a string 'text', return its md5 hash equivalent string. If 'text' is an empty string, return None. >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62' """
return hashlib.md5(text.encode('ascii')).hexdigest() if text else None
import hashlib
def check(candidate): # Check some simple cases assert candidate('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62' assert candidate('') == None assert candidate('A B C') == '0ef78513b0cb8cef12743f5aeb35f888' assert candidate('password') == '5f4dcc3b5aa765d61d8327deb882cf99' # Check some edge cases that are easy to work out by hand. assert True
MultiLineInfilling/HumanEval/162/L0_L1
string_to_md5
def string_to_md5(text): """ Given a string 'text', return its md5 hash equivalent string. If 'text' is an empty string, return None. >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62' """
import hashlib return hashlib.md5(text.encode('ascii')).hexdigest() if text else None
def check(candidate): # Check some simple cases assert candidate('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62' assert candidate('') == None assert candidate('A B C') == '0ef78513b0cb8cef12743f5aeb35f888' assert candidate('password') == '5f4dcc3b5aa765d61d8327deb882cf99' # Check some edge cases that are easy to work out by hand. assert True
MultiLineInfilling/HumanEval/162/L1_L1
string_to_md5
def string_to_md5(text): """ Given a string 'text', return its md5 hash equivalent string. If 'text' is an empty string, return None. >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62' """ import hashlib
return hashlib.md5(text.encode('ascii')).hexdigest() if text else None
def check(candidate): # Check some simple cases assert candidate('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62' assert candidate('') == None assert candidate('A B C') == '0ef78513b0cb8cef12743f5aeb35f888' assert candidate('password') == '5f4dcc3b5aa765d61d8327deb882cf99' # Check some edge cases that are easy to work out by hand. assert True
MultiLineInfilling/HumanEval/163/L0_L0
generate_integers
def generate_integers(a, b): """ Given two positive integers a and b, return the even digits between a and b, in ascending order. For example: generate_integers(2, 8) => [2, 4, 6, 8] generate_integers(8, 2) => [2, 4, 6, 8] generate_integers(10, 14) => [] """
upper = min(8, max(a, b)) return [i for i in range(lower, upper+1) if i % 2 == 0]
lower = max(2, min(a, b))
def check(candidate): # Check some simple cases assert candidate(2, 10) == [2, 4, 6, 8], "Test 1" assert candidate(10, 2) == [2, 4, 6, 8], "Test 2" assert candidate(132, 2) == [2, 4, 6, 8], "Test 3" assert candidate(17,89) == [], "Test 4" # Check some edge cases that are easy to work out by hand. assert True, "This prints if this assert fails 2 (also good for debugging!)"
MultiLineInfilling/HumanEval/163/L0_L1
generate_integers
def generate_integers(a, b): """ Given two positive integers a and b, return the even digits between a and b, in ascending order. For example: generate_integers(2, 8) => [2, 4, 6, 8] generate_integers(8, 2) => [2, 4, 6, 8] generate_integers(10, 14) => [] """
return [i for i in range(lower, upper+1) if i % 2 == 0]
lower = max(2, min(a, b)) upper = min(8, max(a, b))
def check(candidate): # Check some simple cases assert candidate(2, 10) == [2, 4, 6, 8], "Test 1" assert candidate(10, 2) == [2, 4, 6, 8], "Test 2" assert candidate(132, 2) == [2, 4, 6, 8], "Test 3" assert candidate(17,89) == [], "Test 4" # Check some edge cases that are easy to work out by hand. assert True, "This prints if this assert fails 2 (also good for debugging!)"
MultiLineInfilling/HumanEval/163/L0_L3
generate_integers
def generate_integers(a, b): """ Given two positive integers a and b, return the even digits between a and b, in ascending order. For example: generate_integers(2, 8) => [2, 4, 6, 8] generate_integers(8, 2) => [2, 4, 6, 8] generate_integers(10, 14) => [] """
lower = max(2, min(a, b)) upper = min(8, max(a, b)) return [i for i in range(lower, upper+1) if i % 2 == 0]
def check(candidate): # Check some simple cases assert candidate(2, 10) == [2, 4, 6, 8], "Test 1" assert candidate(10, 2) == [2, 4, 6, 8], "Test 2" assert candidate(132, 2) == [2, 4, 6, 8], "Test 3" assert candidate(17,89) == [], "Test 4" # Check some edge cases that are easy to work out by hand. assert True, "This prints if this assert fails 2 (also good for debugging!)"
MultiLineInfilling/HumanEval/163/L1_L1
generate_integers
def generate_integers(a, b): """ Given two positive integers a and b, return the even digits between a and b, in ascending order. For example: generate_integers(2, 8) => [2, 4, 6, 8] generate_integers(8, 2) => [2, 4, 6, 8] generate_integers(10, 14) => [] """ lower = max(2, min(a, b))
return [i for i in range(lower, upper+1) if i % 2 == 0]
upper = min(8, max(a, b))
def check(candidate): # Check some simple cases assert candidate(2, 10) == [2, 4, 6, 8], "Test 1" assert candidate(10, 2) == [2, 4, 6, 8], "Test 2" assert candidate(132, 2) == [2, 4, 6, 8], "Test 3" assert candidate(17,89) == [], "Test 4" # Check some edge cases that are easy to work out by hand. assert True, "This prints if this assert fails 2 (also good for debugging!)"
MultiLineInfilling/HumanEval/163/L1_L3
generate_integers
def generate_integers(a, b): """ Given two positive integers a and b, return the even digits between a and b, in ascending order. For example: generate_integers(2, 8) => [2, 4, 6, 8] generate_integers(8, 2) => [2, 4, 6, 8] generate_integers(10, 14) => [] """ lower = max(2, min(a, b))
upper = min(8, max(a, b)) return [i for i in range(lower, upper+1) if i % 2 == 0]
def check(candidate): # Check some simple cases assert candidate(2, 10) == [2, 4, 6, 8], "Test 1" assert candidate(10, 2) == [2, 4, 6, 8], "Test 2" assert candidate(132, 2) == [2, 4, 6, 8], "Test 3" assert candidate(17,89) == [], "Test 4" # Check some edge cases that are easy to work out by hand. assert True, "This prints if this assert fails 2 (also good for debugging!)"
MultiLineInfilling/HumanEval/163/L3_L3
generate_integers
def generate_integers(a, b): """ Given two positive integers a and b, return the even digits between a and b, in ascending order. For example: generate_integers(2, 8) => [2, 4, 6, 8] generate_integers(8, 2) => [2, 4, 6, 8] generate_integers(10, 14) => [] """ lower = max(2, min(a, b)) upper = min(8, max(a, b))
return [i for i in range(lower, upper+1) if i % 2 == 0]
def check(candidate): # Check some simple cases assert candidate(2, 10) == [2, 4, 6, 8], "Test 1" assert candidate(10, 2) == [2, 4, 6, 8], "Test 2" assert candidate(132, 2) == [2, 4, 6, 8], "Test 3" assert candidate(17,89) == [], "Test 4" # Check some edge cases that are easy to work out by hand. assert True, "This prints if this assert fails 2 (also good for debugging!)"