Rotate image (square matrix) by 90 deg
Tue, 06 May 2025
You have some work to be done by a worker in 7 days. The worker needs to be paid every day after his work. The total cost of the work of 7 days is one gold bar (so every day the worker must be paid 1/7'th of the bar).
You have only one gold bar, and you can make only two cuts in that bar. How will you ensure that the worker is paid every day?
Solution: If you think of somehow breaking the bar into 7 pieces then you are approaching the problem wrongly. You have to break the gold bar in such a way that you can make transactions.
When we pay in money, then also it may be the case that we don't have the change, so we give a bigger note to the worker and he return the change to us (for example, If we are supposed to pay Rs. 80, we give a Rs. 100 note to the worker and he returns Rs. 20)
We have to apply the same thought process here...
Make the two cuts in the bar in such a way that we have following three pieces of the gold bar:
Give Bar-A to worker (You have Bar-B and Bar-C, Worker has Bar-A)
On Day-2:Give Bar-B to worker and take Bar-A back (You have Bar-A and Bar-C, Worker has Bar-B)
On Day-3:Give Bar-A to the worker (You have Bar-C, Worker has Bar-A and Bar-B)
On Day-4:Give Bar-C to the worker and take back Bar-A and Bar-B (You have Bar-A and Bar-B, Worker has Bar-C)
On Day-5:Give Bar-A to worker (You have Bar-B, Worker has Bar-A and Bar-C)
On Day-6:Give Bar-B to worker and take back Bar-A (You have Bar-A, Worker has Bar-B and Bar-C)
On Day-7:Give Bar A to worker (You have nothing and all the bars are with worker)
Tue, 06 May 2025
Tue, 06 May 2025
Tue, 06 May 2025
Leave a comment