brains out, beating (one’s)

(informal) trying very hard to understand or think out something difficult; tiring (oneself) out by thinking.