How should I reference this? Should I reference this? I was having a problem (a mathematical one) in my research, and tried to find the solution. I had some ideas, but none of them solved my problem, I did some research but found nothing, tried to talk with my advisor too (mathematics is not his field), without success. I was stuck in this part. Therefore, I decided to reframe the problem and ask in Quora for help. Within 2 days I received some answers, one that I already have considered but did not helped me, and another that I had previously considered too, but extended.

I implemented the second answer using my problem constraints and needs and it worked, worked better than the state of art for this particular problem (using of course the rest of my job). Intrigued, I asked how the Quora guy (a mathematical professor) found the solution, he said that it was pure logical intuition and little bit of statistics. Later I searched if it was a published solution and found a similar, but not identical solution, buried inside a part of an algorithm in a published paper.

I told my advisor that I had found the solution, but did not mentioned Quora or the paper, he did not asked me either how I found the solution. Now I am considering to use this solution, found on Quora, as part of my research (With intent to be published), but how should do this? If I do not mention Quora could I be in risk of being accused of plagiarism? Should I point the name of the Quora professor in a "thank you footnote" or cite the Quora answer? Should I use as reference the published paper?

Note: I know that I should talk with my advisor about this, I will. But first I need some arguments on how to present the idea to him.

Any informed help would be appreciated.
As your implementation is based on the Quora solution, you obviously have to credit the author. Depending on how big a part of the entire thing this solution is, you might even consider offering the mathematician coauthorship for this.

If it suffices to acknowledge: As the Quora post is public, I would suggest to cite the post (and potentially do the thanks via footnote/acknowledgement section in addition). This ensures in particular that an interested reader can go and read the original post, which might be of interest in addition to your implementation.

Regarding the published paper: First, given that finding this solution was not trivial, I would suggest to cite it in your paper already only for the sake of others searching for these things. Moreover, you should give context for the solution you implemented, and the paper might belong to that context.