Straining your thinking processes repeatedly until you hopefully find resolution in the form of an intellectual orgasm.
Wacking off theory after theory until you come to a head with a solution.
I've been working on this problem continually for some time, and my intellectual masturbation has finally led to resolution.
Jane: Did you get your homework finished?
Dick: I spent last night engaged in intellectual masturbation til I finally was satisfied. It really drained me.