Years ago I wrote a program to do this for a C182, a C210 and later for a Saratoga. The challenge is that in a piston single, the cruise speeds are low enough so that winds can be quite significant. Because actual winds change from forecast, it is desirable to have the calculations updated in flight. When I did this, GPS was not available. And calculations were done on laptops or on a programmable calculator.
The smallest solution was to use simultaneous differential equations, although I know one person who later wrote software for this is did so with look up tables. The performance of the aircraft (initially fitted from the POH) was reduced to equation form.
At the time gas prices were shockers, and seldom were flights optimized for minimum time, it was always for minimum fuel burn. I used this for pleasure flying only, and for the routes and weather I flew in, the solutions were typically 4 to 12k altitude. If a tailwind, one ran at the lower end of the power range, whether that was 45 or 55%. If a headwind, one was often pushing the higher end of the power range, usually 65 to 80% depending upon the aircraft.
Today, I just guess the power setting I want, and go. If in the summer, I might go below 55%, but cruising in the northeast US in the wintertime, at 12k, at 45% is not a warm proposition.