Mbpp/767

✅ 完美通过 Base: PASS Plus: PASS
测试评估
指标结果
Base 测试PASS
Plus 测试PASS
代码长度530 字符
模型生成的代码 (530 字符)
def get_pairs_count(arr, target_sum):
    """
    Count the number of pairs (i, j) with i < j such that arr[i] + arr[j] == target_sum.
    
    Args:
        arr: List of numbers.
        target_sum: The desired sum for each pair.
        
    Returns:
        The number of pairs whose sum equals target_sum.
    """
    freq = {}
    count = 0
    for num in arr:
        complement = target_sum - num
        if complement in freq:
            count += freq[complement]
        freq[num] = freq.get(num, 0) + 1
    return count
Base 失败测试用例
  • 无失败测试
Plus 失败测试用例
  • 无失败测试