amazon interview questions how far apart are the poles

This is a classic sort of trick question the thing to look at is not any sort of complicated trigonometr. Anything like that is to start with the most basic question: how far down does the cable go because the cable needs to get from the top to this height? It needs to go from a height of 50 meters above the ground to 10 meters above the ground. That means the vertical distance it travels is 40 m. Then each will back to the top of the other tower. ThereS another 40 meters back up. So its 2 vertical distances of 40 meters, which has used all the available cable. The horizontal distance must be 0 because all of the 80 meters of cable has been used just to go up and down. So our answer for the distance between the towers is 0 meters. The idea behind this question is before you dive in and start doing, complicated math, drawing triangles trying to work out angles stuff, like that. You want to stop and think ask some basic questions about. WhatS going on and go from there. Did you know? Numerade has step-by-step video solutions, matched directly to more than +2,000 textbooks.

Amazon Interview question.How far are the poles apart? The hanging cable problem.

About Me: Presh Talwalkar

I run the MindYourDecisions channel on YouTube, which has over 1 million subscribers and 200 million views. I am also the author of The Joy of Game Theory: An Introduction to Strategic Thinking, and several other books which are available on Amazon.

(As you might expect, the links for my books go to their listings on Amazon. As an Amazon Associate I earn from qualifying purchases. This does not affect the price you pay.)

By way of history, I started the Mind Your Decisions blog back in 2007 to share a bit of math, personal finance, personal thoughts, and game theory. Its been quite a journey! I thank everyone that has shared my work, and I am very grateful for coverage in the press, including the Shorty Awards, The Telegraph, Freakonomics, and many other popular outlets.

I studied Economics and Mathematics at Stanford University.

Feel free to send me an email [email protected]. I get so many emails that I may not reply, but I save all suggestions for puzzles/video topics.

If you purchase through these links, I may be compensated for purchases made on Amazon. As an Amazon Associate I earn from qualifying purchases. This does not affect the price you pay.

Book ratings are from January 2022.

(US and worldwide links) https://mindyourdecisions.com/blog/my-books

Mind Your Decisions is a compilation of 5 books:

The Joy of Game Theory shows how you can use math to out-think your competition. (rated 4.2/5 stars on 224 reviews)

40 Paradoxes in Logic, Probability, and Game Theory contains thought-provoking and counter-intuitive results. (rated 4.1/5 stars on 38 reviews)

The Irrationality Illusion: How To Make Smart Decisions And Overcome Bias is a handbook that explains the many ways we are biased about decision-making and offers techniques to make smart decisions. (rated 4/5 stars on 24 reviews)

The Best Mental Math Tricks teaches how you can look like a math genius by solving problems in your head (rated 4.2/5 stars on 76 reviews)

Multiply Numbers By Drawing Lines This book is a reference guide for my video that has over 1 million views on a geometric method to multiply numbers. (rated 4.3/5 stars on 30 reviews)

Mind Your Puzzles is a collection of the three “Math Puzzles” books, volumes 1, 2, and 3. The puzzles topics include the mathematical subjects including geometry, probability, logic, and game theory.

Math Puzzles Volume 1 features classic brain teasers and riddles with complete solutions for problems in counting, geometry, probability, and game theory. Volume 1 is rated 4.4/5 stars on 87 reviews.

Math Puzzles Volume 2 is a sequel book with more great problems. (rated 4.1/5 stars on 24 reviews)

Math Puzzles Volume 3 is the third in the series. (rated 4.2/5 stars on 22 reviews)

Teachers and students around the world often email me about the books. Since education can have such a huge impact, I try to make the ebooks available as widely as possible at as low a price as possible.

Currently you can read most of my ebooks through Amazon’s “Kindle Unlimited” program. Included in the subscription you will get access to millions of ebooks. You don’t need a Kindle device: you can install the Kindle app on any smartphone/tablet/computer/etc. I have compiled links to programs in some countries below. Please check your local Amazon website for availability and program terms.

