Hi Tahar,
This is upper-intermediate grammar, and a typical question on a placement test.
"You didn't need to take a taxi," means a taxi ride didn't happen.
"You needn't have taken a taxi," means a taxi ride happened, but it was unnecessary. The "[modal] have [past participle]" pattern tells us about an imagined past. It didn't really happen.