测试评估
| 指标 | 结果 |
|---|---|
| Base 测试 | PASS |
| Plus 测试 | PASS |
| 代码长度 | 438 字符 |
模型生成的代码 (438 字符)
def highest_Power_of_2(n: int) -> int:
"""
Returns the highest power of 2 that is less than or equal to n.
Assumes n is a positive integer.
"""
if n < 1:
# Handle non-positive edge case if needed, though problem implies positive n.
return 0
# Using bit length to find the most significant bit's value
# Example: n=10 -> binary 1010, bit_length=4, 1<<(4-1)=8
return 1 << (n.bit_length() - 1)
Base 失败测试用例
- 无失败测试
Plus 失败测试用例
- 无失败测试