def partition(n, m):
    """
    Helper function. splits list n into m partitions
    """
    p = map(lambda x: list(), range(m))
    index = 0
    for item in n:
        p[index].append(item)
        if index < m - 1:
            index += 1
        else:
            index = 0
    return filter(lambda x: len(x) > 0, p)
