An example is (Tanaka and the speaker are in a relationship.):

> どれだけあたしと田中さんが頭をひねったか  
>  (I think it means something like) How long have Tanaka and I...

頭をひねった doesn't make much sense literally, so I'm not sure about it.
CC BY-SA 3.0
2015-06-02T11:44:56.957
24724
2015-12-27T17:30:41.823
10241
question
meaning
What does 頭をひねった mean?
"puzzle over" might be the one option. Ex.
昨日の変な天候にどれだけあたしと田中さんが頭をひねったか、言葉で表現するのは難しい (puzzle over the weird weather)

Another option is "devise" or "contrive". Ex.
この問題を解決するためにどれだけあたしと田中さんが頭をひねったか、あなたにはわからないだろう
CC BY-SA 3.0
2015-06-28T06:18:27.417
25381
2015-06-29T14:27:03.180
2015-06-29T14:27:03.180
10264
10264
24724
answer
Consider "scratching your head".

I suspect the person who downvoted here may not realize that this expression
has two (semi-related yet distinct) meanings:

  1. An intensive mental process trying to find some answer or solution, with at least the potential that such answer or solution might actually be found. This is the case where one might use the "rack your brain" translation.

  2. Wondering about or being confused or puzzled by something. One reference describes this as 「疑問に思う」, and gives as an example 「高すぎる見積もりの数字に頭をひねる」. There is no notion that your mental activity is going to resolve the confusion; you're just stating that your brain was spinning because you are (or were) confused or surprised or couldn't understand something. This is the case where one is better off with the "head scratching" translation. In the example above: "The high estimate left me scratching my head", or perhaps more colloquially, "The estimate was head-scratchingly high". 

The English word "puzzle" actually works for both, with slight variations:

  1. "how much Tanaka and I puzzled over this"

  2. "how puzzled Tanaka and I were by this"
CC BY-SA 3.0
2015-12-27T06:39:59.157
30083
2015-12-27T17:30:41.823
2015-12-27T17:30:41.823
24724
answer