Life has been good to you so far. Now you
have a job, and, you're thinking, life is even better now that you
have a paycheck! However, your job has been trying, and a little
bit boring. So, you'd like to take up some time developing an
algorithm to make the job even easier than it already is. Here's
you job: You are the Measure Minister. People in your town, being
too stupid to use a yardstick , bring to you all their stuff to
measure. Everything is measured in exact inches. (The foregoing
fact makes this problem simple, albeit not realistic. Thus, for
this problem, you can assume no one will ever bring you anything
measuring 3.5 inches, or 78.23 inches, or 9.01 inches, or ...) Your
only tool-o-measurement is a piece of string exactly 8 inches long.
Write an algorithm that you (or your replacement) may use to
measure in the most efficient way all the stuff that the
townspeople might bring to you to measure. Remember, they can bring
you little things or big things...or even really big things!
Remember, your measures will always be to the nearest inch, and the
string you use is exactly 8 inches long. yardştick ninja.
All the things can be measured to the nearest inch if we can fold the string.
One way is to fold the string in half 3 times to make it exactly 1 inch long(8/2 = 4, 4/2 = 2, 2/2 = 1). This way we can use the one inch string to measure the objects.
Other way is to measure the objects using 8 inch string, if the remaining part of the object is less than 8 inches long, fold the string and then measure. For eg, to measure 25 inches, first use 8 inches string 3 times(we get 24) and then fold the string 3 times to get 1 inch string and use it to measure the remaining part.
Both the methods will get the same answer. The first one will take longer, the second one will be faster.
Hope this helps.
Please rate the answer if you like it.
Do leave a comment.An suggestion/query is much appreciated.
Life has been good to you so far. Now you have a job, and, you're thinking,...
Human Resources You have just graduated with your HAS degree and have been hired by Quality Home Care. The owner hasn’t given you a written job description or even a title but has told you what he wants you to do. “I started this company because I got tired of the bureaucracy at Mega Health System. We couldn’t get anything done. Even when it was obviously best for the patients and for the company, there was always some reason we...
Overview Title Manager's Hot Seat: Listening Skills: Yeah, Whatever Pilar Grimault has scheduled a meeting with her department’s young Creative Director, Miguel Valentino. He has recently completed a campaign for a longstanding client, Jezebel. Although the campaign was a huge success, the client has complained to Pilar about Miguel’s project management skills. Here's the video transcript -Hello. Hey, I just came down the street, and I was stopped by three different people. We're a hit. We're a huge hit. i...
Amazon to Competition: We Will Crush You! Amazon to Employees: We Will Churn You! Globally, Amazon is one of the largest and most successful companies in any industry. Technological innovation has contributed to its success, as has its employee acquisition practices, which are exceptionally high. The question is what has allowed this company to thrive and maintain its success? This activity is important because it shows how companies like Amazon hire based on personality and individual differences. Such companies place...
David’s Story “Life is difficult.” I once read these three trivial words in a book, but never knew how true to life and impactful they would be until one fateful fall evening. Before I begin, let me back up and tell you more about who I am and how I got here. I am a Caucasian male raised in a small conservative town in Maine by hard-working middle-class parents. My compassionate mother juggled raising three rambunctious children, me being the...