When approaching any problem, a really good heuristic is to try out various solutions in a trial and error approach.
Taking programming as an example, often, the best solutions to solve the problem at hand are found via tinkering around with the code until the best result is found.
“Good software, like wine, takes time.” – Joel Spolsky 🍷
— Programming Wisdom (@CodeWisdom) August 18, 2017
With time, most programming problems are solved.
Sometimes, some of the oldest programs remain the most robust (following the Lindy effect). So, if a program has been around for twenty or more years, it is likely that it will be around for twenty more years. grep is an example of this.
Similar trial and error approaches do work in other areas of life such as losing weight. Each human body is different. What works for one person may not work for another. Because of this, it pays off to try various diets, exercises, fasting etc when trying to lose weight or attain some fitness goal.
The point is: there is no formula for doing certain things. Tinkering is often the best way to go about it.