wu :: forums (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi)
riddles >> cs >> Find Credit or Debit
(Message started by: Erik on Mar 11th, 2015, 11:54am)

Title: Find Credit or Debit
Post by Erik on Mar 11th, 2015, 11:54am
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

Title: Re: Find Credit or Debit
Post by towr on Mar 11th, 2015, 12:09pm
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.



Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board