Brewer's: Cudgel One's Brains
(To). To make a painful effort to remember or understand something. The idea is from taking a stick to beat a dull boy under the notion that dulness is the result of temper or inattention.
“Cudgel thy brains no more about it; for our dull ass will not mend his place with beating.” —Shakespeare: Hamlet, v. 1.