<jupyter_start><jupyter_text>https://leetcode.com/problems/heaters/<jupyter_code>def findRadius(houses, heaters) -> int:
    def is_covered(houses, heaters, radius):
        coverage = []
        for h in heaters:
            coverage += [j for j in range(h-radius,h+radius+1)]
        return all([house in coverage for house in houses])
    covered = all([house in heaters for house in houses])
    i = 0
    while covered == False:
        i+=1
        covered = is_covered(houses, heaters, i)
    return i
findRadius([1,5],[2])
# findRadius([282475249,622650073,984943658,144108930,470211272,101027544,457850878,458777923],
# [823564440,115438165,784484492,74243042,114807987,137522503,441282327,16531729,823378840,143542612])
def findRadius(houses, heaters) -> int:
    best = -float('inf')
    for h in houses:
        cur_best = min([abs(h-he) for he in heaters])
        if cur_best > best: 
            best = cur_best
    return best
findRadius([1,5],[2,5])
def findRadius(houses, heaters) -> int:
    best = -float('inf')
    for h in houses:
        cur_best = min([abs(h-he) for he in heaters])
        if cur_best > best: 
            best = cur_best
    return best
def findRadius(houses, heaters) -> int:
    houses.sort()
    heaters.sort()
    j = 0
    d = {}
    cur_l = heaters[j]
    cur_r = heaters[j]
    h_len = len(heaters)-1
    while j <= h_len:
        for i,house in enumerate(houses):
            while house>cur_r and j <= h_len:
                j+=1
                cur_l = cur_r
                cur_r = heaters[j] if j <= h_len else cur_r
            d[house] = (cur_l,cur_r)    
        break
    max_dist = 0
#     return d
    for k,h in d.items():
        max_dist = max(min([abs(k-v) for v in h]),max_dist)
    return max_dist#,d
            
ho,he = [90,95,100,20],[1,2,4]
ho,he = [282475249,622650073,984943658,144108930,470211272,101027544,457850878,458777923],[823564440,115438165,784484492,74243042,114807987,137522503,441282327,16531729,823378840,143542612]        
findRadius(ho,he)
def findRadius(houses, heaters) -> int:
    houses.sort()
    heaters.sort()
    cur_l = heaters[j]
    cur_r = heaters[j]
    max_dist = j = 0
    for i,house in enumerate(houses):
        while house>cur_r and j <= len(heaters)-1:
            j+=1
            cur_l = cur_r
            cur_r = heaters[j] if j <= len(heaters)-1 else cur_r
        max_dist = max(min(abs(house-cur_l),abs(house-cur_r)),max_dist)
    return max_dist
ho,he = [90,95,100,20],[1,10]
findRadius(ho,he)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13002364066193853, 'fraction_numerical': 0.1426319936958235, 'mean_word_length': 2.7559171597633134, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 14, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '653183', 'license': 'MIT', 'n_tokens_mistral': 1175, 'n_tokens_neox': 961, 'n_words': 197, 'path': 'lt475_heaters_radius.ipynb', 'repo_name': 'devkosal/code_challenges', 'size': '2538'}