Abstract. We construct a homology algebraic algorithm for computing combinatorial formulas of all finite degree knot invariants. Its input is an arbitrary weight system, i.e., a virtual principal part of a finite degree invariant, and the output is either a proof of the fact that this weight system actually does not correspond to any knot invariant or an effective description of some invariant with this principal part, i.e., a finite collection of easily described singular chains of full dimension in the space of spatial curves such that the value of this invariant on any generic knot is equal to the sum of multiplicities of these chains in a neighborhood of the knot. (In examples calculated by now, the former possibility never occurred.) This algorithm is formally realized over Z 2 , but its generalization to the case of arbitrary coefficients is just a technical task. The algorithm is based on the study of a complex of chains in the space of smooth curves in the three-dimensional space with a fixed flag of directions, and also in the discriminant variety of this space of curves.