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

Function has_same_digits

project_euler/problem_070/sol1.py:58–72  ·  view source on GitHub ↗

Return True if num1 and num2 have the same frequency of every digit, False otherwise. >>> has_same_digits(123456789, 987654321) True >>> has_same_digits(123, 23) False >>> has_same_digits(1234566, 123456) False

(num1: int, num2: int)

Source from the content-addressed store, hash-verified

56
57
58def has_same_digits(num1: int, num2: int) -> bool:
59 """
60 Return True if num1 and num2 have the same frequency of every digit, False
61 otherwise.
62
63 >>> has_same_digits(123456789, 987654321)
64 True
65
66 >>> has_same_digits(123, 23)
67 False
68
69 >>> has_same_digits(1234566, 123456)
70 False
71 """
72 return sorted(str(num1)) == sorted(str(num2))
73
74
75def solution(max_n: int = 10000000) -> int:

Callers 1

solutionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected