Skip to content

Lesson 2 of 6

The Take-Home: Read the Brief, Cut Scope and Ship Something That Runs

Work a take-home brief from the first reading to a tool that runs, and learn where to spend a three-hour limit.

7 minForward Deployed Engineering

After this lesson you will be able to read a take-home brief for what it asks and what it leaves out, write down your assumptions, decide what to cut, and build a small tool that runs first time for the person marking it.

You need Python 3.9 or later. The code uses only the standard library, so there is nothing to install. Where this course writes python, use python3 if that is the command on your machine.

The brief

Here is the brief, as an interviewer acting for Calder Freight might send it:

"Calder Freight's warehouse system exports a file of shipments every night. Our billing system exports a file of invoices. Finance believes some shipments are never invoiced and some are invoiced for the wrong amount. Write a tool that takes the two files and reports the problems. Please spend no more than three hours. Send us your code and a short README."

Two sample files come with it. In your fde-interview folder, create shipments.csv with exactly this content:

shipment_id,customer,shipped_on,weight_kg,agreed_amount
S-1001,Aldgate Foods,2026-03-02,420,1250.00
S-1002,Aldgate Foods,2026-03-02,180,640.00
S-1003,Penrose Tools,2026-03-03,960,2310.50
S-1004,Penrose Tools,2026-03-04,75,310.00
S-1005,Marlow Print,2026-03-04,230,815.00
S-1006,Marlow Print,2026-03-05,510,1490.00

Then create invoices.csv. The third row has a lower-case id with a space after it, before the comma. Keep both; they matter.

invoice_id,shipment_id,customer,amount
INV-501,S-1001,Aldgate Foods,"1,250.00"
INV-502,S-1002,Aldgate Foods,460.00
INV-503,s-1003 ,Penrose Tools,2310.50
INV-504,S-1005,Marlow Print,815.00
INV-505,S-1005,Marlow Print,815.00
INV-506,S-1009,Marlow Print,120.00

Read it twice, then read the data

Read the brief once for what it asks. It asks for a tool, two inputs, a report of problems, code and a README. It names two kinds of problem: shipments never invoiced, and wrong amounts.

Read it again for what it does not say. It does not say what the report should look like. It does not say which file is right when the two disagree. It does not say whether the files are clean. A customer never tells you everything, and a good brief checks whether you notice.

Now read the data, which is the step most often skipped. Open both files and read every row; there are only twelve. You will find things the brief never mentioned:

  • Invoice INV-501 writes its amount as 1,250.00, with a comma. The shipment says 1250.00.
  • Invoice INV-503 has the shipment id s-1003 , in lower case with a space after it.
  • Shipment S-1005 has two invoices.
  • Invoice INV-506 points at shipment S-1009, which is not in the shipments file.

The first two are the same value written two ways. A tool that reports them as problems buries the real ones under false alarms. The last two are real problems that the brief did not ask about. Finding them is the difference between doing the task and understanding the customer.

Write your assumptions down

You usually cannot ask the customer questions during a take-home, so you decide, and you write the decision down. Add these to notes.md under the heading "Assumptions". They go into the README in the next lesson.

  • The shipments file is the record of what was agreed. When the amounts differ, the report shows both and does not say which is right.
  • Shipment ids are compared without regard to case or surrounding spaces.
  • A comma in an amount is a thousands separator.
  • A shipment with two invoices is reported even when both amounts are correct, because the customer may have been charged twice.
  • An invoice for a shipment that is not in the file is reported. It may belong to another night's export.

An assumption written down is a decision the interviewer can disagree with and still respect. An assumption left in your head looks like something you missed.

Decide what to cut

Three hours is short. Spend the first twenty minutes reading and deciding, about two hours building and checking, and keep the last forty minutes for the README. To fit that, cut on purpose:

  • No web page and no database. A command that prints a report answers the brief.
  • No settings. The column names are in the sample files, so the tool uses them as they are.
  • No handling of files too large to hold in memory.

Write the cuts in notes.md under the heading "Left out". A README that says what was left out, and what you would do about it with more time, reads as judgement. A tool that silently lacks those things reads as an oversight.

Build it

Create reconcile.py in the same folder:

"""Compare a shipments export with an invoices export and report what does not match.

Usage: python reconcile.py shipments.csv invoices.csv
"""

import csv
import sys
from decimal import Decimal


def clean_id(value):
    """Shipment ids arrive with stray spaces and mixed case. Compare them in one form."""
    return value.strip().upper()


