Skip to content

JohnSteeleUrban/proto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Proto

Another random excercise. I cannot remember if it was for an interview or some online code challenge.

Nonetheless. An example of code.

Parse a custom protocol format

Your application must interface with an old-school mainframe MPS7 for payment processing. This means consuming a proprietary binary protocol format.

Task

You must read in a file, txnlog.dat, and parse it according to the specification in Notes below.

You must answer the following questions:

  • What is the total amount in dollars of debits?
  • What is the total amount in dollars of credits?
  • How many autopays were started?
  • How many autopays were ended?
  • What is balance of user ID 2456938384156277127?

You must supply your source code as part of your answer. Write your code in your best programming language.

Notes

MPS7 transaction log specification:

Header:

| 4 byte magic string "MPS7" | 1 byte version | 4 byte (uint32) # of records |

The header contains the canonical information about how the records should be processed.

Record:

| 1 byte record type enum | 4 byte (uint32) Unix timestamp | 8 byte (uint64) user ID |

Record type enum:

  • 0x00: Debit
  • 0x01: Credit
  • 0x02: StartAutopay
  • 0x03: EndAutopay

For Debit and Credit record types, there is an additional field, an 8 byte (float64) amount in dollars, at the end of the record.

All multi-byte fields are encoded in network byte order.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages