import math


def distance_to_prereqs(state, prereqs):
    """(euclidean) distance of a state to a set of prerequisites"""
    dist_sum = 0
    for k in prereqs.keys():
        pre, val = prereqs[k], state[k]
        dist_sum += pre.distance(val)
    return math.sqrt(dist_sum)