You're over complicating things. Only two figures are needed. Total ascent (the total height gained) and total distance. These are the ones that are easily available on Strava etc. Jost take those two figures and divide one by the other.
Keep it simple.
No need to worry about height lost, distance travelled while losing height, or in the flat.
Have reflected on this. I was training for an event using a mixture of outdoor routes and turbo sessions. I wanted to manage my effort and training load sign Wednesdays very interested in working out how hard a route would/could be.
I think your formula is
very useful - ours one of my few bookmarks, but think it reflects the minimum or potential hardness of a route. As others have pointed out it is still possible to make a flat route very hard for yourself by increasing your pace/intensity/normalised power.
I recently did a route that was 69km at 1%. But I pushed hard as I had left the dog at home and wanted to do it under 3 hours. If I had ridden it with my friend it would have taken 3.5 hours, at least. Same route, but my pace and effort made it harder.
This is a typical elevation profile for around our parts. My route described above (admittedly compressed by Strava phone app to make it look even harder).
Having said that, once routes start to get above, say 1.5% it is likely that the minimum effort required to do them and the difference with actual effort is less for any given rider.