Question: 
Write a function to find the smallest range that includes at-least one element from each of the given arrays.


Model's Code:
def find_minimum_range(arrays):
    import heapq

    min_heap = []
    max_value = float('-inf')

    for i, array in enumerate(arrays):
        heapq.heappush(min_heap, (array[0], i, 0))
        max_value = max(max_value, array[0])

    min_range = float('inf')
    start, end = -1, -1

    while min_heap:
        min_value, array_index, value_index = heapq.heappop(min_heap)

        if max_value - min_value < min_range:
            min_range = max_value - min_value
            start, end = min_value, max_value

        if value_index + 1 == len(arrays[array_index]):
            break

        next_value = arrays[array_index][value_index + 1]
        heapq.heappush(min_heap, (next_value, array_index, value_index + 1))
        max_value = max(max_value, next_value)

    return (start, end)



Sample Correct Code:
from heapq import heappop, heappush
class Node:
    def __init__(self, value, list_num, index):
        self.value = value
        self.list_num = list_num
        self.index = index
    def __lt__(self, other):
        return self.value < other.value
def find_minimum_range(list):
    high = float('-inf')
    p = (0, float('inf'))
    pq = []
    for i in range(len(list)):
        heappush(pq, Node(list[i][0], i, 0))
        high = max(high, list[i][0])
    while True:
        top = heappop(pq)
        low = top.value
        i = top.list_num
        j = top.index
        if high - low < p[1] - p[0]:
            p = (low, high)
        if j == len(list[i]) - 1:
            return p
        heappush(pq, Node(list[i][j + 1], i, j + 1))
        high = max(high, list[i][j + 1])


Asserts:
assert find_minimum_range([[3, 6, 8, 10, 15], [1, 5, 12], [4, 8, 15, 16], [2, 6]]) == (4, 6)
assert find_minimum_range([[ 2, 3, 4, 8, 10, 15 ], [1, 5, 12], [7, 8, 15, 16], [3, 6]]) == (4, 7)
assert find_minimum_range([[4, 7, 9, 11, 16], [2, 6, 13], [5, 9, 16, 17], [3, 7]]) == (5, 7)


Tests:
Test 1 of 3: PASS
Test 2 of 3: PASS
Test 3 of 3: PASS

Test 342 of 974: 248/342 (72.51461988304094%): success