Computer Model of a "Sense of Humour". I. General Algorithm