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

Function equality

project_euler/problem_047/sol1.py:59–69  ·  view source on GitHub ↗

Check the equality of ALL elements in an iterable >>> equality([1, 2, 3, 4]) False >>> equality([2, 2, 2, 2]) True >>> equality([1, 2, 3, 2, 1]) False

(iterable: list)

Source from the content-addressed store, hash-verified

57
58
59def equality(iterable: list) -> bool:
60 """
61 Check the equality of ALL elements in an iterable
62 >>> equality([1, 2, 3, 4])
63 False
64 >>> equality([2, 2, 2, 2])
65 True
66 >>> equality([1, 2, 3, 2, 1])
67 False
68 """
69 return len(set(iterable)) in (0, 1)
70
71
72def run(n: int) -> list[int]:

Callers 1

runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected