-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathis_zero_zero.py
More file actions
58 lines (47 loc) · 1.7 KB
/
is_zero_zero.py
File metadata and controls
58 lines (47 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import math
import sys
def is_zero():
# The classic
return 0 == 0
def is_zero_unicode_match():
return ord("0") - ord("0") == 0
def is_zero_cos_arccos():
# Using trigonometry for some reason
return round(math.cos(math.acos(0)), 10) == 0
def is_zero_by_list_sum():
# Using list comprehension and sum to prove nothing
return sum([int(i) for i in ""]) == 0
def is_zero_overthought_subtraction():
result = ((((((5 - 5) * 10) + 0) * 1))) // 1
return result == len("")
def is_zero_by_limits():
x = 5
x = x + 1e-50000
try:
result = ((x+5)*(x-5)/(x-5)) == 0
return result
except ZeroDivisionError: return True # using limits to define this when x->5 we can say that the limit is, indeed, zero.
def is_zero_from_memory_check():
return sys.getsizeof(0) - sys.getsizeof(0) == 0
def is_zero_just_to_be_sure(): # maybe one of the tests fail. We have to be sure...
return is_zero() and is_zero_unicode_match() and is_zero_cos_arccos() and is_zero_by_list_sum() and is_zero_overthought_subtraction() and is_zero_from_memory_check()
def main():
checks = [
is_zero,
is_zero_unicode_match,
is_zero_cos_arccos,
is_zero_by_list_sum,
is_zero_overthought_subtraction,
is_zero_by_limits,
is_zero_from_memory_check,
is_zero_just_to_be_sure,
]
print("🔍 Running absurd checks to see if 0 == 0:\n")
for i, func in enumerate(checks, 1):
try:
result = func()
print(f"Check #{i:02}: {func.__name__} => {'True' if result else 'False'}")
except Exception as e:
print(f"Check #{i:02}: {func.__name__} => Error: {e}")
if __name__ == "__main__":
main()