测试评估
| 指标 | 结果 |
|---|---|
| Base 测试 | PASS |
| Plus 测试 | PASS |
| 代码长度 | 665 字符 |
模型生成的代码 (665 字符)
def digit_distance_nums(a: int, b: int) -> int:
"""
Computes the sum of the absolute per-digit differences between two integers.
The numbers are aligned by their least significant digits; the shorter number
is padded with leading zeros.
"""
# Use absolute values to ignore sign
a = abs(a)
b = abs(b)
# Convert to strings
sa = str(a)
sb = str(b)
# Pad the shorter string with leading zeros
max_len = max(len(sa), len(sb))
sa = sa.zfill(max_len)
sb = sb.zfill(max_len)
# Sum the absolute differences of corresponding digits
return sum(abs(int(ca) - int(cb)) for ca, cb in zip(sa, sb))
Base 失败测试用例
- 无失败测试
Plus 失败测试用例
- 无失败测试