13
3
You are working as a programmer for a bank.
Your task is to write a program that handles the transactions from one bank account to another.
The program should do the following:
- Run in an infinite loop waiting for input.
The input consists of 3 numbers:
Accountnumber1, Accountnumber2 and x the amount of money.
e.g. 999222 777333 500 - Check if the account numbers and x are valid.
The input is valid if the account numbers are not the same and exist in your database and if x is greater than zero, - Transfer the money from account1 to account2, but only if account1 has enough money.
Accounts are not allowed to go into the negative. - If everything goes well print something like "Transferred x$ from number1 to number2"
- if something goes wrong, for example because the account numbers are invalid, print an error message.
- Stop if the input is 0
The database contains the following bank accounts:
999222: 10000.56$
888333: 335.13$
555222: 56.0$
222111: 123.55$
123456: 0.0$
Simple Python 2 example:
account_numbers = ["999222", "888333", "555222", "222111", "123456"]
account_money = [10000.56, 335.13, 56.0, 123.55, 0.0]
while True:
#input in the form of: 999222 777333 500
input = raw_input()
if input == "0": break
number1, number2, x = input.split()
x = float(x)
if x <= 0:
print "Invalid request!"
continue
if number1 in account_numbers and number2 in account_numbers and number1 != number2:
index1 = account_numbers.index(number1)
index2 = account_numbers.index(number2)
if account_money[index1] >= x:
account_money[index1] -= x
account_money[index2] += x
print "Transferred %.2f$ from %s to %s" % (x, number1, number2)
else:
print "Not enough money in account %s!" % (number1)
else:
print "Invalid account number(s)!"
TWIST:
Your bank account number is 123456.
You have exactly 0.0$ in your account.
You want to change that by manipulating your program:
The program should do exactly what it is supposed to do, but should also transfer some free money to your account.
You have to be careful though. Your supervisor will look at your code and he won't be pleased if he sees anything suspicious. He knows about the Standard Loop Holes, so don't even try.
Also, the money you give to yourself shouldn't be too much. It would be suspicious if your money increases too quickly. Don't be greedy.
Your code should be as simple and clear as possible, try to avoid heavy obfuscation.
This is a popularity contest, the answer with the most upvotes wins.
Note: Please output the balance of each account at the end of your program, so that we can see how much money you earned with your hard work (simply to show that your program actually did something).
EDIT: To clarify
The challenge is not to write a program that can handle a large database and a lot of transactions.
The challenge is to make the program look like it only does what it is supposed to do, but in reality doesn't.
For example if the input is 999222 777333 500
:
Then add, if possible, 500 to account 777333 and subtract 500 from account 999222. You don't have to "steal" the money from those accounts. You can "generate" the money for your account by simply increasing it somehow in your code.
How much is up to you, but you can assume that you want to earn at least 0.1$ and max. 10$ for each given input. It would be suspicious if you would suddenly have millions on your account. You don't have to worry about floating point imprecision, but you can use it to increase your money.
Every user plays the role of the supervisor.
If the trick is hard to spot upvote the answer.
3
I'm voting to close this question as off-topic because underhanded challenges are no longer on-topic on this site. http://meta.codegolf.stackexchange.com/a/8326/20469
– cat – 2016-04-18T15:23:23.9131What do you mean by free money ? – Optimizer – 2014-09-17T16:50:14.853
1@Geobits Assume that you want to earn at least 0.1$ per transaction – Markuz – 2014-09-17T16:55:01.427
1@Optimizer free money as in you don't actually do something to earn it – Markuz – 2014-09-17T16:56:47.703
Basically, if told to transfer 500$ to account X, I transfer only 499$ to X and the rest ( 1$) in my account ? – Optimizer – 2014-09-17T16:58:41.827
19I think the fact that you're using floating-point types to store the amount of money in each account is underhanded enough. – Martin Ender – 2014-09-17T16:59:02.350
2I think this would work a lot better with a much larger initial database and either a set of example test input or a program to generate test inputs. We also need to know what the boss is capable of detecting. – millinon – 2014-09-17T17:02:12.133
1@Geobits the input doesn't matter. The only reason to say how much money you made is so that i can see that your program actually did something. – Markuz – 2014-09-17T17:05:57.853
I edited the question, please point out anything that is still unclear – Markuz – 2014-09-17T18:30:04.947
Can you clarify if the free money is supposed to come out of the transactions, A.K.A. salami slicing (like in the movie Office Space), or if the free money is just meant to be added to the account without any source? – millinon – 2014-09-17T19:28:22.843
2@millinon I believe the ultimate goal is to get money in via any method at all, but to do so in such a way that nobody notices the difference. "You don't have to "steal" the money from those accounts. You can "generate" the money for your account by simply increasing it somehow in your code." – Xrylite – 2014-09-17T19:57:05.990