Determines if num is in the form 1_2_3_4_5_6_7_8_9 >>> is_square_form(1) False >>> is_square_form(112233445566778899) True >>> is_square_form(123456789012345678) False
(num: int)
| 34 | |
| 35 | |
| 36 | def is_square_form(num: int) -> bool: |
| 37 | """ |
| 38 | Determines if num is in the form 1_2_3_4_5_6_7_8_9 |
| 39 | |
| 40 | >>> is_square_form(1) |
| 41 | False |
| 42 | >>> is_square_form(112233445566778899) |
| 43 | True |
| 44 | >>> is_square_form(123456789012345678) |
| 45 | False |
| 46 | """ |
| 47 | digit = 9 |
| 48 | |
| 49 | while num > 0: |
| 50 | if num % 10 != digit: |
| 51 | return False |
| 52 | num //= 100 |
| 53 | digit -= 1 |
| 54 | |
| 55 | return True |
| 56 | |
| 57 | |
| 58 | def solution() -> int: |