<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sparsify(dirname, output_every):
 """Remove files from an output directory at regular interval, so as to make it as if there had been more iterations between outputs. Can be used to reduce the storage size of a directory. If the new number of iterations between outputs is not an integer multiple of the old number, then raise an exception. Parameters dirname: str A path to a directory. output_every: int Desired new number of iterations between outputs. Raises ------ ValueError The directory cannot be coerced into representing `output_every`. """

    fnames = get_filenames(dirname)
    output_every_old = get_output_every(dirname)
    if output_every % output_every_old != 0:
        raise ValueError('Directory with output_every={} cannot be coerced to'
                         'desired new value.'.format(output_every_old))
    keep_every = output_every // output_every_old
    fnames_to_keep = fnames[::keep_every]
    fnames_to_delete = set(fnames) - set(fnames_to_keep)
    for fname in fnames_to_delete:
        os.remove(fname)