wit: sense of humor or intelligence
imagine that your wit or intelligence is a limited space. All the things that you can understand (algebra, english, easy crossword puzzles) can fit inside of the space of your intelligence. However when you encounter a problem which you cannot solve, you find that the answer is not inside your comprehension (no matter how hard you 'search'), so you 'stand' at the limit of your comprehension (your wit's end) peering outward trying to find an answer, with no idea how.
I was at my wit's end trying to discover how it worked. I had no ideas on how to solve the problem, even after working on it for many months.