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/160/L3_L3
do_algebra
def do_algebra(operator, operand): """ Given two lists operator, and operand. The first list has basic algebra operations, and the second list is a list of integers. Use the two given lists to build the algebric expression and return the evaluation of this expression. The basic algebra operations: Addition ( + ) Subtraction ( - ) Multiplication ( * ) Floor division ( // ) Exponentiation ( ** ) Example: operator['+', '*', '-'] array = [2, 3, 4, 5] result = 2 + 3 * 4 - 5 => result = 9 Note: The length of operator list is equal to the length of operand list minus one. Operand is a list of of non-negative integers. Operator list has at least one operator, and operand list has at least two operands. """ expression = str(operand[0]) for oprt, oprn in zip(operator, operand[1:]): expression+= oprt + str(oprn)
return eval(expression)
def check(candidate): # Check some simple cases assert candidate(['**', '*', '+'], [2, 3, 4, 5]) == 37 assert candidate(['+', '*', '-'], [2, 3, 4, 5]) == 9 assert candidate(['//', '*'], [7, 3, 4]) == 8, "This prints if this assert fails 1 (good for debugging!)" # 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/161/L0_L0
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" """
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
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/L0_L1
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" """
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
flg = 0 idx = 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/L0_L2
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" """
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
flg = 0 idx = 0 new_str = list(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/L0_L3
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" """
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
flg = 0 idx = 0 new_str = list(s) for i in 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/L0_L4
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" """
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
flg = 0 idx = 0 new_str = list(s) for i in s: if i.isalpha():
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/L0_L5
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 = 1 idx += 1 s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
flg = 0 idx = 0 new_str = list(s) for i in s: if i.isalpha(): new_str[idx] = i.swapcase()
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/L0_L6
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" """
idx += 1 s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
flg = 0 idx = 0 new_str = list(s) for i in s: if i.isalpha(): new_str[idx] = i.swapcase() flg = 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/L0_L7
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" """
s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
flg = 0 idx = 0 new_str = list(s) for i in s: if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 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/L0_L8
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" """
for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
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 = ""
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/L0_L9
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" """
s += i if flg == 0: return s[len(s)::-1] return s
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:
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/L0_L10
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" """
if flg == 0: return s[len(s)::-1] return s
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
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/L0_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" """
return s[len(s)::-1] return s
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:
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/L0_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" """
return s
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]
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/L0_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/L1_L1
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
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
idx = 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/L1_L2
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
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
idx = 0 new_str = list(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/L1_L3
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
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
idx = 0 new_str = list(s) for i in 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/L1_L4
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
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
idx = 0 new_str = list(s) for i in s: if i.isalpha():
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/L1_L5
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
flg = 1 idx += 1 s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
idx = 0 new_str = list(s) for i in s: if i.isalpha(): new_str[idx] = i.swapcase()
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/L1_L6
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 += 1 s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
idx = 0 new_str = list(s) for i in s: if i.isalpha(): new_str[idx] = i.swapcase() flg = 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/L1_L7
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
s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
idx = 0 new_str = list(s) for i in s: if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 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/L1_L8
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
for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
idx = 0 new_str = list(s) for i in s: if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 1 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/L1_L9
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
s += i if flg == 0: return s[len(s)::-1] return s
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:
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/L1_L10
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
if flg == 0: return s[len(s)::-1] return s
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
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/L1_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
return s[len(s)::-1] return s
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:
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/L1_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
return s
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]
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/L1_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/L2_L2
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
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
new_str = list(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/L2_L3
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
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
new_str = list(s) for i in 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/L2_L4
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[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
new_str = list(s) for i in s: if i.isalpha():
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/L2_L5
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
flg = 1 idx += 1 s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
new_str = list(s) for i in s: if i.isalpha(): new_str[idx] = i.swapcase()
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/L2_L6
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
idx += 1 s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
new_str = list(s) for i in s: if i.isalpha(): new_str[idx] = i.swapcase() flg = 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/L2_L7
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
s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
new_str = list(s) for i in s: if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 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/L2_L8
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
for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
new_str = list(s) for i in s: if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 1 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/L2_L9
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
s += i if flg == 0: return s[len(s)::-1] return s
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:
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/L2_L10
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
if flg == 0: return s[len(s)::-1] return s
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
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/L2_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
return s[len(s)::-1] return s
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:
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/L2_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
return s
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]
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/L2_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/L3_L3
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)
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
for i in 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/L3_L4
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)
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
for i in s: if i.isalpha():
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/L3_L5
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)
flg = 1 idx += 1 s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
for i in s: if i.isalpha(): new_str[idx] = i.swapcase()
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/L3_L6
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)
idx += 1 s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
for i in s: if i.isalpha(): new_str[idx] = i.swapcase() flg = 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/L3_L7
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)
s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
for i in s: if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 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/L3_L8
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 new_str: s += i if flg == 0: return s[len(s)::-1] return s
for i in s: if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 1 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/L3_L9
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)
s += i if flg == 0: return s[len(s)::-1] return s
for i in s: if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 1 s = "" for i in new_str:
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/L3_L10
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)
if flg == 0: return s[len(s)::-1] return 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
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/L3_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)
return s[len(s)::-1] return 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:
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/L3_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)
return 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]
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/L3_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/L4_L4
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:
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
if i.isalpha():
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/L4_L5
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:
flg = 1 idx += 1 s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
if i.isalpha(): new_str[idx] = i.swapcase()
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/L4_L6
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:
idx += 1 s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
if i.isalpha(): new_str[idx] = i.swapcase() flg = 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/L4_L7
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:
s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 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/L4_L8
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:
for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 1 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/L4_L9
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:
s += i if flg == 0: return s[len(s)::-1] return s
if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 1 s = "" for i in new_str:
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/L4_L10
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 flg == 0: return s[len(s)::-1] return s
if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 1 s = "" for i in new_str: s += i
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/L4_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:
return s[len(s)::-1] return s
if i.isalpha(): new_str[idx] = i.swapcase() flg = 1 idx += 1 s = "" for i in new_str: s += i 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/L4_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:
return 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]
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/L4_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/L5_L5
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():
flg = 1 idx += 1 s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
new_str[idx] = i.swapcase()
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/L5_L6
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():
idx += 1 s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
new_str[idx] = i.swapcase() flg = 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/L5_L7
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():
s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
new_str[idx] = i.swapcase() flg = 1 idx += 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/L5_L8
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():
for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
new_str[idx] = i.swapcase() flg = 1 idx += 1 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/L5_L9
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():
s += i if flg == 0: return s[len(s)::-1] return s
new_str[idx] = i.swapcase() flg = 1 idx += 1 s = "" for i in new_str:
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/L5_L10
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():
if flg == 0: return s[len(s)::-1] return s
new_str[idx] = i.swapcase() flg = 1 idx += 1 s = "" for i in new_str: s += i
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/L5_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():
return s[len(s)::-1] return s
new_str[idx] = i.swapcase() flg = 1 idx += 1 s = "" for i in new_str: s += i 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/L5_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():
return s
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]
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/L5_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/L6_L6
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()
idx += 1 s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
flg = 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/L6_L7
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()
s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
flg = 1 idx += 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/L6_L8
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()
for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
flg = 1 idx += 1 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/L6_L9
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()
s += i if flg == 0: return s[len(s)::-1] return s
flg = 1 idx += 1 s = "" for i in new_str:
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/L6_L10
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()
if flg == 0: return s[len(s)::-1] return s
flg = 1 idx += 1 s = "" for i in new_str: s += i
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/L6_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()
return s[len(s)::-1] return s
flg = 1 idx += 1 s = "" for i in new_str: s += i 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/L6_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()
return s
flg = 1 idx += 1 s = "" for i in new_str: s += i 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/L6_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/L7_L7
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
s = "" for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
idx += 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/L7_L8
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
for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
idx += 1 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/L7_L9
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
s += i if flg == 0: return s[len(s)::-1] return s
idx += 1 s = "" for i in new_str:
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/L7_L10
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
if flg == 0: return s[len(s)::-1] return s
idx += 1 s = "" for i in new_str: s += i
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/L7_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
return s[len(s)::-1] return s
idx += 1 s = "" for i in new_str: s += i 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/L7_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
return s
idx += 1 s = "" for i in new_str: s += i 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/L7_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/L8_L8
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
for i in new_str: s += i if flg == 0: return s[len(s)::-1] return s
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/L8_L9
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 += i if flg == 0: return s[len(s)::-1] return s
s = "" for i in new_str:
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/L8_L10
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
if flg == 0: return s[len(s)::-1] return s
s = "" for i in new_str: s += i
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/L8_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
return s[len(s)::-1] return s
s = "" for i in new_str: s += i 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/L8_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
return s
s = "" for i in new_str: s += i 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/L8_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/L9_L9
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 = ""
s += i if flg == 0: return s[len(s)::-1] return s
for i in new_str:
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/L9_L10
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 = ""
if flg == 0: return s[len(s)::-1] return s
for i in new_str: s += i
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/L9_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 = ""
return s[len(s)::-1] return s
for i in new_str: s += i 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/L9_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 = ""
return s
for i in new_str: s += i 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/L9_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/L10_L10
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:
if flg == 0: return s[len(s)::-1] return s
s += i
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/L10_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:
return s[len(s)::-1] return s
s += i 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/L10_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:
return s
s += i 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/L10_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: