-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathin.py
86 lines (79 loc) · 2.61 KB
/
in.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
def inside(x, a, b):
if a == b:
return True
if a < b:
if a < x and x <= b:
return True
else:
return False
else:
if b < x and x <= a:
return False
else:
return True
def inside2(x, a, b, incl=True):
if a == b:
return incl or x != a
if a < b:
if a < x:
if incl:
return x <= b
else:
return x < b
else:
return False
else:
if x <= a:
if incl:
return b >= x
else:
return b > x
else:
return True
def simple_inside(x, a, b, incl=True):
if incl:
if a < b:
return (a < x and x <= b)
else:
return (a < x or x <= b)
else:
if a < b:
return (a < x and x < b)
else:
return (a < x or x < b)
print inside(2, 10, 33)
print inside(2, 33, 10)
print inside(10, 2, 33)
print inside(10, 33, 2)
print inside(33, 2, 10)
print inside(33,33, 2)
print inside(2, 10, 2)
print inside (3, 3, 45)
print inside (3, 45, 45)
print inside (3, 45, 3)
print inside (333, 45, 333)
print "...."
print inside2(2, 10, 33), simple_inside(2, 10, 33)
print inside2(2, 33, 10), simple_inside(2, 33, 10)
print inside2(10, 2, 33), simple_inside(10, 2, 33)
print inside2(10, 33, 2), simple_inside(10, 33, 2)
print inside2(33, 2, 10), simple_inside(33, 2, 10)
print inside2(33,33, 2), simple_inside(33,33, 2)
print inside2(2, 10, 2), simple_inside(2, 10, 2)
print inside2(3, 3, 45), simple_inside(3, 3, 45)
print inside2(3, 45, 45), simple_inside(3, 45, 45)
print inside2(3, 45, 3), simple_inside(3, 45, 3)
print inside2(333, 45, 333), simple_inside(333, 45, 333)
print inside2(333, 333, 333), simple_inside(333, 333, 333)
print inside2(2, 10, 33, False) , simple_inside(2, 10, 33, False)
print inside2(2, 33, 10, False) , simple_inside(2, 33, 10, False)
print inside2(10, 2, 33, False) , simple_inside(10, 2, 33, False)
print inside2(10, 33, 2, False) , simple_inside(10, 33, 2, False)
print inside2(33, 2, 10, False) , simple_inside(33, 2, 10, False)
print inside2(33,33, 2, False) , simple_inside(33,33, 2, False)
print inside2(2, 10, 2, False) , simple_inside(2, 10, 2, False)
print inside2(3, 3, 45, False) , simple_inside(3, 3, 45, False)
print inside2(3, 45, 45, False) , simple_inside(3, 45, 45, False)
print inside2(3, 45, 3, False) , simple_inside(3, 45, 3, False)
print inside2(333, 45, 333, False) , simple_inside(333, 45, 333, False)
print inside2(333, 333, 333, False) , simple_inside(333, 333, 333, False)