Check if t = f(positive_integer) = log2(sqrt(4*positive_integer+1)/2 + 1/2) is a real number. >>> check_partition_perfect(2) True >>> check_partition_perfect(6) False
(positive_integer: int)
| 42 | |
| 43 | |
| 44 | def check_partition_perfect(positive_integer: int) -> bool: |
| 45 | """ |
| 46 | |
| 47 | Check if t = f(positive_integer) = log2(sqrt(4*positive_integer+1)/2 + 1/2) is a |
| 48 | real number. |
| 49 | |
| 50 | >>> check_partition_perfect(2) |
| 51 | True |
| 52 | |
| 53 | >>> check_partition_perfect(6) |
| 54 | False |
| 55 | |
| 56 | """ |
| 57 | |
| 58 | exponent = math.log2(math.sqrt(4 * positive_integer + 1) / 2 + 1 / 2) |
| 59 | |
| 60 | return exponent == int(exponent) |
| 61 | |
| 62 | |
| 63 | def solution(max_proportion: float = 1 / 12345) -> int: |