Mbpp/594

✅ 完美通过 Base: PASS Plus: PASS
测试评估
指标结果
Base 测试PASS
Plus 测试PASS
代码长度882 字符
模型生成的代码 (882 字符)
def diff_even_odd(lst):
    """
    Return the difference between the first even and first odd number in the list.
    The difference is calculated as (first even) - (first odd).
    """
    first_even = None
    first_odd = None
    
    for num in lst:
        if num % 2 == 0 and first_even is None:
            first_even = num
        elif num % 2 != 0 and first_odd is None:
            first_odd = num
            
        # If we have found both, we can stop early
        if first_even is not None and first_odd is not None:
            break
            
    # In case the list lacks an even or odd number, we might raise an error,
    # but based on the problem description, we assume both exist.
    if first_even is None or first_odd is None:
        raise ValueError("List must contain at least one even and one odd number.")
        
    return first_even - first_odd
Base 失败测试用例
  • 无失败测试
Plus 失败测试用例
  • 无失败测试