Paying with RINGS | Adobe,Inmobi Interview

A man comes to a small hotel where he wishes to stay for 7 nights. He reaches into his pockets and realizes that he has no money, and the only item he has to offer is a gold chain, which consists of 7 rings connected in a row (not in a loop).
The hotel proprietor tells the man that it will cost 1 ring per night, which will add up to all 7 rings for the 7 nights.
“Ok,” the man says. “I’ll give you all 7 rings right now to pre-pay for my stay.”
“No,” the proprietor says. “I don’t like to be in other people’s debt, so I cannot accept all the rings up front.”
“Alright,” the man responds. “I’ll wait until after the seventh night, and then give you all of the rings.”
“No,” the proprietor says again. “I don’t like to ever be owed anything. You’ll need to make sure you’ve paid me the exact correct amount after each night.”
The man thinks for a minute, and then says “I’ll just cut each of my rings off of the chain, and then give you one each night.”
“I do not want cut rings,” the proprietor says. “However, I’m willing to let you cut two of the rings if you must.”
The man thinks for a few minutes and then figures out a way to abide by the proprietor’s rules and stay the 7 nights in the hotel. What is his plan?



Solution :

Break into this way ..
0 | 00| 0000

First day  - 0
2nd day - give 00 and take 0
3rd day - give 00 and 0
4th day - give 0000 and take 00 , 0
5th day - give 0
6th day - give 00 and take 0
7th day - give 0 

Leave a Reply

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

For Inserting code :
Paste your code in the comment form, select it and then click the language link

C | C++ | Java |