-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
39 lines (33 loc) · 821 Bytes
/
utils.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
def my_min(a, b, index=0):
if index == 0:
if a == b:
return a
if a[index] < b[index]:
return a
elif a[index] > b[index]:
return b
else:
return my_min(a, b, index=index + 1)
def my_max(a, b):
if a == b:
return a
minval = my_min(a, b)
if minval == a:
return b
return a
def my_a_greater_than_b(a, b): # these are tuples.
if a == b:
return False
maxval = my_max(a, b)
signal = maxval == a
return signal
def my_a_within_b(a, b):
if a == b:
return False
a_s, a_e = a["start"], a["end"]
b_s, b_e = b["start"], b["end"]
if a_s == b_s and a_e == b_e:
return False
c_s, c_e = my_max(a_s, b_s), my_min(a_e, b_e)
signal = (c_s == a_s) and (c_e == a_e)
return signal