MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / is_square_form

Function is_square_form

project_euler/problem_206/sol1.py:36–55  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

34
35
36def 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
58def solution() -> int:

Callers 1

solutionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected