My mommy taught me to overcome the impossible:
— Shut your mouth and eat.
Most of the time a software developer solve pretty common problems.
Occasionally we face a problem which is solvable, however has many different solutions, and the most difficult part is to find the best one among all of them.
However sometimes we face a quite unusual problem. A problem that we spend a huge amount of time to solve, and still we don't see a solution.
Unfortunately, a modern education system doesn't teach you how to solve unsolvable problems. Just remember your days back in school, college or university. Whenever you had any test, you were quite limited in time. And if you haven't succeeded in that given period of time then you've probably got “F”. This period of time is usually about an hour or so.
The bad news is that in real life there are vast amount of problems that require much more than an hour to solve. However most people just don't know what to do next if they couldn't solve a problem in a short period of time. They never did it before, and their experience says that if a problem cannot be solved in that period of time then it doesn't have a solution at all.
Here is an example of another unfortunate state of things. Whenever you're asked to solve an artifical problem — by your educatoinal institution or by the potential employer — they often force you not just to solve the problem, but to do this in some strictly-defined way. And if you refuse to solve it in the asked way then it is considered as a failure, even if you have found a correct solution somehow else.
However in real life things are much different. You have a problem, and you need a solution. This solution should answer to your requirements, such as implementation cost, performance impact or cost of maintenance. What exact sequence of steps should this solution consists of — that's absolutely doesn't matter as long as it answers your general requirements.
There is even more. An ability to contemplate a variety of different sequences of steps which should lead you from the problem to its solution — is a standalone skill, which is very important, which should train, and which, in fact, is more than a half of success. Every challenging problem consists of a sequence of lesser problems, and the success lies in the ability of finding that particular sequence among a vast variety of possible sequences. And this is absolutely normal if you spend a week for finding this specific sequence, and 15 minutes for going through it from the problem to its solution. In fact, this week of your time wasn't wasted as it may look. This 15 minutes is a valuable product of that week.
All of that means that if you faced a problem which you can't solve in a very long period of time, then it means almost for sure that you've picked a wrong sequence, and, therefore, you're solving a wrong problem. However, many people don't see the difference between solving the original problem and being stuck within a wrong sequence.
If you stuck with some problem which you can't solve for a week, a month, or even several months — don't panic, don't upset, don't surrender. Ask yourself instead: “do I really need to overcome this step that I've stuck on to solve the original problem?”. You'll be surprised on how often the answer is “no”.