Grab a mug, tshirt, and more at the official site for merchandise: Mind Your Decisions at Teespring.

I) The cable has to be 80.02m (it definitely rounds to 80m, so its not that wild of a requirement)

If you assume the cable in the 10m example can be expressed as a parabolic equation, then consider the following:

We also know, due to symmetry, that >>>> a = 2h (double the distance to the vertex from the origin is the distance between the two poles) **

II) We must choose to model the curvature of the chain parabolically, as opposed to using a catenary curve (I know, I know, but just hear me out)

I dont like the “Logical” answer that the video gives, because it actually cant be true. The cable cannot have a “bend” in it from being doubled over and still hang directly down 40m and then climb back up 40m and still be a total length of 80m. The bend or fold in the cable makes this impossible.

Abstract:

In this post we use R’s capabilities to solve nonlinear equation systems in order to answer an extension of the hanging cable problem to suspension bridges. We then use R and ggplot to overlay the solution to an of the Golden Gate Bridge in order to bring together theory and practice.

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. The markdown+Rknitr source code of this blog is available under a GNU General Public License (GPL v3) license from github.

The so called Amazon’s hanging cable problem explained in this youtube video (watched 2.4 mio times! ) goes as follows:

A cable of 80 meters (m) is hanging from the top of two poles that are both 50 m from the ground. What is the distance between the two poles, to one decimal place, if the center of the cable is:

  • 20 m above the ground?
  • 10 m above the ground?
  • Allegedly, (b) has been used as an Amazon interview question, however, the problem is much older and has otherwise nothing to do with Amazon. Can you solve (b)? Or even (a)? The problem can be illustrated as follows:

    Hint: The solution to (a) is concisely described in Chatterjee and Nita (2010) and for (b) you need to do little more than just think. So instead of applying at Amazon, let’s take the question to the next level: Apply for the orange belt in R: How you wouldn’t solve the hanging cable problem by instead solving the hanging cable problem suspension bridge style!

    As explained in the video the catenary curve is the geometric shape, a cable assumes under its own weight when supported only at its ends. If instead the cable supports a uniformly distributed vertical load, the cable has the shape of a parabolic curve. This would for example be the case for a suspension bridge with a horizontal suspended deck, if the cable itself is not too heavy compared to the road sections. A prominent example of a suspension bridges is the Golden Gate Bridge, which we will use as motivating example for this post.

    Rephrasing the cable problem as the ‘suspension bridge problem’ we need to solve a two-component non-linear equation system:

  • the first component ensures that the parabolic curve with vertex at ((0,0)) goes through the poles at the x-values (-x) and (x). In other words: the distance between the two poles is (2x). Note that the coordinate system is aligned such that the lowest point of the cable is at the origo.
  • the second component ensures that the arc-length of the parabola is as given by the problem. Since the parabola is symmetric it is sufficient to study the positive x-axis
  • The two criteria are converted into an equation system as follows: [ begin{align*} a x^2 &= 50 – text{height above ground} \ int_0^x sqrt{1 + left(frac{d}{du} a u^2right)^2} du &= 40. end{align*} ]

    Here, the general equation for arc-length of a function (y=f(u)) has been used. Solving the arc-length integral for a parabola can either be done by numerical integration or by solving the integral analytically or just look up the resulting analytic expression as eqn 4.25 in Spiegel (1968). Subtracting the RHS from each LHS gives us a non-linear equation system with unknowns (a) and (x) of the form

    [ left[ begin{array}{c} y_1(a,x) \ y_2(a,x) end{array} right] = left[ begin{array}{c} 0 \ 0 end{array} right]. ]

    Writing this in R code:

    To ensure (x>0) we re-parametrized the equations with (theta_2 = log(x)) and provide the function theta2ax to backtransform the result. We can now use the nleqslv package to solve the non-linear equation system using a one-liner:

    In other words, for a cable of length 80m the pole of a suspension bridge will be located 23.7m from the origo, which means the two poles of the bridge will be 47.3m apart, which is also the span of the bridge.

    Using arc_method="numeric" instead of the analytic solution gives

    It is re-assuring to see that the numerical integration method yields the same result as the analytic method. The analytic method has mathematical beauty, the numerical method allows the data scientist to solve the problem without diving into formula compendiums or geometry.

    Using the same code, but with the y-functions formulated for the catenary case we obtain

    In other words the solution to the original cable problem is (x=22.7 m) whereas the answer to the suspension bridge version is (x=23.7m). The difference to the parabolic form can be seen from the following graph:

    We test our theory by studying the cable of the Golden Gate suspension bridge. Shown below is a photograph by D Ramey Logan available under a CC BY 4.0 license. For presentation in this post the was tilted by -0.75 degrees (around the camera’s view axis) with the r package to make the sea level approximately horizontal. Parabolic and catenary overlays (no real difference between the two) were done using the theory described above.

    We manually identify center, sea level and poles from the and use annotation_raster to overlay the on the ggplot of the corresponding parabola and catenary. See the code on github for details.

    The fit is not perfect, which is due to the camera’s direction not being orthogonal to the plane spanned by the bridge – for example the right pole appears to be closer to the camera than the left pole . We scaled and ‘offsetted’ the so the left pole is at distance 640m from origo, but did not correct for the tilting around the (y)-axis. Furthermore, distances are being distorted by the lens, which might explain the poles being too small. Rectification and perspective control of such s is a photogrammetric method beyond the scope of this post!

    This post may not to impress a Matlab coding engineer, but it shows how R has developed into a versatile tool going way beyond statistics: We used its optimization and analysis capabilities. Furthermore, given an analytic form of (y(theta)), R can symbolically determine the Jacobian and, hence, implement the required Newton-Raphson solving of the non-linear equation system directly – see the Appendix. In other words: R is also a full stack mathematical problem solving tool!

    As a challenge to the interested reader: Can you write R code, for example using r, which automatically identifies poles and cable in the and based on the known specification of these parameters of the Golden Gate Bridge (pole height: 230m, span 1280m, clearance above sea level: 67.1m), and perform a rectification of the ? If yes, Stockholm University’s Math Department hires for Ph.D. positions every April! The challenge could work well as pre-interview project. 😉

    Because the y_1(a,x) and y_2(a,x) are both available in closed analytic form, one can form the Jacobian of non-linear equations system by combining the two gradients. This can be achieved symbolically using the deriv or Deriv::Deriv functions in R.

    Given starting value (theta) the iterative procedure to find the root of the non-linear equation system (y(theta) = 0) is given by (Nocedal and Wright 2006, Sect. 11.1)

    [ theta^{(k+1)} = theta^k – J(theta^k)^{-1} y(theta), ]

    where (J) is the Jacobian of the system, which in this case is a 2×2 matrix.

    By iterating Newton-Raphson steps we can find the solution of the equation system manually:

    We show the moves of the algorithm in a 2D contour plot for (r(a,x) = sqrt{y_1(a,x)^2 + y_2(a,x)^2}). The solution to the system has (r(a,x)=0). See the code on github for details.

    Want better grades, but can’t afford to pay for Numerade?

    Enter your parent or guardian’s email address:

    Already have an account?

    FAQ

    How far apart are the poles Amazon interview questions?

    But notice 40 m from the top of a 50 m pole is already 10 m above the ground. The cable therefore is hanging directly downward! The cable has to be doubled back upon itself, and the two poles must be coincident and 0 m apart! This part is actually a trick question: the two poles are a distance of 0 apart.

    How far apart are the Poles answer?

    Thus the distance between the poles is equal to 46 m.

    How do you solve the Amazon hanging cable interview question?

    Thus the distance between the poles is equal to 46 m.

    How do you solve a hanging cable question?

    Thus the distance between the poles is equal to 46 m.

    Related Posts

    Leave a Reply

    Your email address will not be published. Required fields are marked *