测试评估
| 指标 | 结果 |
|---|---|
| Base 测试 | PASS |
| Plus 测试 | PASS |
| 代码长度 | 517 字符 |
模型生成的代码 (517 字符)
def find_even_pair(nums):
"""
Count the number of pairs (i, j) with i < j such that nums[i] ^ nums[j] is even.
Two numbers XOR to an even number iff they have the same parity.
Therefore, we count even and odd numbers, then compute combinations.
"""
even_count = sum(1 for x in nums if x % 2 == 0)
odd_count = len(nums) - even_count
# number of pairs among even numbers + number of pairs among odd numbers
return even_count * (even_count - 1) // 2 + odd_count * (odd_count - 1) // 2
Base 失败测试用例
- 无失败测试
Plus 失败测试用例
- 无失败测试