from lib_misc import permutations


def euler_024_library():
    from itertools import permutations
    return int("".join(list(permutations("0123456789"))[1000000 - 1]))


def nth(generator, n):
    for i in range(n):
        next(generator)
    return next(generator)


def nth_permutation(iterable, n):
    """ Returns the nth permutation of the iterable. """
    #  XXX: Implement this!
    return 0


def euler_024():
    g = permutations("0123456789")
    return int(nth(g, 1000000 - 1))


if __name__ == "__main__":
    print("e024.py: {}".format(euler_024()))
    assert(euler_024() == 2783915460)
