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

Function is_9_pandigital

project_euler/problem_038/sol1.py:44–55  ·  view source on GitHub ↗

Checks whether n is a 9-digit 1 to 9 pandigital number. >>> is_9_pandigital(12345) False >>> is_9_pandigital(156284973) True >>> is_9_pandigital(1562849733) False

(n: int)

Source from the content-addressed store, hash-verified

42
43
44def is_9_pandigital(n: int) -> bool:
45 """
46 Checks whether n is a 9-digit 1 to 9 pandigital number.
47 >>> is_9_pandigital(12345)
48 False
49 >>> is_9_pandigital(156284973)
50 True
51 >>> is_9_pandigital(1562849733)
52 False
53 """
54 s = str(n)
55 return len(s) == 9 and set(s) == set("123456789")
56
57
58def solution() -> int | None:

Callers 1

solutionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected