Mbpp/388

✅ 完美通过 Base: PASS Plus: PASS
测试评估
指标结果
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 失败测试用例
  • 无失败测试