Boss

Boss: Ledger Pipeline

The boss
Boss Fight!
Every passing test breaks a shield.

The Guild treasurer slides a smudged ledger across the table. Some lines are comments, some are blank, some are just plain broken, and names are spelled in every case imaginable. "Who spent what? I need a report by moonrise."

Build a pipeline of small, pure functions. An entry is a tuple (member, item, amount).

Assignment

  1. parse(lines) returns a list of entries. Each good line is date,member,item,amount. Skip blank lines, lines starting with #, lines without exactly 4 fields, and lines whose amount isn't a number (EAFP!). Clean names with .strip().title() and items with .strip(), and turn amounts into float.
  2. totals(entries) returns a dict mapping each member to their total, each rounded to 2 decimals.
  3. ranking(entries) returns member names, biggest total first; equal totals sorted A to Z.
  4. report(entries) returns lines like "1. Ada: 42.50", in ranking order.
  5. big_items(entries, limit) returns a sorted list of the unique item names that had any single amount above limit.