Skip to content

Instantly share code, notes, and snippets.

@foca
Created October 10, 2010 02:41
Show Gist options
  • Save foca/618868 to your computer and use it in GitHub Desktop.
Save foca/618868 to your computer and use it in GitHub Desktop.
How to get from my house to the office
This is basically an approximate drawing of the map between my home (H) and our
new office (O). The real map is http://bit.ly/home-to-office ("B" in the map is
my house, "A" the office).
I was bored while walking home from the office, and started thinking if it's
shorter to take a left or a right as I leave my house. (This only holds for
walking, biking there I must go through route a and come through route b due to
one-way streets, but I will walk there most days, since it's around 800-900m.)
<-- x --> <- y ->
--------------------
| H |
| |
| | r
| | o
| | u
r | | t
o | | e
u | |
t | / b
e | /
| /
a | /
| /
| /
| /
| /
| /
| /
| /
| /
| /
| /
| /
|/
|
|
|
| O
-----------
The shortest of "route a" and "route b" (for going from H to O and back) depends
on how close H is to either corner (x and y). If y is a 37% of the block, then
route b is shorter, while route a is shorter otherwise.
The parts that are different for both routes, are similar to a side (a) and the
hypothenuse (b) of triangle. Let's call (c) the other side of the triangle. In
that case:
[1] a^2 + c^2 = b^2
And we can say
y = c - x
We want to find where should "H" be inside (c) so that route a and route b are
the same length. Put in other way, we want to determine x so that:
a + x = b + c - x
Which gives:
[2] x = (b + c - a) / 2
Looking at the real map (http://bit.ly/home-to-office) we can approximate:
[3] b = 2c
Then, from [2] and [3] we want x so that:
[4] x = (3c - a) / 2
And, from [1] and [3]:
a^2 + c^2 = 4c^2
Clearing for a yields:
a = ± sqrt(3)*c
Which, combined with [4] gives:
x = (3c ± sqrt(3)*c) / 2
Or, more succintly:
x = (3 ± sqrt(3)) * c / 2
If we say c is 1 (as in "1 block"), then:
x = 3/2 ± sqrt(3)/2
Which gives two (approximate) solutions of:
x = 2.36 or x = 0.63
And since x < c, it holds that:
x = 0.63
y = 0.37
So, depending on whether my house is within the eastern 37% of the block, or the
western 63% of the block, it's shorter to take one way or the other to the office.
*UPDATE*: I measured the difference, and x = 0.53, so route b is shorter by about
10 meters (or 30 feet for the imperial-minded)
So sue me, I was bored :P
@neme101
Copy link

neme101 commented Oct 11, 2010

!!! o.O !!!
I hope you can get Civ V running well, you have WAAAAAY too much time in your hands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment