beat (one's) brains out
try very hard to understand or think out something difficult; tire (oneself) out by thinking.