I’ll start by saying I believe this particular puzzle is not possible to solve, but it would be nice if I had proof it’s not possible, so here we go:
Say you’ve been given an ATM card and its PIN. You have to go up to a particular ATM and start using it to withdraw money from the associated account. You’re told the account has some unknown-to-you value X between a known minimum and maximum number of dollars in it, inclusive, The max possible balance will be at least 1000 more than the minimum. The balance is an integer amount, no cents. Your goal is to draw down the account to whatever that minimum you were told was, but no further.
The ATM has only one function, and that’s to attempt withdrawals in the exact amount you enter on the screen, whole dollars only. You can’t check the balance, and you can’t deposit money back into it. You punch in an amount you want, and if the account has at least that much left in it, the ATM dispenses the money into your greedy hands and the hidden account balance is reduced by that amount. If the account doesn’t have enough, it will tell you so, and there’s no penalty for attempting to take too much except the ATM will beep at you annoyingly and the withdrawal fails. There’s no limit to how many times you try withdrawals, but at some point you have to declare yourself done and stop using the ATM.
If you end up drawing down the account to any other balance besides the minimum you were told, you’ve failed the test, and you shouldn’t have started withdrawing in the first place.
I know a solution for when the minimum=0 and the maximum is any whole number greater than 0. I’ll leave that as an exercise for the reader. Oh here, I’ll spoiler it for you:
Start with the largest even power of 2 less than or equal to the max, and attempt that withdrawal. Then divide your withdrawal amount by 2 again and again until your last attempt at 1, and after that you’ll have emptied the account. Or do it backwards. Or just withdraw 1 each time until you get told there’s no more money left, but that might take a while, though. I’m sure there are more solutions.
Is there a solution for some other exact minimum where it’s greater than 0? Is there a general solution for any minimum over zero? (Min <= X <= Max; Max-Min >= 1000)
If it helps any, I would particularly like a solution for minimum=10, max=100000, but any other numbers would be interesting.