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?
Catenaries (Score:5, Insightful)
Knowing the math offhand for a catenary is not the best predictor of performance in most jobs.
you fail (Score:5, Insightful)
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
Re: (Score:2)
Re: (Score:2)
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.
Re: (Score:2)
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)
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
oh god no, not again (Score:2)
(fittingly, I can no longer find the story on the weird NJ site)
The Men in Black say there is no cable [trytoscare.me], and I sleep better at night not obsessively thinking about it, and so will you.
Re: (Score:2)
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
Re: (Score:2)
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)
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.
Think like a physicist (Score:2)
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)
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.
Re: (Score:3)
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.
Re: (Score:3)
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
Re: (Score:2)
I'll have to remember that one!
Solution to A without a caternary (Score:5, Informative)
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.
Re: (Score:2)
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?)
One decimal place, not one digit.. 0.0km 0.0km ;) (Score:3, Informative)
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..
Re: (Score:2)
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.
Re: (Score:2)
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.
Re: (Score:3)
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
Re: (Score:2)
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)
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
Let's complicate everything unnecesarily (Score:2)
Re: (Score:3)
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)
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
Re: (Score:2)
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.
Re: (Score:2)
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.
Re: Catenaries (Score:3)
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...
Re: (Score:2)
It sold some books though. Just like every other HR fad.
Re: Catenaries (Score:5, Insightful)
+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.
Re: (Score:2)
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.
Re: (Score:2)
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.
Re: (Score:3)
Well, perhaps they're good a tolerating stress from a technical situation (server has gone down), but bad a tolerating social pressure?
Re: (Score:2)
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.
Re: (Score:3)
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)
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.
Re: (Score:2)
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)
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.
Re: (Score:2)
Perhaps this is an interview for someone who has to lay cable.
Re: (Score:3)
Re: (Score:2)
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.
Re: (Score:2)
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
Re: (Score:2)
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.
Re: (Score:2)
Misleading summary (Score:3)
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.
Another kind of click bait. (Score:3)
Re: (Score:3)
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.
Re: (Score:2)
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
parabola? (Score:2)
Re: (Score:3)
Catenary, in case A. Straight line in case B. In case B, the poles are 0 feet apart and the cable is hanging straight down.
Re:parabola? (Score:5, Informative)
No, it's a catenary. The equation is y=cosh(ax)/a. If you try to solve the problem by assuming it's a parabola (y=ax^2), you'll get a wrong answer.
Re: (Score:2)
Note that even if you know the equation for y as a function of x, solving for the length of the rope will involve an unpleasant integral.
Re: (Score:3)
The definition of a catenary is a cable hanging from two points.
QED
Re: (Score:2)
This was proven by Huygens, Bernoulli and Leibniz in the 17th century...
Re:parabola? (Score:5, Funny)
Re: (Score:3)
https://lmgtfy.com/?q=catenary... [lmgtfy.com]
Re: (Score:3)
It can be considered a parabola, and that's also probably how they expect you to solve it.
However, a hanging chain/rope isn't exactly a parabola because of the own weight of the rope or chain, hence the answer will only be an approximation without knowing the weight and -very complex- math (and local gravity, air pressure/density etc).
In English such shape appears to be called a catenary https://en.wikipedia.org/wiki/... [wikipedia.org]
Re: (Score:2)
A catenary is close enough to a parabola that solving for a parabola would probably be accurate to the one decimal given in the problem.
Re: (Score:2)
Except even a parabola approximation is not in the slight bit easy to solve.
Employers Who Ask Irrelevant Interview Questions (Score:4, Insightful)
Re: (Score:2)
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.
Re: (Score:2)
Re:Employers Who Ask Irrelevant Interview Question (Score:4, Insightful)
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.
Re: (Score:2)
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).
Re: (Score:2)
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)
I wonder... (Score:5, Funny)
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..."
Bad question (Score:2)
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.
The problem with trick questions... (Score:2)
... 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)
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.....
Re: (Score:2)
"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.
Answer is obvious (Score:4, Funny)
Grammar fascist checking in (Score:3)
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?
Re:Grammar fascist checking in (Score:4, Insightful)
testing the approach and struggle (Score:4, Insightful)
Answer (Score:2)
The poles are less than 80.0 meters apart.
Funny question (Score:2)
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.
Re: (Score:2)
Question A is far more complex than that. Look at the diagram. The cable is a curve, not two line segments.
It's a trick question! (Score:2)
The answer is: "Sorry for wasting your time. This probably isn't a great fit."
Required for their hiring audience (Score:5, Interesting)
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.
another one (Score:2)
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.
That's a shit diagram (Score:2)
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
easy answers (Score:2)
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...
You don't even need to know what a catenary is... (Score:4, Funny)
The answer is 60.Use the KISS principle. (Score:2)
Okay, so...a couple of questions (Score:3)
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).
Re: (Score:2)
Ok they should ask can you work 80-100 hour weeks with NO OT PAY?
Re: (Score:2)
Re: (Score:2)
Having someone who won't overthink things won't be thinking about that. It's kind of the perfect question.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Yeah, because Amazon runs a search business? Maybe you'd get fired/not hired if you were applying to Wolfram; but Amazon isn't in search business.
Re: (Score:2)
Re: (Score:2)
Funny you mention that. Google execs specifically state that Amazon is their #1 competitor in search. Why? Because Amazon is a product search engine first and foremost. While Google.com may mainly be a general purpose web search engine, one of the top things people search for is products to purchase (or just generally researching products), and when people want to do that, Google is usually skipped, and users go straight to Amazon. So yes, they are indeed a search business.
Re: (Score:2)
Eh, no.
https://www.amazon.com/s?k=goo... [amazon.com]
Re: (Score:2)
Okay... https://www.amazon.com/s?k=chr... [amazon.com]
Re: (Score:2)
I'm not sure most people would want to hire someone so easily triggered by this problem.
Try carefully reading the problem before you go off during an interview. The tops of the two poles are 50 feet off of the ground, not the poles. Perhaps poorly worded, but still obvious to the reader. Also the "center cable" is not "present over the entire length of the cable" since there is only a single cable, so there is no "center cable". They did not say "center of the cable". Since there is only one cable ment
Re: (Score:2)
I'm not sure most people would want to hire someone so easily triggered by this problem.
Oh, I would. People who can spot unstated assumptions and recognize ambiguities are enormously valuable. People who can produce a product from a specification are pretty common. People who can write good specifications are not.
Unless you have people asking the right questions -- even if the answers seem obvious, you can end up giving the customer a 1/12 scale model of the 18-foot-high Stonehenge they wanted (This is Spinal Tap). Or maybe delivering a structure which is 50 meters tall instead of the catwal
Re: (Score:2)
your poles are not 50m off the ground. They are on the ground.
If you're going to be that pedantic, at least know that they would be buried significantly below-ground or they'd fall over in a slight breeze.