I don't know if this is the correct board to post this, it is something that has been bothering me for a while and I'm dumb.See the picture, I need to find a path that goes from one point to the other. Assuming the line can only follow the grid, what is the path that will result in the smallest distance travelled, and why?
All paths that go down and right in any order are the same length.If you find this interesting, it happens to have an entire field of study: https://wikiless.org/wiki/Taxicab_geometry?lang=en
>>16477505This dude is right in what he's trying to say (although you can get to a lot of unwanted places by random combinations of down and right). If your real problem is more general, you need a pathfinding algorithm. Look them up, see what's suitable to your task.
>>16477499https://en.wikipedia.org/wiki/Breadth-first_search
>>16477505>All paths that go down and right in any order are the same length.On the other hand, if we can add another constraint like minimizing turns then we will be able to find an optimal path
>>16477499just use brute force nigga
>>16479908then extract from the simulation the lowest distance traveled
>>16477499Just use A*. A* (or really any Dijkstra's derivative) will work.
>>16478586There are still two optimal paths in that case: you can either go down-right or right-down.>>16477538>>16479912Not what OP asked.
>>16479908>just use brute force nigga>>16479908>then extract from the simulation the lowest distance traveledonly the tiniest, smoothest of brains' first instinct is to rush and program a 'simulation' instead of actually thinking critically about the problemfucking idiot
>>16477499catalan numbers/thread
>>16477499This is some leetcode question, ask /g/
If you're walking in a city, try to keep the remaining number of horizontal crossings and vertical crossings the same, so your path resembles a diagonal than an L. The distance traveled isn't shorter, but you won't waste time waiting for the light to change since you're conserving the option to adjust your path.
>>16480203can i solve it just draw stairs retard it goes diagonal
>>16480203i can solve it retard just draw stairs
Random walk