To cudgel one's brains


to exercise one's wits.

See also: Cudgel