[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/sci/ - Science & Math


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: grid.png (47 KB, 1240x1240)
47 KB
47 KB PNG
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
>>
>>16477505
This 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.
>>
>>16477499
https://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
>>
>>16477499
just use brute force nigga
>>
>>16479908
then extract from the simulation the lowest distance traveled
>>
>>16477499
Just use A*. A* (or really any Dijkstra's derivative) will work.
>>
>>16478586
There are still two optimal paths in that case: you can either go down-right or right-down.
>>16477538
>>16479912
Not what OP asked.
>>
>>16479908
>just use brute force nigga
>>16479908
>then extract from the simulation the lowest distance traveled
only the tiniest, smoothest of brains' first instinct is to rush and program a 'simulation' instead of actually thinking critically about the problem
fucking idiot
>>
>>16477499
catalan numbers
/thread
>>
>>16477499
This 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.
>>
>>16480203
can i solve it just draw stairs retard it goes diagonal
>>
>>16480203
i can solve it retard just draw stairs
>>
Random walk



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.