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:
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)!"
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.