“To bang your head against a wall” emphasises a sense of frustration resulting from numerous failed attempts to make progress with something.
head
To be like a bear with a sore head
This is a simile which is a figure of speech involving the comparison of one thing with another thing of a different kind.