In this paper, mechanical systems subject to impacts and contacts, that would be not controllable if the impacts were absent (usually called jugglers), are considered. On the basis of an algorithm taken from the literature and of a new procedure to determine a reference trajectory for such a class of systems, a fully algorithmic procedure, able to compute a control input that achieves dead-beat regulation of the "uncontrollable" subsystem just by using impacts, is given. Such a procedure exploits some tools borrowed from algebraic geometry that allow to solve parametric systems of equalities and inequalities. A practical example of application of the given procedure is reported.