Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×
Math

Can You Solve the 'Hanging Cable' Problem, Used as an Amazon Interview Question? 283

An anonymous reader shares a problem that Amazon asks in its interviews: A cable of 80 meters is hanging from the top of two poles that are both 50 meters off the ground. What is the distance between the two poles (to one decimal point) if the center cable is (a) 20 meters off the ground and (b) 10 meters off the ground?
*

This discussion has been archived. No new comments can be posted.

Can You Solve the 'Hanging Cable' Problem, Used as an Amazon Interview Question?

Comments Filter:
  • Catenaries (Score:5, Insightful)

    by mlyle ( 148697 ) on Wednesday February 19, 2020 @01:31PM (#59743316)

    Knowing the math offhand for a catenary is not the best predictor of performance in most jobs.

    • you fail (Score:5, Insightful)

      by goombah99 ( 560566 ) on Wednesday February 19, 2020 @01:33PM (#59743324)

      Knowing the math offhand for a catenary is not the best predictor of performance in most jobs.

      yes but recognizing when you can skip the hard part is what is very valued on the job. For B the answer is 0.0

      • by Win0ver ( 613215 )
        Yeah except Amazon did not ask A first, and the sole purpose of doing so is baiting the parent's answer.
        • Yeah except Amazon did not ask A first

          Aaaand ... that's the point being made. You're supposed to spot that B is a trap.

          • by Win0ver ( 613215 )

            Yeah except Amazon did not ask A first

            Aaaand ... that's the point being made. You're supposed to spot that B is a trap.

            What point? That the trick question Amazon asked can be even trickier by asking another similar yet valid question beforehand?
            The whole point of A is to 'trick' people into giving up before reaching B, which, again Amazon did NOT do.
            A lot more people would get B right without it.

            • here's why (Score:5, Insightful)

              by goombah99 ( 560566 ) on Wednesday February 19, 2020 @02:00PM (#59743484)

              It's because if you are software engineer and someone asks for something sometimes it's better to ask what they require instead. So if someone asks you to pack a plane with boxes, you don't go solving the knapsack problem unless you have to. It would be better to recognize when a simple question has a hard solution then think of ways to finesse the hard part away. So for example, if you amazon, process the orders in a different order so the distribution of box sizes to be packed next will always give you a solvable case for the plane.

              1. knowing when a problem is hard as asked
              2. Knowing how to find an easy case of a hard problem

              that is. Knowing how to get stuff done not just hard math

      • The problem here is the first question sets the mind up for "I don't know this" and the second question is then contexted. If you know the catenary equations and whatnot, you look at the second and immediately see the obvious problem because you've got internal context with which to frame the question and so immediately process the framing. If you don't, you notice they're both similar problems you can't answer.

        In other words: noticing that problem B is a special case of problem A is unlikely.

        Likewis

        • What it accomplishes? Well in reality you often are free to choose a different problem, so choose one that's easy to answer.

          For example, that's the whole process of Gedanken experiments. Find an edge case or a case where you can work out the answer and it tells you more about the problem.

          If the customer asks for a pen that will write upside down or you should not rush off to desing it but ask why not use a pencil.

          If you are asked to sort a list, you might want to know why? perhaps they only need to displ

          • Re:you fail (Score:4, Insightful)

            by bluefoxlucid ( 723572 ) on Wednesday February 19, 2020 @03:31PM (#59743958) Homepage Journal

            If your seals are below operating temperature, just rely on the initial firing to warm up the secondary backup seals, so when the primary fails you'll still be good.

            If you can't find a round gasket, use a square one of the correct size and put it under compression.

            Pull data into a cache line before the permissions check and then invalidate it and drop the cached value if the permission check fails.

        • The problem here is the first question sets the mind up for "I don't know this" and the second question is then contexted.

          This is the sort of problem your regularly deal with in University-level physics courses: one that looks very tricky but which, with a little thought, is actually very simple. So no, the first question is an excellent test to see whether you are a formula script-kiddie or someone who actually thinks about problems and is not put off just because they look hard.

        • Re:you fail (Score:5, Insightful)

          by Nite_Hawk ( 1304 ) on Wednesday February 19, 2020 @05:18PM (#59744472) Homepage

          Likewise, what is this supposed to demonstrate?

          The "intelligence" of the interviewer and whether or not the interviewee fits within the same social clique that enjoys gotcha-style whiteboard debates over actually getting anything done.

        • by Cederic ( 9623 )

          The thing is, I don't know catenary equations, so devised a crude 'two right-angle triangles' approximation that UngroundedLightning summarised in another post.

          When I apply that same crude approximation to B it gives me an answer of 0.0. The trick doesn't actually work, my method delivers the correct answer anyway.

      • by hawk ( 1151 )

        The *best* response to one of these that I've heard of was on a "what does this code d" question.

        The response? "Hopefully, gets the author fired."

        hawk

      • by goombah99 ( 560566 ) on Wednesday February 19, 2020 @02:45PM (#59743674)

        you can also solve A without hard math, just geometry.

        first drop the factors of 10 so it's 5 tall and 2 off the ground and 8 long

        find upper bound:
        Imagine the rope taught in two triangles. Then one of those triangles has a base of 2.64 = sqrt(16-9)

        find lower bound:
        replace the rope with 4 sticks each 2 long.
        pin the left and right sticks to their flagpoles. this leaves two triangles for the remaining sticks to form.
            length of base of one triangle 1.76 = sqrt( 4 -1)

        So the full witdth is twice those bounds: 5.2 > X >3.5

        pick a value in the middle 4.35

        that's got 1 digit accuracy on the right answer.

        • by Hartree ( 191324 )

          Yeah, modeling it as two triangles was the first thing that occurred to me as soon as I saw the "to one digit accuracy".

          In the real world, close enough is often much better than exactly right.

          (And I have done the catenary problem, though it's been 30 years or so. Why try remembering either a differential equations problem, or a formula I've not used since when I can do something quick, dirty and good enough?)

        • The question is, does the approximation get to within 1dp (error0.1m).

          But more to the point, just be dirty and report the result in km, so to 1dp the answers are 0km and 0km ;)

          They dont specify the answer needs to be in meters, and thats the kind of answer that should get you fast-tracked to management..

      • yes but recognizing when you can skip the hard part is what is very valued on the job. For B the answer is 0.0

        Yes, and the value in writing a function to calculate the distance between two poles which only returns a correct value when the value is 0 is extremely useful.

      • If B=0
        The 80m cable would be split in half so it would 40m hanging down. with 50m poles, leaving a distance to 10m. The question has a 20m distance. so the poles will need to be greater then 0.

      • by pz ( 113803 )

        For anything sort of cable that you might expect to hang between 50' tall poles, the answer to (B) is "no possible value" because no such cable has a zero bending radius and sufficiently high flexibility.

        Ah, you said to one decimal point. The answer is still "no possible value" because the heights were specified without tolerances and therefore must be assumed to be exact. Or, if you actually handed this problem to an engineer, they'd suggest you have under-specified the requirements (and, again, "no pos

    • by godrik ( 1287354 )

      I don't think many people know these equations. Personally I have never seen them. And I assume they are more looking to see how you approach the problem rather than find a real answer.

      I would approach the problem assuming the cable is not curve but straight to derive a first order approximation. If that wasn't enough, I'd assume it is parabolic to derive a second order approximation. And if you need more precision than that, call an expert.

      • Re: (Score:3, Informative)

        by Anonymous Coward

        Well b) is rather obvious and easy, if you fold an 80m cable in half how long is it? 40m.

        If you hang something 40m long from a 50m pole, how far off the ground is it? 10m.

        So how close are the polls? Very obviously 0.0 because for the midpoint of the cable to be 10m off the ground it must simply be folded in half...

        In this respect it's a pretty decent interview question as it quickly separates those who go off on a complete fucking tangent and come up with an overly complex solution because they think they'r

        • What if we're talking about fiber optics that require a minimum bend radius to avoid snapping?
          • Then you fail, because they're testing to see if you can work to simplify the question not complicate it. Let the "customer" complicate it later if the need is there, but start with the simple solution.... and start with the easiest part of the solution and work toward the harder parts next.

        • Re: Catenaries (Score:5, Insightful)

          by OneSmartFellow ( 716217 ) on Wednesday February 19, 2020 @06:21PM (#59744768)
          Actually, until you explained it, I didn't understand how question B was easily solved.

          I don't look at questions in that manner.  I assume that the question is a valid question, and never would consider that someone would ask a special case question.

          But that's just me, I am not a dick
    • by mbkennel ( 97636 )
      part (b) is a corner case you can figure out by logic. (0)

      Part (a) is definitely hard to solve with full physics, but you could make an analytical approximation of a quadratic function, parameterized by a single unknown (angle at the connection), and solve for that unknown value such that the total length is 80. Once you know the shape of the quadratic you can solve the problem.
    • Knowing the math offhand for a catenary is not the best predictor of performance in most jobs.

      It does however weed out job candidates which is real effect of this problem. Sure, you might not get the best candidates from the pool but you have fewer to choose from. It's not a good filter but it's still a filter.

    • Used to be a question at Google's interviews. There's even a book about these questions.

      Google eventually admitted that it did not work, just like every other HR fad...

      • by ceoyoyo ( 59147 )

        It sold some books though. Just like every other HR fad.

      • Re: Catenaries (Score:5, Insightful)

        by Moof123 ( 1292134 ) on Wednesday February 19, 2020 @02:24PM (#59743594)

        +1. So far in my interviewing the best indicator is to get folks talking about their work. You quickly figure out things like:
        1) Did they ACTUALLY do the work described, or were they just part of the team.
        2) Were they excited and proud of what they did.
        3) Did they actually understand the problem at hand, or did they just fiddle with it and shoulder shrug their way to a mediocre solution.
        4) Or did they over obsess with finding they optimum solution and blow the schedule.

        Trick questions often just make already nervous candidates shut down.

        • Agreed, but you know, to ask this kind of questions, you need to be able to understand the answer. It's so much easier to ask a stupid question from a book and see if the answer is exactly what's written in the book.

          More seriously, what you described is good but needs to be complemented with a hands-on exercise. I've seen candidates very good at communicating what was done by others and even the problem (as explained by others). Then fail totally to do even the most basic implementation.

        • Trick questions often just make already nervous candidates shut down.

          This is also useful knowledge, if a candidate will run screaming from a stressful (non-) solution situation. Grace under pressure, and all that rot...

          Sometimes the "Kobyashi Maru" test will give an insightful result, even if the outcome is predetermined.

          • by olau ( 314197 )

            Well, perhaps they're good a tolerating stress from a technical situation (server has gone down), but bad a tolerating social pressure?

      • by AmiMoJo ( 196126 )

        It works really well. If the company asks me that kind of question I know I don't want to work there. It's an indication that the company is either driven by a clueless HR department or that the technical people wouldn't know a good developer if one walked in their door, or both.

    • The thought process and how the candidate deals with stress is what us being measured -- NOT the answer.

      Case (b) is rather trivial to solve. If you can't figure this out then you probably don't know how to think outside the box.

      Do stupid problems like this guarantee "great coders"? No, you need a _different_ test for that. You can only assess what you test for. Math problems like this are only a tiny slice of what programming is about. The harsh reality is that you will be maintaining someone else's mess (

      • Re: (Score:2, Insightful)

        by Anonymous Coward

        Most programming doesn't even use this sort of math. I don't remember shit for math, barely remember what a cos is much less any identity relationships between cosh/sinh. I've done everything from "big scripting" to enterprise development and driver development over the last 24 years and never been an issue.

        Obviously it depends on where you work, but a pretty small percentage of developers need to know much complex math.

      • To the best of my knowledge Amazon doesn't create any products or work in any industry under which the engineer should be stressed while working. The ones I know work in a shiny new office building.

    • I call BS. (Score:5, Interesting)

      by Spazmania ( 174582 ) on Wednesday February 19, 2020 @02:11PM (#59743528) Homepage

      I call BS. I took Amazon's internal training for interviewers last year. The specifically teach you not to ask this sort of question. Instead you're supposed to ask STAR questions: Situation, Task/Action, Result.

    • The 10 meter part doesn't require much math; the poles are 0m apart, since it's 40m straight down to the middle of the cable if it is 10m off the ground. Yes, I'd have a hard time solving the 20m part without googling.
    • Knowing the math offhand for a catenary is not the best predictor of performance in most jobs.

      But having heard the riddle before could be. I knew the answer before I even read TFS. So I get the job, right?

      Not that I'd ever accept a job from Amazon. Especially not in Crystal City.

    • I have to agree.
      Even for school quizzes asking such questions, they are based on topic of the week, where you as a student is prepared to cover such questions.

      the off the cuff questions for a job where I was expected to say handle a graphing Algorithm, or statistical probability. Then given a rogue Trigonometry question, is no that useful.
      If I had access to some reference materal to help me look up arch length of a parabola then I could probably do the math.

      I have forgotten more math equations then most peo

    • It doesn't say you can't use Google. I would just pull out my phone. Google the question and tell them the answer in 5 seconds. Because that's also how I do my job.

      School needs to wake up to the current reality which is that the internet is now effectively a part of my knowledge. I can google things faster than I can even recall some things that I have memorized.

      • You miss the point of the exercise entirely. Its not about the answer, its how you go about solving the problem that is of interest to the hiring company. Why the hell are they going to hire you if you just are gonna google stuff. What value do you provide?
  • by aardvarkjoe ( 156801 ) on Wednesday February 19, 2020 @01:36PM (#59743334)

    I couldn't think of an easy way to solve the problem, so I went to the link. In the video of their solution, they say that the Amazon interview question was actually (b) -- which is the "trick" question. (a) can be kind of interesting mathematically, but it doesn't sound like anybody expected a solution from an interview subject at Amazon.

    • They took a nifty trick question used to weed out those that can't see the bigger logical picture and altered it into clickbait. I like everyone else thought about question A first, which completely ruins the simplicity and intention of the original B question.
      • It would have weeded me out. I don't know anything about the first part of the problem so I stopped thinking about it even before considering B.

        It doesn't change the fact that I've got 20+ years professional experience and am very good at what I do. These types of interview questions do not identify the skills and competencies required for technology careers. They just waste a lot of people's time and eliminate a lot of people with the requisite skills and they don't ever know about it.

      • I like everyone else thought about question A first, which completely ruins the simplicity and intention of the original B question.

        Whereas I, who became "test wise" some time before highschool, did a quick look at all the parts - and found the B answer right away.

        Skimming ahead on many typical tests will find the easy questions you can answer quickly or already know, and find the places where a later question inadvertently reveals the answer to an earlier one. (Then you can go answer most of the remainder

  • Isn't the shape a parabola? If so, then not so complicated, isn't it?
  • by thechemic ( 1329333 ) on Wednesday February 19, 2020 @01:37PM (#59743342)
    Don't bother to entertain the question, and move on to a real employer.
    • by novakyu ( 636495 )

      Well---that's why they propose to pay you a boatload of money, so that you'll put up with their B.S.

      I guess it's a choice---put up with their B.S. and make a lot of money, or find a job that you will find fulfilling regardless of compensation.

      • They appear to pay a boatload of money because they have no other choice: Amazon has a very strong reputation for mistreating employees to the point of burnout. People who place in those jobs have 2 years to be set for life, because their brain will be too fried to work in the industry thereafter. It's not actually a lot of money when you have to plan on 2 years until retirement or starting a new career from scratch.
    • by war4peace ( 1628283 ) on Wednesday February 19, 2020 @01:58PM (#59743472)

      This.
      It's a nice mind-jerk-off question, for those who like that kind of stuff. And it's a good way for HR drones or white collars to feel a sense of undeserved superiority establishing dominance with the candidate. But really, if they can't figure out proper interview questions which are actually relevant, then maybe you don't want to work there.

      • by ceoyoyo ( 59147 )

        At any decent job the interview goes both ways. If some HR jerk wants to ask stupid questions like that, ask some back. Bonus points if they're actually relevant to the job (HR won't be able to answer those either).

    • At a previous job, for a tech position, we had created a test for people to work out, just to judge their skills (that has a varied results). One time an applicant came in for the test, we were really busy that day (why we needed an other employee) so after him waiting for 15 minutes before we can get the test ready, he just left and never came back.

      There was an other person who just refused to take the test because of his experience working in "Fortune 500 Companies"

      Every job out there is going to have a

  • Lunch (Score:4, Funny)

    by Anonymous Coward on Wednesday February 19, 2020 @01:40PM (#59743362)
    "Do I still get lunch, given that your puzzle question makes me no longer want to work here?"
  • I wonder... (Score:5, Funny)

    by gosand ( 234100 ) on Wednesday February 19, 2020 @01:44PM (#59743386)

    I wonder if the day after the interview, and twice a week every week thereafter, they email candidates with "We see you're interested in cables and poles. Perhaps you would be interested in these deals..."

  • If that was used in an Amazon interview, the interviewer was going against his training. Amazon trains its interviewers to ask STAR questions: Situation, Task/Action, Result.

  • ... is that real-world problems are often not trick questions. Trick answers in software engineering are things like "Just add a thread" or " That can be fixed with another mutex". Unfortunately, it's sometimes nice to actually UNDERSTAND the problem, so that you can see if there are any hidden gotchas, or even to find better solutions.

    I mean yes, getting that one of the answers is degenerate is great, but it doesn't actually provide any insight to the candidate's ability to solve the general problem, or

  • Trick question (Score:4, Insightful)

    by bleh-of-the-huns ( 17740 ) on Wednesday February 19, 2020 @02:01PM (#59743494)

    There is no center cable, therefore the answer is 0. Language skills are just as important as math skills, if they had asked "center of the cable", then it would be a valid question, but "center cable" implies there are cables on either side, as there is only one cable in the image, there can be no center cable.....

    • "center cable" implies there are cables on either side, as there is only one cable in the image, there can be no center cable.....

      Center implies that there are an equal number of cables on either side. Zero is equal to zero, so it's the center cable.

  • by Neurotoxic666 ( 679255 ) <neurotoxic666.hotmail@com> on Wednesday February 19, 2020 @02:10PM (#59743526) Homepage
    The distance does not matter. Shipping is free when you subscribe to Prime.
  • by Baleet ( 4705757 ) on Wednesday February 19, 2020 @02:13PM (#59743540)

    A cable of 80 meters is hanging from the top of two poles that are both 50 meters off the ground.

    The poles are 50 meters off the ground? Or the top of the poles that the cable is hanging from is 50 meters off the ground? If only there were some word to tell how tall the poles are.

    What is the distance between the two poles (to one decimal point) if the center cable is (a) 20 meters off the ground and (b) 10 meters off the ground?

    The center cable? I thought there was only one cable. Does this mean the center of the cable?

  • by e**(i pi)-1 ( 462311 ) on Wednesday February 19, 2020 @02:14PM (#59743546) Homepage Journal
    As has been pointed out, the second problem (10 meter off the ground) is a good problem as it gives 0 as then half of the rope length is just the distance to the bottom. The question with the 20 meter off the ground probably did not expect an exact solution in the first case but tested how the candidate would approach a difficult problem. The exact solution using the graph of f(x) = cosh(ax) is hard: there are two unknowns, the parameter a and the end point which is half of the pole distance. It leads to two equations ,where one involves elliptic integrals. the arc length of the catenary is only elementary if a=1. Also approximating as a parabola (as Kepler did) gives a difficult arc length integral. I suspect that one expected the candidate to come up with an approximation. A simple approximation replaces the rope with a straight line so that one has a triangle with hypotenuse 40 and where one side 30. One can then give a rough estimate 2 sqrt(700) for the distance between the two poles which is the situation if the rope is piecewise linear (which is the case if a heavy weight is at the bottom). The actual solution is smaller.
  • The poles are less than 80.0 meters apart.

  • Hmm...
    It the poles were touching (distance = 0), the 80m cable would hand down 40 feet. So B = 0.

    Solving for A involves Pythagoras, I got 52. But cables do not hang that way.

    A ... forms two triangles,
    Side 1 = (50 - 20) = 30
    Side 2 is unknown.
    Side 3 = (cable length / 2) = 40

    (a**2 + b**2 = c**2, ...)

    (30**2 = 900) + x = (40**2 = 1600)
    1600 - 900 = 700
    sqrt 700 = about 26 x 2 = 52.
    A = 52.

    • Question A is far more complex than that. Look at the diagram. The cable is a curve, not two line segments.

  • The answer is: "Sorry for wasting your time. This probably isn't a great fit."

  • by ErichTheRed ( 39327 ) on Wednesday February 19, 2020 @02:46PM (#59743678)

    Amazon, Microsoft and similar are looking to hire mostly new graduates without a whole lot of work experience. The brain-teaser interview questions are basically an extension of school, and you'll select for people who are good problem-solvers and test-answerers but not necessarily good real-world workers. If you don't have a lot of experience to go on, your fallback is evaluating a candidate's academic record. When most people applying have an almost perfect GPA (grade inflation, especially in private colleges) you have to come up with some other weed-out tool.

    I've read a couple of books written by sociologists, psychologists and the like that put forth the theory that the people who did the best in school aren't necessarily the best workers for the modern world. Someone who crams for standardized tests from birth and never gets anything besides an A has been conditioned that if they just jump through the hoops and hurdles put in front of them, they'll succeed. And in the old world that was true...if you got into an Ivy League school, you'd be at least guaranteed a management consulting job or investment banker position, both of which pay extremely well. But now that we have automation taking a lot of the work here, people are finding that the more rigidly you're programmed to find the answer they want you to find, the less innovative you are. Amazon/Microsoft/whatever would probably do better not looking for grade-getting robots and expanding their search to people who may not have done the best in school, but have some other kind of differentiating spark.

  • I had one of my interviews with Amazon that was how would you build DropBox. Not sure what the "answer" was they were looking for. Only thing I could guess is being able to jump up and down the level of detail.

    How would you detect changes (file system watcher thread), how would you minimize storage needs (some sort of hash to detect duplicates and store a single copy), etc.

  • For one thing, the drawing they include is extremely misleading.
    Which perhaps is the first clue it's a bogus kind of question, assuming scale is consistent and actually means something. I mean, it could just be a quick napkin drawing, but considering they ask for a mathematical answer down to 1 decimal point, one would assume they'd exercise the same precision in the drawing?
    That the fact that they drew the 80m cable as slack between the two poles would suggest that the poles must be considerably less than

  • B is simplest, 0.

    A is easy too, you know it's going to be less than 80 m. So to the first decimal 0.0 km (or, if you must, mi) is absolutely and entirely correct.

    And to know that before reading some of the answers here, I'd never heard of a catenary...

  • by balaam's ass ( 678743 ) on Wednesday February 19, 2020 @03:12PM (#59743834) Journal
    You only need to posit that the shape of the cable will minimize the potential energy. Then use the Calculus of Variations to get Euler-Lagrange equations, solve those, and boom: catenary! ;-) Then plug in your boundary conditions. (2nd year undergrad physics curriculum.)
  • Keep it Simple Stupid: Common sense would suggest that the cable probably would not hang exactly as pictured in the diagram. It would more likely hang in the shape of a perfect semi-circle. That being said, if the height of the poles is 50m and the distance from the cable to the ground is 20m, that means the difference would be the radius of that semi-circle, which is 30m. Double that and you get the distance between the poles: 60m. Very simple.
  • by PortHaven ( 242123 ) on Thursday February 20, 2020 @11:06AM (#59746728) Homepage

    How thick is the cable, what it the cables flexibility? These alter how the cable will curve. Just saying..

    Then, I would of asked for a scrap of paper and a ruler. Cut the paper to the specified lengths. Laid the paper cable in the two request positions. And just been like...here's your answers.

    I would then ask if ANYONE who interviewed with them ever answered the problem using that method. And when they likely responded "No". Then I would tell them, they would be stupid not to hire me. As clearly, they had no one who thought quite like me, and it was clear that I found solution others did not. And if there was a need for a math formula, it makes more sense to either refer to a knowledge expert (be it an colleague with a math degree or google).

Stellar rays prove fibbing never pays. Embezzlement is another matter.

Working...