Attitude towards exercises in mathematics
I'm doing self study on a couple of topics in mathematics, such as real analysis, abstract algebra, and linear algebra. From time to time, there are always a couple of exercises which I found too difficult to solve. I spend quite some time to think about them. When I fail, I google to find the solutions. Most of the time, I get the solutions.
However, there are some downsides to this attitude. First, I would spend too much time on a single problem. So I feel that my progress is a little bit too slow. Other than that, when I read a solution, I don't get the real understanding of the problem. When I read a proof, my brain is working mechanically to check every statement, so I don't know what exactly is going on.
I start to wonder whether I'm doing this correctly. What I want to ask here is, what should I do when I encounter difficult exercises? Should I think about them myself until I get the answers? Or should I skip the difficult ones and move on to the next chapters, then go back after I gain more understanding?
It depends on the textbook. However, most authors like to include a few exercises that they feel will challenge even very good students (and there is at least one respected author who deliberately includes open research problems among his exercises), so it's not necessarily grounds for panic if you fail to solve some of the exercises.
It's always a good idea to at least try all of the exercises. Some authors use the exercises to present useful facts (typically "prove that such-and-such", and sometimes entire well-known concepts that are peripheral to the main development are defined only in an exercise); trying to solve it will help you remember the result later even if you didn't succeed in proving it.
If you get stuck, however, just leave it be and carry on -- unless it's a majority of the exercises for a chapter or section that fail you. Return to them later, and if they still seem interesting and hard even then, you can consider asking for help here.
I agree with Henning that you should "at least try" all of the exercises.
There's quite a large (and non empty) territory between skipping and solving an exercise: giving it more than a cursory glance, actually understanding what you asked to prove/disprove, feeling that the result seems logical/plausible, and the conditions seems ok (no more data than necessary, nor less... and no typos!), seeing that if the assumptions were changed in this or that way the problem would be trivial or impossible, thinking about particular cases, making some drawings or numerical evaluations, relating to theorems or other problems, imagining possible paths for the solution, making an tentative evaluation of how difficult and fruitful the problem is for you, make some try and fail miserably...
All this and more can often be done in a few minutes; it's less that solving the exercise (and, of course, you should strive to solve completely by yourself a decent amount) but it's quite productive to do some of this for all the exercises.
You can strike a middle ground- work on the difficult exercises till you are stuck. Then come to MSE and ask for help with the point where you are stuck. Depending on how much help you want you can ask for complete answers or just hints etc.
That is what I am planning to do when I start going through Rudin. You may also want to tag the question as 'homework' as that is an important cue to some users that they should not provide complete solutions.
This is the sort of problem that anyone attempting to learn mathematics on their own will encounter. Over time, I've developed a few strategies that have worked for me. With regard to understanding proofs, I first attempt to prove the theorem on my own without first consulting the text. When this is unsuccessful, I'll read over the author's argument briefly to try to find the key idea and I'll then try to reconstruct the proof again. When I can't understand the author's steps I'll consult another reference. If I can't find another reference I'll post a question here. I also ask questions here that are more conceptual in nature that are harder to find references to.
With regard to exercises, it is unfortunate for the self-learner that most (higher) mathematics text are incomplete; they might have tons of great exercises but no solutions, thereby making it impossible to get a "second opinion" on your work or help you when you get stuck. Whether this is laziness on the part of the author or based on philosophical conviction is irrelevant; the fact is that this situation makes things far more difficult for the motivated self-learner than they need to be. So, my advice in this regard is to seek out more complete texts that have answers to at least some of the problems. It can take some effort, but depending on what you are interested in, you can probably find at least a few texts in this category. Indeed, many of the solutions to more popular texts can be found online as you've found; unfortunately though, this can be rather hit-or miss.
Problem texts however are also very good for exercise practice. The Linear Algebra Problem Book by Halmos, for instance, is an example of a very enlightening text in this genre. He teaches you just enough theory, just-in-time, to allow you to solve the next problem. If you can't solve the problem, he has detailed solutions to each one.
With regard to general analysis, there are many sources of problems with solutions. Alaprantis and Burkinshaw's Problems in Real Analysis, Solutions to Lang's Undergraduate Analysis and one of my favorite resources is Erdman's Problem Text in Advanced Calculus available freely from the authors website.
For basic algebra, perhaps Blythe's problem book Algebra Through Practice would be beneficial. I can't say though I like this one as much as the other texts I've used, but it's OK, but maybe a little too basic to get you very far. Dummit and Foot has great exercises and many solutions can be found on-line in some form.
The approach to the exercises is the same as with the proofs. I first give a serious attempt and only consult the solution when I'm stuck. Also, if I'm trying to get through more material, I usually "time box" my activity and agree with myself to "give up" after a certain amount of time. I really don't like to do this but I've found that if I spend at least 15-30 minutes on a "moderately" difficult problem that I still can't solve I can appreciate the solution a lot more when it is revealed.
I think that the key point of view for good learning is to think about problems rather as a way to gather experience than as a challenge. If you feel you learned enough from a problem and you can't get anything out of it any more, go ahead without it and learn new mathematics: you will see as often your ability to solve problems depends on what tools you know at the moment more than on your ingenuity. If you don't strictly need a solution (for example, if you are preparing for an exam and you have to know those things) try to share the problem with others mathematicians, often this forces you to think about the problem from a different point of view and will be useful to others. Finally, reading a solution it's not a crime (you always have to understand it), but it often kills your interest about the problem and what it can give to you.