def getHeuristic(state, problem, heuristic, dic):
    """
    wrapper for the heuristics to avoid recomputing when already called for a specific state. The heuristics are stored in dic
    """
    if state not in dic:
        h = heuristic(state, problem)
        dic[state] = h
        return h
    else:
        return dic[state]