Mbpp/631

✅ 完美通过 Base: PASS Plus: PASS
测试评估
指标结果
Base 测试PASS
Plus 测试PASS
代码长度451 字符
模型生成的代码 (451 字符)
def replace_spaces(s: str) -> str:
    """
    Replace spaces with underscores and underscores with spaces in the given string.

    This function swaps the space character ' ' and the underscore '_'.
    It works for any mix of both characters without interference.
    """
    # Create a translation table that maps space to underscore and underscore to space
    trans_table = str.maketrans({' ': '_', '_': ' '})
    return s.translate(trans_table)
Base 失败测试用例
  • 无失败测试
Plus 失败测试用例
  • 无失败测试