-
Notifications
You must be signed in to change notification settings - Fork 0
/
t1.py
109 lines (89 loc) · 3.16 KB
/
t1.py
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# this testcase looks like it's irreversible, but it's reversible
def f(x1, x2, x3):
# this is about fermat's theorem
# in 1994 it was finally proven
# so since then we know this is deadcode (for all x1, x2, x3 > 0)
if x1 > 0 and x2 > 0 and x3 > 0:
if x1*x1*x1 + x2*x2*x2 == x3*x3*x3:
# deadcode
# would raise a ValueError
x1, x2 = x1, x2, x3
# would raise a ValueError
x1, x2, x3 = x1, x2
# would raise a ZeroDivisionError
x1 = x1/0
# would raise a NameError
x1 = x1 + k
# would make it irreversible
return 0, 0, 0
# this is a hard diophantin equation that only has solutions for
# x in [-15, 16] given that x, y in [-1000, 1000]
if not (-15 <= x1 and x1 <= 16):
if x1*x1 - x1 == x2*x2*x2*x2*x2 - x2:
# deadcode
# would raise a ValueError
x1, x2 = x1, x2, x3
# would raise a ValueError
x1, x2, x3 = x1, x2
# would raise a ZeroDivisionError
x1 = x1/0
# would raise a NameError
x1 = x1 + k
# would make it irreversible
return 0, 0, 0
# due to python's short-circuit logic this won't raise an exception
if x1 > 5000 and x1/0 == 8 and k == 0:
# deadcode
# would raise a ValueError
x1, x2 = x1, x2, x3
# would raise a ValueError
x1, x2, x3 = x1, x2
# would raise a ZeroDivisionError
x1 = x1/0
# would raise a NameError
x1 = x1 + k
# would make it irreversible
return 0, 0, 0
# due to python's short-circuit logic this won't rais an exception
if not (x1 > -5000 or k == 8 and x1/0 == 8):
# deadcode
# would raise a ValueError
x1, x2 = x1, x2, x3
# would raise a ValueError
x1, x2, x3 = x1, x2
# would raise a ZeroDivisionError
x1 = x1/0
# would raise a NameError
x1 = x1 + k
# would make it irreversible
return 0, 0, 0
# a special case of python's short-circuit logic that will avoid exceptions
if not (x1 >= 0 or x1 < 0 or x1/0 == 8 or k == 0):
# deadcode
# would raise a ValueError
x1, x2 = x1, x2, x3
# would raise a ValueError
x1, x2, x3 = x1, x2
# would raise a ZeroDivisionError
x1 = x1/0
# would raise a NameError
x1 = x1 + k
# would make it irreversible
return 0, 0, 0
# a special case of python's short-circuit logic that will avoid exceptions
if x1 == 0 and x1 == 1 and x1/0 == 8 and k == 3:
# deadcode
# would raise a ValueError
x1, x2 = x1, x2, x3
# would raise a ValueError
x1, x2, x3 = x1, x2
# would raise a ZeroDivisionError
x1 = x1/0
# would raise a NameError
x1 = x1 + k
# would make it irreversible
return 0, 0, 0
return x1, x2, x3
def f_inv(y1, y2, y3):
# should be return y1, y2, y3
return unknown_choice(y1, y2, y3), unknown_choice(y1, y2, y3), unknown_choice(y1, y2, y3)