测试评估
| 指标 | 结果 |
|---|---|
| Base 测试 | PASS |
| Plus 测试 | PASS |
| 代码长度 | 535 字符 |
模型生成的代码 (535 字符)
def remove_Occ(s: str, ch: str) -> str:
"""
Remove the first and last occurrence of a given character from the string.
If the character appears only once, that single occurrence is removed.
If the character is not present, the original string is returned.
"""
first = s.find(ch)
if first == -1: # character not found
return s
last = s.rfind(ch)
if first == last: # only one occurrence
return s[:first] + s[first+1:]
else:
return s[:first] + s[first+1:last] + s[last+1:]
Base 失败测试用例
- 无失败测试
Plus 失败测试用例
- 无失败测试