aboutsummaryrefslogtreecommitdiff
path: root/util/Search.py
blob: 25882da6469f50e7a716e2c83b0f32f12ede3a79 (plain)
1
2
3
4
5
6
7
8
from bisect import *
def find_le(a, x):
    'Find rightmost value less than or equal to x'
    return bisect_right(a, x)-1

def find_ge(a, x):
    'Find leftmost value greater than x'
    return bisect_left(a, x)