solve dunction now returns a solution type, containing a path and a cost