def clean_amount(value):
    """Amounts arrive as 1250.00 or 1,250.00. Decimal keeps the pennies exact."""
    return Decimal(value.replace(",", "").strip())


def read_rows(path):
    with open(path, newline="", encoding="utf-8") as handle:
        return list(csv.DictReader(handle))


def reconcile(shipments, invoices):
    """Return the findings as (kind, shipment id, detail), in the same order on every run."""
    agreed = {}
    for row in shipments:
        agreed[clean_id(row["shipment_id"])] = clean_amount(row["agreed_amount"])
    by_shipment = {}
    for row in invoices:
        by_shipment.setdefault(clean_id(row["shipment_id"]), []).append(row)

    findings = []
    for shipment_id, amount in sorted(agreed.items()):
        matched = by_shipment.get(shipment_id, [])
        if not matched:
            findings.append(("not_invoiced", shipment_id, f"agreed {amount}"))
            continue
        if len(matched) > 1:
            numbers = ", ".join(row["invoice_id"] for row in matched)
            findings.append(("invoiced_twice", shipment_id, numbers))
        for row in matched:
            invoiced = clean_amount(row["amount"])
            if invoiced != amount:
                detail = f"agreed {amount}, {row['invoice_id']} says {invoiced}"
                findings.append(("wrong_amount", shipment_id, detail))
    for shipment_id in sorted(set(by_shipment) - set(agreed)):
        numbers = ", ".join(row["invoice_id"] for row in by_shipment[shipment_id])
        findings.append(("unknown_shipment", shipment_id, numbers))
    return findings


def main():
    if len(sys.argv) != 3:
        sys.exit("Usage: python reconcile.py shipments.csv invoices.csv")
    shipments = read_rows(sys.argv[1])
    invoices = read_rows(sys.argv[2])
    findings = reconcile(shipments, invoices)
    print(f"{len(shipments)} shipments, {len(invoices)} invoices, {len(findings)} findings")
    for kind, shipment_id, detail in findings:
        print(f"{kind:18}{shipment_id:10}{detail}")


if __name__ == "__main__":
    main()

Be ready to explain three choices in this file during a walkthrough. Amounts are Decimal and not float, because money held as floating-point numbers can differ in a far decimal place and raise false alarms. The comparing lives in reconcile, a function that takes rows and returns findings and never opens a file or prints, which makes it easy to test. The findings come out sorted by shipment id, so two runs on the same files give the same report.

Run it and check the answer

In a terminal, in the fde-interview folder, run:

python reconcile.py shipments.csv invoices.csv

You should see:

6 shipments, 6 invoices, 5 findings
wrong_amount      S-1002    agreed 640.00, INV-502 says 460.00
not_invoiced      S-1004    agreed 310.00
invoiced_twice    S-1005    INV-504, INV-505
not_invoiced      S-1006    agreed 1490.00
unknown_shipment  S-1009    INV-506

Check the report against the rows you read by hand. S-1001 and S-1003 are not in it, which is right: the comma and the lower-case id were cleaned away before comparing. S-1002 was agreed at 640.00 and invoiced at 460.00, two digits swapped. S-1004 and S-1006 have no invoice. S-1005 has two. S-1009 has an invoice and no shipment. That is five findings, and you can account for each one.

That check is the habit to bring to the interview. You did not only run the tool. You knew what it should say before it said it, and that is what lets you tell a customer the report can be trusted.

Key takeaways

  • Read the brief twice: once for what it asks, once for what it leaves out.
  • Read the sample data row by row before writing code; it holds problems the brief never mentions.
  • Write every assumption down, because a written assumption is a decision and an unwritten one looks like a miss.
  • Cut scope on purpose and say what you cut.
  • Know what the tool should report before you run it, then check the report against that.

Try it

Finance will want totals. Change only the main function of reconcile.py so that, after the findings, the report prints one line for each kind of finding with how many there are, for example not_invoiced: 2. Predict the count lines on paper first, then run the tool on the sample files and compare. A good result leaves the reconcile function untouched, prints the same five findings as before, and ends with four count lines that add up to five.

Official documentation

Ready to use this in a job?

Rolebound applies to matching roles for you.

Start now

Written with AI and checked automatically. Nobody has run these steps by hand, and tools change, so a command may behave differently in the version you install. Spotted a mistake? Tell us.

    Cookies on Rolebound

    We use necessary cookies to sign you in and keep the site working — those cannot be turned off. We would also like to set analytics and advertising cookies so we can see which pages help people get interviews and which adverts brought them here. Nothing optional is set unless you say yes, and you can change your mind at any time from “Cookie settings” in the footer. Read our Privacy Policy.