Mbpp/398

❌ 均未通过 Base: FAIL Plus: FAIL
测试评估
指标结果
Base 测试FAIL
Plus 测试FAIL
代码长度568 字符
模型生成的代码 (568 字符)
def sum_of_digits(nums):
    """
    Compute the sum of digits of each number in a given list.
    
    Args:
        nums (list of int): A list of integers (can be negative or positive).
        
    Returns:
        int: The total sum of all digits of all numbers.
    """
    total = 0
    for num in nums:
        # Work with absolute value to ignore sign
        n = abs(num)
        # Sum digits of the number
        while n > 0:
            total += n % 10
            n //= 10
        # If the number was 0, its digit sum is 0 (nothing added)
    return total
Base 失败测试用例
  • [[[10, 20, 4, 5, 'b', 70, 'a']]]
Plus 失败测试用例
  • [[10, -5, 'abc', 0, 3.14]]