wu :: forums
« wu :: forums - Find Credit or Debit »

Welcome, Guest. Please Login or Register.
Apr 25th, 2024, 5:25pm

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: ThudnBlunder, SMQ, towr, Eigenray, Grimbal, william wu, Icarus)
   Find Credit or Debit
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: Find Credit or Debit  (Read 525 times)
Erik
Newbie
*





   


Posts: 27
Find Credit or Debit  
« on: Mar 11th, 2015, 11:54am »
Quote Quote Modify 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: male
Posts: 13730
Re: Find Credit or Debit  
« Reply #1 on: Mar 11th, 2015, 12:09pm »
Quote Quote Modify 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
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

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