I am fairly new to Stack Exchange, starting with stackoverflow.com. I added a math.stackexchange.com account to ask questions about my current self-study in Categorical Type Theory. Today, I posted a textbook exercise along with my solutions ((here and here). Some of the comments I have recieved are not quite as positive as I expected. So now I would like to ask the opinions from other members of this community. How do you feel about posting exercise solutions?
I think how you should post the exercise and solution, and how well they are received by the community, might depend on what your ultimate goal is in posting them here. As you haven't said what that is, I'll make a few different guesses and post my opinion on each.
If you want people to check your work, I think it is best if you try to narrow it down to a small area where you are particularly unsure that what you have done is valid. That way, you can ask a more focused question. It's not much fun to check someone else's potentially long and complicated proof for errors that may or may not exist. As your handle is @Code-Guru, consider whether you would enjoy debugging a bunch of someone else's code if they didn't point to a specific block and say, "hey, this is the part which I don't know if it works correctly."
If you want to see alternative solutions, it would be good to say so in the question. Sometimes, askers want help with a specific approach, and posting a completely different solution is not that helpful. Sometimes, answerers see that a solution has already posted, and are discouraged from posting another one. If you do want to see lots of different solutions, it would be good to explicitly ask for them.
If you want to document a result for future reference, StackExchange policy explicitly allows it, but I would suggest that you reserve it for things that could be particularly notable or useful to others. The main reason I say this is because I would not like to see this site turn into a database of solutions to textbook exercises.
In any case, if you just post a textbook exercise and its solution without any context indicating where you're coming from, it's hard for me to tell what you want from us! We're here to answer your questions, but there is no question mark in your question, only an imperative -- and that has already been fulfilled by you. So what do you want us to do?
It's allowed to ask a question and answering it. However, it seems that your posted the answer just after the question, and the other members have not time enough to think about the problem. They could avoid reading the answer, but often when we see the question we also see the answer. If you post the answer, I we are not encouraged to think more about the problem, at least less than a question which haven't receive any comment or answer.
In this particular case, it seems that you had the answer before posting the question. I guess the aim in asking the question is to see different solutions. What you can do is post the exercise, then wait a while (say for example 24 hours, in order to allow every body to see the question) and post the answer.
I think it is perfectly fine. I have done it many times with good results. I might should say that when I post a solution, the solution is usually wrong and I know it. I typically post the book's answer.
When I post my answer, I post it as part of the question.