cudgel (one's) brains
To try very hard to comprehend, solve, think of, or remember something. I was up all night cudgeling my brains for a way to pay off all my debts. She cudgeled her brains to remember the man's name.
cudgel your brain (or brains)
think hard about a problem. This expression was used by Shakespeare in Hamlet: ‘Cudgel thy brains no more about it’.