Author |
Topic: Find Credit or Debit (Read 536 times) |
|
Erik
Newbie
Posts: 27
|
|
Find Credit or Debit
« on: Mar 11th, 2015, 11:54am » |
Quote Modify
|
Parse a bank statement efficiently that has merged the Credit / Debit information and we don’t know if an entry is credit (money in) or debit (money out). It is of this format: Date1, TransactionText, AbsoluteAmount Date1, TransactionText, AbsoluteAmount Date1, TransactionText, AbsoluteAmount, EndOfDayBalance Date2, TransactionText, AbsoluteAmount Date2, TransactionText, AbsoluteAmount, EndOfDayBalance … The problem is that ‘AbsoluteAmount’ is always positive, and only the last entry on each day has the balance. Write code which takes this input and outputs the same data but with AbsoluteAmount replaced by the correct ‘Amount’ (negative for debit, positive for credit). Sample: 2014-01-01, Cheque, 100, 1000 2014-01-02, Cheque, 200 2014-01-02, Cheque, 400 2014-01-02, ATM, 100 2014-01-02, Target, 300, 200 2014-01-03, Payday, 1000 2014-01-03, ATM, 100, 1100
|
|
IP Logged |
|
|
|
towr
wu::riddles Moderator Uberpuzzler
Some people are average, some are just mean.
Gender:
Posts: 13730
|
|
Re: Find Credit or Debit
« Reply #1 on: Mar 11th, 2015, 12:09pm » |
Quote Modify
|
What should we do with ambiguous cases like: 2014-01-02, ATM, 100, 200 2014-01-03, Cheque1, 100 2014-01-03, Cheque2, 100, 200 Here, either Cheque1 could be debit and Cheque2 credit, or vice versa.
|
|
IP Logged |
Wikipedia, Google, Mathworld, Integer sequence DB
|
|
|
|