import pkgutil
import importlib


def import_solver(package, day):
    """Import and return a solver module for a day of the Advent calendar.

    Return None if the module can't be found. No ImportError is raised in this
    situation in order to distinguish it from an error occurring during import.
    """

    prefix = 'd' + day
    for module_info in pkgutil.iter_modules(package.__path__):
        if module_info.name.startswith(prefix):
            name = package.__name__ + '.' + module_info.name
            return importlib.import_module(name)
    return None