I sometimes provide answers to an OP that is essentially a fix to their code that they can understand, but they may not be the best answer for the problem. A recent example has led me here, see this question (disclaimer: the accepted answer is mine), but there is a better answer posted.
I am asking if, for a given piece of code provided by the OP, it is better to provide a completely different solution that would be more efficient computationally that the OP does not understand (as you can clearly see by the comments underneath the second answer on the provided question)?
This better answer would perpetuate "better coding practices" for future viewers trying to solve the same problem.
Or an answer that seeks to modify and clarify the OP's existing code to make it functional, while also providing an explanation as to what OP did wrong in practice?