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

Function check1

project_euler/problem_104/sol1.py:70–99  ·  view source on GitHub ↗

Takes a number and checks if it is pandigital from END >>> check1(123456789987654321) True >>> check1(120000987654321) True >>> check1(12345678957656779870004321) False

(number: int)

Source from the content-addressed store, hash-verified

68
69
70def check1(number: int) -> bool:
71 """
72 Takes a number and checks if it is pandigital from END
73
74 >>> check1(123456789987654321)
75 True
76
77 >>> check1(120000987654321)
78 True
79
80 >>> check1(12345678957656779870004321)
81 False
82
83 """
84
85 check_last = [0] * 11
86
87 # mark last 9 numbers
88 for _ in range(9):
89 check_last[int(number % 10)] = 1
90 number = number // 10
91 # flag
92 f = True
93
94 # check last 9 numbers for pandigitality
95
96 for x in range(9):
97 if not check_last[x + 1]:
98 f = False
99 return f
100
101
102def solution() -> int:

Callers 1

solutionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected